|
Area Chart |
Posted by Dan on Apr-16-2012 20:03 |
|
Hi Mr. Kwan
I am working with your chart software and until now everything worked fine.
But there is a problem, maybe you can help me with a quick info.
Have a look at the picture i posted.
There you can see a water level measurement(blue) drawn by height of the groundwater level and the date.
There is also a line(red) in the chart representing a border for whatever. Nevermind it is just a simple line.
Here comes my question. Is it possible to draw the area chart like:
- the area over the 0 level has to be grey
- the area between 0 and the blue line has to be grey
- the area below the blue line has to be filled out with blue, no matter if the blue line is in + or - scale
Right now my code looks like this:
$c = new XYChart(742, 251, 0xffffff, 0xcccccc);
$c->setPlotArea(45, 35, 680, 175, 0xA6CAE6, -1, -1, $c->dashLineColor(0xA6CAE6, 0x000103), $c->dashLineColor(0xA6CAE6, 0x000103));
$c->xAxis->setLabels($label_x);
$layer = $c->addAreaLayer();
$snowPattern = $c->patternColor2("../ChartDirector/phpdemo/water_inverse.png");
$lineLayerObj = $c->addLineLayer($compareline, -1, "Red Transactions");
$lineLayerObj->setLineWidth(2);
$layer = $c->addAreaLayer();
$areaLayerObj = $layer->addDataSet($data);
$areaLayerObj->setDataColor($snowPattern, 0x095EA8,-1,-1);
$areaLayerObj->setLineWidth(2);
$c->yAxis->setLinearScale(-20, 10, 5);
header("Content-type: image/png");
print($c->makeChart2(PNG));
With the standard properties the area will be filled out between 0 and minus waterlevel blue line. For me this doesn't fit. Just the area below the blue line has to be blue.
Right now i do it like this:
The background of the plotarea is deepblue. Then i take the grey color to fill out the area. This works only for the area between 0 and the blue line. And as you can see it doesn't work at all.
What else can I do?
Is there any method or code that just fills out an area below a line?
Or how can i erase the "0" as an important point for the area? Because the 0 looks like a special value for the area. The area always depends on the 0. How can i change the 0 to e.g. -100 that the area will be filled out from the blue line to the -100 ?
Thank you
Dan
|
Re: Area Chart |
Posted by Peter Kwan on Apr-17-2012 03:40 |
|
Hi Dan,
From your requirement, I assume it means the followings:
- The area below the blue line is blue. All other area is grey.
To do this, you may set the plot area background to grey. Then you may add an area layer using the blue line, and use Layer.setBaseLine to set the baseline to a large negative value, like:
$areaLayerObj->setBaseLine(-999999999);
Hope this can help.
Regards
Peter Kwan |
Re: Area Chart |
Posted by Dan on Apr-17-2012 15:46 |
|
Hi Peter,
cool this helps. I tried it and it works.
Before your answer i found this solution:
$m = $c->yAxis->addMark(-999,0,0);
$SLL = $c->addLineLayer($data, 0xA6CAE6, "Line");
$SLL->setLineWidth(2);
$c->addInterLineLayer($SLL->getline(),$m->getline(),0xA6CAE6);
It worked as well but your solution is better.
Thanks mate. |
|