簡體   English   中英

Highcharts在3個圖表上同步范圍選擇器和導航器

[英]Highcharts synchronise range selector and navigator on 3 charts

我想要同步3個圖表上的導航器和范圍選擇器。

我目前在最后一張圖表的底部具有導航器,在第一張圖表的頂部具有范圍選擇器。 但是,這些仍然僅控制其相關圖表,而與其他圖表不同步。

請看我的小提琴: http : //jsfiddle.net/gdf0swa9/

var options = {
                                        "chart": {
                                            "type": "line",
                                            "polar": false,
                                            "zoomType": "x",
                                            "inverted": false
                                        },
                                        "rangeSelector": {
                                            "enabled": true
                                        },
                                        "navigator": {
                                            "enabled": false
                                        },
                                        "scrollbar": {
                                            "enabled": false
                                        },
                                        "title": {
                                            "text": "Peak",
                                            "align": "left",
                                            "floating": false
                                        },

                                        "subtitle": {
                                            "text": " "
                                        },

                                        "series": [{
                                            "name": "Peak",
                                            "turboThreshold": 0,
                                            "color": "#FF0000",
                                            "threshold": 14,
                                            "type": "line",
                                            "dashStyle": "Solid",
                                            "negativeColor": "#ffee58",
                                            "colorByPoint": false,
                                            "visible": true
                                        }, {
                                            "name": "Minimum",
                                            "type": "line",
                                            "color": "#f44336",
                                            "dashStyle": "ShortDash",
                                            "visible": false
                                        }, {
                                            "name": "Maximum",
                                            "dashStyle": "LongDash",
                                            "type": "line",
                                            "color": "#f44336",
                                            "visible": false
                                        }, {
                                            "name": "Threshold",
                                            "type": "line",
                                            "color": "#f50057",
                                            "visible": false
                                        }, {
                                            "name": "Location Temperature",
                                            "visible": false
                                        }],
                                        "data": {
                                            "csv": "\"Movement\";\"Peak\";\"Minimum\";\"Maximum\";\"Threshold\";\"Location Temperature\"\n1;12.87;12;15;14;20\n2;16;12;15;14;23\n3;12.92;12;15;14;22\n4;13.14;12;15;14;25\n5;12.88;12;15;14;24\n6;13.03;12;15;14;23\n7;12.76;12;15;14;20\n8;16;12;15;14;22\n9;12.72;12;15;14;20\n10;13.2;12;15;14;24",
                                            "googleSpreadsheetKey": false,
                                            "googleSpreadsheetWorksheet": false
                                        },

                                        "pane": {
                                            "background": []
                                        },
                                        "responsive": {
                                            "rules": []
                                        },
                                        "yAxis": [{
                                            "title": {
                                                "text": "(V)"
                                            }
                                        }],
                                        "xAxis": [{
                                            "plotBands": [{}]
                                        }],
                                        "plotOptions": {
                                            "series": {
                                                "dataLabels": {
                                                    "enabled": false
                                                }
                                            }
                                        },
                                        "legend": {
                                            "layout": "vertical",
                                            "enabled": false,
                                            "align": "center",
                                            "floating": false
                                        },
                                        "annotations": [{}],
                                        "tooltip": {
                                            "shared": false
                                        },
                                        "credits": {
                                            "text": " ",
                                            "enabled": false
                                        },
                                        "accessibility": {
                                            "describeSingleSeries": false
                                        }
                                    };
                                    new Highcharts.StockChart("highcharts-67f948af-71a4-4556-ad25-ec142f0f406f", options);
                                }
                            }
                        })();

您可以使用afterSetExtremes事件並為其他圖表設置正確的xAxis極限值:

events: {
    afterSetExtremes: function(e) {
        for (var i = 0; i < 2; i++) {
            Highcharts.charts[i].xAxis[0].setExtremes(e.min, e.max, true, false);
        }
    }
}

現場演示: http : //jsfiddle.net/BlackLabel/gyt5pjc7/

API參考: https : //api.highcharts.com/highcharts/xAxis.events.afterSetExtremes

暫無
暫無

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

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