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

Message ListMessage List     Post MessagePost Message

  tick spacing in Arbitrary XY Line Chart
Posted by Rob on May-16-2012 05:29
Hello,
I have this XY line chart, where the Y values are percentages, and the X values are ChartTime dates for a given set of time. The X values are the dates for when a value was expected, and may not necessarily have a corresponding Y value (it then has NoValue passed). I used the following ChartDirector functions to remove all auto labels, and then create one for each date I passed in an array


$c->xAxis->setLabelStyle("", 8, Transparent);
$c->xAxis->setLabelFormat("~"); //DISABLE AUTO SCALE LABELS
#-------------------------------------------------------------------------------
for ($a = 0; $a < count($EntryDateHolder); $a++)//{
#-------------------------------------------------------------------------------
$markObj = $c->xAxis->addMark($EntryDateHolder[$a], -1, $c->formatValue($EntryDateHolder[$a], "{value|yyyy-mm-dd}"));
$markObj->setMarkColor(0xcccccc, 0x000000);
$markObj->setDrawOnTop(false);
$markObj->setFontAngle(45);
#-------------------------------------------------------------------------------
}//END FOR

I am passing each daily date from a previous set range. I see the XLabels and Gridlines for each of the daily updates, but in between each day there is another vertical gridline. Also, for some reason the spacing is longer than the others in between the gridlines at a random section of the chart.

Are there other ChartDirector formatting commands I have forgot to include to fix thids? Thank you.

  Re: tick spacing in Arbitrary XY Line Chart
Posted by Peter Kwan on May-17-2012 03:55
Hi Rob,

Usually, if someone wants to determine all labels on the axis, he would also want to determine the axis scale (instead of using auto-scale). Otherwise, there is no guarantee that the axis scale will be appropriate for the labels.

For your case, if all your labels are one day part, you may consider to use:

#specify the axis scale and use daily labels
$c->xAxis->setDateScale($EntryDateHolder[0], $EntryDateHolder[count($EntryDateHolder) - 1], 86400);
#the label format
$c->xAxis->setLabelFormat("{value|yyyy-mm-dd}");
$c->xAxis->setLabelStyle("arial.ttf", 8, 0x000000, 45);

If you prefer to use your existing method, the setLabelStyle and setLabelFormat line should have remove all aut0-scale labels and their associated grid lines (unless they are called after the axis has already been layout using BaseChart.layout or BaseChart.layoutAxes, or there are another setLabelFormat line in your code that sets the label format back).

To test if this is the case, you may consider to remove your "for" loop. Do you still see any vertical grid lines? If you still see the grid lines, may be you can comment out the setLabelStyle and setLabelFormat line so as to see the actual auto-scaled labels.  Are the grid lines aligned with the auto-scaled labels (meaning that the grid lines are caused by the labels)?

Also, for testing, you may consider to use the label format "{value|yyyy-mm-dd hh:nn:ss}". In this way, you can be sure that the marks are really equally spaced.

If the above still cannot solve the problem, would you mind to inform me the complete charting part of your code, as well as the resulting chart image? I will try it myself to diagnose the problem.

Regards
Peter Kwan