个人博客 个人博客
首页
  • 前端
  • 后端
  • Git
  • Docker
  • 网络
  • 操作系统
工具
阅读
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

董先亮

前端react开发
首页
  • 前端
  • 后端
  • Git
  • Docker
  • 网络
  • 操作系统
工具
阅读
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 常用配置
    • title 标题
    • legend 图例
    • grid 网格
      • tooltip 提示框
    • xAxis x轴
      • 常见问题
    • yAxis y轴
    • backgroundColor 背景色
    • color 调色盘列表
    • angleAxis 极坐标角度轴(x轴)
    • radiusAxis 极坐标径向轴(y轴)
  • 图表
  • 底层分析
  • Echarts
NeverStop1024
2022-09-14
目录

常用配置

# title (opens new window) 标题

  • show (opens new window) 是否显示
  • text (opens new window) 主标题
  • textStyle (opens new window) 主标题文字样式(宽高、行高、大小、粗细、阴影、超出处理、省略号、阴影等)
  • subtext (opens new window) 副标题(拥有与主标题相同的配置)
  • left、right、top、bottom (opens new window) 在容器中的位置
  • padding (opens new window) 内边距
  • 整体背景、边框、阴影 (opens new window)
  • target (opens new window) 超链接
  • z (opens new window) z值(类似与z-index)

# legend (opens new window) 图例

  • show (opens new window) 图例是否显示
  • itemGap (opens new window) 每项图例的间隔
  • icon (opens new window) 图例图标(圆形、长方形、三角形、菱形、箭头等等),也可以自定义
  • textStyle (opens new window) 图例文字样式配置(与标题配置相同)
  • itemWidth、itemHeight (opens new window) 图例的宽高(只是图例的小方块,不包含文字)
  • left、right、top、bottom (opens new window) 在容器中的位置
  • width、height (opens new window) 图例整个盒子的宽高
  • orient (opens new window) 图例布局(横向、纵向)
  • data (opens new window) 图例的配置数组(可对每个图例进行针对性配置)
  • backgroundColor (opens new window) 图例盒子的背景色
  • borderColor、borderWidth、borderRadius (opens new window) 图例盒子的边框、粗细、圆角半径
  • type (opens new window) 图例类型(展示不开,是否支持滚动)
    • scrollDataIndex (opens new window) 显示的第一个图例
    • pageButtonItemGap (opens new window) 分页按钮与中间分页文字的距离
    • pageButtonGap (opens new window) 分页按钮离图例的距离
    • pageButtonPosition (opens new window) 分页按钮位置(前面、后面)
    • pageFormatter (opens new window) 分页信息格式化(默认格式:当前页/总页数)
    • pageIcons (opens new window) 分页按钮图标(可更换左右切换按钮)
    • pageIconColor (opens new window) 分页按钮可点击时的颜色
    • pageIconInactiveColor (opens new window) 分页按钮不可点击时的颜色
    • pageIconSize (opens new window) 分页按钮大小(可配置宽高)
    • pageTextStyle (opens new window) 分页信息的文字样式(与标题配置项相同)
    • animation、animationDurationUpdate (opens new window) 翻页是否有动画、动画时长
  • z (opens new window) z值(类似与z-index)
  • align (opens new window) 图例中文字位置(文字在左边图例在右边、文字在右边图例在左边)
  • padding (opens new window) 图例盒子的内边距
  • selectedMode (opens new window) 是否可以点击图例控制显示隐藏
  • inactiveColor (opens new window) 图例关闭时的颜色
  • selected (opens new window) 当前选中图例的列表
  • tooltip (opens new window) 图例提示(图例文字很长时可以做裁剪,然后用上这个提示,做个鼠标悬停提示)
  • shadowBlur、shadowColor等 (opens new window) 图例盒子阴影相关配置
  • selector (opens new window) 选择器(全选、反选)与选择器相关配置

# grid (opens new window) 网格

图表是在直角坐标系中进行绘制,grid也就是对坐标系进行配置,更改绘图区域的位置、大小等
echarts3后,一个echart对象可以存在多个grid了,也就是说一个echart对象可以放多个图表

  • show (opens new window) 是否显示坐标系网格
  • left、right、top、bottom (opens new window) 直角坐标系在容器中的位置,也代表着图表的大小
  • width、height (opens new window) 直角坐标系的宽高
  • backgroundColor、borderColor、shadowBlur (opens new window) 坐标系背景、边框、阴影相关配置

# tooltip (opens new window) 提示框

  • show (opens new window) 是否展示提示框

# xAxis x轴

直角坐标系 grid 中的 x 轴相关配置,一个grid组件一般只能放两个x轴

  • show (opens new window) 是否显示x轴
  • type (opens new window) 坐标轴类型(数值轴、类目轴、时间轴等)
  • offset (opens new window) x轴与grid网格的间距
  • name (opens new window) x轴名称
  • nameLocation (opens new window) x轴名称显示位置(比如x轴名称是"时间","时间"的显示位置)
  • nameTextStyle (opens new window) x轴名称的文字样式(同标题配置)
  • nameGap (opens new window) x轴名称与轴线的距离
  • nameRotate (opens new window) 轴名称旋转角度
  • min、max (opens new window) x轴最小、最大值
  • data (opens new window) 对x轴每个刻度(类目)进行单独设置
  • axisLine (opens new window) 轴线相关配置
    • show (opens new window) 是否显示轴线
    • lineStyle (opens new window) 轴线样式
    • 其他轴线配置 (opens new window)
  • axisTick (opens new window) 轴线刻度相关配置
  • axisLabel (opens new window) 坐标轴标签相关配置
  • splitLine (opens new window) x轴在grid中的分割线(是否显示、分割线的样式)
  • splitNumber (opens new window) 分割段数
  • minInterval、maxInterval (opens new window) x轴自动计算最小、最大间隔
  • interval (opens new window) 强制设置x轴间隔
  • boundaryGap (opens new window) x轴两侧留白配置
  • inverse (opens new window) 是否为反向坐标轴
  • position (opens new window) x轴位置(上方、下方),默认下方
  • gridIndex (opens new window) grid索引,默认第一个
    • 如果一个echart实例中有多个图表,这个属性才有用

# 常见问题

  • 使用Echarts时,X轴文本太长的解决方案 (opens new window)

# yAxis y轴

同x轴配置相同

# backgroundColor (opens new window) 背景色

echarts实例背景色

# color (opens new window) 调色盘列表

echarts中所有color属性,都能用该属性提供的渐变或纹理方案

# angleAxis (opens new window) 极坐标角度轴(x轴)

用来做玫瑰图

  • axisLine (opens new window) 轴线相关配置

# radiusAxis (opens new window) 极坐标径向轴(y轴)

编辑 (opens new window)
上次更新: 2022/09/19
图表

图表→

最近更新
01
mock使用
07-12
02
websocket即时通讯
07-12
03
前端面试题
07-09
更多文章>
Theme by Vdoing | Copyright © 2022-2023 NeverStop1024 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式