Hi, Guys:
I asked you the following question yesterday:
> Normally the axis's label value is from smaller to bigger one. How can I set the label value from bigger one to smaller one?
> For example, I have a primiary axis Y, whose value is from 1 to 100 (smaller ==> bigger), I need a secondary axis Y, whose value is from 1 to 0.01 (bigger ==> smaller). How can i set it?
You told me your current version can not do it, I don't know if it's the same for winform, ASP.NET, and WPF, which means none of them can do the reverse axis?
thanks ...
/Cathy
that is correct. however, in WinForms and ASP.NET you could implement a custom solution for this using a custom layer or the FillSceneGraph event. it would be tricky, but basically you can redo the labels on one axis, and resize/reposition the data in the chart layer.
another way to approach this would be to modify the data (multiply all the values by -1) and just use IRenderLabel to change the axis labels so it appears values on a reverse scale are being plotted.
David Negley"] that is correct. however, in WinForms and ASP.NET you could implement a custom solution for this using a custom layer or the FillSceneGraph event. it would be tricky, but basically you can redo the labels on one axis, and resize/reposition the data in the chart layer. another way to approach this would be to modify the data (multiply all the values by -1) and just use IRenderLabel to change the axis labels so it appears values on a reverse scale are being plotted.
Great idea. I've implemented the second approach successfully.
My first thought was to reverse the x-axis RangeMin and RangeMax in FillSceneGraph event handler like this:
IAdvanceAxis xx = (IAdvanceAxis)ultraChart1.CompositeChart.ChartLayers[0].ChartLayer.Grid["X"]; double minPos = xx.MapMinimum - 10; //give more space to start/end of axis to avoid Icon trimming double maxPos = xx.MapMaximum + 5;
//spatialTrendsChart.XAxis.RangeMin = (double)xx.MapInverse(minPos); //spatialTrendsChart.XAxis.RangeMax = (double)xx.MapInverse(maxPos); spatialTrendsChart.XAxis.RangeMin = (double)xx.MapInverse(maxPos); spatialTrendsChart.XAxis.RangeMax = (double)xx.MapInverse(minPos); spatialTrendsChart.XAxis.RangeType = AxisRangeType.Custom;
This does work for the chart: everything is horizontally mirrored. However, the axis labels are gone (not displayed).
Cheers,
Jason
sometimes you can prevent clipping like this by increasing the axis margins (using the properties under under chart.Axis.Y.Margins)
Hi David,
Thank you so much for your explanation. That makes it much clearer. I think I'll stick to the *(-1) way which works well for me. The only thing is that when this happens for Y-axis, and the layout behavior for the axis labels is set to Auto, it doesn't automatically give a proper range (bottom or top points clipped). It works ok for positive values.
Thanks heaps!
The axis layer just doesn't account for the possibility of right-to-left ... I'm not sure if it will generate the text labels with negative bounds, or if the loop just exits based on some condition. This is just a feature that has never been planned or implemented. The fact that it works in the chart layer is just a happy coincidence.
The first approach would be a matter of handling the FillSceneGraph event and looping through e.SceneGraph to see if the Text primitives are in there (maybe they are with negative height/width, i'm not really sure). If the Text primitives are there, all you have to do is reposition them (you can use the Axis mapping functions by casting e.Grid["X"] as IAdvanceAxis). If the Text primitives are not there, you can still add new ones and add them to e.SceneGraph. You can use this same technique for the chart layer primitives (usually Boxes or Polylines), if necessary.