From fe40eda28f24fbe115545f65965f2403f8ce295d Mon Sep 17 00:00:00 2001 From: Henri Bergius Date: Wed, 7 Mar 2018 16:07:30 +0100 Subject: [PATCH] Handle situations where there is no reference --- elements/linechart.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/elements/linechart.js b/elements/linechart.js index 9a3cc4f..b8e011b 100644 --- a/elements/linechart.js +++ b/elements/linechart.js @@ -107,13 +107,12 @@ class LineChart extends Component { return res; }); - const shapes = references.split(' ').map((spec, idx) => { + const shapes = references.split(' ').filter(spec => !isNaN(parseFloat(spec))).map((spec, idx) => { let colorIdx = data.length + idx; if (colorIdx > colors.length) { // Start cycle again colorIdx = idx; } - let color = colors[colorIdx]; const res = { type: 'line', xref: 'paper', // x relative to [0,1] "paper" axis @@ -123,7 +122,7 @@ class LineChart extends Component { y0: parseFloat(spec), y1: parseFloat(spec), line: { - color, + color: colors[colorIdx], width: 1, }, };