react-trend v1.2.3 Release NotesRelease Date: 2017-03-10 // almost 3 years ago
🛠 Fix bug with single-value Trends coloured by gradients
v1.2.2fixed an issue with single-value Trends, but I was only testing it with single-colour Trends, not ones with gradients.
0️⃣ It turns out a quirk of the default
objectBoundingBoxgradient space is that paths that are 0px tall cannot have gradients applied. Even if the stroke of the path means that it's 10px of actual screen-space, the shape itself has no height dimension, and the stroke property is rendered invalid.
An alternate approach would have been to switch gradient spaces to
userSpaceOnUse, but this had the adverse effect of changing how all gradients are applied.
👍 While we could have specified to apply the gradient space conditionally on the values, this limits us in the future for tweening between data sets. Better to have a single rule for all data values.
The hacky solution we settled on was to apply a very slight (0.0001) offset to the first data point, when all data points are equal. This has no effect on how it is rendered, because it is far too small of a different to be visible, but it's enough to circumvent the SVG spec's rule about objectBoundingBox gradient spaces.