javascript Highcharts 没有多个系列的多个 x 轴?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20135141/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 17:49:15  来源:igfitidea点击:

Highcharts multiple x-Axis without multiple series?

javascripthighchartsaxesmultiple-axes

提问by natecraft1

This fiddle uses multiple series and displays an axis for each of them. Is it possible to use a single series to make several Axes? http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/combo-multi-axes/

这个小提琴使用多个系列并为每个系列显示一个轴。是否可以使用单个系列制作多个 Axes?http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/combo-multi-axes/

xAxis:[{
        categories:setup.x_mixed,
        maxZoom:5,
        minPadding: 0.2,
        labels:{
          "enabled":setup.categories_label,
          "y":1,
          "style":{
            "fontSize":13,
            "color":"#999",
            fontFamily:"'helvetica neue',helvetica",
            whiteSpace:"nowrap",
            textOverflow:"clip",
            width:"100%",
            marginTop:legendSpacing
          },
          formatter:function () {
            return this.value.split("|")[0]
          }
        },
        lineColor:"rgba(255,255,255,0)",
        tickWidth:0,
        offset:0
      }, { // Secondary yAxis
        categories:setup.x_mixed,
        maxZoom:5,
        minPadding: 0.2,
        labels:{
          "enabled":setup.categories_label,
          "y":16,
          "style":{
            "fontSize":13,
            "color":"#999",
            fontFamily:"'helvetica neue',helvetica",
            whiteSpace:"nowrap",
            textOverflow:"clip",
            width:"100%",
            marginTop:legendSpacing
          },
          formatter:function () {
            return this.value.split("|")[1]
          }
        },
        lineColor:"rgba(255,255,255,0)",
        tickWidth:0,
        offset:0

        }],

回答by Sebastian Bochan

You can also use linkedTo paramtetr on extra axis http://api.highcharts.com/highcharts#yAxis.linkedTo

您还可以在额外的轴上使用linkedTo paramtetr http://api.highcharts.com/highcharts#yAxis.linkedTo

回答by Strikers

its pretty simple,

它很简单,

declare 2 xAxis same like the yAxis you mentioned in the example with one of them as opposite:true

声明 2 个 xAxis 与您在示例中提到的 yAxis 相同,其中一个为 opposite:true

As you have only one series set the second axis extremes same as the first one using getExtremes() and setExtremes(), as shown in this fiddle here http://jsfiddle.net/W43Zb/

由于您只有一个系列,使用 getExtremes() 和 setExtremes() 将第二个轴的极端设置为与第一个相同,如这里的小提琴所示http://jsfiddle.net/W43Zb/

Hope this will help you

希望能帮到你