Jpgraph: How to manually set Ranges for X-axis and Y-asxis

Friend picture Friend · Sep 13, 2012 · Viewed 8.4k times · Source

Hello People i need to make some change to Jp graph...

1)i need to set X-axis range from '0' to '100' with step size '10'.

2)i need to set Y-axis range from '-5' to '6' with step size '1'.

3)i need to label the point selected on the graph, something like if the selected values are

'70' and '2'(which is shown in the graph),i wanna name it as 'point1' , if the second selected point lies on '80' and '3' then i want to name it as 'point2'..'point1 and point2 should come on the graph itself...'..is there a way to fix this?please help me to do fix these issues...

Answer

Josh Naylor picture Josh Naylor · Sep 25, 2012
$graph = new Graph(450,400,'auto');
$graph->SetScale("textlin");

// set major and minor tick positions manually
$graph->yaxis->SetTickPositions(array(0,10,20,30,40,50,60,70,80,90,100), array(5,15,25,35,45,55,65,75,85,95);

$graph->xaxis->SetTickLabels(array(-5,-4,-3,-2,-1,0,1,2,3,4,5,6));

$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
$graph->xaxis->HideLine(false);
$graph->xaxis->HideTicks(false,false);

Thats point 1 and 2. I dont know about 3 but they're plenty on online tutorials. Check out http://jpgraph.net/