echarts柱状图基本属性。

1 篇文章 0 订阅

X轴线颜色

    var barwidth = 32;// 柱状图宽度
    var radius =[4, 4, 0, 0];//柱状图圆角
    return {
        title: {
                textStyle: {
                fontWeight: 'normal',      
                color: '#fff' // 标题颜色
            },
            
        },
        tooltip: {},
        legend: {
            data:[data.series[0].name,data.series[1].name,data.series[2].name],//legend标题
            textStyle:{
                fontSize:16, // legend标题字体大小
                color:'#fff' //legend标题字体颜色
            }
        },
        xAxis: [//X轴(横轴)
            {
                data: data.categories,
                axisLine: { //x轴线的颜色以及宽度
                    show: true,
                    lineStyle: {
                        color: "#ffff", //x轴线的颜色
                        width: 2, //x轴线的宽度
                        type: "solid"
                    },
                    textStyle: {
                        fontSize:14,//x轴字体大小
                        color: '#fff'//字体颜色
                    }
                }
            }
        ],
        yAxis: [//Y轴线
            {
                type: 'value',
                scale: true,
                name: '分',//轴线名称(单位)
                axisLine: {//左边Y轴线的颜色以及宽度
                    show: true,
                    lineStyle: {
                        color: "#ffff",
                        width: 2,
                        type: "solid"
                    }
                },
                nameTextStyle: {
                    color: '#fff',
                    fontSize: 14 //纵坐标单位字体大小
                },
                max: 100, //最大刻度
                min: 0, //最小刻度
                axisLabel: {
                    show: true,
                    textStyle: {
                        fontSize:14,//左边纵坐标字体大小
                        color: '#fff'
                    }
                },
                splitLine:{
                show:false
              },
                boundaryGap: [0.2, 0.2]
            },
            {
                type: 'value',
                scale: true,
                axisLine: {//右边Y轴线的颜色以及宽度
                    show: true,
                    lineStyle: {
                        color: "#ffff",
                        width: 2,
                        type: "solid"
                    }
                },
                axisLabel: {
                    show: true,
                    textStyle: {
                        fontSize:14,//右边纵坐标字体大小
                        color: '#fff'
                    }
                },
                splitLine:{
                show:false
              },
                boundaryGap: [0.2, 0.2]
            }
        ],
        series: [ //数据
            {
                name: data.series[0].name, //数据名称
                showBackground: true, 
                label:  //图上的字体颜色,位置,字体大小
                {
                    show: true,
                    position: 'top',
                    fontSize:14,
                    color: '#ffffff'
                },
                barWidth: barwidth, //柱状图宽度
                itemStyle: //柱状图要是渐变
                 {
                    normal: {
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: 'rgba(0, 206, 209, 1)'},
                                {offset: 0.5, color: 'rgba(0, 206, 209, 1)'},
                                {offset: 1, color: 'rgba(51, 187, 255, 0)'}
                            ]
                        ),
                        barBorderRadius: radius  //柱状图圆角
                    }
                },
                type: 'bar', //图类型,柱状图bar,折线图:line
                data: data.series[0].data  //数据
            },
            {
                name: data.series[1].name,
                showBackground: true,
                label: {
                    show: true,
                    position: 'top',
                    fontSize:14,
                    color: '#ffffff'
                },
                barWidth: barwidth,
                itemStyle: {
                    normal: {
                        //柱形图圆角,初始化效果
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: '#88cc66'},
                                {offset: 0.5, color: '#88cc66'},
                                {offset: 1, color: 'rgba(51, 187, 255, 0)'}
                            ]
                        ),
                        barBorderRadius: radius
                    },
                },
                type: 'bar',
                data: data.series[1].data
            },
            {
                name: data.series[2].name,
                type: 'line',
                itemStyle: {color: 'rgba(242, 214, 58, 1)',},
                yAxisIndex: 1,
                smooth: true,
                data: data.series[2].data
            }

        ]
    };

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值