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

Message ListMessage List     Post MessagePost Message

  Set Scatter Chart scale specifically...
Posted by Edward Hermanson on Feb-04-2013 06:51
We use a custom algorithm to come up with numbers to pass in to the SetLinearScale() method. When using SetLinearScale() we would like to make sure that even when zero is not on the chart (which is fine) the numbers reflect a scale that would include zero as a major tick, if it were there. I.E. If the max was 20 and the min was 10 and the chart shows tick of 10,12,14,16,18, and 20, if you extended those number down you would have 8,6,4,2,0,-2,-4 etc. When we use SetLinearScale() we sometimes get a scale, that if extended would not include zero like 9,6,3,1,-1,-3,-6-9 etc. Do you know of an algorithmic way of avoiding this?

Another option would be to set the major ticks specifically. Is there a way of doing this in chart director?

  Re: Set Scatter Chart scale specifically...
Posted by Peter Kwan on Feb-04-2013 20:02
Hi Edward,

As far as I know, if the ticks are automatically chosen by ChartDirector, they always pass through zero if extended. So it should not be possible for ChartDirector to choose ticks like 9, 7, 5, .... (Note that the 9, 6, 3 example you mentioned does pass through zero if extended => 9, 6, 3, 0, -3, -6, -9 .....)

If in your chart, the ticks if extended do not pass through zero, would you mind to clarify if the ticks are specified by your code (the setLinearScale allows you to specify the tick increment), or is it specified by ChartDirector?

Note the the following requirements can be logical contradictory:

(i) The ticks must start and end at the given max and min values.
(ii) The ticks must pass through zero if extended.
(iii) There must not be too many ticks to make the chart unreadable.

As an example, suppose you want the axis scale to be from 1 - 100. Because of (ii), the tick increment must be at most 1 (otherwise, the tick at 1, when extended, will not pass through zero). But then there will be 100 ticks and the chart may become unreadable.

If you let ChartDirector determine the ticks (when you call setLinearScale, your code do not supply the tick increment), ChartDirector will adjust the max and min values to meet all three conditions. For example, if the given min and max value is 1 - 100, ChartDirector may change it to 0 - 100 and use a tick increment of 10. In other words, ChartDirector may not use the exact min and max values provided by your code.

You may use Axis.setRounding to tell ChartDirector not to adjust the given min and max values, then ChartDirector can only guarantee (ii) and (iii), that is, the ticks may not pass through the given max or min values.

If you are writing your own code to determine the tick positions, just note that (i), (ii) and (iii) are contradictory, and your code may need to give up one of them.

Regards
Peter Kwan

  Re: Set Scatter Chart scale specifically...
Posted by Edward Hermanson on Feb-05-2013 02:00
Thank you Peter. I appreciate your clear and lucid responses. We were specifying the tick increment and min and max values. I see how this could lead to a contradiction.

We don't have to use SetLinearScale(). We started using it (and specifying tick increment) because the scale was different between our web and print versions and we need to make them consistant. We use a multiplier for the chart size and plot area to make the image a higher resolution for print (even though it is displayed at the same size) and this was leading to about twice as many tics in the larger image.

Really our only requirements are that we can specify a margin around the data on the outside of the chart and specify the number of tics on an axis regardless of chart size.

What do you think would be most effective for this?

  Re: Set Scatter Chart scale specifically...
Posted by Peter Kwan on Feb-06-2013 00:39
Hi Edward,

If the scale is automatically determined by ChartDirector, ChartDirector will try to put as many ticks as possible on the axis but will ensure the tick spacing be at least 20 pixels (for vertical axis) or 50 pixels (for horizontal axis). This ensures the chart is labelled to a fine detail, but the labels are still clearly readable. The minimum tick spacing is configurable using Axis.setTickDensity.

So by default, tf your chart is larger in pixel size, ChartDirector may put more ticks on it. To avoid this, you may set the minimal tick spacing as proportional to your chart size.

For example, in your web chart, you may use setTickDensity(20), while in your printed chart (assume it is drawn twice as large in pixel size), you may use setTickDensity(40). In this way, both charts will contain the same scale and same number of ticks.

For the scale "margin", ChartDirector by default will ensure at least 5% of the scale is the margin. This is configurable using Axis.setAutoScale. For example, if the maximum data value is 99, ChartDirector may use 110 as the maximum scale instead of 100, because of the requirement of having 5% scale margin. Note that the zero point is handled specially. If the data range is 1 - 99, ChartDirector may use 0 to 110 as the scale, as the scale extension would not cross the zero boundary. Also, ChartDirector has the tendency to include 0 in the axis scale. (See the documentation on setAutoScale for the "zero affinity" parameter.)

Please let me know if the aboev can address you issue.

Regards
Peter Kwan

  Re: Set Scatter Chart scale specifically...
Posted by Edward Hermanson on Feb-11-2013 13:41
Thank you Peter. Yes that is what I needed. setTickDensity() works best. Our print charts are 3X larger so 20/60 is perfect. Once again you have been very helpful.