Silverlight Toolkit chart: Multiple series with bar and line

心已入冬 提交于 2019-12-25 08:02:21

问题


I am having problem to show the grid in a way that I wanted. But I am also not sure whether it is possible to do that in the Silverlight toolkit chart. So any help or direction on this would be appreciated.

<Grid x:Name="LayoutRoot" Background="White">
<charting:Chart x:Name="myChart" Width="600" Height="400">
<charting:BarSeries                 
Title="Tasks"
ItemsSource="{Binding Path=Data1}"
IndependentValueBinding="{Binding Month}"
DependentValueBinding="{Binding Task}"
DependentRangeAxis="{Binding ElementName=TaskAxis}">
</charting:BarSeries>
<charting:LineSeries                 
Title="Benefits"
ItemsSource="{Binding Path=Data1}"
IndependentValueBinding="{Binding Month}"
DependentValueBinding="{Binding Benefits}"
DependentRangeAxis="{Binding ElementName=BenefitsAxis}">
</charting:LineSeries>
<charting:Chart.Axes>
<charting:LinearAxis Orientation="Y" Location="Left" Title="First" x:Name="TaskAxis" />
<charting:LinearAxis Orientation="Y" Location="Right" Title="Second" x:Name="BenefitsAxis" />
</charting:Chart.Axes>
 </charting:Chart>
</Grid>

Given the above snippet, is it possible to have the Yaxis on the left to show the month and the top x-axis to show the tasks value, and bottom x-axis to show the benefits value.

So in a way, it is sharing the Yaxis for the month. and it can use either top/bottom x-axis or even right Yaxis to plot the tasks and benefits value.

What do you guys think?

Thanks.


回答1:


The example below has the task axis on the top and the benefits axis on the bottom, with a shared Y-axis on the left:

<toolkit:Chart x:Name="myChart" Width="600" Height="800">
    <toolkit:BarSeries                 
            Title="Tasks"
            ItemsSource="{Binding Path=Data1}"
            IndependentValueBinding="{Binding Month}"
            DependentValueBinding="{Binding Task}"
            DependentRangeAxis="{Binding ElementName=TaskAxis}">
    </toolkit:BarSeries>

    <toolkit:BarSeries                 
            Title="Benefits"
            ItemsSource="{Binding Path=Data1}"
            IndependentValueBinding="{Binding Month}"
            DependentValueBinding="{Binding Benefits}"
            DependentRangeAxis="{Binding ElementName=BenefitsAxis}">
    </toolkit:BarSeries>

    <toolkit:Chart.Axes>
        <toolkit:LinearAxis Orientation="X" Location="Top" Title="Task" x:Name="TaskAxis" />
        <toolkit:LinearAxis Orientation="X" Location="Bottom" Title="Benefits" x:Name="BenefitsAxis" />
    </toolkit:Chart.Axes>
</toolkit:Chart>


来源:https://stackoverflow.com/questions/10050691/silverlight-toolkit-chart-multiple-series-with-bar-and-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!