当前位置: 首页 > news >正文

echarts图表基本使用

折线图

import * as echarts from 'echarts';const chartDom = document.getElementById('main');
const myChart = echarts.init(chartDom);
const option = {xAxis: {type: 'category',data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']},yAxis: {type: 'value'},series: [{data: [820, 932, 901, 934, 1290, 1330, 1320],type: 'line',smooth: true}]
};option && myChart.setOption(option);

折线图样式设置

在这里插入图片描述

饼图

import * as echarts from 'echarts';const chartDom = document.getElementById('main');
const myChart = echarts.init(chartDom);
const option = {tooltip: {trigger: 'item'},legend: {top: '5%',left: 'center'},series: [{name: 'Access From',type: 'pie',radius: ['40%', '70%'],avoidLabelOverlap: false,itemStyle: {borderRadius: 10,borderColor: '#fff',borderWidth: 2},// label: {//   show: false,//   position: 'center'// },emphasis: {label: {show: true// fontSize: 40,// fontWeight: 'bold'}},labelLine: {show: true},data: [{ value: 1048, name: 'Search Engine' },{ value: 735, name: 'Direct' },{ value: 580, name: 'Email' },{ value: 484, name: 'Union Ads' },{ value: 300, name: 'Video Ads' }]}]
};option && myChart.setOption(option);

饼图样式设置

在这里插入图片描述

标题设置 title:{ text: '男生', left:'center', bottom:'80', },

当有多个饼图时,可通过在series列表中添加center: ['50%','50%']改变饼图位置

柱状图

import * as echarts from 'echarts';var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;option = {grid: {show: true},tooltip: {show: true},xAxis: {type: 'category',data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],axisLine: {lineStyle: {type: 'dashed'}}},yAxis: {type: 'value',splitLine: {lineStyle: {type: 'dashed'}}},series: [{data: [120, 200, 150, 80, 70, 110, 130],type: 'bar',itemStyle: {color: {x: 0,y: 0,x2: 0,y2: 1,colorStops: [{ offset: 0, color: '#4DD9A7' },{ offset: 0.5, color: '#80E4C0' },{ offset: 1, color: '#B6F1DD' }],global: false}}},{data: [120, 200, 150, 80, 70, 110, 130],type: 'bar',itemStyle: {color: {x: 0,y: 0,x2: 0,y2: 1,colorStops: [{ offset: 0, color: '#5EADF3' },{ offset: 0.5, color: '#98CAF6' },{ offset: 1, color: '#C4E0F9' }]}}}]
};option && myChart.setOption(option);

柱状图样式设置

在这里插入图片描述

http://www.lryc.cn/news/106274.html

相关文章:

  • 排序进行曲-v1.0
  • 算法入门篇——用位运算解决一些问题
  • 腾讯云-宝塔添加MySQL数据库
  • 【雕爷学编程】MicroPython动手做(27)——物联网之掌控板小程序
  • Mysql删除重复数据通用SQL
  • “快速入门Spring Boot:从零开始构建Web应用程序“
  • 微信小程序tab加列表demo
  • 深入挖掘地核和地幔之间的相互作用
  • 网络:SecureCRT介绍
  • 我的512天创作纪念日
  • mysql进阶-用户密码的设置和管理
  • 2023年最新智能优化算法之——切诺贝利灾难优化器 (CDO),附MATLAB代码和文献
  • uniapp跨域解决
  • 力扣-94、144、145-前中后序遍历
  • 什么是线程?为什么需要线程?和进程的区别?
  • 【业务功能篇61】SpringBoot项目流水线 dependencyManagement 标签整改依赖包版本漏洞问题
  • uniapp使用getStorage对属性赋值无效
  • 20230802-下载并安装android-studio
  • python 第九章 —— GUI界面开发(tkinter详解)
  • 线段树合并例题
  • Stable Diffusion 硬核生存指南:WebUI 中的 VAE
  • vue项目 前端加前缀(包括页面及静态资源)
  • 使用文心一言等智能工具指数级提升嵌入式/物联网(M5Atom/ESP32)和机器人操作系统(ROS1/ROS2)学习研究和开发效率
  • 【Rust 基础篇】Rust动态大小类型:理解动态大小类型与编写安全的代码
  • 【Python】使用nuitka打包Python程序为EXE可执行程序
  • 背景图片及精灵图
  • 简要介绍 | 生成模型的演进:从自编码器(AE)到变分自编码器(VAE)和生成对抗网络(GAN),再到扩散模型
  • 8.2Thread类的常见属性
  • 博客摘录「 mvvm框架工作原理及优缺」2023年7月31日
  • 第12章 Linux 实操篇-Linux磁盘分区、挂载