Show all lines in legend

This commit is contained in:
Matthias 2020-06-23 21:18:43 +02:00
parent e41b23e02f
commit 6e497f1214
2 changed files with 8 additions and 3 deletions

View File

@ -9,6 +9,7 @@
<script> <script>
import { timestampms } from '@/shared/formatters'; import { timestampms } from '@/shared/formatters';
import ECharts from 'vue-echarts'; import ECharts from 'vue-echarts';
import randomColor from '../../shared/randomColor';
import 'echarts'; import 'echarts';
const MARGINLEFT = '5%'; const MARGINLEFT = '5%';
@ -103,7 +104,6 @@ export default {
if ('subplots' in this.plotConfig) { if ('subplots' in this.plotConfig) {
let plotIndex = 2; let plotIndex = 2;
Object.entries(this.plotConfig.subplots).forEach(([key, value]) => { Object.entries(this.plotConfig.subplots).forEach(([key, value]) => {
subPlots.legend.push(key);
// define yaxis // define yaxis
subPlots.yaxis.push({ subPlots.yaxis.push({
scale: true, scale: true,
@ -134,16 +134,17 @@ export default {
height: '8%', height: '8%',
}); });
Object.entries(value).forEach(([sk, sv]) => { Object.entries(value).forEach(([sk, sv]) => {
subPlots.legend.push(sk);
// entries per subplot // entries per subplot
const col = this.dataset.columns.findIndex((el) => el === sk); const col = this.dataset.columns.findIndex((el) => el === sk);
if (col) { if (col) {
const sp = { const sp = {
name: key, name: sk,
type: 'line', type: 'line',
xAxisIndex: plotIndex, xAxisIndex: plotIndex,
yAxisIndex: plotIndex, yAxisIndex: plotIndex,
itemStyle: { itemStyle: {
color: sv.color, color: sv.color || randomColor(),
}, },
encode: { encode: {
x: colDate, x: colDate,

View File

@ -0,0 +1,4 @@
export default function () {
// eslint-disable-next-line no-bitwise
return `#${((Math.random() * 0xffffff) << 0).toString(16)}`;
}