简体   繁体   English

高图两次绘制相同的图表

[英]Highcharts rendering the same chart twice

Does anyone know how to use highcharts to render the same chart twice? 有谁知道如何使用高图两次绘制同一张图表? My code that I have is: 我的代码是:

$(function () {
$('#SuccessFailedRatio, #CounterfeitRatio').highcharts({
    chart: {
....

I have two divs in my html with the id's shown above. 我的html中有两个div,其ID如上所示。 Only one chart appears in CounterfeitRatio. “伪造比率”中仅显示一张图表。 Does anyone know how to make it appear in both divs? 有谁知道如何使它出现在两个div中? Thanks for the help! 谢谢您的帮助!

I would separate your options into an object and then add that to two charts. 我会将您的选项分成一个对象,然后将其添加到两个图表中。 Highcharts by default will only load your chart into the first element that fits your jQuery selector, so you have to add it to two elements specifically. 默认情况下,Highcharts只会将图表加载到适合jQuery选择器的第一个元素中,因此您必须将其专门添加到两个元素中。 Here is a jsFiddle! 这是一个jsFiddle!

var options = {
    title: {
        text: 'Monthly Average Temperature',
        x: -20 //center
    }
    //etc...
};

$('#container').highcharts(options);
$('#container2').highcharts(options);

You can use this option: 您可以使用此选项:

$('#container').highcharts($.extend({},options));
$('#container2').highcharts($.extend({},options));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM