简体   繁体   English

如何打开新的图表到相邻的 <div> 在栏上单击highchart

[英]How to open new chart to the adjacent <div> on bar click in highchart

I'm new to Highcharts and need two charts(lets assume Chart a and chart B). 我是Highcharts的新手,需要两个图表(假设图表a和图表B)。 So creating one is simple. 因此创建一个很简单。 On bar click of chart(Chart A) I want a new chart(Chart B) to open adjacent to the existing <div> (Chart A). 在图表的条形图上单击(图A),我想在现有的<div>旁边打开一个新的图表(图B)(图A)。 So both chart should be visible once bar is clicked. 因此,一旦单击条,两个图表都应该可见。 New chart (chart B) should be different for each bar clicked of first Chart (Chart A) 新图表(图表B)对于第一个图表(图表A)单击的每个条形都应不同

我认为,如果图表彼此相关,则不必有2个不同的图表...您需要的是这样的东西 ...只需单击任何一个条形即可看到魔术

You can simply bind click event on a bar, then create second chart in a specific div, see: http://jsfiddle.net/Yrygy/147/ 您可以简单地在栏上绑定click事件,然后在特定的div中创建第二个图表,请参见: http : //jsfiddle.net/Yrygy/147/

var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container',
        type: 'bar'
    },
    plotOptions: {
        bar: {
            point: {
                events: {
                    click: renderSecond
                }
            }
        }
    },
    series: [{
        data: [{
            y: 100,
            name: 'test'
        }, {
            y: 34,
            name: 'click'
        }, {
            y: 67,
            name: 'other'
        }]
    }]
});

function renderSecond(e) {
    var point = this;
    $("#detail").highcharts({
        title: {
            text: point.name + ':' + point.y
        },
        series: [{
            data: [1, 2, 3]
        }]
    });
}

And markup: 和标记:

<div id="container" style="min-width: 400px; height: 300px; margin: 0 auto"></div>
<div id="detail" style="min-width: 400px; height: 300px; margin: 0 auto"></div>

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

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