Skip to content

Commit

Permalink
Merge pull request #1039 from neo4j-labs/fix/default-color-scheme-bar…
Browse files Browse the repository at this point in the history
…-chart

Fix/default color scheme bar chart
  • Loading branch information
alfredorubin96 authored Feb 18, 2025
2 parents 8669f3b + 7a249d2 commit b3f3299
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/chart/bar/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,25 @@ const NeoBarChart = (props: ChartProps) => {
const chartColorsByScheme = getD3ColorsByScheme(colorScheme);
// Compute bar color based on rules - overrides default color scheme completely.
const getBarColor = (bar) => {
let { id } = bar;
let colorIndex = keys.indexOf(id);
let { index: colorIndex } = bar;
if (colorIndex >= chartColorsByScheme.length) {
colorIndex %= chartColorsByScheme.length;
}

const dict = {};
if (!props.selection) {
return chartColorsByScheme[colorIndex];
}

const dict = {};
dict[selection.index] = bar.indexValue;
dict[selection.value] = bar.value;
dict[selection.key] = bar.id;

const validRuleIndex = evaluateRulesOnDict(dict, styleRules, ['bar color']);
if (validRuleIndex !== -1) {
return styleRules[validRuleIndex].customizationValue;
}

return chartColorsByScheme[colorIndex];
};

Expand Down

0 comments on commit b3f3299

Please sign in to comment.