Skip to content
Snippets Groups Projects
Commit 8438280a authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Add scale fix to staff graph

parent ff4a01e7
No related branches found
No related tags found
1 merge request!34Rework to use a common font config across graphs and add x-axis and legends on top and bottom of graphs
......@@ -46,7 +46,6 @@ const chartOptions = {
},
},
scales: {
x: {
position: 'top' as const,
......@@ -61,14 +60,33 @@ const chartOptions = {
ticks: {
callback: (value: string | number) => {
if (typeof value === 'number') {
return `${value * 100}%`;
return `${value}%`;
}
return value;
},
},
grid: {
drawOnChartArea: false
}
},
afterDataLimits: function (axis) {
const indices = Object.keys(ChartJS.instances)
// initial values should be far outside possible range
let max = -999999
let min = 999999
for (const index of indices) {
if (ChartJS.instances[index] && axis.chart.scales.x2) {
min = Math.min(ChartJS.instances[index].scales.x.min, min);
max = Math.max(ChartJS.instances[index].scales.x.max, max);
}
}
axis.chart.scales.x2.options.min = min;
axis.chart.scales.x2.options.max = max;
axis.chart.scales.x2.min = min;
axis.chart.scales.x2.max = max;
},
},
y: {
stacked: true,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment