eCharts-柱状图(横置) 配置说明

// 实例化eChart图表
function initEchart( idName, option ) {
    var myEchart = echarts.init( document.getElementById( idName ) );

    myEchart.setOption( option );
}

// 随机数生成
function randomNum( digitNumber, holdNumber ) {
    var random = Math.random();
    random = Math.pow( 10, digitNumber ) * random;
    random = random.toFixed(holdNumber);

    return random;
}
var option = {
        title: {
            text: "XX市历年空气质量优良天数比例",
            subtext: "",
            x: '16',
            textStyle: {
                fontWeight: 'normal'
            }
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#6a7985'
                }
            }
        },
        toolbox: {
            orient: 'horizontal',
            feature: {
                magicType: {
                    type: ['line', 'bar']
                },
                restore: {show: true},
                saveAsImage: {show: true}
            },
            bottom: 15,
            right: 20
        },
        grid: {     // 上下左右边距
            top: "20%",
            bottom: "10%",
            left: "8%",
            right: "3%",
            containLabel: true
        },
        xAxis: [{
            type: 'value',
            name: '',
            nameTextStyle: {
                color: '#6d9269'
            },
            position: 'top',
            max: 100,
            boundaryGap: [0, 0.01],
            axisTick: {
                show: false,
                alignWithLabel: false
            },
            axisLine: {
                show: false
            },
            splitLine: {
                show: false
            }
        }],
        yAxis: [{
            type: 'category',
            name: "年份",
            nameTextStyle: {
                color: '#6d9269'
            },
            nameGap: 30,
            data: ["2012", "2013", "2014", "2015", "2016", "2017"],     // Y轴分布类型
            splitLine: {
                show: false
            },
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLabel: {
                textStyle: {}
            }
        }],
        series: [{
            name: "优良天数",
            type: "bar",
            stack: 'chart',
            data: data,     // X轴对应类型的数值
            itemStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(
                            0, 0, 1, 0,
                            [
                                {offset: 0, color: '#a8e8a1'},
                                {offset: 1, color: '#65c95b'}
                            ]
                    )
                }
            }
        }, {
            type: 'bar',
            stack: 'chart',
            silent: true,
            itemStyle: {
                normal: {
                    color: '#f5f5f5'
                }
            },
            data: reverseData
        }]
    }
var echartId = 'lineChart-01';
initEchart(echartId, option);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值