From 4d08dd4e8c23bccbfcf41eff9c030bff48de8415 Mon Sep 17 00:00:00 2001 From: jsers Date: Wed, 13 May 2020 11:48:01 +0800 Subject: [PATCH] Fix the color of the serie in the comparison --- web/src/components/Graph/Graph/index.tsx | 2 +- web/src/components/Graph/util/normalizeSeries.tsx | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/web/src/components/Graph/Graph/index.tsx b/web/src/components/Graph/Graph/index.tsx index 0a6956f1..f6862396 100644 --- a/web/src/components/Graph/Graph/index.tsx +++ b/web/src/components/Graph/Graph/index.tsx @@ -60,7 +60,7 @@ export default class Graph extends Component { chartOptions = config.chart; headerHeight = 35; counterList = []; - series = []; + series = [] as any[]; state = { spinning: false, errorText: '', diff --git a/web/src/components/Graph/util/normalizeSeries.tsx b/web/src/components/Graph/util/normalizeSeries.tsx index 62873d29..c087c426 100644 --- a/web/src/components/Graph/util/normalizeSeries.tsx +++ b/web/src/components/Graph/util/normalizeSeries.tsx @@ -1,12 +1,14 @@ import _ from 'lodash'; import { hexPalette } from '../config'; -import { SerieInterface } from '../interface'; +import { SerieInterface, GraphDataInterface } from '../interface'; -export default function normalizeSeries(data: any[]) { +export default function normalizeSeries(data: any[], graphConfig: GraphDataInterface): SerieInterface[] { + const { comparison } = graphConfig; + const isComparison = !!_.get(comparison, 'length', 0); const series = [] as SerieInterface[]; _.each(_.sortBy(data, ['counter', 'endpoint']), (o, i) => { const { endpoint, comparison } = o; - const color = getSerieColor(o, i); + const color = getSerieColor(o, i, isComparison); const separatorIdx = o.counter.indexOf('/'); let counter = endpoint ? '' : o.counter;