Skip to content

Commit 9d4bfb3

Browse files
authored
fix: chart options (#1573)
1 parent 552ee31 commit 9d4bfb3

File tree

1 file changed

+17
-4
lines changed
  • src/unfold/static/unfold/js

1 file changed

+17
-4
lines changed

src/unfold/static/unfold/js/app.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,22 @@ const DEFAULT_CHART_OPTIONS = {
446446
width: 0,
447447
},
448448
ticks: {
449-
display: false,
450-
font: {
451-
size: 13,
449+
color: "#9ca3af",
450+
display: function (context) {
451+
return context.chart.data.datasets.some((dataset) => {
452+
return (
453+
dataset.hasOwnProperty("displayYAxis") && dataset.displayYAxis
454+
);
455+
});
456+
},
457+
callback: function (value) {
458+
const suffix = this.chart.data.datasets.find(
459+
(dataset) => dataset.suffixYAxis
460+
)?.suffixYAxis;
461+
if (suffix) {
462+
return `${value} ${suffix}`;
463+
}
464+
return value;
452465
},
453466
},
454467
grid: {
@@ -521,7 +534,7 @@ const renderCharts = () => {
521534
new Chart(ctx, {
522535
type: type || "bar",
523536
data: parsedData,
524-
options: options ? JSON.parse(options) : DEFAULT_CHART_OPTIONS,
537+
options: options ? JSON.parse(options) : { ...DEFAULT_CHART_OPTIONS },
525538
})
526539
);
527540
}

0 commit comments

Comments
 (0)