echarts柱状图上显示数值

本文详细解析了ECharts图表配置的各个参数,包括x轴、y轴、系列数据的设置,以及如何通过itemStyle定制样式,如标签显示、颜色设置等。通过具体示例,展示了如何创建一个带有阴影提示的柱状图,并对坐标轴刻度进行对齐优化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

option = {
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
        type: 'value'
    },
    series: [{
         itemStyle: {
                 normal: {
                     label: {
                         show: true,
                         position: 'top',
                         textStyle: {
                             color: '#800080'
                         }
                     }
                 }
             },
        data: [120, 200, 150, 80, 70, 110, 130],
        type: 'bar'
    }]
};

app.title = '坐标轴刻度与标签对齐';

option = {
    color: ['#3398DB'],
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器,坐标轴触发有效
            type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            data : ['Mon', 'Tue'],
            axisTick: {
                alignWithLabel: true
            }
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series : [
        {
            name:'直接访问',
            type:'bar',
             itemStyle: {
                 normal: {
                     label: {
                         show: true,
                         position: 'top',
                         textStyle: {
                             color: '#800080'
                         }
                     }
                 }
             },
            barWidth: '20%',
            data:[10000, 20000]
        }
    ]
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值