echarts 3D示例 echart, echarts-gl

echarts官网有很多的炫酷的3D模型

来尝试实现下,使用原本的柱状图或者折线图代码创建echarts示例,使用cdn的方式引入echarts

复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.3.0/dist/echarts.min.js"></script>
    <title>ECharts Pie Chart with Click Event</title>
  </head>
  <body>
    <div id="pieChart" style="width: 600px; height: 400px"></div>
    <script>
      const data = [
        { value: 335, name: "Category 1" },
        { value: 310, name: "Category 2" },
        { value: 234, name: "Category 3" },
        { value: 135, name: "Category 4" },
        { value: 1548, name: "Category 5" },
      ];
      // 初始化 ECharts 实例
      const myChart = echarts.init(document.getElementById("pieChart"));
      // 配置饼图
      const option = {
        series: [
          {
            name: "Pie Chart",
            type: "pie",
            radius: "55%",
            center: ["50%", "60%"],
            data: data,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
      // 将配置设置到 ECharts 实例中
      myChart.setOption(option);
    </script>
  </body>
</html>

就会得到一个饼图

使用这个案例:Examples - Apache ECharts

在官网案例添加代码查看模型的数据

还需要引入echarts-gl的cdn, 应用中安装echarts-gl,只引入就好,不需要做额外的操作,会自动扩展echarts的功能

复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.2/dist/echarts.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/echarts-gl@2.0.9/dist/echarts-gl.min.js"></script>

    <title>ECharts Pie Chart with Click Event</title>
  </head>
  <body>
    <div
      id="pieChart"
      style="width: 600px; height: 600px; border: 5px solid red"
    ></div>
    <script>
      const list = 这里放从官网复制过来的数组
// 初始化 ECharts 实例
      const myChart = echarts.init(document.getElementById("pieChart"));
      // 将配置设置到 ECharts 实例中
      let option = {
        grid3D: {},
        tooltip: {},
        xAxis3D: {
          type: "category",
        },
        yAxis3D: {
          type: "category",
        },
        zAxis3D: {},
        visualMap: {
          max: 1e8,
          dimension: "Population",
        },
        dataset: {
          dimensions: [
            "Income",
            "Life Expectancy",
            "Population",
            "Country",
            { name: "Year", type: "ordinal" },
          ],
          source: list,
        },
        series: [
          {
            type: "bar3D",
            // symbolSize: symbolSize,
            shading: "lambert",
            encode: {
              x: "Year",
              y: "Country",
              z: "Life Expectancy",
              tooltip: [0, 1, 2, 3, 4],
            },
          },
        ],
      };
      // 将配置设置到 ECharts 实例中
      myChart.setOption(option);
    </script>
  </body>
</html>

看下是很大的

看下效果

相关推荐
rockey6273 小时前
C#脚本引擎之AScript与Jurassic、Jint对比
javascript·c#·.net·js·script·动态脚本
Profile排查笔记4 小时前
指纹浏览器哪个好?从 Profile、代理、权限和自动化能力判断是否适合
前端·人工智能·后端·自动化
lzhdim5 小时前
12、JavaScript常见的内存泄露问题 - JavaScript学习系列文章
开发语言·前端·javascript·学习·ecmascript
denggun123455 小时前
yield
前端·数据库·python
前端snow5 小时前
ai agent -- prompt汇总
前端
muddjsv7 小时前
前端性能优化实战:从加载到渲染的全面提速指南
前端·性能优化
deli0070077 小时前
JSON 树形查看器:粘贴即解析,折叠展开一目了然
前端·数据库·json·ai编程
guanguan0_07 小时前
PageProxy:页面维度接口地图 + 一键场景切换
前端·ai编程·请求代理·proxy工具
liangshanbo12158 小时前
虚拟列表深度面试题整理
java·开发语言·前端
IT_陈寒8 小时前
Redis内存警告竟是因为这个不起眼的配置项
前端·人工智能·后端