Loop chart colors

This commit is contained in:
rubenwardy 2023-01-02 17:34:34 +00:00
parent 72d999e759
commit c1600b90a6
2 changed files with 5 additions and 5 deletions

@ -184,12 +184,12 @@ async function load_data() {
function setup_chart(ctx, data) {
data.datasets = data.datasets.map((set, i) => {
const colorIdx = data.datasets.length - i - 1;
const colorIdx = (data.datasets.length - i - 1) % chartColors.length;
return {
fill: true,
backgroundColor: chartColorsBg[colorIdx] ?? chartColorsBg[0],
borderColor: chartColors[colorIdx] ?? chartColors[0],
pointBackgroundColor: chartColors[colorIdx] ?? chartColors[0],
backgroundColor: chartColorsBg[colorIdx],
borderColor: chartColors[colorIdx],
pointBackgroundColor: chartColors[colorIdx],
...set,
};
});

@ -2,7 +2,7 @@
<script src="/static/libs/chart.min.js"></script>
<script src="/static/libs/chartjs-adapter-date-fns.bundle.min.js"></script>
<script src="/static/libs/chartjs-plugin-annotation.min.js"></script>
<script src="/static/package_charts.js?v=8"></script>
<script src="/static/package_charts.js?v=9"></script>
{% endmacro %}