Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
415
XamDataChart with StackedColumnSeries bound to Dictionary?
posted

Would it be possible to bind a XamDataChart that is displaying a stacked column series to a Dictionary? Ideally I would like to do something like this:

<ig:XamDataChart.Series>
<ig:StackedColumnSeries XAxis="{Binding ElementName=StackedColumnXAxis}"
                                            YAxis="{Binding ElementName=StackedColumnYAxis}"
                                            ItemsSource="{Binding MyDictionary}">
        <ig:StackedColumnSeries.Series>
                <ig:StackedFragmentSeries ValueMemberPath="Key.Title" Title="Title" />
                        <ig:StackedFragmentSeries ValueMemberPath="Key.Hydro" Title="Hydro" />
                        <ig:StackedFragmentSeries ValueMemberPath="Key.Nuclear" Title="Nuclear" />
                        <ig:StackedFragmentSeries ValueMemberPath="Key.Gas" Title="Gas" />
                        <ig:StackedFragmentSeries ValueMemberPath="Key.Oil" Title="Oil" />
        </ig:StackedColumnSeries.Series>
</ig:StackedColumnSeries>
</ig:XamDataChart.Series>
The Dictionary would be something like this:
Dictionary<PowerData, decimal> and the PowerData key would have all the data that I care about. Note how everything above is bound to items on the key.
I'm doing it this way, since some of the same data is already bound to a bar chart which I know works with the Dictionary container. All the samples show the data being bound to ObservableCollections or to List types in C#. So I wanted to see if this is feasible before creating all the infrastructure.
Parents
No Data
Reply
  • 415
    Verified Answer
    Offline posted

    This does work. I wish I knew how to get the proper syntax highlighting in this forum. But basically, this worked just as I had hoped. Setting the ValueMemberPath to point to the Key.<valueitem> on the underlying data was all I needed to do. Binding the StackedColumnSeries to the Dictionary worked fine.

    So I think I am good to go except for ToolTips. I want a tooltip that shows the value of each individual rectangle on a stacked bar and the name of the component that made that rect. Any ideas?

Children
No Data