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

Message ListMessage List     Post MessagePost Message

  Problem using area layers and autoscale
Posted by Eugene Kuch on Jan-30-2011 00:15
Hi there,

I have a question of using area layers and auto-scaling together.
There is a chart with several areas. Here is sample python code:

c.yAxis().setAutoScale(0.1, 0.1, 0)
some_area = c.addAreaLayer2(Stack)
some_area.setXData(['1','2','3'])
ds1 = some_area.addDataSet([100, 101, 102]).setDataColor(Transparent, Transparent)
ds2 = some_area.addDataSet([4, 5, 6]).setDataColor(0xaaaaaa, Transparent)

I suppose to see y-axis to have values about in range 80-130, but instead it appears to be in range 0-130. Looks like ChartDirector really treats second dataset as [4,5,6] instead calculates ds1+ds2 ([104, 106, 108])

I know I can use setLinearScale(80, 130) to get the desired effect, but is it a feature or a bug which can be fixed?

  Re: Problem using area layers and autoscale
Posted by Peter Kwan on Jan-31-2011 17:39
Hi Eugene,

For a stacked chart with purely positive data, by default, ChartDirector will set the axis scale to start from 0, because it is consistent with the most common reason of using a stacked chart.

For example, in your case, you can say ithe data range is from 100 to 108. Suppose ChartDirector chooses an axis scale of 99 to 109 (so the labels is 99, 100, 101, ... 109). Assuming both stacks are coloed, the bottom stack (the first data set) will appear to be small compared to the top stack (the second data set). This is misleading as the data values for the bottom stack (100 to 102) are much larger than the top stack (4 to 6).

The problem is because in a stacked chart, people will compare the data values both vertically and horizontally. If the bottom stack has a much larger value than the top stack, the bottom stack should also occupy much more space. So we cannot trim the y-axis from the bottom side, just like we cannot trim the x-axis from the left or right side. In contrast, for a normal line chart, people are only comparing data values horizontally, so we can trim the axis from the bottom side.

For your case, I see that you do not intend to display the bottom stack at all (it is set to Transparent). So it seems your intention is to fill a region between two lines. For this type of chart, you may consider to use a "InterLineLayer". The "InterLineLayer" is a layer that can fill the region between two lines.

For example:

line1 = c.addLineLayer(data1, 0xaaaaaa).setXData(dataX)
line2 = c.addLineLayer(data2, 0xaaaaaa).setXData(dataX)
c.addInterLineLayer(line1.getLine(), line2.getLine(), 0xaaaaaa)

Hope this can help.

Regards
Peter Kwan

  Re: Problem using area layers and autoscale
Posted by Eugene Kuch on Jan-31-2011 19:19
Hi Peter,

Excellent! Your example is exactly what i need. I looked for this feature in documentation but didn't find somehow.

Thank you very much for advising!

Eugene