100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
UI fixes for several chart issues (#2234)
Martin Peeters2d6bb90c2da8
diff --git a/ui/app/shared/locales/en/or.json b/ui/app/shared/locales/en/or.jsonindex 4754cfb50..64e71c257 100644--- a/ui/app/shared/locales/en/or.json+++ b/ui/app/shared/locales/en/or.json@@ -167,6 +167,7 @@"intervalBy1minute": "Per minute","intervalBy5minutes": "Per 5 minutes","intervalBy5minutes-auto": "Auto (5min)",+ "intervalBy15minutes": "Per 15 minutes","intervalBy30minutes": "Per 30 minutes","intervalBy30minutes-auto": "Auto (30min)","intervalByhour": "Per hour",diff --git a/ui/app/shared/locales/nl/or.json b/ui/app/shared/locales/nl/or.jsonindex 36d4ea19c..4ee916fd4 100644--- a/ui/app/shared/locales/nl/or.json+++ b/ui/app/shared/locales/nl/or.json@@ -167,6 +167,7 @@"intervalBy1minute": "Per minuut","intervalBy5minutes": "Per 5 minuten","intervalBy5minutes-auto": "Auto (5min)",+ "intervalBy15minutes": "Per 15 minuten","intervalBy30minutes": "Per 30 minuten","intervalBy30minutes-auto": "Auto (30min)","intervalByhour": "Per uur",diff --git a/ui/component/or-app/src/or-header.ts b/ui/component/or-app/src/or-header.tsindex 26fc05225..51b6c2a67 100644--- a/ui/component/or-app/src/or-header.ts+++ b/ui/component/or-app/src/or-header.ts@@ -21,6 +21,7 @@ import {AppStateKeyed, router, updateRealm} from "./index";import {AnyAction, Store} from "@reduxjs/toolkit";import * as Model from "@openremote/model";import {i18next} from "@openremote/or-translate";+import {when} from "lit/directives/when.js";export {DEFAULT_LANGUAGES, Languages}@@ -474,12 +475,12 @@ export class OrHeader extends LitElement {const currentRealm = this.realms.find((t) => t.name === this.realm);let realmTemplate = html`- <div id="realm-picker">- ${this.realms.length > 1 ? html`+ ${when(this.realms?.length > 1, () => html`+ <div id="realm-picker"><span>${currentRealm ? currentRealm.displayName : ""}</span><or-icon icon="chevron-down"></or-icon>- ` : ``}- </div>+ </div>+ `)}`;if (manager.isSuperUser()) {diff --git a/ui/component/or-attribute-barchart/package.json b/ui/component/or-attribute-barchart/package.jsonindex afc390287..f345c62a7 100644--- a/ui/component/or-attribute-barchart/package.json+++ b/ui/component/or-attribute-barchart/package.json@@ -24,7 +24,7 @@"@openremote/or-mwc-components": "workspace:*","@openremote/or-translate": "workspace:*","@openremote/rest": "workspace:*",- "echarts": "~5.6.0",+ "echarts": "~6.0.0","lit": "^3.3.1","moment": "^2.29.4"},diff --git a/ui/component/or-attribute-barchart/src/index.ts b/ui/component/or-attribute-barchart/src/index.tsindex a975fb90a..bf07a627a 100644--- a/ui/component/or-attribute-barchart/src/index.ts+++ b/ui/component/or-attribute-barchart/src/index.ts@@ -89,6 +89,7 @@ export enum BarChartInterval {NONE = "none",ONE_MINUTE = "1Minute",FIVE_MINUTES = "5Minutes",+ FIFTEEN_MINUTES = "15Minutes",THIRTY_MINUTES = "30Minutes",ONE_HOUR = "hour",ONE_DAY = "day",@@ -1235,7 +1236,7 @@ export class OrAttributeBarChart extends LitElement {minInterval: this._intervalConfig!.millis,min: this._startOfPeriod,max: this._endOfPeriod,- boundaryGap: false,+ boundaryGap: false as any,splitArea: {show: true,areaStyle: {@@ -1347,6 +1348,7 @@ export class OrAttributeBarChart extends LitElement {[BarChartInterval.AUTO, {displayName:"auto", steps: 1, orFormat: DatapointInterval.MINUTE, momentFormat: "minutes", millis: 60000}],[BarChartInterval.ONE_MINUTE, {displayName:"1Minute", steps:1, orFormat:DatapointInterval.MINUTE,momentFormat:"minutes", millis: 60000}],[BarChartInterval.FIVE_MINUTES, {displayName:"5Minutes", steps:5, orFormat:DatapointInterval.MINUTE,momentFormat:"minutes", millis: 300000}],+ [BarChartInterval.FIFTEEN_MINUTES, {displayName:"15Minutes", steps:15, orFormat:DatapointInterval.MINUTE,momentFormat:"minutes", millis: 900000}],[BarChartInterval.THIRTY_MINUTES, {displayName:"30Minutes", steps:30, orFormat:DatapointInterval.MINUTE,momentFormat:"minutes", millis: 1800000}],[BarChartInterval.ONE_HOUR, {displayName:"hour", steps:1, orFormat:DatapointInterval.HOUR,momentFormat:"hours", millis: 3600000}],[BarChartInterval.ONE_DAY, {displayName:"day", steps:1, orFormat:DatapointInterval.DAY,momentFormat:"days", millis: 86400000}],diff --git a/ui/component/or-attribute-history/package.json b/ui/component/or-attribute-history/package.jsonindex f926a8efc..728c3864e 100644--- a/ui/component/or-attribute-history/package.json+++ b/ui/component/or-attribute-history/package.json@@ -29,7 +29,7 @@"@openremote/or-mwc-components": "workspace:*","@openremote/or-translate": "workspace:*","@openremote/rest": "workspace:*",- "echarts": "~5.6.0",+ "echarts": "~6.0.0","jsonpath-plus": "^6.0.1","lit": "^3.3.1","lodash": "^4.17.21",diff --git a/ui/component/or-attribute-history/src/index.ts b/ui/component/or-attribute-history/src/index.tsindex 69452f7b9..85ae80207 100644--- a/ui/component/or-attribute-history/src/index.ts+++ b/ui/component/or-attribute-history/src/index.ts@@ -463,20 +463,12 @@ export class OrAttributeHistory extends translate(i18next)(LitElement) {end: 100},{+ type: 'slider',start: 0,end: 100,+ showDataShadow: false,backgroundColor: bgColor,fillerColor: bgColor,- dataBackground: {- areaStyle: {- color: this._style.getPropertyValue("--internal-or-attribute-history-graph-fill-color")- }- },- selectedDataBackground: {- areaStyle: {- color: this._style.getPropertyValue("--internal-or-attribute-history-graph-fill-color"),- }- },moveHandleStyle: {color: this._style.getPropertyValue("--internal-or-attribute-history-graph-fill-color")},diff --git a/ui/component/or-chart/package.json b/ui/component/or-chart/package.jsonindex ad6af62e3..2628f0796 100644--- a/ui/component/or-chart/package.json+++ b/ui/component/or-chart/package.json@@ -33,7 +33,7 @@"@openremote/or-mwc-components": "workspace:*","@openremote/or-translate": "workspace:*","@openremote/rest": "workspace:*",- "echarts": "~5.6.0",+ "echarts": "~6.0.0","lit": "^3.3.1","lodash": "^4.17.21","moment": "^2.29.4"diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.tsindex b7d114041..274b3ad21 100644--- a/ui/component/or-chart/src/index.ts+++ b/ui/component/or-chart/src/index.ts@@ -632,6 +632,7 @@ export class OrChart extends translate(i18next)(LitElement) {yAxis: [{type: "value",+ alignTicks: true,axisLine: { lineStyle: {color: this._style.getPropertyValue("--internal-or-chart-text-color")}},boundaryGap: ["10%", "10%"],scale: true,@@ -641,6 +642,7 @@ export class OrChart extends translate(i18next)(LitElement) {},{type: "value",+ alignTicks: true,show: (this.attributeConfig?.rightAxisAttributes?.length ?? 0) > 0,axisLine: { lineStyle: {color: this._style.getPropertyValue("--internal-or-chart-text-color")}},boundaryGap: ["10%", "10%"],@@ -665,18 +667,9 @@ export class OrChart extends translate(i18next)(LitElement) {(this.chartOptions.dataZoom as DataZoomComponentOption[]).push({start: 0,end: 100,+ showDataShadow: false,backgroundColor: bgColor,fillerColor: bgColor,- dataBackground: {- areaStyle: {- color: this._style.getPropertyValue("--internal-or-chart-graph-fill-color")- }- },- selectedDataBackground: {- areaStyle: {- color: this._style.getPropertyValue("--internal-or-chart-graph-fill-color")- }- },moveHandleStyle: {color: this._style.getPropertyValue("--internal-or-chart-graph-fill-color")},@@ -1297,6 +1290,7 @@ export class OrChart extends translate(i18next)(LitElement) {// Load Predicted Datadataset = await this._loadAttributeData(this.assets[assetIndex], attribute, color ?? this.colors[colourIndex], true, smooth, stacked, stepped, area, faint, false , `${asset.name} | ${label} ${i18next.t("predicted")}`, options, unit);+ dataset.yAxisIndex = shownOnRightAxis ? 1 : 0;data.push(dataset);// If necessary, load Extended Data@@ -1382,14 +1376,14 @@ export class OrChart extends translate(i18next)(LitElement) {if(query.type === "lttb") {// If number of data points is set, only allow a maximum of 1 point per pixel in width- // Otherwise, dynamically set number of data points based on chart width (1000px = 100 data points)+ // Otherwise, dynamically set number of data points based on chart width (1000px = 200 data points)if(query.amountOfPoints) {if(this._chartElem?.clientWidth > 0) {query.amountOfPoints = Math.min(query.amountOfPoints, this._chartElem?.clientWidth);}} else {if(this._chartElem?.clientWidth > 0) {- query.amountOfPoints = Math.round(this._chartElem.clientWidth / 10);+ query.amountOfPoints = Math.round(this._chartElem.clientWidth / 5);} else {console.warn("Could not grab width of the Chart for estimating amount of data points. Using 100 points instead.");query.amountOfPoints = 100;diff --git a/ui/component/or-dashboard-builder/src/panels/attributes-panel.ts b/ui/component/or-dashboard-builder/src/panels/attributes-panel.tsindex ec3972712..278c2fc66 100644--- a/ui/component/or-dashboard-builder/src/panels/attributes-panel.ts+++ b/ui/component/or-dashboard-builder/src/panels/attributes-panel.ts@@ -206,7 +206,7 @@ export class AttributesPanel extends LitElement {}protected getLoadedAsset(attrRef: AttributeRef): Asset | undefined {- return this.loadedAssets?.find(asset => asset.id === attrRef.id);+ return this.loadedAssets?.find(asset => asset.id === attrRef.id && attrRef.name && asset.attributes?.[attrRef.name] !== undefined);}protected removeWidgetAttribute(attributeRef: AttributeRef) {diff --git a/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts b/ui/component/or-dashboard-builder/src/settings/barchart-settings.tsindex 5335f3562..043065795 100644--- a/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts+++ b/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts@@ -85,9 +85,9 @@ export class BarChartSettings extends WidgetSettings {const isMultiAxis = !!attrSettings.rightAxisAttributes?.length;const attributeIconCallback = (asset: Asset, attribute: Attribute<any>, descriptor?: AssetDescriptor) => {- let color = this.widgetConfig.attributeColors?.find(a => a[0].id === asset.id && a[0].name === attribute?.name)?.[1]?.replace("#", "");+ let color = this.widgetConfig.attributeColors?.find(a => a[0].id === asset.id && a[0].name === attribute.name)?.[1]?.replace("#", "");if(!color) {- const index = this.widgetConfig.attributeRefs?.findIndex(ref => ref.id === asset.id && ref.name === attribute?.name);+ const index = this.widgetConfig.attributeRefs?.findIndex(ref => ref.id === asset.id && ref.name === attribute.name);if(index >= 0) color = OrChart.DEFAULT_COLORS?.[index]?.replace("#", "");}return html`<span>${getAssetDescriptorIconTemplate(descriptor, undefined, undefined, color)}</span>`;diff --git a/ui/component/or-dashboard-builder/src/settings/chart-settings.ts b/ui/component/or-dashboard-builder/src/settings/chart-settings.tsindex 3d371ef5b..5a078a9d2 100644--- a/ui/component/or-dashboard-builder/src/settings/chart-settings.ts+++ b/ui/component/or-dashboard-builder/src/settings/chart-settings.ts@@ -452,15 +452,6 @@ export class ChartSettings extends WidgetSettings {protected openColorPickDialog(attributeRef: AttributeRef) {const inputElem = this._attributesPanelElem?.shadowRoot?.querySelector(`#chart-color-${attributeRef.id}-${attributeRef.name}`) as HTMLInputElement | undefined;if(inputElem) {- let oldColor = this.widgetConfig.attributeColors?.find(x => x[0] === attributeRef)?.[1];- if(!oldColor) {- const index = this.widgetConfig.attributeRefs?.indexOf(attributeRef);- if(index >= 0) {- oldColor = OrChart.DEFAULT_COLORS?.[index];- }- }- // Update value- inputElem.value = oldColor ?? "";// Listen for changesinputElem.addEventListener("input", debounce(() => {diff --git a/yarn.lock b/yarn.lockindex 51c9c415c..a336d54de 100644--- a/yarn.lock+++ b/yarn.lock@@ -1919,7 +1919,7 @@ __metadata:"@openremote/or-mwc-components": "workspace:*""@openremote/or-translate": "workspace:*""@openremote/rest": "workspace:*"- echarts: "npm:~5.6.0"+ echarts: "npm:~6.0.0"lit: "npm:^3.3.1"moment: "npm:^2.29.4"languageName: unknown@@ -1958,7 +1958,7 @@ __metadata:"@openremote/or-mwc-components": "workspace:*""@openremote/or-translate": "workspace:*""@openremote/rest": "workspace:*"- echarts: "npm:~5.6.0"+ echarts: "npm:~6.0.0"jsonpath-plus: "npm:^6.0.1"lit: "npm:^3.3.1"lodash: "npm:^4.17.21"@@ -2020,7 +2020,7 @@ __metadata:"@openremote/or-translate": "workspace:*""@openremote/rest": "workspace:*""@types/offscreencanvas": "npm:^2019.6.4"- echarts: "npm:~5.6.0"+ echarts: "npm:~6.0.0"lit: "npm:^3.3.1"lodash: "npm:^4.17.21"moment: "npm:^2.29.4"@@ -5379,13 +5379,13 @@ __metadata:languageName: nodelinkType: hard-"echarts@npm:~5.6.0":- version: 5.6.0- resolution: "echarts@npm:5.6.0"+"echarts@npm:~6.0.0":+ version: 6.0.0+ resolution: "echarts@npm:6.0.0"dependencies:tslib: "npm:2.3.0"- zrender: "npm:5.6.1"- checksum: 10c0/6d6a2ee88534d1ff0433e935c542237b9896de1c94959f47ebc7e0e9da26f59bf11c91ed6fc135b62ad2786c779ee12bc536fa481e60532dad5b6a2f5167e9ea+ zrender: "npm:6.0.0"+ checksum: 10c0/60bbb4f00ac679d2f81d7a0aa684597c8ccc46041c5ae536def4c4bbb85d5557c1653a536ac6e11f42757718ab66e2bbc35d53d795173c50e8541154c8d59bbdlanguageName: nodelinkType: hard@@ -11597,11 +11597,11 @@ __metadata:languageName: nodelinkType: hard-"zrender@npm:5.6.1":- version: 5.6.1- resolution: "zrender@npm:5.6.1"+"zrender@npm:6.0.0":+ version: 6.0.0+ resolution: "zrender@npm:6.0.0"dependencies:tslib: "npm:2.3.0"- checksum: 10c0/dc1cc570054640cbd8fbb7b92e6252f225319522bfe3e8dc8bf02cc02d414e00a4c8d0a6f89bfc9d96e5e9511fdca94dd3d06bf53690df2b2f12b0fc560ac307+ checksum: 10c0/c794e05ee969c750de6d17cfff60d9d4e6342d1591cf6ba3e488fb084ac7a0415355fe4aec55f83a400fd4cda63792db0533362455058ac06f6e1343be28d0celanguageName: nodelinkType: hard