Because i did a tutorial on how to make pie charts in PHP. I thought i would make a series of them lol. Next is how to make a simple line chart.
This line chart is very basic and may seem detailed less, but this will help you get a feel on how to start. I will later be creating more advance ones of each of these different type of graphs, so stay tuned
Firstly i want to set up some arrays to hold our values. We are going to make 2 sets of arrays with the same results. This is because we will later change one set and keep the others the same for later use.
//We want to count how many arrays we have
$count = count($Array);
//Add all the values together
$arraySum = array_sum($Array);
Currently with this script we can only make the graph using 11 different figures. I will show you later how we can change this in a more advance tutorial.
Now we have done that, we want to set the image width and height
$imgWidth=250; // Do not change
$imgHeight=250; //Do not change
For the purpose of this tutorial, do not change the values as it will cause problems. In the advance tutorial will go through this.
Now what we need to do is change the first set of values. These will be used to plot the graph. If we did not do this process we would have a problem. If we used the values we have in the array at the moment. One major error will occur. That is if any of the values are over 250 will mean the plot will appear outside of the actual image and because we have a value over a 1000 it will appear WAY outside the image.
We need to make these first set of numbers easier to plot and stay within out boundaries. We can do this by using the following code.
the code above will set the array values to a smaller number, but of course in comparisons these values would still plot the same as the normal ones would, but the new ones will stay in the image boundaries.
We need to now set the header as a image type
And now we can start actually creating the colours we are going to use and also create the actual image the graph will show on.