我想创建一个图表,显示1年内的Apple股票价格。我想在URL https://api.iextrading.com/1.0/stock/aapl/chart/1y中的JavaScript代码中合并“ close”值和“ date”。 “关闭”值是y值,“日期”是x值。我希望我的图表在https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/demo/line-time-series/中看起来像这样。我该怎么办?
$.getJSON(
'https://api.iextrading.com/1.0/stock/aapl/chart/1y',
function (data) {
Highcharts.chart('container', {
chart: {
zoomType: 'x'
},
title: {
text: 'Apple Stock Price Over 1 Year'
},
subtitle: {
text: document.ontouchstart === undefined ?
'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in'
},
xAxis: {
type: 'datetime'
},
yAxis: {
title: {
text: 'Stock Price'
}
},
legend: {
enabled: false
},
plotOptions: {
area: {
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
marker: {
radius: 2
},
lineWidth: 1,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
},
series: [{
type: 'area',
name: 'Apple Stock Price',
data: data
}]
});
}
);