Javascript Highcharts示例修改

Javascript Highcharts示例修改,javascript,highcharts,lines,Javascript,Highcharts,Lines,下面是我想修改的Highcharts示例的链接。我想让正确的2个y轴成为一个。目前,图形上的每条线对应一个y轴,因为它们具有不同的比例。我要创建的图表将有一个右轴,但对应于图表中两条线的最低点和最高点。例如,如果线A的低值为5(且低于线B中的任何值),而线B的极值为90(且高于线A中的任何值),则这两个值将用于轴。图表上的两条线应对应一个刻度 链接: 刮匙代码: var chart; $(document).ready(function() {

下面是我想修改的Highcharts示例的链接。我想让正确的2个y轴成为一个。目前,图形上的每条线对应一个y轴,因为它们具有不同的比例。我要创建的图表将有一个右轴,但对应于图表中两条线的最低点和最高点。例如,如果线A的低值为5(且低于线B中的任何值),而线B的极值为90(且高于线A中的任何值),则这两个值将用于轴。图表上的两条线应对应一个刻度

链接:

刮匙代码:

var chart;
            $(document).ready(function() {
                chart = new Highcharts.Chart({
                    chart: {
                        renderTo: 'container',
                    },
                    title: {
                        text: 'Example 1'
                    },
                    xAxis: [{
                        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 
                            'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
                    }],
                    yAxis: [{ // Primary yAxis
                        labels: {
                            formatter: function() {
                                return this.value +'%';
                            },
                            style: {
                                color: '#89A54E'
                            }
                        },
                        title: {
                            text: 'Percent Change',
                            style: {
                                color: '#89A54E'
                            }
                        },
                        opposite: true

                    }, { // Secondary yAxis
                        gridLineWidth: 0,
                        title: {
                            text: 'Measure',
                            style: {
                                color: '#4572A7'
                            }
                        },
                        labels: {
                            formatter: function() {
                                return this.value + 'k';
                            },
                            style: {
                                color: '#4572A7'
                            }
                        }
                    }, { // Tertiary yAxis
                        gridLineWidth: 0,
                        title: {
                            text: '',
                            style: {
                                color: '#AA4643'
                            }
                        },
                        labels: {
                            formatter: function() {
                                return this.value +' %';
                            },
                            style: {
                                color: '#AA4643'
                            }
                        },
                        opposite: true
                    }],

                series: [{
                    name: 'Measures',  //Button on Graph -- Measures
                    color: '#363534',
                    type: 'column',
                    yAxis: 1,
                    data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
            }, {
                    name: 'Percentage Change 1', //Button on Graph -- Purple
                    type: 'spline',
                    color: '#E17000',
                    yAxis: 2,
                    data: [30,40,35,25,14,25,39,28,21,78,23,36,5],
                    marker: {
                        enabled: false
            },
                    dashStyle: 'shortdot'
            }, {
                     name: 'Percentage Change 2', //Button on Graph -- Orange
                     color: '#A31A7E',
                     type: 'spline',
                     data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 35],
            }]
                });
            });
首先,也许考虑另一种表示数据的方式。多重尺度可能会造成精神紧张

  • 第二,也许这有帮助?我已删除
    $(文档)。准备就绪…
    包装

              var chart;
    
            chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'container',
                },
                title: {
                    text: 'Example 1'
                },
                xAxis: [{
                    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 
                        'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
                }],
                yAxis: [{ // Primary yAxis
                    labels: {
                        formatter: function() {
                            return this.value +'%';
                        },
                        style: {
                            color: '#878787'
                        }
                    },
                    title: {
                        text: 'Percent Change',
                        style: {
                            color: '#878787'
                        }
                    },
                    opposite: true
    
                }, { // Secondary yAxis
                    gridLineWidth: 0,
                    title: {
                        text: 'Measure',
                        style: {
                            color: '#4572A7'
                        }
                    },
                    labels: {
                        formatter: function() {
                            return this.value + 'k';
                        },
                        style: {
                            color: '#4572A7'
                        }
                    }
                }],
            series: [{
                name: 'Measures',  //Button on Graph -- Measures
                color: '#363534',
                type: 'column',
                yAxis: 1,
                data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
        }, {
                name: 'Percentage Change 1', //Button on Graph -- Purple
                type: 'spline',
                color: '#E17000',
                data: [30,40,35,25,14,25,39,28,21,78,23,36,5],
                marker: {
                    enabled: false
        },
                dashStyle: 'shortdot'
        }, {
                 name: 'Percentage Change 2', //Button on Graph -- Orange
                 color: '#A31A7E',
            type: 'spline',
             data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 35],
    }]  });
    

  • 有一个选项可以设置串联阵列的yAxis属性。为两个系列对象设置yAxis:0。无论图表上有多少个系列项目,这都应给出一个Y轴