echarts使用title代替坐标轴名称

坐标轴名称的位置,随着名称长度、坐标轴最值长度的变化,属实难以控制,所以尝试使用title取代: 

option = {
        title: [{
            text: "单位:左边一个坐标轴名称",
            left: "18px",
            top: 0,
            textStyle: {
                color: "#999",
                fontSize: 12,
                fontWeight: '400'
            }
        }, {
            text: "单位:右边一个坐标轴名称",
            right: "18px",
            top: 0,
            textStyle: {
                color: "#999",
                fontSize: 12,
                fontWeight: '400'
            }
        }],
        grid: {
            left: '25',
            right: '25',
            bottom: '24',
            top: '75',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            data: ['01-01', '01-02', '01-03', '01-04', '01-05', '01-06', '01-07'],
            splitLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLine: {
                show: false
            },
        },
        yAxis: [{
            type: 'value',
            axisLabel: {
                color: '#999',
                textStyle: {
                    fontSize: 12
                },
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#F3F4F4'
                }
            },
            axisTick: {
                show: false
            },
            axisLine: {
                show: false
            },
        }, {
            type: 'value',
            axisLabel: {
                color: '#999',
                textStyle: {
                    fontSize: 12
                },
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#F3F4F4'
                }
            },
            axisTick: {
                show: false
            },
            axisLine: {
                show: false
            },
        }],
        series: [{
                name: '订单总数',
                type: 'line',
                smooth: true,
                data: [3, 2, 4, 4, 5, 3, 8],
                yAxisIndex: 0,
            },
            {
                name: '消费金额',
                type: 'line',
                smooth: true,
                data: [999, 54, 34, 2222, 32225, 1111],
                yAxisIndex: 1,
            }
        ]
    };
 

很完美(神奇的title,很多场景都可以用title处理):

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值