javascript 在同一页面上使用 highchart 和 highstock
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11324790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
use highchart and highstock on the same page
提问by devmonster
I have this page:
我有这个页面:
<script type="text/javascript" src="jQuery/Highcharts/highstock1.1.6.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highcharts2.1.4.js"></script>
and in the page I use
在我使用的页面中
$.getJSON(
"server/indice.server.php?row=" + row +"&item="+ item,
null,
function(data)
{
chartindice = new Highcharts.Chart(
{
chart:
{
renderTo: 'graph',
defaultSeriesType: 'line',
zoomType: 'x'
},
/////moore setting..
series:
[{
type: 'area',
name: titleindice,
data: indice,
showInLegend : false //disable the the show/hide icon
}]
});
});
and an highstock graph
和高库存图
window.chart = new Highcharts.StockChart({
chart: {
renderTo: 'chartHistory'
},
rangeSelector: {
selected: 2
},
series: [{
data: history,
type: 'spline',
tooltip: {
valueDecimals: 2
}
}]
});
and they can't work together, just one or the other.
他们不能一起工作,只有一个。
What can I do?
我能做什么?
回答by lbrutti
Got same trouble with conflicting Highchart and Highstock. here's the official solution:
Highchart 和 Highstock 冲突时遇到了同样的问题。这是官方的解决方案:
Keep in mind that the Highcharts.Chart constructor and all features of Highcharts are included in Highstock, so if you are running Chart and StockChart in combination, you only need to load the highstock.js file.
请记住 Highcharts.Chart 构造函数和 Highcharts 的所有功能都包含在 Highstock 中,因此如果您同时运行 Chart 和 StockChart,则只需加载 highstock.js 文件。
回答by Sebastian Bochan
Highcharts is included in highstock.js, so please take look at the example, how use highcharts with highstock.js
.
Highcharts 包含在 highstock.js 中,因此请查看示例,如何将 highcharts 与highstock.js
.
http://jsfiddle.net/sbochan/PtXhB/
http://jsfiddle.net/sbochan/PtXhB/
Secondly I advice to use the newest highstock.
其次,我建议使用最新的highstock。
回答by haryx8
I have experienced the same problem when I tried to use Highstock chart and Angular Gauge, And the problem was solved when I try to rearrange highstock highchart javascript library like this
我在尝试使用 Highstock chart 和 Angular Gauge 时遇到了同样的问题,当我尝试像这样重新排列 highstock highchart javascript 库时,问题就解决了
<script type="text/javascript" src="jQuery/Highcharts/highcharts.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highstock.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highcharts-more.js"></script>
or (if you don't want to use additional graphics)
或(如果您不想使用其他图形)
<script type="text/javascript" src="jQuery/Highcharts/highcharts.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highstock.js"></script>
I hope it can be useful
我希望它有用
回答by user2614209
you must delete this file:
你必须删除这个文件:
highcharts.js
highcharts.js
i tried and it works
我试过了,它有效
回答by Diego Favero
Im my case, including only HighStock's file worked for HighChart's as well.
我的情况是,仅包括 HighStock 的文件也适用于 HighChart。
I have many charts, highchart's or highstock's, possible to be included on same page, and I just call HighStock.js once and it works for both !
我有很多图表,highchart 或 highstock,可以包含在同一页面上,我只调用一次 HighStock.js,它对两者都适用!
回答by MISSIRIA
Use just highstock.jsand delete highcharts.jsAnd It's work well for me And Good luck
只使用 highstock.js并删除highcharts.js对我来说效果很好,祝你好运
回答by Grooveek
Highstock contains most of HighCharts code. Have you tried including only highstock.js in your page to display both charts ?
Highstock 包含大部分 HighCharts 代码。您是否尝试过在页面中只包含 highstock.js 来显示两个图表?
回答by srikanth arroju
I had same issue and got fixed by ordering my JS as below.
我有同样的问题,并通过如下订购我的 JS 得到解决。
<script type="text/javascript" src="$javascript_folder/highstock.js"></script>
<script type="text/javascript" src="$javascript_folder/highcharts.js"></script>
I don't know its working fine according Ardi. Is works fine for me when i load highstock.js first followed by highcharts.
根据Ardi,我不知道它的工作正常。当我首先加载 highstock.js 然后加载 highcharts 时,对我来说效果很好。