Browse Source

UI: refactoring

pull/11168/head
rusikv 2 years ago
parent
commit
7b2e38e04b
  1. 6
      ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart-widget.component.ts
  2. 14
      ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart.ts

6
ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart-widget.component.ts

@ -169,10 +169,6 @@ export class TimeSeriesChartWidgetComponent implements OnInit, OnDestroy, AfterV
} }
public toggleLegendKey(legendKey: LegendKey) { public toggleLegendKey(legendKey: LegendKey) {
this.timeSeriesChart.toggleKey(legendKey.dataKey); this.timeSeriesChart.toggleKey(legendKey.dataKey, legendKey.dataIndex);
for (const id of Object.keys(this.ctx.subscriptions)) {
const subscription = this.ctx.subscriptions[id];
subscription.updateDataVisibility(legendKey.dataIndex);
}
} }
} }

14
ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart.ts

@ -60,7 +60,14 @@ import {
measureAxisNameSize measureAxisNameSize
} from '@home/components/widget/lib/chart/echarts-widget.models'; } from '@home/components/widget/lib/chart/echarts-widget.models';
import { DateFormatProcessor, ValueSourceType } from '@shared/models/widget-settings.models'; import { DateFormatProcessor, ValueSourceType } from '@shared/models/widget-settings.models';
import { formattedDataFormDatasourceData, formatValue, isDefinedAndNotNull, isEqual, mergeDeep } from '@core/utils'; import {
formattedDataFormDatasourceData,
formatValue,
isDefined,
isDefinedAndNotNull,
isEqual,
mergeDeep
} from '@core/utils';
import { DataKey, Datasource, DatasourceType, FormattedData, widgetType } from '@shared/models/widget.models'; import { DataKey, Datasource, DatasourceType, FormattedData, widgetType } from '@shared/models/widget.models';
import * as echarts from 'echarts/core'; import * as echarts from 'echarts/core';
import { CallbackDataParams, PiecewiseVisualMapOption } from 'echarts/types/dist/shared'; import { CallbackDataParams, PiecewiseVisualMapOption } from 'echarts/types/dist/shared';
@ -290,7 +297,7 @@ export class TbTimeSeriesChart {
} }
} }
public toggleKey(dataKey: DataKey): void { public toggleKey(dataKey: DataKey, dataIndex?: number): void {
const enable = dataKey.hidden; const enable = dataKey.hidden;
const dataItem = this.dataItems.find(d => d.dataKey === dataKey); const dataItem = this.dataItems.find(d => d.dataKey === dataKey);
if (dataItem) { if (dataItem) {
@ -310,6 +317,9 @@ export class TbTimeSeriesChart {
this.timeSeriesChart.setOption(this.timeSeriesChartOptions, this.stackMode ? {notMerge: true} : {replaceMerge: mergeList}); this.timeSeriesChart.setOption(this.timeSeriesChartOptions, this.stackMode ? {notMerge: true} : {replaceMerge: mergeList});
this.updateAxes(); this.updateAxes();
dataKey.hidden = !enable; dataKey.hidden = !enable;
if (isDefined(dataIndex)) {
this.ctx.defaultSubscription.updateDataVisibility(dataIndex);
}
if (enable) { if (enable) {
this.timeSeriesChart.dispatchAction({ this.timeSeriesChart.dispatchAction({
type: 'highlight', type: 'highlight',

Loading…
Cancel
Save