SVGGraph 3.20
Published
This version of SVGGraph ticks off something that has been on the to-do list since late 2019, so I'm glad to get it done. Especially because I had to learn or relearn some maths stuff to get it working.
Curved best-fit lines
I wasn't actually sure if this was a good idea or not - after all, I've already added support for curved line graphs. There is an important difference though: curved line graphs draw a curve that passes through all the points, whereas a curved best-fit line is a plot of the mathematical function that best matches the points.
Here's an example using the data from a previous graph that shows earthquake magnitudes with a curved best-fit line added in:
I don't believe the magnitude of earthquakes worldwide follows a mathematical curve, but this graph shows the best match for the data using a quintic function.
Okay, but what's "quintic"?
A quintic just means a mathematical function with fifth power in it like this:
y = ax5 + bx4 + cx3 + dx2 + ex + f
This is the default curve function that SVGGraph will use. There is a new option,
best_fit_type
that can be set to another function to use instead, e.g.
“quadratic”, “cubic” or “quartic”. I am planning
to add support for more types of curve, but these seemed like a reasonable start.
Anything else?
The only other change in this version is adding support for using CSS units
in font sizes and line spacings. By CSS units, I only mean fixed units, not things
like em
or ex
. To be more specific, the supported units
are px
, in
, cm
, mm
, pt
and pc
.
Download here
The new version of SVGGraph is available from the downloads page, or from GitHub / Packagist with Composer.