diff --git a/client/src/app/gauges/controls/html-graph/graph-bar/graph-bar.component.ts b/client/src/app/gauges/controls/html-graph/graph-bar/graph-bar.component.ts index 0b72198fc..4aa7c5589 100644 --- a/client/src/app/gauges/controls/html-graph/graph-bar/graph-bar.component.ts +++ b/client/src/app/gauges/controls/html-graph/graph-bar/graph-bar.component.ts @@ -298,6 +298,7 @@ export class GraphBarComponent extends GraphBaseComponent implements OnInit, Aft offline: false, decimals: 0, responsive: true, + backgroundColor: null, // to set in property maintainAspectRatio: false, indexAxis: 'x', gridLinesShow: true, // to set in property @@ -313,6 +314,10 @@ export class GraphBarComponent extends GraphBaseComponent implements OnInit, Aft } // suggestedMin: 0 }, + grid: { + color: 'rgba(0, 0, 0, 0.2)', + display: true + } }, x: { display: true, @@ -322,6 +327,10 @@ export class GraphBarComponent extends GraphBaseComponent implements OnInit, Aft size: 12 } }, + grid: { + color: 'rgba(0, 0, 0, 0.2)', + display: true + } } }, plugins: { diff --git a/client/src/app/gauges/controls/html-graph/graph-base/graph-base.component.ts b/client/src/app/gauges/controls/html-graph/graph-base/graph-base.component.ts index 149829225..3d5324304 100644 --- a/client/src/app/gauges/controls/html-graph/graph-base/graph-base.component.ts +++ b/client/src/app/gauges/controls/html-graph/graph-base/graph-base.component.ts @@ -55,4 +55,5 @@ export interface GraphOptions extends ChartOptions { gridLinesColor?: string; plugins?: any; scales?: any; + backgroundColor?: string; } diff --git a/client/src/app/gauges/controls/html-graph/graph-property/graph-property.component.html b/client/src/app/gauges/controls/html-graph/graph-property/graph-property.component.html index cfe72161c..35a56db4a 100644 --- a/client/src/app/gauges/controls/html-graph/graph-property/graph-property.component.html +++ b/client/src/app/gauges/controls/html-graph/graph-property/graph-property.component.html @@ -160,7 +160,7 @@
{{'graph.property-theme-type' | translate}} - + {{'graph.property-theme-owner' | translate}} {{'graph.property-theme-light' | translate}} {{'graph.property-theme-dark' | translate}} @@ -177,7 +177,7 @@
{{'graph.property-yaxis-color' | translate}} - @@ -185,7 +185,7 @@
{{'graph.property-xaxis-color' | translate}} - diff --git a/client/src/app/gauges/controls/html-graph/graph-property/graph-property.component.ts b/client/src/app/gauges/controls/html-graph/graph-property/graph-property.component.ts index cf724de20..e13bbdce1 100644 --- a/client/src/app/gauges/controls/html-graph/graph-property/graph-property.component.ts +++ b/client/src/app/gauges/controls/html-graph/graph-property/graph-property.component.ts @@ -41,10 +41,9 @@ export class GraphPropertyComponent implements OnInit, OnDestroy { private _onDestroy = new Subject(); - constructor( - public dialog: MatDialog, - private translateService: TranslateService) { - } + constructor(public dialog: MatDialog, + private translateService: TranslateService) { + } ngOnInit() { if (this.data.settings.type.endsWith('bar')) { @@ -105,34 +104,37 @@ export class GraphPropertyComponent implements OnInit, OnDestroy { this.options.dateGroup = Utils.getEnumKey(GraphDateGroupType, GraphDateGroupType.hours); } } + this.options.scales['y'].grid.color = this.options.gridLinesColor; + this.options.scales['y'].grid.display = this.options.gridLinesShow; + this.options.scales['x'].grid.color = this.options.gridLinesColor; + this.options.scales['x'].grid.display = this.options.gridLinesShow; + this.data.settings.property.options = JSON.parse(JSON.stringify(this.options)); + this.onPropChanged.emit(this.data.settings); + } + + onGraphThemaChanged() { + const yScale = this.options.scales['y']; + const xScale = this.options.scales['x']; if (this.options.theme === this.themeType.light) { - this.options.scales['y'].ticks.color = '#666'; - this.options.scales['x'].ticks.color = '#666'; + yScale.ticks.color = '#666'; + xScale.ticks.color = '#666'; this.options.plugins.legend.labels.color = '#666'; + this.options.plugins.datalabels.color = '#666'; this.options.plugins.title.color = '#666'; + this.options.gridLinesColor = 'rgba(0, 0, 0, 0.2)'; + this.options.backgroundColor = null; } else if (this.options.theme === this.themeType.dark) { - this.options.scales['y'].ticks.color = '#fff'; - this.options.scales['x'].ticks.color = '#fff'; + yScale.ticks.color = '#fff'; + xScale.ticks.color = '#fff'; this.options.plugins.legend.labels.color = '#fff'; + this.options.plugins.datalabels.color = '#fff'; this.options.plugins.title.color = '#fff'; + this.options.gridLinesColor = '#808080'; + this.options.backgroundColor = '242424'; + } else if (this.options.theme === this.themeType.customise) { + this.options.backgroundColor = null; } - - const yScale = this.options.scales['y']; - if(!yScale.hasOwnProperty('grid')) { - yScale.grid = {}; - } - - yScale.grid.color = 'rgba(0, 0, 0, 0.1)'; - - const xScale = this.options.scales['x']; - if(!xScale.hasOwnProperty('grid')) { - xScale.grid = {}; - } - - xScale.grid.color = 'rgba(0, 0, 0, 0.1)'; - - this.data.settings.property.options = JSON.parse(JSON.stringify(this.options)); - this.onPropChanged.emit(this.data.settings); + this.onGraphChanged(); } onEditNewGraph() { diff --git a/client/src/app/gauges/controls/html-graph/html-graph.component.ts b/client/src/app/gauges/controls/html-graph/html-graph.component.ts index 1b02f5966..88f4e848e 100644 --- a/client/src/app/gauges/controls/html-graph/html-graph.component.ts +++ b/client/src/app/gauges/controls/html-graph/html-graph.component.ts @@ -68,6 +68,11 @@ export class HtmlGraphComponent extends GaugeBaseComponent { let opt = { panel: { height: htmlGraph.clientHeight, width: htmlGraph.clientWidth } }; opt = { ...GraphBarComponent.DefaultOptions(), ...opt }; componentRef.instance.setOptions(opt); + if (gab.property.options.backgroundColor) { + window['svgEditor']?.setColor(gab.property.options.backgroundColor, 100, 'fill'); + } else { + window['svgEditor']?.setColor('none', 100, 'fill'); + } componentRef.instance['myComRef'] = componentRef; return componentRef.instance;