Hello. I'm using a particular value n for the major tickmark interval for my XamDataChart. I want the tickmarks to be displayed as exact multiples of that interval (-3n, -2n, -n, 0, n, 2n, etc.) For example, if I've set the Y axis display range to be from -135.2 to 380.7, and I set my intervals to display at multiples of 100.0, I would like the major tickmarks to be at:
-100.0, 0.0, 100.0, 200.0, 300.0
However, the chart currently positions the tickmarks at:
-135.2, -35.2, 64.8, 164.8, 264.8, 364.8.
Is there a SIMPLE way to set the initial position of the tickmarks so there is guaranteed to be a major tickmark at zero? I'm not trying to force the zero tickmark to always be drawn (i.e. if my data were from 320 to 720, I wouldn't see the mark at 0.0, but would want to see lines at 400, 500, 600, 700, as if the intervals BEGAN at zero). I know I could create my own TickmarkValues subclass, but this seems like a lot of work for what should be a default feature of a graph.
Thanks,
Ed
Hello Ed,
Thank you for your post. I have been looking into it and I can suggest you see this link from our online documentation:
http://help.infragistics.com/Help/NetAdvantage/WPF/2012.1/CLR4.0/html/xamDataChart_Creating_Custom_Axis_Tickmark_Values.html
where it is shown step by step how to create custom tickmarks. Also I can say that you can calculate the values based on your axis interval and populate the Tickmarks collection with the appropriate values.
Hope this helps you.
Thanks, Stefan. I ended up using that page, and creating an IEnumerable<double> that returns the ticks between the minimum and maximum range:
public static IEnumerable<double> RangeEnumerator(double start, double end, double interval) { //Get the two values evenly divisible by the interval that lie within the range. int firstInterval = (int)Math.Ceiling((Math.Min(start, end) / interval)); int lastInterval = (int)Math.Floor((Math.Max(start, end) / interval)); return Enumerable.Range(firstInterval, lastInterval - firstInterval + 1).Select(i => i * interval); }
If there isn't a property of the XamDataChart that can be set to force intervals to be spaced from zero, I'd like to request that one be added as a feature.