echarts数据可视化图表(一):柱状图

echarts数据可视化图表(一):柱状图

效果图:

代码如下:

注意:需引用echarts.js

  <script src="js/4.2.1/echarts.min.js"></script>

html

<div class="box-echarts" id="Echarts05"></div>

css

.box-echarts{
    width:500px;
    height:500px;
}

js

var loadEcharts05 = function (){
        var myChartss = echarts.init(document.getElementById("Echarts05"));
        var option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                },
                formatter: function (params) {
                    return params[0].name + ': ' + params[0].value;
                }
            },
            grid: {
                left: chartsRelativeSize(1, 'r'),
                right: chartsRelativeSize(1, 'r'),
                bottom: chartsRelativeSize(0.5, 'r'),
                top:chartsRelativeSize(1, 'r'),
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    data: ["济宁","泰安","烟台","枣庄","日照","青岛","淄博"],
                    axisLine: {
                        lineStyle: {
                            color: '#363A51'
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    axisLabel: {
                        formatter: '{value}',
                        textStyle: {
                            color: '#fff'
                        },
                        interval: 0
                    }
                }],
            yAxis: [
                {
                    type: 'value',
                    splitLine:{
                        lineStyle:{
                            color:"#363A51"
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#363A51'
                        }
                    },
                    axisTick: {
                        show: false,
                        interval: 2

                    },
                    axisLabel: {

                        textStyle: {
                            color: '#019ABA'
                        },
                        formatter:function(value,index){
                            var r = '';
                            if(value>100000000){//亿
                                r = (value/100000000).toFixed(1) + '亿';
                            }else if(value>10000){//万
                                r = (value/10000).toFixed(1) + '万';
                            }else{
                                r = value;
                            }
                            return r;
                        }
                    }
                }
            ],
            series: [
                {
                    "name": "",
                    type: 'pictorialBar',
                    symbolSize: [30, 16],
                    symbolOffset: [0, -10],
                    symbolPosition: 'end',
                    itemStyle: {
                        normal: {
                            color: function (params) {
                                var colorList = ['#EA5353', '#f27326', '#9DD530', '#38CFCA', '#6C54E2', '#4D86DB', '#DBD64D'];
                                return colorList[params.dataIndex%colorList.length]
                            }
                        }
                    },
                    data: [100,55,58,12,45,48,78]
                },
                {
                    name: '',
                    type: 'pictorialBar',
                    symbolSize: [30, 16],
                    symbolOffset: [0, 5],
                    z: 12,
                    itemStyle: {
                        normal: {
                            color: function (params) {
                                var colorList = ['#EA5353', '#f27326', '#9DD530', '#38CFCA', '#6C54E2', '#4D86DB', '#DBD64D'];
                                return colorList[params.dataIndex%colorList.length]
                            }
                        }
                    },
                    data: [100,55,58,12,45,48,78]
                },
                {
                    type: 'bar',
                    barWidth: "30",
                    itemStyle: {
                        normal: {
                            color: function (params) {
                                var colorList = ['#EA5353', '#f27326', '#9DD530', '#38CFCA', '#6C54E2', '#4D86DB', '#DBD64D'];
                                return colorList[params.dataIndex%colorList.length]
                            },
                            opacity: .7
                        }
                    },
                    data: [100,55,58,12,45,48,78]

                }


            ]
        };
        myChartss.setOption(option);
    };

 

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端互助会

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值