Group: Forum Members
Last Active: 11 Years Ago
Posts: 18,
Visits: 1
|
HI
I am showing BarSeries using the following x-y pairs: (1.45, 12) (1.46, 13) (2.45, 16) (12.45, 23) (178.45, 332) ...
The problem is how to compute the proper BarWidth avoid bars overlapping. My algorithm is like this: Step 1: Find the closest bars on x-axis.((1.45, 12) and (1.46, 13) are closest bars and the difference is only 0.01) Step 2: Convert this samllest difference 0.01 to parent relative value. Since the default bar width is 2 with unit of NRelativeUnit.ParentPercentage Step 3: Choose the min value from the converted value and the default value 2
But i don't know how to do the conversion in step2 above, i've tried the code below but doesn't work, any help?
gap = xValues[minGapIndex + 1] - xValues[minGapIndex];
var xAxisLength = (_chartWrapper.Chart.Axes[(int)StandardAxis.PrimaryX] as NAxis).Scale.RulerRange.GetLength();
gap = gap / xAxisLength * 100;
barSeries.BarWidth = new NLength((float)Math.Min(gap,2), NRelativeUnit.ParentPercentage);
xl
|
Group: Forum Members
Last Active: Yesterday @ 1:54 AM
Posts: 3,054,
Visits: 4,009
|
Hi, If you have to display just regular bars (not stacked or clustered) you can use a range series (NRangeSeries) instead of a bar series. This way you will be able to specify the bar widths in scale units, so there will be no need to convert from scale to model (which can be tricky in some situations).
Best Regards, Nevron Support Team
|