As for the chart to correctly sort out the data you need?

Hello!
5ccac45b5b4a7338526091.png
In Highcharts xAxis in to sort out the data? so it was not only 4 of an item from the array, and all, in this case line ,but can be not only strings
const data = [
 ["custom Oct", 100, "custom 12", 120, "custom 121", 500],
 ["the number of fu", 140, "custom 12", 150, "custom 555", 300],
 ["Custom 20", 200, "custom 22", 222, "555 Oct", 400],
 ["a number of BU", 80, "custom 11", 0, "555 Oct", 600]
];

https://codesandbox.io/s/qxzokx6wp6
Did so but it's not right 5ccac5b83d7f2442631813.png
March 20th 20 at 11:29
1 answer
March 20th 20 at 11:31
items.reduce((acc, arr) => acc.concat(arr.filter(el => typeof el === 'string')), []);

or:
items.reduce((acc, arr) = > [..., acc, ...arr.filter(el => typeof el === 'string')], []);
but if there are all numbers? - Alexandro.Nien commented on March 20th 20 at 11:34
@kristina, will return an empty array. - Paula_Koelpin commented on March 20th 20 at 11:37
@karee, not just numbers and strings this is an example, can come in numbers and be converted into a date - Alexandro.Nien commented on March 20th 20 at 11:40
@karee, I mean that the array may be so, and that is not clear
const data = [
[1497052800, 100, 1597052800, 120, 1597052800, 120],
[1497139200, 140, 1597052800, 80],
[1497225600, 200, 1597052800, 222],
[1497312000, 80, 1597052800, 100],
]; - Alexandro.Nien commented on March 20th 20 at 11:43
@kristina, well, handle this option:
items.reduce((acc, arr) => acc.concat(arr.filter(filterFn)), []);

where filterFn your filter function returns true if the element should be added to the result, and false if the element is not needed. - Paula_Koelpin commented on March 20th 20 at 11:46
@kristina, in your case makes difficulties of what you're working with a date as a number. Since the numbers are parsed in date and to distinguish in your case is like a crutch:
const isDate = el => typeof el === 'number' && el > 1000000000;


const filterFn = el => !(typeof el === 'number' && !isDate(el));
- Paula_Koelpin commented on March 20th 20 at 11:49

Find more questions by tags JavaScriptHighchartsReact