echart常用图表配置

2023-11-17

柱状图

3D柱状图

效果

在这里插入图片描述

代码

import { graphic } from 'echarts'

const VALUE = Array.from({ length: 24 }, () => Math.floor(Math.random() * (5000 - 1000)) + 1000)

const CubeLeft = graphic.extendShape({
  shape: {
    x: 0,
    y: 0
  },
  buildPath: function (ctx, shape) {
    const xAxisPoint = shape.xAxisPoint
    const c0 = [shape.x, shape.y]
    const c1 = [shape.x - 9, shape.y - 9]
    const c2 = [xAxisPoint[0] - 9, xAxisPoint[1] - 9]
    const c3 = [xAxisPoint[0], xAxisPoint[1]]
    ctx
      .moveTo(c0[0], c0[1])
      .lineTo(c1[0], c1[1])
      .lineTo(c2[0], c2[1])
      .lineTo(c3[0], c3[1])
      .closePath()
  }
})
const CubeRight = graphic.extendShape({
  shape: {
    x: 0,
    y: 0
  },
  buildPath: function (ctx, shape) {
    const xAxisPoint = shape.xAxisPoint
    const c1 = [shape.x, shape.y]
    const c2 = [xAxisPoint[0], xAxisPoint[1]]
    const c3 = [xAxisPoint[0] + 18, xAxisPoint[1] - 9]
    const c4 = [shape.x + 18, shape.y - 9]
    ctx
      .moveTo(c1[0], c1[1])
      .lineTo(c2[0], c2[1])
      .lineTo(c3[0], c3[1])
      .lineTo(c4[0], c4[1])
      .closePath()
  }
})
const CubeTop = graphic.extendShape({
  shape: {
    x: 0,
    y: 0
  },
  buildPath: function (ctx, shape) {
    const c1 = [shape.x, shape.y]
    const c2 = [shape.x + 18, shape.y - 9]
    const c3 = [shape.x + 9, shape.y - 18]
    const c4 = [shape.x - 9, shape.y - 9]
    ctx
      .moveTo(c1[0], c1[1])
      .lineTo(c2[0], c2[1])
      .lineTo(c3[0], c3[1])
      .lineTo(c4[0], c4[1])
      .closePath()
  }
})
graphic.registerShape('CubeLeft', CubeLeft)
graphic.registerShape('CubeRight', CubeRight)
graphic.registerShape('CubeTop', CubeTop)
const option = {
  backgroundColor: '#010d3a',
  title: {
    left: 'center',
    text: '数量统计',
    textStyle: {
      color: '#A2D4E6',
      fontSize: 14
    }
  },
  grid: {
    left: 20,
    right: 40,
    bottom: '19%',
    containLabel: true
  },
  xAxis: {
    name: '时间',
    type: 'category',
    data: Array.from(new Array(23 + 1).keys()).slice(0),
    axisLine: {
      show: true,
      lineStyle: {
        color: '#3eb2e8'
      }
    },
    offset: 20,
    axisTick: {
      show: false,
      length: 9,
      alignWithLabel: true,
      lineStyle: {
        color: '#7DFFFD'
      }
    },
    axisLabel: {
      fontSize: 10
    }
  },
  yAxis: {
    name: '数量',
    type: 'value',
    axisLine: {
      show: true,
      lineStyle: {
        color: '#3eb2e8'
      }
    },
    splitLine: {
      lineStyle: {
        color: '#4784e8'
      }
    },
    axisTick: {
      show: false
    },
    axisLabel: {
      fontSize: 16
    },
    boundaryGap: ['20%', '20%']
  },
  series: [
    {
      type: 'custom',
      renderItem: (_params, api) => {
        const location = api.coord([api.value(0), api.value(1)])
        return {
          type: 'group',
          children: [
            {
              type: 'CubeLeft',
              shape: {
                api,
                xValue: api.value(0),
                yValue: api.value(1),
                x: location[0],
                y: location[1],
                xAxisPoint: api.coord([api.value(0), 0])
              },
              style: {
                fill: new graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: '#3B80E2'
                  },
                  {
                    offset: 1,
                    color: '#49BEE5'
                  }
                ])
              }
            },
            {
              type: 'CubeRight',
              shape: {
                api,
                xValue: api.value(0),
                yValue: api.value(1),
                x: location[0],
                y: location[1],
                xAxisPoint: api.coord([api.value(0), 0])
              },
              style: {
                fill: new graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: '#3B80E2'
                  },
                  {
                    offset: 1,
                    color: '#49BEE5'
                  }
                ])
              }
            },
            {
              type: 'CubeTop',
              shape: {
                api,
                xValue: api.value(0),
                yValue: api.value(1),
                x: location[0],
                y: location[1],
                xAxisPoint: api.coord([api.value(0), 0])
              },
              style: {
                fill: new graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: '#3B80E2'
                  },
                  {
                    offset: 1,
                    color: '#49BEE5'
                  }
                ])
              }
            }
          ]
        }
      },
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      },
      data: VALUE
    }
  ]
}

排行榜柱状图

效果

在这里插入图片描述

代码

import { graphic } from 'echarts'
const options = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        // Use axis to trigger tooltip
        type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
      }
    },
    grid: {
      left: '4%',
      right: '8%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      name: '流量',
      nameLocation: 'end',
      nameTextStyle: {
        color: '#A2D4E6',
        fontSize: 14,
        fontWeight: 400
      },
      offset: 20,
      nameGap: -10,
      position: 'top',
      show: true,
      type: 'value',
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: false
      },
      splitLine: {
        //网格线
        show: false
      }
    },
    yAxis: {
      name: '名称',
      nameTextStyle: {
        color: '#A2D4E6',
        fontSize: 14,
        fontWeight: 400,
        padding: [0, 0, 0, -80]
      },
      type: 'category',
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: true,
        interval: '0',
        textStyle: {
          fontSize: 12,
          color: '#687284'
        }
      },
      data: [
        '10xxxx',
        '9xxxx',
        '8xxxx',
        '7xxxx',
        '6xxxx',
        '5xxxx',
        '4xxxx',
        '3xxxx',
        '2xxxx',
        '1xxxx'
      ]
    },
    series: [
      {
        name: '数量',
        type: 'bar',
        stack: 'total',
        itemStyle: {
          color: new graphic.LinearGradient(0, 0, 1, 0, [
            { offset: 0, color: '#00E4FF' },
            { offset: 1, color: '#008AFF' }
          ])
        },
        emphasis: {
          focus: 'series'
        },
        label: {
          normal: {
            show: true,
            position: 'right',
            color: '#687284',
            fontSize: '10'
          }
        },
        data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      }
    ]
  }

排行榜反转柱状图

效果

在这里插入图片描述

代码

import { graphic } from 'echarts'

const options = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        // Use axis to trigger tooltip
        type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
      }
    },
    grid: {
      left: '8%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      name: '得分',
      nameLocation: 'end',
      nameTextStyle: {
        color: '#A2D4E6',
        fontSize: 14,
        fontWeight: 400
      },
      offset: 20,
      nameGap: -10,
      position: 'top',
      show: true,
      type: 'value',
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: false
      },
      splitLine: {
        //网格线
        show: false
      },
      inverse: true //反转坐标轴
    },
    yAxis: {
      name: '名称',
      nameTextStyle: {
        color: '#A2D4E6',
        fontSize: 14,
        fontWeight: 400,
        padding: [0, 0, 0, 80]
      },
      type: 'category',
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: true,
        interval: '0',
        textStyle: {
          fontSize: 12,
          color: '#687284'
        }
      },
      position: 'right',
      data: [
        '10xxxx',
        '9xxxx',
        '8xxxx',
        '7xxxx',
        '6xxxx',
        '5xxxx',
        '4xxxx',
        '3xxxx',
        '2xxxx',
        '1xxxx'
      ]
    },
    series: [
      {
        name: '数量',
        type: 'bar',
        stack: 'total',
        itemStyle: {
          color: new graphic.LinearGradient(1, 0, 0, 0, [
            { offset: 0, color: '#00E4FF' },
            { offset: 1, color: '#008AFF' }
          ])
        },
        emphasis: {
          focus: 'series'
        },
        label: {
          normal: {
            show: true,
            position: 'left',
            color: '#687284',
            fontSize: '10'
          }
        },
        data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      }
    ]
  }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

echart常用图表配置 的相关文章

  • 关于docker和podman

    docker daemon 存在问题 单点故障问题 docker daemon一旦死亡 所有容器都将死亡 docker daemon 拥有运行中的容器的所有子进程 所有docker操作都需由具有跟root相同权限的用户执行 构建容器时 可能
  • 【华为OD机试】按身高和体重排队(C++ Python Java)2023 B卷

    时间限制 C C 1秒 其他语言 2秒 空间限制 C C 262144K 其他语言524288K 64bit IO Format lld 语言限定 C clang11 C clang 11 Pascal fpc 3 0 2 Java jav
  • Thread.Sleep(0)的妙用

    https www cnblogs com JianGuoWan p 9139698 html Thread Sleep 0 表示挂起0毫秒 你可能觉得没作用 你要写Thread Sleep 1000 就有感觉了 似乎毫无意义 MSDN的说
  • VS2010配色方案

    找了很久的配色方案 绝对是精挑细选的 现在分享一下地址 http www hanselman com blog VisualStudioProgrammerThemesGallery aspx 个人喜欢的配色方案 Ragnarok 附图 忘

随机推荐

  • 添加数据设置某个列自增_流量物联卡这样设置,网速立马变快

    物联卡是什么 简单而言 物联卡跟手机卡的区别就是 不能打电话和发短信 物联卡有自己的流量池 共享流量 比如下图就是某个物联卡的套餐 移动APN设置 移动设置APN 安卓手机需要把设备的接入点改成CMIOT 具体步骤如下 A 找到设置移动网络
  • 本地主机连接阿里云数据库(自建数据库)排雷

    最近在阿里云上开了一台云主机 自己搭建了数据库作为数据库使用 正当我本地去连接云上mysql时 发现死活连接不上 我这边阿里云上安全组端口已经放开了 出方向和入方向都开了歪 但是依然连接不上 是不是数据库做了限制 此时的我恍然大悟 欻欻欻欻
  • 叉积的意义

    我们知道 向量的叉积可以帮助我们求出一个和已知两个向量构成的平面相互垂直的另一个向量 例如求法向量 而且一般来说 都是求三维空间的向量的叉积 下面我们要讨论的就是各种 为什么如此 考虑两个相互不平行的三维向量 它们的叉积 以行列式形式来表示
  • 用VRTK4.0如何实现与UI交互(保姆级别教程)

    1 导入Tilia UnityUI master包 点击下面的链接直接跳到这个界面studentutu Tilia UnityUI Tilia package for VRTK 4 featuring support for Unity U
  • Your python install is corrupted. Please fix the '/usr/bin/python' symlink.

    执行如下命令就ok了 sudo ln sf usr bin python2 7 usr bin python 如果还是不行 reinstall sudo apt get install reinstall python 参考地址 https
  • ‘open3d.open3d.geometry.PointCloud‘ object has no attribute ‘voxel_down_sample‘

    scene cloud open3d geometry PointCloud scene cloud points open3d utility Vector3dVector scene points scene cloud scene c
  • 第四讲 系统建模方法

    系统建模一般流程 实际系统的分析方法大致类似 但对于实际系统的模型实现方式则有多种 1 面向方程 图框 的因果建模 基于图框进行系统模型实现 的软件很多 如Simulink AMESim 应用于控制领域 等 2 面向对象 非因果 的物理建模
  • Ztree和eazyUi-tree的区别

    l 在页面中引入ztree相关的文件 1 1 使用简单json数据构造ztree 重点
  • 常用端口

    端口号码 层 名称 注释 1 tcpmux TCP 端口服务多路复用 5 rje 远程作业入口 7 echo Echo 服务 9 discard 用于连接测试的空服务 11 systat 用于列举连接了的端口的系统状态 13 daytime
  • 使用father打包发布前端工具库

    father库说明 GitHub https github com umijs father 升级迁移 教程使用father v1 版本较老 可参考下面的教程升级 father 4升级教程 安装 yarn add father 项目配置 0
  • WebStorm、Idea编辑器中右侧的SVN下拉,提交标志不见了呢?--已解决

    新打开的窗口 没有SVN的下拉标志如何把他弄出来呢 首先你得安装了小乌龟软件 然后来到编辑器中 选择 1 VCS Enable Version Control Integretion 2 选择Subversion 点击OK ok 完成
  • logback打印日志不显示具体的信息,显示问号

    目录 表象 原因 日志打印的Appender是使用的ch qos logback classic AsyncAppender 正确配置 表象 配置
  • java21天打卡Day13-正则表达式

    原来正则表达式是这样用的
  • 前端实现文件在线预览

    需求 一个览pdf word xls ppt等文件需要在线预览功能 介绍 使用 XDOC文档预览云服务文档地址 基于HTTP的REST方式调用 只需要传入URL 支持pdf docx xlsx pptx rtf jpg png mp4等多种
  • DINO-DETR论文学习记录

    摘要 我们介绍了DINO 带有改进的去噪器box的DETR 一种最先进的端到端对象检测器 DINO 通过使用对比方式进行去噪训练 混合查询选择方法进行锚点初始化以及用于框预测的ook forward twice方案 在性能和效率方面比以前的
  • 使用WIFI模块AT指令进行HTTP交互

    超文本传输协议 HTTP HyperText Transfer Protocol 是互联网上应用最为广泛的一种网络协议 所有的WWW文件都必须遵守这个标准 设计HTTP最初的目的是为了提供一种发布和接收HTML页面的方法 用户通过M0M1系
  • linux cd命令怎么用

    在Linux中 cd命令是用来改变当前工作目录的 具体使用方法如下 打开终端 输入cd命令 后面跟上要进入的目录的路径 例如 如果要进入home目录 可以输入cd home 按下回车键即可进入指定目录 如果要返回上一级目录 可以使用 cd
  • Arudio项目实战——003 TracKingTheCar(循迹小车)

    Arudio项目实战 003 TracKingTheCar 循迹小车 Cblock源码 Cblock转Arduino源代码 include
  • 信息学奥赛一本通C++语言——1111:不高兴的津津

    题目描述 津津上初中了 妈妈认为津津应该更加用功学习 所以津津除了上学之外 还要参加妈妈为她报名的各科复习班 另外每周妈妈还会送她去学习朗诵 舞蹈和钢琴 但是津津如果一天上课超过八个小时就会不高兴 而且上得越久就会越不高兴 假设津津不会因为
  • echart常用图表配置

    echart常用图表配置 柱状图 3D柱状图 效果 代码 排行榜柱状图 效果 代码 排行榜反转柱状图 效果 代码 柱状图 3D柱状图 效果 代码 import graphic from echarts const VALUE Array f