`
zengshaotao
  • 浏览: 752800 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

双Y轴

 
阅读更多

$(document).ready(function() {

        chart = new Highcharts.Chart({

            chart: {

                renderTo: 'container'

            },

            xAxis: [{

                categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',

                    'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

            }],

            yAxis: [{ // 第一个Y轴

                labels: {//刻度

                    formatter: function() {

                        return this.value +'°C';

                    },

                    style: {

                        color: '#89A54E'

                    }

                },

                title: {//y轴名称

                    text: 'Temperature',

                    style: {

                        color: '#89A54E'

                    }

                }

            }, { // 第二个Y轴

                title: {

                    text: 'Rainfall',

                    style: {

                        color: '#4572A7'

                    }

                },

                labels: {

                    formatter: function() {

                        return this.value +' mm';

                    },

                    style: {

                        color: '#4572A7'

                    }

                },

                opposite: true //表示是否跟第一个在反方向位置

            }],

        

            series: [{

                type: 'column',

                yAxis:1,//用来指定数据对应的y轴,不写表示默认选择第一个y轴

                data: [49.9, 71.5, 176.4, 129.2, 144.0, 196.0, 115.6, 118.5, 216.4, 114.1, 195.6, 54.4]

            }, {

                type: 'line',//这里也可以是column

                data: [5.0, 9.9,5.5, 7.5, 11.2, 21.5, 25.2, 26.5, 12.3, 18.3, 19.9, 9.6]

            }]

        });

    });

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics