Loop chart colors
This commit is contained in:
@@ -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 %}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user