Can BarSeries have different number of items, like Points?

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
cwodarczyk82
Posts: 43
Joined: Mon Oct 19, 2015 2:50 am

Can BarSeries have different number of items, like Points?

Post by cwodarczyk82 » Mon Oct 19, 2015 3:17 am

I have been playing around with the BarSeries for quite some time, trying to figure out how to get what i want, but am not quite able to figure it out...
Essentially, I am going to want something like the following:
I have a list of states with their top resources, and I want the resources to represent each of the BarSeries.
I want these bar series represented for each state, but each state does not have the same resources as income.
For instance, I have Iowa set to receive income from Tech and Banking.
New Jersey has banking and tourism, as well as New York.
So, I have three series: Banking, Tourism and Tech, that's three bar series, color coded.
I sort the states, having Iowa, New Jersey and New York on the axis (using custom ticks, so Iowa is 0.0, New Jersey is 1.0 and New York is 2.0).
Obviously, this is all mocked up data just to play with this, and isn't the end product I'm trying to make, but this output will be very similar to what I want.
When i use the PointLineSeries, I can get what I want:

Code: Select all

       
      
       private void PlotPointItem(StateResourceType resourceType, 
            PointLineSeries lineSeries, 
            AxisX xAxis,
            IEnumerable<StateTopResourcesDataEntry> entries)
        {
            var seriesPoints = new List<SeriesPoint>();

            foreach (var data in entries)
            {
                var plotItem = data.Resources.SingleOrDefault(r => r.ResourceType.Equals(resourceType));

                if (plotItem != null)
                {
                    var seriesPoint = new SeriesPoint();

                    var item = xAxis.CustomTicks.FirstOrDefault((t) => t.LabelText.Equals(data.StateName));

                    if (item != null)
                    {
                        seriesPoint.X = item.AxisValue;
                    }
                    else
                    {
                        seriesPoint.X = 0;
                    }

                    seriesPoint.Y = plotItem.IncomeFrom;

                    seriesPoints.Add(seriesPoint);
                }
            }
            //Assign the data for the point line series
            lineSeries.Points = seriesPoints.ToArray();
        }
And this is the result I get:
PointLineSeriesResult.PNG
PointLineSeriesResult.PNG (37.56 KiB) Viewed 11127 times
However, when I switch over to using a bar graph, I would expect similar results, but I don't get them that way....

Code: Select all

        private void PlotPointItem(TickStateInfo tick,
            Dictionary<StateResourceType, BarSeries> barSeries,
            AxisX xAxis)
        {
            foreach (var resourceItem in tick.ResourceList)
            {
                BarSeries barItem;
                if (barSeries.TryGetValue(resourceItem.ResourceType, out barItem))
                {
                    barItem.AddValue(tick.XAxisValue, resourceItem.IncomeFrom, resourceItem.IncomeFrom.ToString(), true);
                }
            }
            
        }
I find that unless I provide a 0.0 value for states that don't have that resource defined, everything gets all messed up... I am currently grouping by location, instead of index... if i insert a 0.0 value for all non-existent resources, everything is fine, and all the items appear in the proper 'bucket' (bucket being the state). If i don't provide a 0.0 value, things are all messed up (see attachment).
BarSeries.png
BarSeries.png (84.81 KiB) Viewed 11127 times
What happens is, the 89.23 Tourism value actually belongs to New Jersey, not New York, and the 91 value for new york's tourism is no where to be seen...

I have validated with breakpoints in my VS IDE that I am setting the location to 1.0 for New Jersey's tourism value of 89.23 and 2.0 for New York's tourism value of 91, but it won't work, I have to do this:

Code: Select all

private void PlotPointItem(TickStateInfo tick,
            Dictionary<StateResourceType, BarSeries> barSeries,
            AxisX xAxis)
        {
            var listUsed = new List<StateResourceType>();
            foreach (var resourceItem in tick.ResourceList)
            {
                BarSeries barItem;
                if (barSeries.TryGetValue(resourceItem.ResourceType, out barItem))
                {
                    barItem.AddValue(tick.XAxisValue, resourceItem.IncomeFrom, resourceItem.IncomeFrom.ToString(), true);
                    listUsed.Add(resourceItem.ResourceType);
                }
            }

            foreach (var series in barSeries.Where(series => !listUsed.Contains(series.Key)))
            {
                series.Value.AddValue(tick.XAxisValue, 0.0, "0.0", true);
            }
        }
And then it gives me the data in the correct position:
BarSeriesWorks.png
BarSeriesWorks.png (79.79 KiB) Viewed 11127 times
However, in the end, I am going to have dozens of different possible 'resources', and setting each item to 0 is just not going to be practical... is there a way I can skip items, or some workaround I can do (like set 0 value item bars to width 0, it doesn't appear you can set individual bar widths to 0..)
Please let me know if you would like more information...
Thank you for your time!

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Can BarSeries have different number of items, like Point

Post by ArctionPasi » Mon Oct 19, 2015 7:58 pm

Hi,

we'll investigate this soon, it'll take time to find a workaround or support in LightningChart built-in.
LightningChart Support Team, PT

cwodarczyk82
Posts: 43
Joined: Mon Oct 19, 2015 2:50 am

Re: Can BarSeries have different number of items, like Point

Post by cwodarczyk82 » Mon Oct 19, 2015 9:05 pm

Thank you for replying so timely!

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Can BarSeries have different number of items, like Point

Post by ArctionPasi » Wed Nov 18, 2015 8:28 pm

The support for this was included in 6.5.5
LightningChart Support Team, PT

cwodarczyk82
Posts: 43
Joined: Mon Oct 19, 2015 2:50 am

Re: Can BarSeries have different number of items, like Point

Post by cwodarczyk82 » Thu Nov 19, 2015 5:38 am

Yes, thank you.. was able to validate this evening finally that this functionality is working... :)

Post Reply