My x axis is in feet from zero to many thousands. I divide the x values by 100 before populating with addXY. I increment by 1. Thus the x axis shows 1, 2, 3, etc. with 3 minor ticks between them. However, I need to increment by .5 with 4 minor ticks and the format of the labels needs two decimal points with a plus sign (+) substituted for a period (.).
So my x axis needs to display like... 0 0+50 1+00 1+50 2+00 etc. with the minor ticks in between. I have been unsuccessful at even getting the axis labels to format with two decimal points, let alone substituting the period with a plus sign.
I need to know exactly how (detailed) to accomplish this formatting. And please don't ask for a project, simply pick any line chart and put the x axis in feet from zero up to a few hundred / 100, increment by .5 and what you will get is 0, 0.50, 1, 1.50, 2, 2.50, etc. Which, as explained, needs to be (for me) 0, 0+50, 1+00, 1+50, 2+00, 2+50, etc.
X axis label format
-
- Newbie
- Posts: 22
- Joined: Tue Apr 30, 2013 12:00 am
Re: X axis label format
Well, nevermind.... but for others needing anything similar, I finally got it like this..
Code: Select all
// Args contains axis, index order to be displayed, labelText
function handleGetAxisLabel($sender, $args){
if ($args[0] === $sender->getAxes()->getBottom()){
$args[0]->getLabels()->labelText = number_format($args[2],2,"+","");
}// end if
}// end function
$handlers = new EventHandlerCollection();
$handlers->add(new EventHandler(new ChartEvent('OnGetAxisLabel'),'handleGetAxisLabel'));
//$chart = new TChart(1000,600, $handlers);