echarts使用总结

#### 柱状图柱子渐变及设置柱子宽度

legend: {

    data: ['使用时长(h)'],

    right:'10%'

},

series: [

    {

        data: [120, 200, 150, 80, 70, 110, 130],

        name:'使用时长(h)',

        type: 'bar',

        barWidth : 40,//柱图宽度

        itemStyle: {

            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [

                { offset: 0, color: '#71ADF2' },

                { offset: 1, color: '#2668C9' }

            ])

        },

    }

]

#### 饼图 文字描述+百分比   文字颜色与模块颜色一致

color:["#70B3F9","#1BBE6D","#FE9B02","#9966E2","#EB4115"],

series: [

    {

        name: 'Access From',

        type: 'pie',

        radius: ['40%', '70%'],

        avoidLabelOverlap: false,

        itemStyle: {

            shadowOffsetX:-3,

            shadowOffsetY:3,

            shadowBlur: 10,

            shadowColor: 'rgba(0, 0, 0, 0.5)'

        },

        emphasis: {

            itemStyle: {

                shadowBlur: 10,

                shadowOffsetX: 0,

                shadowColor: 'rgba(0, 0, 0, 0.5)'

            }

        },

        labelLine:{  

            length: 15, // 第一段线 长度

            length2: 50, // 第二段线 长度

            lineStyle: {

                color: "#666666",  // 指示线颜色

                type:"dashed"

             }

        },

        label: {

            formatter: '{a|{b}}\n{hr|}',

            //折线图文字颜色

            color:"#666666",

            rich: {

                //圆点位置大小配置

                hr: {

                    //auto自定义

                    backgroundColor: "inherit",

                    borderRadius: 6,

                    width: 6,

                    height: 6,

                    padding: [6, 6, 0, -24]

                },

                a: {

                    padding: [-6, 10, -20, 15]

                },

                textStyle:{

                    fontSize:16

                },

            }

        },

        data: [

            { value: 1048, name: 'Search Engine' },

            { value: 735, name: 'Direct' },

            { value: 580, name: 'Email' },

            { value: 484, name: 'Union Ads' },

            { value: 300, name: 'Video Ads' }

        ]

    }

]

#### 堆叠柱图

data: ['一月','二月','三月','四月','五月','六月'],

data: [5,2,4,1,8,2],

data: [1,5,6,3,7,4],

xAxis: {

    data: xAxisData,

    splitLine: {

        show: true,

        lineStyle:{

            color: ['#E7EAEC'],

            width: 1,

            type: 'solid'

        }

    },

},

series: [

    {

        name: 'bar',

        type: 'bar',

        stack: 'one',

        emphasis: emphasisStyle,

        data: data1,

        barWidth : 40,//柱图宽度

        itemStyle: {

            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [

                { offset: 0, color: '#71ADF2' },

                { offset: 1, color: '#2668C9' }

            ])

        },

    },

    {

        name: 'bar2',

        type: 'bar',

        stack: 'one',

        emphasis: emphasisStyle,

        data: data2,

        itemStyle: {

            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [

                { offset: 0, color: '#FE9B02' },

                { offset: 1, color: '#F2BF71' }

            ])

        },

    }

]

#### 折线拐点

tooltip: {

    trigger: 'axis'

},

grid: {

    left: '3%',

    right: '4%',

    bottom: '3%',

    containLabel: true

},

color:["#2C8BF0","#FE9B02"],

series: [

    {

        name: 'Email',

        type: 'line',

        smooth: true,

        data: [120, 132, 101, 134, 90, 120, 65],

        symbol:'circle',

        showSymbol: false,

        symbolSize:16,   //拐点圆的大小

        lineStyle: {

            color: '#2C8BF0',

            width: 4,

            shadowColor: 'rgba(44, 139, 240, .5)',//设置折线阴影

            shadowBlur: 10,

            shadowOffsetY: 10,

        },

        emphasis: {

            // 鼠标hover上去的时候,拐点的颜色和样式

            itemStyle: {

                color: '#2C8BF0', //颜色

                width:10,

                height:10,

                borderColor: '#D2F6FC', //图形的描边颜色

                borderWidth: 2, // 描边的线宽

                shadowBlur: 5, // 图形的阴影大小

                shadowColor: '#E7FCFF', // 图形的阴影颜色

            },

        },

    },

    {

        name: 'Union Ads',

        type: 'line',

        smooth: true,

        data: [130, 120, 134, 101, 120, 65, 120],

        symbol:'circle',

        showSymbol: false,

        symbolSize:16,   //拐点圆的大小

        lineStyle: {

            color: '#FE9B02',

            width: 4,

            shadowColor: 'rgba(254, 155, 2, .5)',//设置折线阴影

            shadowBlur: 10,

            shadowOffsetY: 10,

        },

        emphasis: {

            // 鼠标hover上去的时候,拐点的颜色和样式

            itemStyle: {

                color: '#FE9B02', //颜色

                width:5,

                height:5,

                borderColor: '#FED2B1', //图形的描边颜色

                borderWidth: 2, // 描边的线宽

                shadowBlur: 10, // 图形的阴影大小

                shadowColor: '#FFE5D2', // 图形的阴影颜色

            },

        },

    }

]

//坐标轴颜色

axisLine:{

    lineStyle:{

        color:'red'

    }

},

//x轴文字旋转

axisLabel:{

    rotate:30,

    interval:0

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Echarts是一个优秀的数据可视化库,可以帮助开发者快速构建各种图表和数据展示的界面。在使用Echarts时,我们通常会用到v-show这个指令来控制图表的显示和隐藏。 v-show是Vue.js框架中的一个指令,用于根据表达式的值来控制DOM元素的显示和隐藏。当表达式的值为真时,DOM元素会显示出来;当表达式的值为假时,DOM元素会隐藏起来。 在使用Echarts时,可以将图表所在的DOM元素与v-show指令结合使用,通过改变表达式的值来控制图表的显示和隐藏。 例如,假设有一个按钮来控制图表的显示和隐藏,通过点击按钮可以改变一个布尔类型的变量showChart的值。通过在图表所在的DOM元素上添加v-show指令,设置表达式为showChart,就可以实现根据showChart变量的值来显示或隐藏图表。 ``` <template> <div> <button @click="toggleChart">点击切换图表显示</button> <div v-show="showChart" id="chart"></div> </div> </template> <script> export default { data() { return { showChart: true, // 其他图表相关的配置 } }, methods: { toggleChart() { this.showChart = !this.showChart; }, // 其他方法和事件处理逻辑 }, mounted() { // 初始化Echarts图表 const chart = echarts.init(document.getElementById('chart')); // 图表的相关配置和数据处理逻辑 // ... } } </script> ``` 通过上述代码,可以实现点击按钮切换图表的显示和隐藏效果。当showChart变量为真时,图表会显示出来;当showChart变量为假时,图表会隐藏起来。 总结来说,使用v-show可以方便地控制Echarts图表的显示和隐藏,提升了页面的交互性和用户体验。同时,结合Vue.js框架的特性,可以更加灵活地处理图表的显示和隐藏逻辑。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值