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

Message ListMessage List     Post MessagePost Message

  Area charts with gaps
Posted by Dave on Jan-27-2012 07:47
Attachments:
Hi,

I'm trying to use an area chart that has some missing data in it.  I'm using setGapColor to set a dashed line when there is no data available.  This looks fine when I use a line chart, but when I use an area chart, it ends up looking pretty awful (see attached picture)

Since it does not look like I have the ability to change 'how' that area gets filled, I've been trying other things, but none of them look quite right.  The best answer appears to be to use a pattern with patternColor2 and setDataColor, but patterned areas with gaps appear to completely break ChartDirector.

I've attached the code I'm using for testing.  Could you tell me:
1) is there a way to change the appearance of the 'dashed line fill' for areas?
2) is there something I am doing wrong when using the pattern fill?

Thanks,
Dave
bad_area_fill.png
broken_pattern.png
bad_area.php
bad_area.php

2.30 Kb

  Re: Area charts with gaps
Posted by Peter Kwan on Jan-28-2012 00:51
Hi Dave,

The "dash line color", as its name implies, is intended to color lines only. It cannot be used to fill a region.

Using "pattern color" should work. However, in your case, in your "pattern color" code, you seem to be creating two area layer, with the second area layer being a "Stacked Area Layer" with one data set. (If you just call addAreaLayer without any parameter, it would be treated as addAreaLayer2, and the default would be a Stacked Area Layer.) The correct code should be to set the gap color in the first and only area layer to be a pattern color. In a "Stacked Area Layer", what is plotted is the "stacked area". It means the area begins at 0, and when a data set is added, the area is "stacked up". If a data value is NoValue, the area is not stacked up, but remains at 0. That means your area is from 0 to around 85.6. So the y-axis scale needs to start from 0. You can see that in the "pattern color" chart in your message, the chart is correct. (The top line is at around 85.5, which accurately reflects your data.) The difference is in the y-axis scale. In your "dash line" example, the y-axis scale starts from 85.0, but in your "pattern color" example, the y-axis scale starts from 0, because the latter chart is a stacked area chart.

For using the "pattern color" as the gap color, the correct code is just to set the pattern color as the gap color. There is no need to create two layers.


$l = $c->addAreaLayer($data, $color);
$l->setBorderColor(Transparent);
$l->setXData($labels);
$snowPattern = $c->patternColor2(dirname(__FILE__)."/snow.png");
$l->setGapColor($snowPattern);


Hope this can help.

Regards
Peter Kwan

  Re: Area charts with gaps
Posted by Dave on Jan-28-2012 04:39
That fixed it.  Thanks.