0

I am trying to use the pChart PHP Library for generating a graph. And I am confused about its documentation.

To add data to the graph, the documentation uses code like:

 $MyData = new pData();  
 $data = array(1,2,3,4,99);//some data
 $MyData->addPoints($data,"My Label");

The data plots well on the graph.

What I fail to understand is how is a singular number plotted on X-Y axis. Shouldn't the data be in (x,y) format ?

How's a single number plotted on a XY graph ?

Thanks a lot !

2 Answers2

2

pChart uses series for multiple data sets. Some graphs will allow you to plot one data set against another, for others you overlay data from different series.

However, some charts don't make sense to have multiple data sets, or are best not done this way. Line charts by default are based on an assumption that values on the y axis are 'invariable' and values on the x axis are variable. If no details are given for y, it simply uses the position of the values of x in the array.

The scatter plot will allow you to plot one serie against another. If you import from csv, you can easily assign columns to different series.

0

A single-series column or bar chart

These sort of charts pre-formatted for both positive and negative values. In case of negative values, the X-axis position adjusts itself. They are good for comparing values within a data category, such as monthly sales of a single product. For this you can provide name of months or first month, second month and so on (would be Y-axis).

If you have senario like above example and you did not provide data points for Y-axis program would take respective position of X-axis point as Y-axis point. In this case, key of X-axis point array.

As Pepin the Small explains, some charts still make sense having points for only one serie. Find a example below.

enter image description here

Dan
  • 11
  • 2