bar series labels cut off

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

bar series labels cut off

Post by cwodarczyk82 » Mon Dec 21, 2015 10:39 pm

Hi, Pasi:

I am currently seeing an issue with the bar series labels getting cut off, persumably I am guessing the z order or layering order is such that bars added get a higher z order...

[img]
BarLabelsHidden.PNG
BarLabelsHidden.PNG (5.97 KiB) Viewed 11446 times
[/img]

You can see that the labels get covered up by the bars they are next to.. I am wondering if there is a setting for this (I have been staring at several different options though and it doesn't look like it...)
The current thing I tried above was just to right align the labels so they wouldn't get covered by items to the left, but that doesn't work in the case above... center and left have similar issues...

The only other alternative I can think of is to use SeriesEventMarkers, but that might prove tricky since I'm not sure of the exact x coordinate of the bars themselves... since the graph logic shifts them around when more than one item is on the tick, using the Location field in the value won't work as the x coordinate, and I wasn't sure what else I could actually try...

Thanks for your time!
--Chris

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

Re: bar series labels cut off

Post by ArctionPasi » Tue Dec 22, 2015 12:12 pm

Hi Chris,

Maybe you should rotate the labels by 90 degrees. Set barSeries.LabelStyle.Angle = 90.

If you need more advanced logic, you can read the rendered bar screen coordinates with barSeries.GetBarRectangles method (only in 6.5.5 and newer versions).
That method returns the rendered bar rectangles of all data items in the series.

You can convert between screen coordinates and axis values with axis.CoordToValue and axis.ValueToCoord methods.
LightningChart Support Team, PT

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

Re: bar series labels cut off

Post by cwodarczyk82 » Wed Dec 23, 2015 4:16 pm

Hi, Pasi:

Thanks for the suggestions... I am probably not going to go with the 90 degree solution as that would limit the height of the bar when our graphs are smaller... I am curious though, it seems like when I use this code:

var barSeriesRects = barSeries.GetBarRectangles();
var barSeriesValues = barSeries.GetSeriesValues();

It appears that within the arrays, there is a correspondence to where the ith element in each array represents the same bar in the series...is this true? Would i be able to count on this order? I have tried to correlate them more closely by taking the screen coordinate of the Value property on the barSeriesValue, but it doesn't 'exactly' match up with the screen coordinate value in the Top field of the barSeriesRect... it is most off by 1 pixel it seems.. so I could correlate them through making sure i match the items with an error bandwidth of 1 pixel, which would become less accurate as the graph shrinks, but honestly, at a very small graph region, I don't think accuracy matter all that much anymore...

Otherwise, I could just assume the items in each array are in the same order, but I am always concerned about assumptions unless I know what is going on underneath for certainty...

Thanks!
--Chris

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

Re: bar series labels cut off

Post by cwodarczyk82 » Wed Dec 23, 2015 9:32 pm

Hi, Pasi:

If you don't get a chance to reply right away, that is ok... I think I have found what I need for now... I am going through each tick one by one, finding its location, and finding the bar series values which are connected to that tick...

So something like:

Code: Select all


var eachTicksRegion = CalculateTickRegion(); // Method I wrote to calculate how much room each tick region is given...
var markers = GetMarkers(); // Already created pool of markers for each bar value created

foreach(customTick)
{
    foreach(barSeries)
    {
         var barSeriesRects = barSeries.GetRectangles();

         foreach(barSeries.barSeriesValues)
        {
             // Found value on this tick
             if(value.Location- customTick.AxisValue< double.Epsilon)
             {
                  var tickInScreenCoord = ValueToCoord(customTick.AxisValue);
                  var leftRegion = tickInScreenCoord - (eachTickRegion / 2.0);
                  var rightRegion = tickInScreenCoord + (eachTickRegion  / 2.0);

                  foreach(rect in barSeriesRects)
                  {
                        var avg = (rect.Left + rect.Right) / 2.0;
                        if(avg > leftRegion && avg < rightRegion) // Found rectangle that goes with this value
                        {
                              var xValueCoord = 0.0;
                             if(XAxes.CoordToValue(avg, out xValueCoord, false))
                             {
                                  marker.XValue = xValueCoord; // Places at center horizontally
                                  marker.YValue = value.Value;
                                  break;
                             }
                        }
                  }
                  break;
             }
        }

    }
}
Seems to work pretty well, but is kind of expensive with four concurrent loops... come to think of it, I probably don't need the outer custom tick loop... would still like to know if the two arrays are in the same order...

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

Re: bar series labels cut off

Post by ArctionPasi » Mon Dec 28, 2015 1:13 pm

Hi Chris,

Apologies for the delay, our office was closed for Chrismas.

If you are using BarViewOptions.Grouping = ByLocation, barSeries.GetRectangles order is the ascending by the location value. It means it is not the same than in Values array if Location values are not ascending.

So... how about just sorting the Values array in the ascending order by Location, and the rectangles would be in the same order than the values and manipulation of CustomAxisTicks / markers would be faster and simpler?
LightningChart Support Team, PT

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

Re: bar series labels cut off

Post by cwodarczyk82 » Fri Jan 15, 2016 8:58 pm

Hi, Pasi:

Thanks for the reply... sorry, I had forgotten about this post... i found a solution that seemed to work well, but I will keep this solution in mind should my way not prove efficient enough...

Thanks!
--Chris

Post Reply