echarts初始化仪表盘(gauge)
注意:series的属性可以进一次抽离,例子中是没有抽离的,所以重复属性较多
完整代码
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><style>#main {width: 600px;height: 400px;background-color: #fff;margin: 0 auto;}</style>
</head><body><div id="main"></div><script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.3.1/echarts.min.js"></script><script>let data = {actual: 1000,expected: 500,target: 300}initGaugeChart()function initGaugeChart() {let myChart = echarts.init(document.getElementById('main'))let option = {title: {text: '我是一个title',left: 'center',bottom: 35},legend: {icon: 'roundRect',data: ['实际业绩', '预期业绩', '目标业绩'],bottom: 0,itemWidth: 19,itemHeight: 7,textStyle: {color: '#707070',fontSize: 12}},series: [{name: '实际业绩',type: 'gauge',detail: {formatter: '金额:万元',show: true,fontSize: 10,color: 'rgba(148, 148, 148, 1)',offsetCenter: ['0', '45%']},data: [{value: data.actual}],// 注意:仪表盘的最大值应该是取数据 data中最大的那个值// 不然可能会出现层级显示问题// 同时注意:max是又一个最大值的max: 6000,itemStyle: {color: new echarts.graphic.LinearGradient(0,0,1,0,[{offset: 0,color: '#61BCE2'},{offset: 0.8,color: '#3F7AF3'}],false)},endAngle: 0,startAngle: 180,axisLabel: {show: true,distance: -50,color: '#676767',fontSize: '12px'/*使用formatter 函数修改max显示的最大值formatter: (e) => {return e >= 50000 ? Math.ceil(e / 10000) + '万' : e}*/},axisTick: {show: false},splitLine: {show: false},progress: {show: true,roundCap: true,width: 15,itemStyle: {color: new echarts.graphic.LinearGradient(0,0,0,1,[{offset: 0,color: '#61BCE2'},{offset: 0.8,color: '#3F7AF3'}],false)}},axisLine: {show: true,roundCap: true,lineStyle: {width: 15}},pointer: {show: true,width: 3,length: 35,itemStyle: {color: '#3F7AF3'}},anchor: {show: true,showAbove: true,size: 18,itemStyle: {color: '#9C6BFF'}}},{name: '预期业绩',type: 'gauge',detail: {formatter: '金额:万元',show: true,fontSize: 10,color: 'rgba(148, 148, 148, 1)',offsetCenter: ['0', '45%']},data: [{value: data.expected}],max: 6000,itemStyle: {color: new echarts.graphic.LinearGradient(0,0,1,0,[{offset: 0,color: '#986EEB'},{offset: 0.8,color: '#7256ED'}],false)},endAngle: 0,startAngle: 180,axisLabel: {show: true,distance: -50,color: '#676767',fontSize: '12px'},axisTick: {show: false},splitLine: {show: false},progress: {show: true,roundCap: true,width: 15,itemStyle: {color: new echarts.graphic.LinearGradient(0,0,0,1,[{offset: 0,color: '#986EEB'},{offset: 0.8,color: '#7256ED'}],false)}},pointer: {show: true,width: 3,length: 65,itemStyle: {color: '#7256ED'}},axisLine: {show: true,roundCap: true,lineStyle: {width: 15}}},{name: '目标业绩',type: 'gauge',data: [{value: data.target}],max: 6000,itemStyle: {color: new echarts.graphic.LinearGradient(0,0,1,0,[{offset: 0,color: '#F563AA'},{offset: 0.8,color: '#F1357A'}],false)},detail: {formatter: '金额:万元',show: true,fontSize: 10,color: 'rgba(148, 148, 148, 1)',offsetCenter: ['0', '45%']},endAngle: 0,startAngle: 180,axisLabel: {show: true,distance: -50,color: '#676767',fontSize: '12px'},axisTick: {show: false},splitLine: {show: false},pointer: {show: true,width: 3,length: 34,itemStyle: {color: '#F23A7F'}},progress: {show: true,roundCap: true,width: 15,itemStyle: {color: new echarts.graphic.LinearGradient(0,0,0,1,[{offset: 0,color: '#F563AA'},{offset: 0.8,color: '#F1357A'}],false)}}}]}option && myChart.setOption(option)}</script>
</body></html>
echarts初始化仪表盘(gauge)相关推荐
- 汽车 配件 html 特效,html5 echarts汽车仪表盘图表动画特效
特效描述:html5 echarts 汽车仪表盘 图表动画特效,html5汽车仪表盘,第一次从使用echarts,如何调用js,CSS,测试 代码结构 1. 引入JS 2. HTML代码 // 基于准 ...
- Echarts 多仪表盘(汽车仪表盘,动态刷新)
Echarts 多仪表盘 echarts 作业三 一.任务需求 实现一个汽车仪表盘,需包含四个仪表盘. 二.使用步骤 代码如下(示例): <!DOCTYPE html> <html ...
- echarts初始化中国地图(Map)
echarts初始化中国地图 vue 中可以直接使用,修改文件地址即可 更多echarts例子 1.http://www.ppchart.com/#/ 2.https://www.isqqw.com/ ...
- Echarts关于仪表盘
闲来无事,制作不一样的图标一发,领导让把仪表盘做成百分条,我TM也是醉了,大体样式如下图:(图标是没2秒变化的) <div id="main" style="wid ...
- Echarts分段仪表盘
一.代码简介 本次主要是在Vue web项目中,利用Echarts实现一个多段的仪表盘. 二.功能预览 三.示例代码 <template><div id="echartsG ...
- echarts 设置仪表盘数字的位置_一个 ECharts 做的猜数小游戏
大概 1 年多之前,一位老同学找到我,问能不能帮他做一个非常简单的猜数字游戏,需求是这样的: 在 1 到 100 的整数里,随机选一个数字,让小朋友们猜: 如果猜错了,告知小朋友猜大了还是猜小了: 如 ...
- vue+echarts实现仪表盘
API文档:请点击 仪表盘实例地址:请点击 目标样式: 实现代码: //html部分 <div id="dashboardHumidity" style="widt ...
- echarts扇形仪表盘
效果展示 options代码 {series: [{type: "gauge",max: 20,splitNumber: 16,axisLine: {lineStyle: {wid ...
- echarts 节点(gauge)图的使用
1.导入 import * as echarts from "echarts"; 使用 var myChart = echarts.init(document.getElement ...
最新文章
- 妙用postman系列——postman建组、分享
- 字符串还可以这样初始化--uboot篇
- 增量学习不只有finetune,三星AI提增量式少样本目标检测算法 | CVPR 2020
- 前谷歌工程团队负责人:如何打造一个完美的产品
- 2019-11-23 Modern Family Scripts (01 “Pilot”)
- 为什么越来越多的程序员开始学机器学习?揭秘一个重要原因
- 一位跨平台开发者的自白
- 解决maven dependencies xxx not found
- java读文件指定行开始到文件的最后
- python语言中print函数的作用_python中print()方法有什么
- Django的url别名功能的使用
- 【图像去噪】基于matlab GUI中值滤波图像去噪【含Matlab源码 205期】
- MySQL 入门(十)—— 数据操作
- Java开发常用技术栈
- (专升本)信息安全(计算机病毒)
- poi-tl根据word模板导出word、使用spring-thymeleaf模板生成html并通过docx4j把html转word,使用jxls根据excel模板导出excel(1)
- SAP 采购订单关单
- scheduled一分钟执行一次_Spring中使用@Scheduled创建定时任务
- 二维三维四维vector乃至多维vector数组的建立
- Linux Cobbler批量装机
热门文章
- c-plus day2
- git分支合并之Fast-forword(快进方式)原理剖析
- [导入]古装武侠剧《神农碧血刀》全20集
- 嵌入式软件自动化测试介绍
- 数字IC设计的前端设计和后端设计流程
- liunx php7.0 mysql_Centos7.0以上安装nginx+php7.0+mysql5.7+redis3作为开发php环境
- js享元模式设计原理以及应用案例
- Java实现干支纪年法
- nowcoder contest#115 江西财经大学第一届程序设计竞赛 C 今晚吃鸡
- 基于java+swing+mysql员工工资管理系统