ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  XYChart in DotNet : How to display Linear Axis from 0.1 to 1000?
Posted by Murugan on Aug-13-2015 01:36
Attachments:
Hi,

I am using XYChart in C# DotNet to draw a graph. It is part of big complex graph/Chart
project. I have a scenario where the Graph contains both XAxis and YAxis.
For both axis, the minimum value is 0.1 and maximum value is 1000 but only differs in
scaling.

i.e. YAxis should be Logarithamic where as XAxis should be Linear scaling. I am familiar
with the XYChart for a while and i set the following in code.

// For Yaxis Logarithmic
viewer.setFullRange("y", 0.1, 1000);
viewer.ViewPortTop = 1 - viewer.getViewPortAtValue("y", 1000, true);
viewer.ViewPortHeight = 1 - viewer.getViewPortAtValue("y", 0.1, true) -
viewer.ViewPortTop;

viewer.syncLogAxisWithViewPort("y", xyChart.yAxis());


// For Xaxis Linear
viewer.setFullRange("x", 0.1, 1000);
viewer.ViewPortLeft = viewer.getViewPortAtValue("x", 0.1, false);
viewer.ViewPortWidth = viewer.getViewPortAtValue("x", 1000, false) -
viewer.ViewPortLeft;

viewer.syncLinearAxisWithViewPort("x", xyChart.xAxis());

The graph is getting plotted as expected but the problem is that in XAxis, the minimum
value (0.1) is not displayed. It is mandatory for us to display both the minimum &
maximum Values in Axis.

Below the screenshot of the graph which i get. Please revert back on at the earliest.
ChartDireector.png

  Re: XYChart in DotNet : How to display Linear Axis from 0.1 to 1000?
Posted by Peter Kwan on Aug-13-2015 02:56
Hi Murugan,

By default, ChartDirector auto-scaling will only show regularly spaced labels and "nice"
values. For example, if the x-axis scale is 198.285 to 1003.113, ChartDirector may only
display the labels at 200, 400, 600, 800, 1000, but not at 198.285 or 1003.113. To display
those labels, one way is to use Axis.addMark.

For your case, I assume you are only interested in displaying 0.1 if it is at the axis end
point, but not 0.2 or 0.10001 (after zooming or scrolling, it is possible for these values to be
at the axis end point). If this is the case, you may use:

// Ensure 0.1 is visible as a label on the x-axis
if (viewer.ViewPortLeft == 0)
   c.xAxis().addMark(0.1, -1, "0.1").setMarkColor(Chart.Transparent, 0x000000, 0x000000);

Hope this can help.

Regards
Peter Kwan

  Re: XYChart in DotNet : How to display Linear Axis from 0.1 to 1000?
Posted by Murugan on Aug-13-2015 03:00
Thats a very quick response.

Thank you very much Peter. I will look into this approach.