[英]how to use highstock in ecmascript?
here are an example of code that work, I create a graph这是一个有效的代码示例,我创建了一个图表
import $ from 'jquery';
import Highcharts from 'highcharts';
class test {
constructor(){
let chart = new Highcharts.chart('container', {
chart: {
animation: false
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
}
}
now I want do a stockChart like https://jsfiddle.net/74vn5utd/现在我想做一个像https://jsfiddle.net/74vn5utd/这样的股票图表
but I import it and its module但我导入它和它的模块
import StockChart from 'highcharts/highstock';
import datahc from 'highcharts/modules/data';
after that I load the module之后我加载模块
datahc(StockChart);
and finally I call the chart and最后我调用图表
StockChart.chart('container', {
rangeSelector: {
selected: 1
},
title: {
text: 'AAPL Stock Price'
},
series: [{
name: 'AAPL',
data: response.graph,
tooltip: {
valueDecimals: 2
}
}]
});
I have a regular graph, not a HighStock graph, I don't get it, what is wrong?我有一个常规图表,而不是 HighStock 图表,我不明白,有什么问题?
thanks in advance提前致谢
You still use the chart constructor which creates regular chart.您仍然使用创建常规图表的图表构造函数。
Try to use StockChart.stockChart('container, {...}) , where stockChart is a Highstock constructor.尝试使用StockChart.stockChart('container, {...}) ,其中stockChart是 Highstock 构造函数。
Demo: https://jsfiddle.net/BlackLabel/v4qbyka6/演示: https : //jsfiddle.net/BlackLabel/v4qbyka6/
Highcharts.stockChart('container', {
series: [{
data: data
}]
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.