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
|