feat: add cubic bezier curve - #1410
Conversation
|
Will check it when be near a PC. |
|
|
||
| conf.fill_baseline = checkNumericOption(conf, 'fill_baseline', undefined); | ||
|
|
||
| conf.tension = checkNumericOption(conf, 'tension', DEFAULT_BEZIERC_TENSION, 0); |
There was a problem hiding this comment.
Is it needed to specify minBound or maxBound?
(these are optional arguments of checkNumericOption())
IMHO - should be 0...0.25 (or smaller)
|
@fran68 |
| | upper_bound_secondary | number *or* string | | v0.5.0 | Set a fixed upper bound for the graph secondary Y-axis. String value starting with ~ (e.g. `~50`) specifies soft bound. | ||
| | min_bound_range_secondary | number | | v0.x.x | Applied after everything, makes sure there's a minimum range that the secondary Y-axis will have. Useful for not making small changes look large because of scale. | ||
| | smoothing | boolean | `true` | v0.8.0 | Whether to make graph line smooth. | ||
| | smoothing | boolean | `true` | v0.8.0 | Whether to make graph line smooth. Use `bezierc` to describe a line by a cubic Bezier curve. |
There was a problem hiding this comment.
Does it mean that the smoothing option can be false/true or bezierc? Let's specify it here explicitly. Please check a proposed description, see below.
| this._groupBy = groupBy; | ||
| this._endTime = 0; | ||
| this.fill_baseline = fill_baseline; | ||
| this._tension = tension; |
There was a problem hiding this comment.
There is a mix of different namings here, let's follow this rule: if a property has a getter/setter - then it's name is . THing is that some not-undescored properties are only used in the class, so it is really a mix imho... I will go through all properties of Graph class & set "underscore" where i it is needed (although it is just a cosmetic/stylistic change).this._something (starts with "_"), otherwise just this.something
|
We need to add some description of the new smoothing method into Readme. As a variant: Here:
|
| const p3 = (i + 2 < arr.length) ? arr[i + 2] : p2; | ||
|
|
||
| // First control point (close to p1) | ||
| const cp1x = p1[0] + (p2[0] - p0[0]) * tension; |
There was a problem hiding this comment.
Shouldn't they be addressed as p[X] instead of p[0] ? (for consistency)
Same comment for coords[0][0] above.
| genBezierCPath(coords) { | ||
| // Starting point with x with coords[0][0] and y with coords[0][Y] | ||
| let path = `${coords[0][0]},${coords[0][Y]}`; | ||
| const tension = this._tension; // Default 0.15 |
There was a problem hiding this comment.
Better to remove this comment since we may change a default value in "const.js"
| const DEFAULT_HOURS_TO_SHOW = 24; | ||
| const DEFAULT_POINTS_PER_HOUR = 0.5; | ||
| const DEFAULT_STATIC_VALUE_LABEL_OFFSET = 20; // in % | ||
| const DEFAULT_BEZIERC_TENSION = 0.15; |
There was a problem hiding this comment.
Same as 1/6 ? (approx). Saw this "1/6" parameter in formulae in internet.



This PR adds the option to use the cubic Bezier C curve for a line graph. In this case using the
show_state: lastthe state value matches the value shown by touching the last point.It correlates much better to the values by the linear curve since it's not shaped in the way the quadratic bezier curve is.
