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

Message ListMessage List     Post MessagePost Message

  Y axis upper bound
Posted by robo on Jan-13-2010 06:25
I would like to know how to modify the Simple Line Chart example (ASP.NET) such that if I provide data in the range within the range of 0 to 100, it always displays an upper bound of 100, regardless of the data provided.

For example, if you supply the following data points:

        // The data for the line chart
        double[] data = {30, 28, 40, 35, 15, 48, 24, 3, 50, 32, 25, 45, 15, 31, 20, 45,
        3, 35, 10, 46, 36, 18, 42, 35, 12};

The maximum yAxis value will be 60.

As an example application, let's say I want to display multiple charts side by side that display server load (expressed as % CPU).  The data points for this will all fall somewhere in the range of 0 to 100.  I have different server groupings and I want to include multiple charts on the web form, one for each group.  Being able to compare these with consistent yAxis scales would be helpful.

If each chart is allowed to autoscale, it becomes a bit awkward to compare one chart to another when the y axis of each chart shows a different range.  I know that I can set the zero affinity to 1 (e.g., always use 0 as the starting point), but I'm not sure how to also tell the chart to always include a y axis point of 100.

I've tried using Axis.addZone() as well as Axis.addMark() with no luck.

Any suggestions?

  Re: Y axis upper bound
Posted by Peter Kwan on Jan-13-2010 15:40
Hi robo,

To set 0 - 100 as the axis scale you may use:

// y-axis scale 0 to 100, with a label every 20 units
c.yAxis().setLinearScale(0, 100, 20);

You mentioned you only want to set the axis scale from 0 to 100 if the provided data are in the range 0 to 100. In this case, your code will need to check if your data are from 0 to 100, and call the above line only if your data are actually from 0 to 100.

The above code sets the axis range from 0 to 100. You may also scan all data for charts that will be displayed side by side, and use the global maximum value in setLinearScale. As long as you use the same limits in all charts, they will have the same scale.

Hope this can help.

Regards
Peter Kwan

  Re: Y axis upper bound
Posted by robo on Jan-13-2010 19:54
Thank you!