Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/default color scheme bar chart #1039

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading