Skip to content

Commit

Permalink
Accommodate both horizontal and vertical bar chart patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
contolini committed Sep 26, 2024
1 parent 634fb97 commit 3d213d5
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ const patternizeChartBars = (datasets) => {
'diamond-box',
];
return datasets.map((dataset, i) => {
const randomPattern = patterns[Math.floor(Math.random() * patterns.length)];
dataset.backgroundColor = pattern.draw(
randomPattern,
dataset.backgroundColor,
);
const numPatterns = dataset.data.length;
dataset.backgroundColor = []
.concat(dataset.backgroundColor)
.map((color) => {
return pattern.draw(
patterns[Math.floor(Math.random() * patterns.length)],
color,
);
});
return dataset;
});
};
Expand All @@ -100,7 +104,6 @@ const tooltipOptions = {
const ChartjsPluginCFPB = {
id: 'cfpb-charts',
beforeInit: (chart) => {
console.log(chart);
chart.config.options.plugins.tooltip = tooltipOptions;

if (chart.config.type === 'line') {
Expand Down

0 comments on commit 3d213d5

Please sign in to comment.