Hello!
I am using xamdataChart ColumnSeries with MVVM. I would like to dynamically add column series to the chart via MVVM. I am having a multiselection combobox, each item in the combobox will add/remove a ColumnSeries to the chart when the user checks on the checkbox.
I saw a solution for this but it is quite old, from 8 years ago.
Can someone please upload a solution to achieve this?
Thank you!
Cristina.
Hello Christina,
I noticed your post on another forum thread in which you had requested that the above-mentioned sample be re-uploaded. I have very recently uploaded it to the other forum thread, and for consistency, I will also attach it here. I believe in using it, you should be able to bind to the collection containing your series objects and add or remove them from the chart as you see necessary.
Please let me know if you have any other questions or concerns on this matter.
2783.XamDataChartColumnSeriesBinderCase.zip
Hello Andrew!
Thank you very much for uploading this. I appreciate the prompt reply. It is very helpful.
Hello again,
While testing this with various datapoints I found an issue.
When adding the first series, everything works fine.When adding a following series with subdata less than the first series, only the series with an equal match are displayed, not the entire subdata of the first series. The first series also are incorrectly placed on the x-Axis.
Could you please look into this? I'm unable to upload a sample project, I hope you are able to reproduce this.
Thank you!Cristina.
Hello Cristina,
The behavior in which if a series with sub-data less than the first series is present, then the series is not plotted is expected behavior. For the "category" related series such as the ColumnSeries to work, the bound ItemsSource needs to have the same number and value of categories as is bound to the category axis' ItemsSource property.
You can essentially "fake" the subset in this case by padding your other data sources such that they still have the same number and value of categories, but for the categories that there does not exist a value, use double.NaN for the value instead. This will cause nothing to be plotted for that particular category for a particular series, while still keeping the ItemsSource in a state that the CategoryXAxis and the ColumnSeries that are using it can interface with.
Regarding the "incorrect placement" of the series on the X-Axis, would it be possible for you to please elaborate a little further on what exactly is happening on your end that is incorrect in the placement of the series? Perhaps you could include a screenshot that depicts this incorrect placement?
Hi Andrew,
I followed your advice and "faked" the subset. My numeric datatype for the y-Axis is decimal and I used 0 for the ones with no-value. It appears to be working. The issue with incorrect placement no longer exists.
Thank you.