This commit is contained in:
2020-07-31 19:37:30 +02:00
parent 9e97ab9592
commit 9ec6440dc7
5 changed files with 19 additions and 11 deletions
+4 -3
View File
@@ -1,7 +1,8 @@
<script>
import { Line, mixins } from 'vue-chartjs';
function resolve_data (set, keys) {
function resolve_data (set, index) {
const keys = typeof index === 'string' ? index.split ('/') : index;
const data = set[keys[0]];
if (keys.length === 1)
return data;
@@ -27,7 +28,7 @@ export default {
},
computed: {
chart_data () {
const labels = this.data.map ((d) => d[this.xaxis]);
const labels = this.data.map ((d) => resolve_data (d, this.xaxis));
const datasets = this.yaxis.map ((y, index) => {
const res = {
label: y.label,
@@ -37,7 +38,7 @@ export default {
backgroundColor: y.fill
};
for (const data of this.data)
res.data.push (resolve_data (data, y.field.split ('/')));
res.data.push (resolve_data (data, y.field));
return res;
});
return { datasets, labels };