我需要处理API结果,这样我就不会收到小于0的值,我一直在尝试这种方法,但到目前为止,我还不能:
private handleChart(data: Object): void {
const series = [];
for (const [key, value] of Object.entries(data)) {
series.push({
name: key,
data: value,
type: "line",
});
}
if (series[0].data.length < 0) {
delete series[0].data;
}
console.log(data );
this.plotChart(series);
}
原始代码:
private handleChart(data: Object): void {
const series = [];
for (const [key, value] of Object.entries(data)) {
series.push({
name: key,
data: value,
type: "line",
});
}
this.plotChart(series);
}
1条答案
按热度按时间snz8szmq1#
假设您的数据对象为:
您可以筛选和Map对象。条目的结果如下:
结果将是:
或者,如果要将负值设为下限:
结果: