plot: add support for stringified objects {} to allow change specific points' coordinates (issue #130)

This commit is contained in:
jean-emmanuel 2018-01-29 13:16:50 +01:00
parent e8a5c83b00
commit 5e8aea0022
3 changed files with 16 additions and 5 deletions

View file

@ -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)