Browse Source

Merge pull request #11168 from rusikv/bug/time-series-chart-hidden-history-series

Fixed hidden by default chart series not rendering on unhide
pull/11269/head
Igor Kulikov 2 years ago
committed by GitHub
parent
commit
8716e618e7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      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

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

@ -169,6 +169,6 @@ export class TimeSeriesChartWidgetComponent implements OnInit, OnDestroy, AfterV
}
public toggleLegendKey(legendKey: LegendKey) {
this.timeSeriesChart.toggleKey(legendKey.dataKey);
this.timeSeriesChart.toggleKey(legendKey.dataKey, legendKey.dataIndex);
}
}

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

@ -56,7 +56,14 @@ import {
measureAxisNameSize
} from '@home/components/widget/lib/chart/echarts-widget.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 * as echarts from 'echarts/core';
import { CallbackDataParams, PiecewiseVisualMapOption } from 'echarts/types/dist/shared';
@ -300,7 +307,7 @@ export class TbTimeSeriesChart {
}
}
public toggleKey(dataKey: DataKey): void {
public toggleKey(dataKey: DataKey, dataIndex?: number): void {
const enable = dataKey.hidden;
const dataItem = this.dataItems.find(d => d.dataKey === dataKey);
if (dataItem) {
@ -320,6 +327,9 @@ export class TbTimeSeriesChart {
this.timeSeriesChart.setOption(this.timeSeriesChartOptions, this.stackMode ? {notMerge: true} : {replaceMerge: mergeList});
this.updateAxes();
dataKey.hidden = !enable;
if (isDefined(dataIndex)) {
this.ctx.defaultSubscription.updateDataVisibility(dataIndex);
}
if (enable) {
this.timeSeriesChart.dispatchAction({
type: 'highlight',

Loading…
Cancel
Save