Improved support for theme switching with graphs.

This commit is contained in:
Herbert Wolverson 2024-07-23 15:47:14 -05:00
parent 04129c02c5
commit 5fed418fe6
12 changed files with 143 additions and 0 deletions

View File

@ -136,6 +136,24 @@ export class CakeBacklog extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.legend.data[1].itemStyle.color = window.graphPalette[1];
this.option.legend.data[2].itemStyle.color = window.graphPalette[2];
this.option.legend.data[3].itemStyle.color = window.graphPalette[3];
this.option.series[0].itemStyle.color = window.graphPalette[0];
this.option.series[1].itemStyle.color = window.graphPalette[1];
this.option.series[2].itemStyle.color = window.graphPalette[2];
this.option.series[3].itemStyle.color = window.graphPalette[3];
this.option.series[4].itemStyle.color = window.graphPalette[0];
this.option.series[5].itemStyle.color = window.graphPalette[1];
this.option.series[6].itemStyle.color = window.graphPalette[2];
this.option.series[7].itemStyle.color = window.graphPalette[3];
this.chart.setOption(this.option);
}
update(msg) { update(msg) {
this.chart.hideLoading(); this.chart.hideLoading();

View File

@ -131,6 +131,23 @@ export class CakeDelays extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.legend.data[1].itemStyle.color = window.graphPalette[1];
this.option.legend.data[2].itemStyle.color = window.graphPalette[2];
this.option.legend.data[3].itemStyle.color = window.graphPalette[3];
this.option.series[0].itemStyle.color = window.graphPalette[0];
this.option.series[1].itemStyle.color = window.graphPalette[1];
this.option.series[2].itemStyle.color = window.graphPalette[2];
this.option.series[3].itemStyle.color = window.graphPalette[3];
this.option.series[4].itemStyle.color = window.graphPalette[0];
this.option.series[5].itemStyle.color = window.graphPalette[1];
this.option.series[6].itemStyle.color = window.graphPalette[2];
this.option.series[7].itemStyle.color = window.graphPalette[3];
this.chart.setOption(this.option);
}
update(msg) { update(msg) {
this.chart.hideLoading(); this.chart.hideLoading();

View File

@ -136,6 +136,23 @@ export class CakeDrops extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.legend.data[1].itemStyle.color = window.graphPalette[1];
this.option.legend.data[2].itemStyle.color = window.graphPalette[2];
this.option.legend.data[3].itemStyle.color = window.graphPalette[3];
this.option.series[0].itemStyle.color = window.graphPalette[0];
this.option.series[1].itemStyle.color = window.graphPalette[1];
this.option.series[2].itemStyle.color = window.graphPalette[2];
this.option.series[3].itemStyle.color = window.graphPalette[3];
this.option.series[4].itemStyle.color = window.graphPalette[0];
this.option.series[5].itemStyle.color = window.graphPalette[1];
this.option.series[6].itemStyle.color = window.graphPalette[2];
this.option.series[7].itemStyle.color = window.graphPalette[3];
this.chart.setOption(this.option);
}
update(msg) { update(msg) {
this.chart.hideLoading(); this.chart.hideLoading();

View File

@ -136,6 +136,23 @@ export class CakeMarks extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.legend.data[1].itemStyle.color = window.graphPalette[1];
this.option.legend.data[2].itemStyle.color = window.graphPalette[2];
this.option.legend.data[3].itemStyle.color = window.graphPalette[3];
this.option.series[0].itemStyle.color = window.graphPalette[0];
this.option.series[1].itemStyle.color = window.graphPalette[1];
this.option.series[2].itemStyle.color = window.graphPalette[2];
this.option.series[3].itemStyle.color = window.graphPalette[3];
this.option.series[4].itemStyle.color = window.graphPalette[0];
this.option.series[5].itemStyle.color = window.graphPalette[1];
this.option.series[6].itemStyle.color = window.graphPalette[2];
this.option.series[7].itemStyle.color = window.graphPalette[3];
this.chart.setOption(this.option);
}
update(msg) { update(msg) {
this.chart.hideLoading(); this.chart.hideLoading();

View File

@ -71,6 +71,16 @@ export class CakeQueueLength extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.series[0].lineStyle.color = window.graphPalette[0];
this.option.series[0].itemStyle = window.graphPalette[0];
this.option.series[1].lineStyle.color = window.graphPalette[0];
this.option.series[1].itemStyle = window.graphPalette
this.chart.setOption(this.option);
}
update(msg) { update(msg) {
this.chart.hideLoading(); this.chart.hideLoading();

View File

@ -160,6 +160,23 @@ export class CakeTraffic extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.legend.data[1].itemStyle.color = window.graphPalette[1];
this.option.legend.data[2].itemStyle.color = window.graphPalette[2];
this.option.legend.data[3].itemStyle.color = window.graphPalette[3];
this.option.series[0].itemStyle.color = window.graphPalette[0];
this.option.series[1].itemStyle.color = window.graphPalette[1];
this.option.series[2].itemStyle.color = window.graphPalette[2];
this.option.series[3].itemStyle.color = window.graphPalette[3];
this.option.series[4].itemStyle.color = window.graphPalette[0];
this.option.series[5].itemStyle.color = window.graphPalette[1];
this.option.series[6].itemStyle.color = window.graphPalette[2];
this.option.series[7].itemStyle.color = window.graphPalette[3];
this.chart.setOption(this.option);
}
update(msg) { update(msg) {
this.chart.hideLoading(); this.chart.hideLoading();

View File

@ -82,6 +82,15 @@ export class CircuitRetransmitGraph extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.legend.data[1].itemStyle.color = window.graphPalette[1];
this.option.series[0].lineStyle.color = window.graphPalette[0];
this.option.series[1].lineStyle.color = window.graphPalette[1];
this.chart.setOption(this.option);
}
update(download, upload) { update(download, upload) {
this.chart.hideLoading(); this.chart.hideLoading();
this.ringbuffer.push(download, upload); this.ringbuffer.push(download, upload);

View File

@ -82,6 +82,15 @@ export class CircuitTotalGraph extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.legend.data[1].itemStyle.color = window.graphPalette[1];
this.option.series[0].lineStyle.color = window.graphPalette[0];
this.option.series[1].lineStyle.color = window.graphPalette[1];
this.chart.setOption(this.option);
}
update(download, upload) { update(download, upload) {
this.chart.hideLoading(); this.chart.hideLoading();
this.ringbuffer.push(download, upload); this.ringbuffer.push(download, upload);

View File

@ -43,4 +43,8 @@ export class DashboardGraph {
window.graphList.push(this); window.graphList.push(this);
} }
} }
onThemeChange() {
// Override this if you have to
}
} }

View File

@ -88,6 +88,16 @@ export class QueueStatsTotalGraph extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.legend.data[1].itemStyle.color = window.graphPalette[1];
this.option.series[0].lineStyle.color = window.graphPalette[0];
this.option.series[1].lineStyle.color = window.graphPalette[0];
this.option.series[2].lineStyle.color = window.graphPalette[1];
this.option.series[3].lineStyle.color = window.graphPalette[1];
}
update(marks, drops) { update(marks, drops) {
this.chart.hideLoading(); this.chart.hideLoading();
this.ringbuffer.push(marks, drops); this.ringbuffer.push(marks, drops);

View File

@ -106,6 +106,20 @@ export class ThroughputRingBufferGraph extends DashboardGraph {
this.option && this.chart.setOption(this.option); this.option && this.chart.setOption(this.option);
} }
onThemeChange() {
super.onThemeChange();
this.option.legend.data[0].itemStyle.color = window.graphPalette[0];
this.option.legend.data[1].itemStyle.color = window.graphPalette[1];
this.option.series[0].lineStyle.color = window.graphPalette[0];
this.option.series[0].areaStyle.color = window.graphPalette[0];
this.option.series[1].lineStyle.color = window.graphPalette[0];
this.option.series[1].areaStyle.color = window.graphPalette[0];
this.option.series[2].lineStyle.color = window.graphPalette[1];
this.option.series[3].lineStyle.color = window.graphPalette[1];
this.chart.setOption(this.option);
}
update(shaped, unshaped) { update(shaped, unshaped) {
this.chart.hideLoading(); this.chart.hideLoading();
this.ringbuffer.push(shaped, unshaped); this.ringbuffer.push(shaped, unshaped);

View File

@ -60,6 +60,7 @@ export function initDayNightMode() {
graph.chart = echarts.init(graph.dom, 'vintage'); graph.chart = echarts.init(graph.dom, 'vintage');
} }
graph.chart.setOption(graph.option); graph.chart.setOption(graph.option);
graph.onThemeChange();
}); });
} }
}); });