graphs: set the colors

This commit is contained in:
Girish Ramakrishnan
2025-07-03 15:59:31 +02:00
parent f1057bb4a3
commit 9e27921867
2 changed files with 13 additions and 3 deletions

View File

@@ -22,9 +22,13 @@ const props = defineProps({
type: Array,
validator: (val) => Array.isArray(val) && val.every(item => typeof item === 'string')
},
datasetColors: {
type: Array,
validator: (val) => Array.isArray(val) && val.every(item => typeof item === 'string')
},
yscale: String, // cpu, memory
memory: Object,
cpu: Object
cpu: Object,
});
function createGraphOptions({ yscale, period }) {
@@ -116,7 +120,7 @@ function onPeriodChanged() {
const data = { datasets: [] };
for (const label of props.datasetLabels) {
for (const [index, label] of props.datasetLabels.entries()) {
data.datasets.push({
label: label,
data: [],
@@ -124,7 +128,9 @@ function onPeriodChanged() {
borderWidth: 1, // https://www.chartjs.org/docs/latest/charts/line.html#line-styling
tension: 0.4,
showLine: true,
fill: true
fill: true,
color: props.datasetColors[index],
stack: 'stackgroup' // put them all in same stackgroup
});
}