簡體   English   中英

Highcharts - 多個Y軸

[英]Highcharts - Multiple Y axis

所以我在一個頁面上有多個highcharts圖。 其中一些圖(線)在一個圖上包含多個系列。 我遇到的問題是能夠為一個或兩個系列選擇多個點。

以下是我試圖做的一些示例代碼,但它給我帶來了問題......

function hc_json(series, hc_id) {
    $('#' + hc_id).highcharts('StockChart', {
        chart: {
            events: {           //Sets an event listener for the chart
                /*
                 *  If an event is registered it checks if the external zoom/selects are checked. 
                 *  If select is checked it gets the data points that were within the range at sets 
                 *  them as selected. 
                 */
                selection: function(event) {
                    var mode = $('input[name=mode]:checked', '#' + hc_id  + '_control').val();
                    if (mode != hc_id + '_zoom') {

                        for (var i = 0; i < this.series.length; i++)
                        {
                            console.log("Series: ", this.series);
                            console.log("Series length: ", this.series.length);
                            var points = this.series[i].points;   // visible points
                            var xs = event.xAxis[0]; //There seems to be no min/max forxAxis[1]
                            $.each(points, function (i,p) {
                                if (p.x >= xs.min && p.x <= xs.max) {
                                    console.log("Point:", p.x, "is selected");
                                    p.select(true, true);
                                }
                            });
                            //return false;
                        }
                        return false;
                    }
                },
            },

因此,例如,我希望能夠在圖表上為其中一個系列選擇點,但我希望能夠區分我想要選擇的系列。 我讀了一些“可見”系列,但尚未弄清楚如何制作一個系列可見或不可見。

請看一下這個解決方案:

 chart: {
        events: {
            selection: function(event) {
                var chart = this,
                    min = event.xAxis[0].min,
                    max = event.xAxis[0].max,
                    txt = '';
                if (event.xAxis) {

                    $.each(chart.series,function(i,serie){
                        $.each(serie.data,function(j,point){
                            if(point.x >=min && point.x <=max) {
                                txt += '<br>serie: ' + serie.name + ' point: '+ point.y;
                                point.select(true,true);
                            }
                        });
                    });

                    $report.html(txt);
                }
            }
        },
        zoomType: 'x'
    },

http://jsfiddle.net/cNRx5/2/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM