Ensured bar charts start at 0

This commit is contained in:
Alejandro Celaya
2018-09-08 20:34:04 +02:00
parent 64c1b56973
commit 5d5a2be498
2 changed files with 23 additions and 2 deletions

View File

@@ -33,9 +33,18 @@ export function GraphCard({ title, isBarChart, stats }) {
});
const renderGraph = () => {
const Component = isBarChart ? HorizontalBar : Doughnut;
const legend = isBarChart ? { display: false } : { position: 'right' };
const options = {
legend: isBarChart ? { display: false } : { position: 'right' },
scales: isBarChart ? {
xAxes: [
{
ticks: { beginAtZero: true },
},
],
} : null,
};
return <Component data={generateGraphData(stats)} options={{ legend }} />;
return <Component data={generateGraphData(stats)} options={options} />;
};
return (