SVGGraph 3.0.1 is a bugfix release, but there are a lot of changes in it. Sometimes you just have to rip up the floorboards to kill that annoying insect.*
2,75px s'il vous plaît
The bug that caused all these changes is a very simple one: PHP automatically converts numbers to strings using its current locale. This makes perfect sense, but it meant that running SVGGraph in a locale that uses a comma instead of a full-stop for the decimal separator produced garbled SVG output. SVG always uses a full-stop for its decimal separator, with commas or spaces used for separating values.
To fix this, there are four new classes for the different areas where things
can go wrong.
Attribute are low-level
classes for SVG number values and element attributes.
a class for managing rotation, translation and any other transforms, and
PathData is a class for SVG path elements, which use strings of
numbers and command characters to represent lines, curves and angles.
This all seems a bit much
Why not just wrap the whole of SVGGraph in a big
setlocale(LC_ALL, 'C'); and forget all about it? That was my first
thought, and I think it would probably work in most cases. But the manual page
setlocale has a big warning box on it that says that the
locale is set per-process and not per-thread. What that means is that setting
the locale in one script also sets the locale in other server threads, so if I
had tried to fix it that way SVGGraph could be:
- modifying the output of unrelated scripts in other threads;
- modifying the output of SVGGraph instances in other threads;
- affected by unrelated scripts in other threads using
None of these are very appealing, and the idea of decimal points flip-flopping between commas and full-stops at random points in a script's execution is a bit worrying. My advice: don't convert numbers to strings until you need to output them.
In any case, the new version of SVGGraph is available from the downloads page, or from GitHub / Packagist with Composer.
* I've never ripped up the floorboards to kill an insect, and I don't really think it is a good idea. If you have a problem with insects in your home, contact a professional exterminator and maybe they will spray them or something.