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

Message ListMessage List     Post MessagePost Message

  simpleline.pl
Posted by Leo on Oct-05-2011 09:22
Hey, Peter, great software!

I just want to make simpleline.pl a simple finance chart:

1. how do I make a vertical "gray shaded area" between 12 to 18 on the x-axis, to indicate
recession, for example.

2. how do I make the curve a spline one?

3. how do I add "volume" bar chart at the bottom of the "simple chart"?

Thanks a million.

  Re: simpleline.pl
Posted by Peter Kwan on Oct-06-2011 01:59
Hi Leo,

1. how do I make a vertical "gray shaded area" between 12 to 18 on the x-axis, to indicate recession, for example.

You may use Axis.addZone. For example:

# Add a grey (0xdddddd) zone from the 13th to the 19th x-label position
$c->xAxis()->addZone(12, 18, 0xdddddd);

You may refer to the "Marks and Zones (2)" sample code for another example. (You may look for "Marks and Zones (2)" from the ChartDirector documentation index.)

For a finance chart, it is customary not to treat y = 0 as special (that is, there is no need for the axis to have a tendency to start from 0). The code to disable the "zero affinity" in auto-scaling is:

#Disable zero affinity. Leave 5% scaling margin at top and 15% at bottom. The bottom
#margin is larger to reserve space for the volume bars. See (3) below.
$c->yAxis()->setAutoScale(0.05, 0.15, 0);

2. how do I make the curve a spline one?

Instead of using addLineLayer, please use addSplineLayer.

3. how do I add "volume" bar chart at the bottom of the "simple chart"?

I assume you mean to put the volume bars and the spline within the same plot area (something like in the "Finance Chart (1)" and "Finance Chart (2)" sample code), as opposed to creating two completely separate charts (with 2 plot areas) that happen to be on top of each other.

You may use addBarLayer to add a bar layer to an existing plot area. You would need to bind the layer to a separate y-axis, as the spline is representing price, and the bars representing volume. The code is like:

$layer = $c->addBarLayer($myVolData, 0xffcccc);
$layer->setUseYAxis2();

//use only the bottom 20% of the plot area for the bars
$c->yAxis2()->setMargin($c->getPlotArea()->getWidth() * 0.8);

If instead of the above, what you mean is to have two complete separate charts stacked vertically, you may create two separate charts (two separate XYChart objects), one for the line chart, and one for the bar chart. Then you may create a MultiChart object, and add both charts to the MultiChart object. You may want to disable the x-axis labels on one of the charts (as I suppose one set of x-axis labels is sufficient). This is by setting the axis colors to Transparent using Axis.setColors.

Hope this can help.

Regards
Peter Kwan

  Re: simpleline.pl
Posted by Leo on Oct-07-2011 09:45
Thanks a lot !!