1

I'm using the pChart library and I want to have a X scale of 1-100 but on the chart I want to have divisions in multiples of 10. I have 2000 data points.

Unfortunately my axis X is not readable, as the | is placed at every axis unit, rather than every 10. Now it looks like this - any ideas?

enter image description here

Edit: after using @EPICWebDesign tip i got enter image description here

How to remove duplicate X values. I can do array_unique but then i lose some points on chart.

kskaradzinski
  • 4,954
  • 10
  • 48
  • 70

1 Answers1

1

First Answer

If this is pChart 2, you can use the LabelSkip setting.

ie: "LabelSkip"=>$X,

will make it show only each $X th label, while still showing all of the data points.

From the wiki: You can skip specified number of X labels using LabelSkip. http://wiki.pchart.net/doc.doc.draw.scale.html

Second Answer

You can make the duplicate x axis values null. See PHP: duplicate value removal

Here is a more specific example:

$x = array(1,1,2,3,4,5);
$prev = -1;
foreach ($x as &$point) {
  if ($prev === $point) {
    $point= NULL;
  }
  else {
    $prev = $point;
  }
}
unset($point);
print_r($x); // 1,NULL,2,3,4,5...
Community
  • 1
  • 1
  • I've edit my post could U anwser one more question, about axis X – kskaradzinski May 17 '12 at 07:51
  • Labelskip shouldn't change the data.. I notice the two graphs are very similar but not exactly the same. Are you able to post code? As far as the 1 showing twice, it looks like it did on the first one too, but automatically skipped it there. on the second graph you manually set it to skip 10 spaces, so it showed 1 twice. What is this graph portraying? –  May 17 '12 at 13:44