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

Message ListMessage List     Post MessagePost Message

  Single Y axis having multiple scale
Posted by niket singh on Nov-21-2013 18:02
Hi,

  is it possible to implement in sigle y-axis we can have multiple scale ?

  Instead of having multiple y-axis could we have single y axis in which from top to bottom
we have scale for various datasets like :- for some of yaxis from top we could have scale
for vehcile speed after that we could have for engine speed and so on.

and one more thing can we hide some y-axis scale in multiple y-axis chart but from
functionality point of view it must be intact.

Thanks in advance

Regards
Niket Kumar Singh

  Re: Single Y axis having multiple scale
Posted by Peter Kwan on Nov-22-2013 03:23
Hi niket,

In ChartDirector, multiple scales mean multiple axes. You can put multiple axes in the same place, and configure them so their scales do not overlap.

Consider the "Multple Axes" sample code included in ChartDirector. On the left-side, there are two y-axes. The sample code configures them to be 50 pixels apart. You can change the code so that they are 0 pixels apart, but then their scale overlaps. To solve the problem, you may use Axis.setMargin so that the axis scale does not cover the entire axis. An example is:

//130 pixels top margin - so the yAxis will not put labels in the top 130 pixels. As the
//plot area height is 230 pixels in the sample code, it means the yAxis is using only the
//bottom 100 pixels for the labels
c.yAxis().setMargin(130, 0);

//130 pixels bottom margin, so the leftAxis will not put labels in the bottom 130 pixels.
//It means it is using the top 100 pixels for the labels.
leftAxis.setMargin(0, 130);

You may extend the above method for more axis so that each axis has a segment to put its labels.

Hope this can help.

Regards
Peter Kwan

  Re: Single Y axis having multiple scale
Posted by niket singh on Nov-22-2013 17:13
Hi Peter,

   Peter it's working but what is happening right now is , say i have eight axis and i have
drawn these eight axis at the same distance from the plot area. I have also set the margin
for these eight axis so that all eight axis come one upon other. But the color that i want
and the name at appropriate place did not come. The name and color overlap to each other.

Then i found there is a command Axis.setLength() which i have used which gave me some
sort of solution for the appropriate placement of eight axis scale but eventually it was not
the perfect one even chart layer draws as scale length is plot area length.

is there any way to have a yaxis having four scale or eight scale that depends on
requirement, and also i have to keep the name of the scale in single yaxis left aligment.

I have also tried with setMargin and setLength simulatenously but that also did help me
much . looking for your help again.

otherwise i have to draw it manually using some textBox.

Regards
Niket Kumar Singh

  Re: Single Y axis having multiple scale
Posted by Peter Kwan on Nov-23-2013 00:19
Hi Niket Singh,

For the axis title, you may use BaseChart.addText to add the title text instead of using Axis.setTitle. The BaseChart.addText allows you to add text to any position using any color. Because your code sets the axis margins, and therefore knows the position of the axes, so it should be able to add the titles at the appropriate positions.

For the axis "stem", because they overlap, you may consider to use the same color for all the axis stem (such as black or grey or transparent). You may use different colors for the axis ticks and axis labels. The Axis.setColors allows you to set the colors of the axis stem, ticks and labels separately.

If you would like to axis "stem" to have different colors as well, you may use BaseChart.addLine to add the color line yourself.

An example is:

myAxis.setMargin(a, b);
c.addLine(c.getPlotArea().getLeftX(), c.getPlotArea().getTopY() + a, c.getPlotArea().getLeftX(), c.getPlotArea().getBottomY() - b, myAxisColor);
c.addText(c.getPlotArea().getLeftX() - 50, c.getPlotArea().getTopY() + a + c.getPlotArea().getBottomY() - b) / 2, myAxisTitle, "Arial Bold", 8, 0x000000, Chart.Right);

Hope this can help.

Regards
Peter Kwan