Under review

Bind a column from a ColumnSeries with its Label from CategoryAxis

Lucas Miranda 4 years ago • updated by Oystein Bjorke 4 years ago 1

I'm trying to build a ColumnSeries where instead of clustered bars I'd have just one item per 'group'. I'll try to give an example to illustrate the case:

- I have a collection with the items "Dog", "Cat, "Rat" and "Bird", each one with a (double)value that changes over time.

-I would like to plot a column chart, with the first bar being labeled as "Dog", second as "Cat", and so on. The bars must not be clustered.

-The chart will be updated given a refreshTimer, and it is possible to add new items to the chart, as well as changing or removing the existing ones.

My first approach was creating a generic ColumnSeries and add each of my items as ColumnItems. It worked at first, but when I had to implement the "Remove Item" operation, it became chaos as Labels from the CategoryAxis were not binded to the ColumnItem in any way. I tried to write a logic to solve the issue, but in the end, it failed. While trying this method, I did NOT set up the ItemSource of the CategoryAxis, instead I was adding and removing items from the ActualLabel manually.

On my second attempt, I'm trying to create a ColumnSeries for each of the items, but by doing so, I end up with 4 Labels ("Dog", "Cat", "Rat and "Bird"), each having a group of columns composed by another 4 columns, as each ColumnSeries has the same ItemSource holding all the Items I wanna plot. When I remove an Item, it removes the respective bar from each group, but does not remove its supposed Label (or group). This time, I had to set up the ItemSource from CategoryAxis (same ItemSource of the ColumnSeries), but I'm not sure if or how the bind works (for example, if I add an item to the collection of the ItemSource, will a new Label be created?).

If someone could guide me through a solution for this problem, I would highly appreciate. Thanks in advance.

PS: I can upload images if it helps understanding the case.

Under review

it should be possible to set the ItemsSource of the category axis and the column series to the same collection, and they should stay in sync. If it is not working, then it is probably a bug. Can you create a small example (the dogs and cats sounds good) and add to github issues if the problem persists? Note that invalidation of the plot is not triggered automatically.