javascript - higcharts左右两边坐标设置从0开始
伊谢尔伦
伊谢尔伦 2017-04-11 10:23:48
[JavaScript讨论组]

如图怎么设置两边“0”坐标对齐:

下图是想要实现的效果

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(2)
PHPz

右侧y轴含义是什么

调试页面: http://code.hcharts.cn/demos/...
栗子~

$(function() {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Column chart with negative values'
        },
        xAxis: {
            categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
        },
        yAxis: [{
            labels: {
                formatter: function() {
                    if (this.value < 0) {
                        return "第一等级(" + this.value + ")";
                    } else if (this.value >= 0 && this.value <= 2) {
                        return "第二等级(" + this.value + ")";
                    } else {
                        return "第三等级(" + this.value + ")";
                    }
                }
            }
        },
        {
            opposite: true,
            labels: {
                formatter: function() {
                    if (this.value < 0) {
                        return "1级(" + this.value + ")";
                    } else if (this.value >= 0 && this.value <= 2) {
                        return "2级(" + this.value + ")";
                    } else {
                        return "3级(" + this.value + ")";
                    }
                }
            }
        }],
        credits: {
            enabled: false
        },
        series: [{
            name: 'John',
            yAxis: 0,
            data: [5, 3, 4, 7, 2]
        },
        {
            name: 'Jane',
            yAxis: 0,
            data: [2, -2, -3, 2, 1]
        },
        {
            name: 'Joe',
            yAxis: 1,
            data: [3, 4, 4, -2, 5]
        }]
    });
});
伊谢尔伦

你的意思是总收入、净利润的单位不同,所以右边你就用%显示?

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Efficiency Optimization by Branch'
        },
        xAxis: {
            categories: [
                'Seattle HQ',
                'San Francisco',
                'Tokyo'
            ]
        },
        yAxis: [{
            min: -240,
            title: {
                text: 'Employees'
            }
        }, {
            title: {
                text: 'Profit (millions)'
            },
            opposite: true
        }],
        legend: {
            shadow: false
        },
        tooltip: {
            shared: true
        },
        plotOptions: {
            column: {
                grouping: false,
                shadow: false,
                borderWidth: 0
            }
        },
        series: [{
            name: 'Employees',
            color: 'rgba(165,170,217,1)',
            data: [150, 73, 20],
            pointPadding: 0.3,
            pointPlacement: -0.2
        }, {
            name: 'Profit',
            color: 'rgba(248,161,63,1)',
            data: [-183.6, -178.8, 198.5],
            tooltip: {
                valuePrefix: '$',
                valueSuffix: ' M'
            },
            pointPadding: 0.3,
            pointPlacement: 0.2,
            yAxis: 1
        }]
    });
});
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号