Echarts柱状图 - 柱形颜色渐变

2024-01-16 12:04

本文主要是介绍Echarts柱状图 - 柱形颜色渐变,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在这里插入图片描述
在这里插入图片描述

<!-- 违法 -->
<template><div class="section"><div class="grid_body_top"><div v-for="(item, index) in topList" v-show="item.isShow" :key="index"><i :class="['icon', ...item.iconClass]" /><span class="text">{{ item.text }}</span><span :class="['count', item.textClass]">{{$common.countFormat(infoData[item.key] || 0)}}</span></div></div><div id="EchartsDom" /></div>
</template><script>
export default {name: 'Illegal',components: {},props: {select: {type: String,required: true},infoData: {type: Object,required: true},dataList: {type: Array,// required: truedefault: () => {return [{ value: 10, name: '测试1', pre: '10' },{ value: 20, name: '测试2', pre: '10' },{ value: 5, name: '测试3', pre: '10' },{ value: 20, name: '到三斯', pre: '10' },{ value: 14, name: '测试5', pre: '10' },{ value: 8, name: '测试6', pre: '10' },{ value: 10, name: '测试7', pre: '10' }]}}},data() {return {Echarts: null}},computed: {topList() {return [{text: '执法量',key: 'zfzl',iconClass: ['iconfont', 'ico-police', 'cyan'],textClass: 'white',isShow: this.select === 'jycx'},{text: '缴款量',key: 'yjksl',iconClass: ['iconfont', 'ico-qianbao', 'orange'],textClass: 'orange',isShow: this.select === 'jycx'},{text: '案件量',key: 'zfzl',iconClass: ['iconfont', 'ico-case', 'cyan'],textClass: 'white',isShow: this.select === 'ybcx'},{text: '已裁决',key: 'ycjzl',iconClass: ['icon_blue'],textClass: 'blue',isShow: this.select === 'ybcx'},{text: '未裁决',key: 'wcjzl',iconClass: ['icon_cyan'],textClass: 'cyan',isShow: this.select === 'ybcx'}]},options() {return {title: {show: !this.dataList.length,text: '暂无数据',left: 'center',top: 'center',textStyle: {color: '#fff'}},grid: {top: 10,left: 20,right: 20,bottom: 5,containLabel: true// show: false,},tooltip: {trigger: 'axis',axisPointer: {// type: 'shadow'}// formatter: (params) => {//   const currentData = params[0]//   const index = params[0].dataIndex//   return `${currentData.name}<br>排名:${this.dataList[index].pm}<br>环比:${this.dataList[index].hb}`// }},xAxis: {axisLine: {show: false},axisTick: {show: false},axisLabel: {color: '#5ED7FF'},splitLine: {show: true, // X轴内容区域显示分隔线lineStyle: {type: 'dashed', // 分割线类型为虚线color: '#409EFF' // 分割线颜色}},minInterval: 1 // 坐标轴最小间隔},yAxis: {axisTick: {show: false},axisLine: {// show: true,show: !!this.dataList.length, // 根据数据判断是否展示Y轴轴线(如果只设置为true没有数据时该线依然在)lineStyle: {color: '#409EFF'}},axisLabel: {color: '#5ED7FF'},data: this.dataList.map((item) => item.name)},// dataZoom: [ // 滚动鼠标滚轮进行缩放 https://echarts.apache.org/zh/option.html#dataZoom-inside.type//   {//     type: 'inside'//   }// ],series: [{name: '已裁决',type: 'bar',barMaxWidth: 30, // 柱条最大宽度itemStyle: {// 柱形颜色color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [{ offset: 0, color: '#236CDC' },{ offset: 1, color: '#409EFF' }]),// 柱形边框borderRadius: [0, 100, 100, 0]},emphasis: {itemStyle: {// 鼠标移入柱形颜色color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [{ offset: 1, color: '#236CDC' },{ offset: 0, color: '#409EFF' }])}},data: this.dataList.map((item) => item.value)},{name: '未裁决',type: 'bar',barMaxWidth: 30, // 柱条最大宽度itemStyle: {// 柱形颜色color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [{ offset: 0, color: '#0096C5' },{ offset: 1, color: '#00EDFF' }]),// 柱形边框borderRadius: [0, 100, 100, 0]},emphasis: {itemStyle: {// 鼠标移入柱形颜色color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [{ offset: 1, color: '#0096C5' },{ offset: 0, color: '#00EDFF' }])}},data: this.dataList.map((item) => item.value + 10)}]}}},watch: {dataList() {this.init()}},mounted() {window.addEventListener('resize', () => {if (document.getElementById('EchartsDom')) {this.Echarts = this.$echarts.init(document.getElementById('EchartsDom'))this.Echarts.resize()}})this.init()},created() {},methods: {init() {if (this.Echarts) {this.Echarts.dispose()}this.Echarts = this.$echarts.init(document.getElementById('EchartsDom'))this.Echarts.setOption(this.options)}}
}
</script><style lang='scss' scoped>
.section {height: 100%;overflow: hidden;#EchartsDom {height: calc(100% - 52px);// background-color: #fff;}
}
</style>

这篇关于Echarts柱状图 - 柱形颜色渐变的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/612539

相关文章

利用matlab bar函数绘制较为复杂的柱状图,并在图中进行适当标注

示例代码和结果如下:小疑问:如何自动选择合适的坐标位置对柱状图的数值大小进行标注?😂 clear; close all;x = 1:3;aa=[28.6321521955954 26.2453660695847 21.69102348512086.93747104431360 6.25442246899816 3.342835958564245.51365061796319 4.87

渐变颜色填充

GradientFill函数可以对特定的矩形区域或者三角形区域进行渐变颜色的填充。我们先来看看GradientFill函数到底长得什么样子,帅不帅。 [cpp]  view plain copy print ? BOOL GradientFill(     _In_  HDC hdc,     _In_  PTRIVERTEX pVertex,     _In_  ULONG

使用matplotlib绘制散点图、柱状图和饼状图-学习篇

一、散点图 Python代码如下: num_points = 100x = np.random.rand(num_points) #x点位随机y = np.random.rand(num_points) #y点位随机colors = np.random.rand(num_points) #颜色随机sizes = 1000 * np.random.rand(num_points) # 大

【虚拟机/服务器】非图形化界面下修改Shell中颜色的设置

1、首先 cd ~ && ll 可以看到如下图所示 2、输入 sudo vim .bashrc 进入 .bashrc 并通过 /PS1 迅速从上往下定位第一个PS1 3、输入 i 进入插入模式后修改 else 下面的配置如下 说明:\e[1;32;40m] 其中1表示高亮显示,32表示字体颜色是绿色,40表示背景色为黑色 4、输入 esc 退出编辑模式到命令模式,再输入

C#中的各种画刷, PathGradientBrush、线性渐变(LinearGradientBrush)和径向渐变的区别

在C#中,画刷(Brush)是用来填充图形(如形状或文本)内部区域的对象。在.NET框架中,画刷是System.Drawing命名空间的一部分,通常用于GDI+绘图操作。以下是一些常用的画刷类型: SolidBrush:用于创建单色填充的画刷。HatchBrush:用于创建具有图案填充的画刷。TextureBrush:用于创建具有图像纹理填充的画刷。LinearGradientBrush:用于创

Excel查询颜色RGB值

1.选中单元格,点右键,设置单元格格式-填充-其他颜色-自定义,下面显示的就是该单元格颜色的RGB值 2.与十六进制换算: https://www.sioe.cn/yingyong/yanse-rgb-16/

Echarts使用笔记--饼图,柱状图

开始做前端了,感觉自己是要变成全栈工程师了。。。 今天使用了echart,用之前觉得好高大上好厉害,肯定很复杂。用了以后才发现,使用起来超简单,当然,精通很难,里面的各种配置太多了,本文记录一下自己用到的东西。 echart使用 现在直接引用js文件就可以了 <script src="echarts.min.js"></script> echart组件需要在一个宽高固定的DOM里才能显示

【python web】Flask+Echarts 实现动图图表

flask 是python web开发的微框架,Echarts酷炫的功能主要是javascript起作用,将两者结合起来,发挥的作用更大。下面将Echarts嵌套进Flask的html模板中。 项目结构: 打开demo.py运行,点击console中的链接http://127.0.0.1:5000/ 就可以看到我们想要的动态图表。 demo.py #coding:utf-8fro