Skip to content

Commit b89c22d

Browse files
author
“Bastien
committed
Fix Line chart rule based styling and applying the first matching rule by line
1 parent ff4f12f commit b89c22d

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/chart/line/LineChart.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import React, { useEffect } from 'react';
33
import { NoDrawableDataErrorMessage } from '../../component/editor/CodeViewerComponent';
44
import { evaluateRulesOnDict, useStyleRules } from '../../extensions/styling/StyleRuleEvaluator';
55
import { ChartProps } from '../Chart';
6-
import {
7-
convertRecordObjectToString,
8-
mutateName,
9-
processHierarchyFromRecords,
10-
recordToNative,
11-
toNumber,
12-
} from '../ChartUtils';
6+
import { recordToNative, toNumber } from '../ChartUtils';
137
import { themeNivo } from '../Utils';
148
import { extensionEnabled } from '../../utils/ReportUtils';
159

@@ -77,17 +71,18 @@ const NeoLineChart = (props: ChartProps) => {
7771
// For line charts, the line color is overridden if at least one value meets the criteria.
7872
const getLineColors = (line) => {
7973
const xFieldName = props.selection && props.selection.x;
80-
const yFieldName = line.id && line.id.split('(')[1] && line.id.split('(')[1].split(')')[0];
74+
const yFieldName = line.id;
8175
let color = 'black';
82-
line.data.forEach((entry) => {
76+
for (const entry of line.data) {
8377
const data = {};
84-
data[xFieldName] = entry[selection.x];
85-
data[yFieldName] = entry[selection.value];
78+
data[xFieldName] = entry.x;
79+
data[yFieldName] = entry.y;
8680
const validRuleIndex = evaluateRulesOnDict(data, styleRules, ['line color']);
8781
if (validRuleIndex !== -1) {
8882
color = styleRules[validRuleIndex].customizationValue;
83+
break;
8984
}
90-
});
85+
}
9186
return color;
9287
};
9388

0 commit comments

Comments
 (0)