|
Proper way of adding lines to scatter charts? |
Posted by Rick on Jan-09-2011 15:13 |
|
Peter,
Using addScatterLayer and setting the symbol argument to 0 and fill/edge color to a valid
color permits me to generate a scatter line graph of my desired color.
Using addScatterLayer and setting symbol argument to >0 gives me a xychart with
symbols only.
Now, what should I do if I want both symbols and lines? Using php version.
Thanks! |
Re: Proper way of adding lines to scatter charts? |
Posted by Peter Kwan on Jan-11-2011 00:07 |
|
Hi Rick,
There are plenty of sample code included in ChartDirector with both symbols and lines. For example, see the sample code:
Symbol Line Chart
Symbol Line Chart (2)
Missing Data Points
Uneven Data Points
Spline Line Chart
Multi-Symbol Line Chart
Rotated Line Chart
Arbitrary XY Line Chart
(You may look for the above examples by using the ChartDirector documentation index.)
Hope this can help.
Regards
Peter Kwan |
Re: Proper way of adding lines to scatter charts? |
Posted by Rick on Jan-12-2011 03:46 |
|
Let me ask this a different way -- what are the differences between addScatterLayer and
addLineLayer in how it plots the data? For the X-axis, a line layer has the same distance
between each data point (X value) or is the distance between each point (X value)
determined by the actual X value of the point like a Scatter layer?
Using addScatterLayer to add data to my graph (including missing data) gives me
symbols. What should I do to add a line that has a different color than the symbols? Do I
then need to do a addLineLayer to add the line, and will it deal with missing data ok?
Thanks! |
Re: Proper way of adding lines to scatter charts? |
Posted by Peter Kwan on Jan-12-2011 18:56 |
|
Hi Rick,
Currently, the scatter layer is just a line layer with the line width set to 0 by default. So the scatter layer is in fact the same as the line layer. Everything that can be achieved with a line layer can also be achieved with a scatter layer, and vice versa.
For a line layer, the horizontal distance between each data point is determined by the x-data value of the points, if they are provided (see the "Uneven Data Points" sample code). If you do not provide the x-data values, ChartDirector will automatically set the points as equally spaced. This is the same for the scatter layer (this is what would happen if you use an empty array as the x-data array in addScatterLayer).
For your case, if you need both lines and symbols, you may use a line layer. The code is like (in PHP 5):
$layer = $c->addLineLayer($myYData, 0x0000ff, "My Line");
$layer->setXData($myXData);
$layer->getDataSet(0)->setDataSymbol(DiamondSymbol, 11, 0xff0000, 0x000000);
As demonstrate in the example above, you can use different colors for the line and symbols.
You can handle missing data in a number of ways (leave a gap, use a dash line to bridge the gap, or just join through the gap as it does not exist). You may refer to the "Missing Data Points" sample code for reference.
Hope this can help.
Regards
Peter Kwan |
|