zoukankan      html  css  js  c++  java
  • vue中拖放窗口时echarts图表自适应

    1.

    <div id="cityEchart" ref="chart222">
    
            </div>
    

    2. data

    data(){
            return {
                cityEchart: null
            }
        },

    3. methods

    citySortEchar(){
                this.cityEchart = this.$echarts.init(this.$refs.chart222)
                var option = {
                    color: ['linear-gradient(#e66465, #9198e5)'],
                    tooltip : {
                        trigger: 'axis',
                        axisPointer : {            // 坐标轴指示器,坐标轴触发有效
                            type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        top: '16%',
                        containLabel: true
                    },
                    xAxis : [
                        {
                            type : 'category',
                            data : ['浙江', '江苏', '河南', '安徽', '湖北', '云南', '江西'],
                            axisTick: {
                                alignWithLabel: true
                            },
                            axisLine: {
                                show: false,
                                lineStyle: {
                                    color: '#657CA8'
                                }
                            },
                            splitLine: {
                                show: false,//去除网格线
                            },
                            axisLabel: {
                                show: true,
                                interval: 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: 14
                                }
                            },
                        }
                    ],
                    yAxis : [
                        {
                            name: '人数',
                            nameTextStyle: {
                                color: '#fff',
                                fontSize : 14
                            },
                            splitLine: {
                                show: true,//去除网格线
                                lineStyle:{
                                    color: ['rgba(101,124,168,0.55)'],  //网格线颜色
                                     1,
                                    type: 'solid'
                                }
                            },
                            axisLine: {
                                show: false,//不显示坐标轴线
                            },
                            axisLabel: {show: true,interval: 0,textStyle: {color: '#fff',fontSize: 14}},
                            type : 'value'
                        }
                    ],
                    series : [
                        {
                            name:'直接访问',
                            type:'bar',
                            barWidth: '30%',   //柱形宽度
                            itemStyle: {
                                normal: {
                                    color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                        offset: 0,
                                        color: '#52C5FF'
                                    }, {
                                        offset: 1,
                                        color: '#228FFE'
                                    }]),
                                }
                            },
                            data:[5522, 4487, 3700, 3544, 2844, 1944, 1345]
                        }
                    ]
                };
                this.cityEchart.setOption(option);
                window.addEventListener('resize', this.resizeHandler)
            },
            resizeHandler() {
                this.cityEchart.resize()
            },
  • 相关阅读:
    NOIP普及组2003经验总结
    Day6上午 DP练习题
    Day4 图论
    Day3 数据结构
    使用ettercap进行dns欺骗和获取目标浏览的图片
    flask入门
    攻防世界-web-unserialize3
    数据结构课设作业-----飞机订票系统
    bugku NaNNaNNaNNaN-Batman
    it's a test
  • 原文地址:https://www.cnblogs.com/xhrr/p/12029623.html
Copyright © 2011-2022 走看看