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

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 };

View File

@ -12,7 +12,7 @@
/>
<ChartView
:data="parsed_log"
xaxis="app"
xaxis="timestamp"
:yaxis="datasets"
/>
<TableView
@ -38,9 +38,8 @@ export default {
computed: {
datasets () {
return [
{ label: 'test', field: 'data/num2', color: 'blue', fill: '#0000' },
{ label: 'abc', field: 'data/num1', color: '#ff000055', fill: '#0000' },
{ label: 'def', field: 'data/num1', color: '#00ff00', fill: '#f005' }
{ label: 'foo', field: 'data/num2', color: '#ff000055', fill: '#0000' },
{ label: 'bar', field: 'data/num3', color: '#00ff00', fill: '#0000' }
];
},
parsed_log () {