This article mainly introduces the method of using Jpgraph to draw a simple X-Y coordinate graph in php. The example analyses the related techniques of drawing a coordinate graph and drawing a curve in Jpgraph, A friend of the need can refer to the example of this article describes the php using Jpgraph to draw a simple X-Y coordinate graph method. Share it with you for your reference. The specific implementation method is as follows:
<? Php include ("src/jpgraph. php "); include (" src/jpgraph_line.php "); // store the data to be used for chart creation in the array $ data = array, 90,96); $ graph = new Graph (400,300); // create a new Graph object $ graph-> SetScale ("textlin "); // set the scale style $ graph-> img-> SetMargin (30, 30, 80, 30 ); // Set the chart boundary $ graph-> title-> Set ("Year to Date Cost "); // Set the chart title // Create the linear plot $ lineplot = new LinePlot ($ data); // Create a new LinePlot object $ lineplot- > SetLegend ("Amount (M dollars)"); // Set the legend text $ lineplot-> SetColor ("red "); // Set the curve color // Add the plot to the graph $ graph-> Add ($ lineplot ); // draw a curve on the statistical graph // Display the graph $ graph-> Stroke (); // output the image?>
After running:
I hope this article will help you with php programming.