在Angular中, Highcharts不打印API调用中的点



这是传递给highcharts的series对象的样子。

[0 … 99]
0:
data:
z: 52.4421997
x: 1301702400000
y: 54.9129982
__proto__: Object
name: "Dummy"
__proto__: Object

我没有得到x轴值或y轴值,也没有数据点被打印。

我使用下面的scatter对象,其中series参数是以上述格式传递的数据

scatter(series) : void{
console.log(series);

const chart = new Chart({
chart: {
type: 'scatter',
reflow: true,
zoomType: 'xy',
width: 1328.91
},
title: {
text: ''
},
credits: {
enabled: false
},
xAxis: {
type: "datetime",
title: {
text: ''
},
startOnTick: true,
endOnTick: true,
showLastLabel: true
},
tooltip: {
formatter(): string {
// tslint:disable-next-line: no-string-literal
return '<b>' + this.series.name + '</b><br/>' + '<b>x </b>' + this.x + '<br/><b>y </b>' + this.y;
}
},
yAxis: {
title: {
text: ''
}
},
legend: {
align: 'right',
verticalAlign: 'top',
layout: 'vertical',
x: 0,
y: 50,
floating: false,
backgroundColor: '#FFFFFF',
borderWidth: 0
},
plotOptions: {
scatter: {
marker: {
radius: 5,
states: {
hover: {
enabled: true,
lineColor: '#005580'
}
}
}
}
},
// tslint:disable-next-line: object-literal-shorthand
series: series,
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
enabled: false
}
}
}]
}
});
this.chart = chart;
}

我需要帮助,我的代码是失败的我已经通过按

分配了系列数据
this.scatterData.push({
name: element.name,
data: {
x: element.xvalue,
y: element.param,
z: elememt.pointer
}
});

您需要确保您的序列数组的格式正确。例子:

var series = [
{
data: [
{
x: 1,
y: 2,
z: 5
},
{
x: 2,
y: 4,
z: 1
},
{
x: 3,
y: 1,
z: 10
}]
}];    

如果你从Angular中得到任何错误,最好将series变量code "as any"或者创建一个扩展系列选项的接口。

演示:https://stackblitz.com/edit/highcharts -角-基础-线- 88 sbpi

最新更新