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

相关文章

使用Python和OpenCV库实现实时颜色识别系统

《使用Python和OpenCV库实现实时颜色识别系统》:本文主要介绍使用Python和OpenCV库实现的实时颜色识别系统,这个系统能够通过摄像头捕捉视频流,并在视频中指定区域内识别主要颜色(红... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间详解

OpenCV实现实时颜色检测的示例

《OpenCV实现实时颜色检测的示例》本文主要介绍了OpenCV实现实时颜色检测的示例,通过HSV色彩空间转换和色调范围判断实现红黄绿蓝颜色检测,包含视频捕捉、区域标记、颜色分析等功能,具有一定的参考... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间

苹果macOS 26 Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色

《苹果macOS26Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色》在整体系统设计方面,macOS26采用了全新的玻璃质感视觉风格,应用于Dock栏、应用图标以及桌面小部件等多个界面... 科技媒体 MACRumors 昨日(6 月 13 日)发布博文,报道称在 macOS 26 Tahoe 中

使用Python实现获取屏幕像素颜色值

《使用Python实现获取屏幕像素颜色值》这篇文章主要为大家详细介绍了如何使用Python实现获取屏幕像素颜色值,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 一、一个小工具,按住F10键,颜色值会跟着显示。完整代码import tkinter as tkimport pyau

使用Vue-ECharts实现数据可视化图表功能

《使用Vue-ECharts实现数据可视化图表功能》在前端开发中,经常会遇到需要展示数据可视化的需求,比如柱状图、折线图、饼图等,这类需求不仅要求我们准确地将数据呈现出来,还需要兼顾美观与交互体验,所... 目录前言为什么选择 vue-ECharts?1. 基于 ECharts,功能强大2. 更符合 Vue

python+opencv处理颜色之将目标颜色转换实例代码

《python+opencv处理颜色之将目标颜色转换实例代码》OpenCV是一个的跨平台计算机视觉库,可以运行在Linux、Windows和MacOS操作系统上,:本文主要介绍python+ope... 目录下面是代码+ 效果 + 解释转HSV: 关于颜色总是要转HSV的掩膜再标注总结 目标:将红色的部分滤

利用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 退出编辑模式到命令模式,再输入