繁体   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