带有节点js和react js的HighChart图形
HighChart graphics with node js and react js
我正在使用库 highChart https://www.highcharts.com/ 来制作统计图,我想知道是否有可能在不同时期创建不同的数据,例如我有这样的系列:
Categories : [
'2021-01-01',
'2021-01-02',
'2021-01-03',
'2021-01-04',
'2021-01-05',
'2021-01-06',
'2021-01-07',
'2021-01-08',
'2021-01-09',
'2021-01-10',
'2021-01-11',
'2021-01-12',
'2021-01-13',
'2021-01-14',
'2021-01-15',
'2021-01-16',
'2021-01-17',
'2021-01-18',
'2021-01-19',
'2021-01-20',
'2021-01-21',
'2021-01-22',
'2021-01-23',
'2021-01-24',
'2021-01-25',
'2021-01-26',
'2021-01-27',
'2021-01-28',
'2021-01-29',
'2021-01-30',
]
series : [
{
name : 'serie 1',
data : [
{x : '2021-01-05' , s : 5},
{x : '2021-01-10' , s : 20},
{x : '2021-01-11' , s : 40},
{x : '2021-01-15' , s : 80},
{x : '2021-01-30' , s : 20},
]
}
]
i wanna the x values in the graphic get the period in categories and get the x value from series to compare if the x value in series exist then get s value in the series else put 0
How i can do that in highChart
我实现了将数据解析为所需格式的逻辑。看看这个演示:https://jsfiddle.net/BlackLabel/hrasqo92/
const parsedData = categories.map(category => {
const dataPoint = baseData.filter(data => data.x === category);
if (dataPoint.length) {
return [category, dataPoint[0].y]
} else {
return [category, 0]
}
})
我正在使用库 highChart https://www.highcharts.com/ 来制作统计图,我想知道是否有可能在不同时期创建不同的数据,例如我有这样的系列:
Categories : [
'2021-01-01',
'2021-01-02',
'2021-01-03',
'2021-01-04',
'2021-01-05',
'2021-01-06',
'2021-01-07',
'2021-01-08',
'2021-01-09',
'2021-01-10',
'2021-01-11',
'2021-01-12',
'2021-01-13',
'2021-01-14',
'2021-01-15',
'2021-01-16',
'2021-01-17',
'2021-01-18',
'2021-01-19',
'2021-01-20',
'2021-01-21',
'2021-01-22',
'2021-01-23',
'2021-01-24',
'2021-01-25',
'2021-01-26',
'2021-01-27',
'2021-01-28',
'2021-01-29',
'2021-01-30',
]
series : [
{
name : 'serie 1',
data : [
{x : '2021-01-05' , s : 5},
{x : '2021-01-10' , s : 20},
{x : '2021-01-11' , s : 40},
{x : '2021-01-15' , s : 80},
{x : '2021-01-30' , s : 20},
]
}
]
i wanna the x values in the graphic get the period in categories and get the x value from series to compare if the x value in series exist then get s value in the series else put 0
How i can do that in highChart
我实现了将数据解析为所需格式的逻辑。看看这个演示:https://jsfiddle.net/BlackLabel/hrasqo92/
const parsedData = categories.map(category => {
const dataPoint = baseData.filter(data => data.x === category);
if (dataPoint.length) {
return [category, dataPoint[0].y]
} else {
return [category, 0]
}
})