2

How to show only a fixed number of labels in X-Axis ??

I have tried "LabelSkip", but I think it works only with an interval and not with fixed number of labels.

Here is a print-screen of my chart: enter image description here

Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
Bizboss
  • 7,792
  • 27
  • 109
  • 174

4 Answers4

3

I know it has been a while since this was asked, but it may help someone:

$maxXLabels = 5; // How many labels on-screen?

$labelSkip = floor( count( $timestamp ) / $maxXLabels ); // how many should we skip?
$myPicture->drawScale(array("LabelSkip"=>$labelSkip));
gaco
  • 31
  • 1
3

Are you using pChart 1 or pChart2 ?

This can be achived in pChart 1 using setFixedScale

To draw a scale with a maximum value of 10 with 5 points use the following command before drawing the scale

$Graph->setFixedScale(0,10,5);
Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
  • In pChart2, I found this to be the only way $myPicture->drawScale(array("MinDivHeight"=>50); So if your chart area is 400px wide, this will show 8 labels. Changing it to 100px will only show 4 labels. – Joel Deutscher Jun 16 '11 at 08:06
  • Does this not work for you anymore? If you unaccept the answer, it would be great to know what you used that did work for you. – Joel Deutscher Feb 05 '12 at 22:29
  • $myPicture->drawScale(array("MinDivHeight"=>50); don't work for me – Bizboss Feb 06 '12 at 10:22
1

I have used "LabelSkip"=>(count($series)/10) to have 10 labels on the X axis

Works fine for me

Yair
  • 11
  • 1
0

Joel Deutscher's answer worked for me. I would have up voted it, but I do not have enough stackoverflow reputation for that.

It works exactly as he said: Chart Width / MinDivHeight = Number of labels on the chart.

Here's my code

$scaleSettings = array("DrawXLines"=>FALSE,"Mode"=>SCALE_MODE_START0,"GridR"=>0,"GridG"=>0,"GridB"=>0,"GridAlpha"=>10,"Pos"=>SCALE_POS_TOPBOTTOM, "MinDivHeight" => 50);

$pchart->chart->drawScale($scaleSettings);
Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
Jason S.
  • 485
  • 2
  • 10