|
Arbitrarry XY chart, x axis labels |
Posted by Joe on Apr-15-2011 02:53 |
|
Hello,
I am using PHP chartdirector to create an arbitrary XY chart. My Y values are precentages and my X values are dates. I only want to the labels on the X axis to show for dates that have data for them, how do I force this to happen as right now it seems to calculate its own labeling? Thank you. |
Re: Arbitrarry XY chart, x axis labels |
Posted by Peter Kwan on Apr-15-2011 16:33 |
|
Hi Joe,
If you are using an auto-scaled x-axis, you may disable all labels, and use Axis.addMark to add your own labels. For example (in PHP 5.x):
$c->xAxis->setLabelFormat("~"); //disable auto-scale labels
for ($i = 0; $i < count($dataX); ++$i) {
$c->xAxis->addMark($dataX[$i], 0xcccccc, $c->formatValue($dataX[$i], "{value|mmm-dd}"))->setDrawOnTop(false);
}
Hope this can help.
Regards
Peter Kwan |
Re: Arbitrarry XY chart, x axis labels |
Posted by Joe on Apr-18-2011 23:25 |
|
Thank you, that solved the issue. I also had an issue with tool tips. In my code, I wanted the the tool tips to display the date that is indicated on the x axis. On some data points it will work, on some it just give s a blank. I have attached an image of my chart. There are esssentially three lines being plotted, but all overlaid on each other. On some dates there are a change in the data, indicated by the gray x, the red triangle indicates a normal day.
First I have a trendline with no symbols. This shows the correct value for every date.
Second I added a trend line that has the red triangle symbols for every regular date, and a "NoValue" for every other point. This has no line to connect the symbols.
Third I added a trend line that has the gray cross symbols for every date with special data, and a "NoValue" for every other point. This has no line to connect the symbols.
The code has me placing these trends in the order of
1. Gray Symbols
2. Red Triangles
3. No symbols, but trend line
My tooltip code is:
$toolTip = "title='{field1}-{xLabel}:{value|1}% ({field0}) '";
Where xLabel (date) is not showing up for the gray crosses |
Re: Arbitrarry XY chart, x axis labels |
Posted by Peter Kwan on Apr-19-2011 00:30 |
|
Hi Joe,
In the tooltip configuration, the {xLabel} refers to the x-axis labels. If there is no label on the x-axis for a particular point, the {xLabel} would be empty.
I think instead of using {xLabel}, you may use {x|mm/dd/yyyy}. The {x} refers to the x-coordinate of the points, which should be what you intend to show.
For the trend lines, for some reason, I do not see any attachment with your post. So I can only guess. I guess the trend lines you are drawing are created using addLineLayer (instead of addTrendLayer). For the addLineLayer, if there is a NoValue point in the data series, ChartDirector will interpret this to mean a broken line. See the sample code "Missing Data Points". Basically, ChartDirector will draw a line segment joining a point with the next point. However, if the next point is NoValue, then no segment will be drawn for that pair of points. If every data point has a NoValue point next to it, no segment can even be drawn.
If you intend to draw a line layer joining only the non-NoValue points, you may:
(a) Instead of changing some points to NoValue points, just remove them from the data series.
or
(b) Set the line gap color to the same color as the line color. (This is demonstrated in one of the lines in the "Missing Data Points" sample code.) It is like:
$layer->setGapColor(SameAsMainColor);
If the above still does not solve the problem, would you mind to try upload the image file once more? Note that the forum has a 250 Kbytes upload limit. To upload a file, please use the "Browse" button to browse to the file.
Hope this can help.
Regards
Peter Kwan |
|