From 27faddc5df79167f2141aa16b1d592ad9c2da6c6 Mon Sep 17 00:00:00 2001 From: fhemger <56193816+fhemger@users.noreply.github.com> Date: Fri, 10 Feb 2023 19:26:53 +0100 Subject: [PATCH] make ftui-chart-data attribute border-dash work border-dash='[5,5]' --- .../components/chart/chart-data.component.js | 1 + www/ftui/components/element.component.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/www/ftui/components/chart/chart-data.component.js b/www/ftui/components/chart/chart-data.component.js index 82f64da8..f6b8edcd 100755 --- a/www/ftui/components/chart/chart-data.component.js +++ b/www/ftui/components/chart/chart-data.component.js @@ -39,6 +39,7 @@ export class FtuiChartData extends FtuiElement { color: primaryColor, borderColor: '', borderWidth: 1.2, + borderDash: [], pointRadius: 2, title: '-', log: '-', diff --git a/www/ftui/components/element.component.js b/www/ftui/components/element.component.js index 00a60130..0caa0d42 100755 --- a/www/ftui/components/element.component.js +++ b/www/ftui/components/element.component.js @@ -131,6 +131,9 @@ export class FtuiElement extends HTMLElement { } else if (typeof properties[name] === 'number') { this.defineNumberProperty(name, attr); this.initAttribute(attr, defaultValue); + } else if (typeof properties[name] === 'object' && Array.isArray(properties[name])) { + this.defineArrayProperty(name, attr); + this.initAttribute(attr, defaultValue); } else { this.defineStringProperty(name, attr); this.initAttribute(attr, defaultValue); @@ -179,4 +182,18 @@ export class FtuiElement extends HTMLElement { set(value) { this.setAttribute(attr, value); }, }); } + + defineArrayProperty(name, attr) { + Object.defineProperty(this, name, { + get() { + var attrValue = this.getAttribute(attr); + if(attrValue.match(/^\[.*\]$/)) { + return JSON.parse(attrValue); + } + return []; + }, + set(value) { this.setAttribute(attr, JSON.stringify(value)); }, + }); + } + }