Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all you need to define your y points, for this we need a range. As you are creating your array I would have two variables, <code>$minYear</code> and <code>$maxYear</code>, then for every entry into the array you check if it's smaller than minYear, or bigger than maxYear, and if so replace the value with this one.</p> <p>That gives us our min and max, now we need a range. You need to determine how many points between each year you have. To keep things simple I'm going to assume 1 year is one increment on the y axis. However if you have a maximum number of points on the y axis you can use, then you can use the following formulae to work out how many years are between each point:</p> <pre><code>$increment = ($maxYear - $minYear) / $numPointsOnYAxis; </code></pre> <p>That will give you how many years are between each point on the Y Axis. For simplicity you may wish to round that number using the <code>ceil()</code> function. It means you won't use every point on the Y axis, but it keeps the maths nice and easy.</p> <p>Now we have our range you can use foreach loops to go through your data and plot the graph.</p> <pre><code>$space = ''; foreach($array as $num =&gt; $a) { echo $space . '[x' . $num; foreach($a as $year =&gt; $value) { $y = ceil(($value - $minValue) / $increment); //Work out how many increments up the scale the year needs to be. echo ', y' . $y; } echo ']'; $space = ', '; } </code></pre> <p>That should echo out what you are after. Please not that I haven't tested this code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload