coords: [
{
"date": 1606780800,
"value": -2.389158,
"line": 202012
},
{
"date": 1606953600,
"value": -1.810067,
"line": 202012
},
{
"date": 1607040000,
"value": -1.230976,
"line": 202013
},
{
"date": 1607126400,
"value": -0.651885,
"line": 202013
},
{
"date": 1607126400,
"value": -0.651885,
"line": 202013
}, ....
coords: [
{
"date": 1606780800,
"value": -2.389158,
"line": 202012
},
{
"date": 1606953600,
"value": -1.810067,
"line": 202012
},
{
"date": 1606953600,
"value":0,
"line": 202012
},
{
"date": 1607040000,
"value": -1.230976,
"line": 202013
},
{
"date": 1607126400,
"value": -0.651885,
"line": 202013
},
{
"date": 1607126400,
"value": -0.651885,
"line": 202013
}, {
"date": 1607126400,
"value": 0,
"line": 202013
}, ....
this.chartCoords.trand1 = this.chartCoords.trand1.map(function (name) {
return {{'Number(name.date * 1000), Number(name.value), Number(name.line)'},
{'Number(name.date * 1000), Number(0), Number(name.line)'}}
});
coords.reduce((acc, n, i, a) => (
acc.push(n),
(n.line !== a[i + 1]?.line) && acc.push({ ...n, value: 0 }),
acc
), [])
coords.flatMap((n, i, a) =>
i === ~-a.length || n.line !== a[-~i].line
? [ n, { ...n, value: 0 } ]
: n
)