feat(pages): Improve chart

This commit is contained in:
syuilo 2020-04-19 08:25:22 +09:00
parent 3b6dbd6dc3
commit 4364122804

View file

@ -87,13 +87,13 @@ export class ASEvaluator {
data: { data: {
labels: opts.value.get('labels').value.map(x => x.value), labels: opts.value.get('labels').value.map(x => x.value),
datasets: opts.value.get('datasets').value.map(x => ({ datasets: opts.value.get('datasets').value.map(x => ({
label: x.value.get('label').value, label: x.value.has('label') ? x.value.get('label').value : '',
data: x.value.get('data').value.map(x => x.value), data: x.value.get('data').value.map(x => x.value),
pointRadius: 0, pointRadius: 0,
lineTension: 0, lineTension: 0,
borderWidth: 2, borderWidth: 2,
borderColor: color, borderColor: x.value.has('color') ? x.value.get('color') : color,
backgroundColor: tinycolor(color).setAlpha(0.1).toRgbString(), backgroundColor: tinycolor(x.value.has('color') ? x.value.get('color') : color).setAlpha(0.1).toRgbString(),
})) }))
}, },
options: { options: {
@ -111,6 +111,7 @@ export class ASEvaluator {
} }
}, },
legend: { legend: {
display: opts.value.get('datasets').value.filter(x => x.value.has('label') && x.value.get('label').value).length === 0 ? false : true,
position: 'bottom', position: 'bottom',
labels: { labels: {
boxWidth: 16, boxWidth: 16,
@ -121,8 +122,23 @@ export class ASEvaluator {
}, },
chartArea: { chartArea: {
backgroundColor: '#fff' backgroundColor: '#fff'
},
...(opts.value.get('type').value === 'rader' ? {
scale: {
ticks: {
beginAtZero: opts.value.has('begin_at_zero') ? opts.value.get('begin_at_zero') : false
} }
} }
} : {
scales: {
yAxes: [{
ticks: {
beginAtZero: opts.value.has('begin_at_zero') ? opts.value.get('begin_at_zero') : false
}
}]
}
})
}
}); });
}), }),
}}, { }}, {