plot: add support for stringified objects {} to allow change specific points' coordinates (issue #130)
This commit is contained in:
parent
e8a5c83b00
commit
5e8aea0022
3 changed files with 16 additions and 5 deletions
|
|
@ -16,7 +16,7 @@
|
|||
- switch: added `showValues` to display both values and labels in the buttons; array values can now be selected via osc
|
||||
- rgb: **removed** `touchAddress` option
|
||||
- labels/texts: multiple white spaces are no longer merged
|
||||
- plot: can receive stringified arrays of coordinates; added `bars` option for drawing barcharts
|
||||
- plot: can receive stringified arrays of coordinates or stringified objects for merging coordinates sets; added `bars` option for drawing barcharts;
|
||||
- widgets' `precision` option allows setting a specific data type for numbers (sliders can send doubles !)
|
||||
- misc
|
||||
- event system rewritten
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ The plot receives an array of coordinates and draws them on a chart. Coordinates
|
|||
- `[x, y]` coordinates arrays
|
||||
|
||||
!!! info
|
||||
Coordinates also can be sent as a stringified array
|
||||
Coordinates also can be sent as a stringified array (`[]`). A stringified object can also be sent to change specific points' coordinates (e.g. `{0:1, 4:0}` will change the 1st and 5th points' coordinates) .
|
||||
|
||||
```js
|
||||
{
|
||||
|
|
|
|||
|
|
@ -171,13 +171,24 @@ module.exports = class _plots_base extends _canvas_base {
|
|||
|
||||
setValue(v, options={}) {
|
||||
|
||||
if (typeof v == 'string' && v.indexOf('[') == 0) {
|
||||
if (typeof v == 'string' && (v[0] == '[' || v[0] == '{' )) {
|
||||
v = JSON.parseFlex(v)
|
||||
}
|
||||
|
||||
if (Array.isArray(v)) {
|
||||
if (typeof v == 'object') {
|
||||
|
||||
if (Array.isArray(v)) {
|
||||
|
||||
this.data = v
|
||||
|
||||
} else {
|
||||
|
||||
for (var i in v) {
|
||||
if (!isNaN(i)) this.data[i] = v[i]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.data = v
|
||||
this.batchDraw()
|
||||
|
||||
if (options.sync) this.changed(options)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue