Displaced chart with extreme spline tension values
See original GitHub issueNot sure where this sits on the bug <—> feature request spectrum, but I’ve logged it here as bug as it results in unexpected behaviour…
When interpolating a line using cardinal splines with extreme tension
values outside [0, 1], the plot can be unexpectedly displaced. This is includes the entire plot area, and the data view rectangle relative to the title. The displacement can be beyond the visible path of the interpolated line, making it difficult to compose multiple views.
While the schema suggests the tension
value should be between 0 and 1, there are definitely cases where values outside this range are useful (e.g. this example, but even setting tension
to -1 is useful for creating rounded shapes:
Setting "clip" : true
helpfully clips the view to the rectangle defined by the axes, but it would be more useful if the unclipped area was that of the larger of this rectangle and the minimum enclosing rectangle the interpolated line path. I would also propose that the [0, 1] tension range be removed from the schema given legitimate uses of values beyond this range.
Minimum working example:
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"width": 300,
"height": 300,
"title": { "text": "Overshooting splines"},
"background": "papayawhip",
"data": {
"values": [
{ "x": 20, "y": 10},
{ "x": 30, "y": 30},
{ "x": 50, "y": 10}
]
},
"encoding": {
"x": { "field": "x", "type": "quantitative"},
"y": { "field": "y", "type": "quantitative"}
},
"mark": {
"type": "line",
"tension": -7,
"clip": false,
"interpolate": "cardinal-closed",
"point": { "stroke": "black"}
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
I tightened the bounds calculations in vega/vega#2213, will be included in Vega v5.9.0.
I don’t see why the schema can’t be more permissive.
I’m looking into it. I think we can directly solve for extrema (set the derivative of the Bezier equations to zero) rather than use an iterative method.