【echarts】报错series.render is required.

总结:就是echarts无法保存renderItem函数到json里,因为renderItem是个封装方法,因此需要初始化加载时重新插入renderItem即可

1.描述:控制台报错series.render is required.

原数据json如下:

{type: "bar",coordinateSystem: "rightAngle-x", // 坐标系chartStyle: {width: 8,type: "",markPoint: {data: [{label: {show: false,position: "top",color: "#00e6ff",fontStyle: "normal",fontWeight: "normal",fontSize: "12",},},{label: {show: false,position: "top",color: "#00e6ff",fontStyle: "normal",fontWeight: "normal",fontSize: "12",},},],},},option: {legend: {icon: "circle",show: true,itemWidth: 10,itemheight: 10,textStyle: {color: "#FFFFFF",fontStyle: "normal",fontWeight: "normal",fontSize: "12",},left: "left",top: "top",},title: [{text: "",textStyle: {color: "#FFFFFF",fontStyle: "normal",fontWeight: "normal",fontSize: "18",},left: "left",},{text: "",textStyle: {color: "#FFFFFF",fontStyle: "normal",fontWeight: "normal",fontSize: "14",},left: "left",top: "20",},],tooltip: {trigger: "axis",axisPointer: {type: "line",lineStyle: {type: "dashed",},},backgroundColor: "transparent",borderWidth: 0,borderColor: "transparent",padding: 0,textStyle: {color: "#ffffff",},formatter: function (params) {var text = `<div style="width: 180px;height: 78px;backdrop-filter: blur(10px);background-color:#1A474266;border-radius: 6px 6px 6px 6px;border: 1px solid #2c7d72FF;"><div style="margin:8px 0 10px 10px; font-size: 12px; display: flex; justify-content: space-between"><p> 数据:</p></div><div style="margin:4px 0 9px 8px; padding:11px 10px 9px 9px;font-size: 12px;border-radius:4px;display: flex; justify-content: space-between;align-items: center;background: #1F7D7DE6;width: 164px;height: 28px;"><div style="display: flex; justify-content: space-between;"><div style="width: 10px;height: 10px;background: #3AFDF1;border-radius:50%;margin:5px 5px 0 0"></div><p>${params[0].name}</p></div>  <p>${params[0].value}</p></div></div>`;return text;},},grid: {left: "3%",right: "3%",bottom: "3%",top: "48",containLabel: true,},xAxis: {type: "category",data: [],axisTick: {//刻度线show: false,},axisLine: {//轴线show: true,lineStyle: {color: "#ffffff",width: 1,},},axisLabel: {//轴标签show: true,color: "#FFFFFF",fontStyle: "normal",fontWeight: "normal",fontSize: "12",interval: "auto",rotate: 0,},splitLine: {//网格线show: false,lineStyle: {color: "#33333333",type: "dashed",},},},yAxis: {type: "value",axisTick: {//刻度线show: false,},axisLine: {//轴线show: false,lineStyle: {color: "#35404e",width: 2,},},axisLabel: {//轴标签show: true,color: "#FFFFFF",fontStyle: "normal",fontWeight: "normal",fontSize: "12",},splitLine: {//网格线show: false,lineStyle: {color: "#33333333",type: "dashed",},},},series: [{type: "custom",renderItem: function (params, api) {const location = api.coord([api.value(0), api.value(1)]);return {type: "group",children: [{type: "CubeLeft",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#124340FF",},},{type: "CubeRight",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#155049FF",},},{type: "CubeTop",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#135146FF",},},],};},data: [],markPoint: {data: [{type: "max",component: "最大值",symbolSize: 0,label: {show: false,position: "top",color: "#00e6ff",fontStyle: "normal",fontWeight: "normal",fontSize: "12",},},{type: "min",component: "最小值",symbolSize: 0,label: {show: false,position: "top",color: "#00e6ff",fontStyle: "normal",fontWeight: "normal",fontSize: "12",},},],},},{type: "custom",markPoint: {data: [{type: "max",component: "最大值",symbolSize: 0,label: {show: false,position: "top",color: "#00e6ff",fontStyle: "normal",fontWeight: "normal",fontSize: "12",},},{type: "min",component: "最小值",symbolSize: 0,label: {show: false,position: "top",color: "#00e6ff",fontStyle: "normal",fontWeight: "normal",fontSize: "12",},},],},renderItem: (params, api) => {const location = api.coord([api.value(0), api.value(1)]);return {type: "group",children: [{type: "CubeLeft",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#3CB0B7FF",},},{type: "CubeRight",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#4EFCDDFF",},},{type: "CubeTop",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#3AFDCEFF",},},],};},data: [],},],},}

**

2.重点问题出在这里

因为renderItem是函数当保存为json后,renderItem会丢失

**

renderItem: (params, api) => {const location = api.coord([api.value(0), api.value(1)]);return {type: "group",children: [{type: "CubeLeft",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#3CB0B7FF",},},{type: "CubeRight",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#4EFCDDFF",},},{type: "CubeTop",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#3AFDCEFF",},},],};},

3.解决办法

在created()或mounted()生命周期时,需要对保存的json数据再次特殊处理,对option.series数组里再次插入renderItem函数!

    const renderItem1 = (params, api) => {const location = api.coord([api.value(0), api.value(1)]);return {type: "group",children: [{type: "CubeLeft",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#124340FF",},},{type: "CubeRight",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#155049FF",},},{type: "CubeTop",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#135146FF",},},],};};const renderItem2 = (params, api) => {const location = api.coord([api.value(0), api.value(1)]);return {type: "group",children: [{type: "CubeLeft",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#3CB0B7FF",},},{type: "CubeRight",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#4EFCDDFF",},},{type: "CubeTop",shape: {x: location[0],y: location[1],xAxisPoint: api.coord([api.value(0), 0]),},style: {fill: "#3AFDCEFF",},},],};};option.series[0].renderItem = renderItem1;option.series[1].renderItem = renderItem2;//渲染tooltipconst formatter = (params) => {var text = `<div style="width: 180px;height: 78px;backdrop-filter: blur(10px);background-color:#1A474266;border-radius: 6px 6px 6px 6px;border: 1px solid #2c7d72FF;"><div style="margin:8px 0 10px 10px; font-size: 12px; display: flex; justify-content: space-between"><p> 数据:</p></div><div style="margin:4px 0 9px 8px; padding:11px 10px 9px 9px;font-size: 12px;border-radius:4px;display: flex; justify-content: space-between;align-items: center;background: #1F7D7DE6;width: 164px;height: 28px;"><div style="display: flex; justify-content: space-between;"><div style="width: 10px;height: 10px;background: #3AFDF1;border-radius:50%;margin:5px 5px 0 0"></div><p>${params[0].name}</p></div>  <p>${params[0].value}</p></div></div>`;return text;};option.tooltip.formatter = formatter;

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/54772.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

工作安排 - 华为OD统一考试(E卷)

2024华为OD机试(C卷+D卷)最新题库【超值优惠】Java/Python/C++合集 题目描述 小明每周上班都会拿到自己的工作清单,工作清单内包含n项工作,每项工作都有对应的耗时时长(单位h)和报酬,工作的总报酬为所有已完成工作的报酬之和。那么请你帮小明安排一下工作,保证小明在指定…

科研绘图系列:R语言树结构聚类热图(cluster heatmap)

文章目录 介绍加载R包导入数据数据预处理画图修改图形导出数据系统信息介绍 热图结合树结构展示聚类结果通常用于展示数据集中的模式和关系,这种图形被称为聚类热图或层次聚类热图。在这种图中,热图部分显示了数据矩阵的颜色编码值,而树结构(通常称为树状图或聚类树)则显…

AIGAME背后的强大背景与AI币价值的崛起

AIGAME平台背后汇集了强大的资本和技术支持&#xff0c;凭借蒙特加密产业基金的战略投资和汇旺集团的多元化Web3基础设施建设&#xff0c;AIGAME在全球范围内迅速崛起。平台所使用的Sleepless AI技术&#xff0c;结合区块链与AI的深度融合&#xff0c;赋能AI币&#xff0c;使其…

虚拟社交的新时代:探索Facebook的元宇宙愿景

随着技术的不断进步&#xff0c;社交媒体的形态也在悄然变化。Facebook&#xff08;现名Meta&#xff09;正站在这一变革的前沿&#xff0c;积极探索元宇宙的愿景。元宇宙不仅是虚拟现实&#xff08;VR&#xff09;和增强现实&#xff08;AR&#xff09;的结合&#xff0c;更是…

遍历9个格子winmine!StepBlock和遍历8个格子winmine!StepBox的对决

遍历9个格子winmine!StepBlock和遍历8个格子winmine!StepBox的对决 第一部分&#xff1a;windbg调试记录。 0: kd> g Breakpoint 10 hit winmine!DoButton1Up: 001b:0100390e a130510001 mov eax,dword ptr [winmine!xCur (01005130)] 0: kd> kc # 00 winmine…

【RabbitMQ 项目】服务端:服务器模块

文章目录 一.编写思路二.代码实践三.服务端模块关系总结 一.编写思路 成员变量&#xff1a; muduo 库中的 TCP 服务器EventLoop 对象&#xff1a;用于主线程循环监控连接事件协议处理句柄分发器&#xff1a;用于初始化协议处理器&#xff0c;便于把不同请求派发给不同的业务处理…

Golang | Leetcode Golang题解之第433题最小基因变化

题目&#xff1a; 题解&#xff1a; func diffOne(s, t string) (diff bool) {for i : range s {if s[i] ! t[i] {if diff {return false}diff true}}return }func minMutation(start, end string, bank []string) int {if start end {return 0}m : len(bank)adj : make([][…

OpenHarmony标准系统mipi摄像头适配

OpenHarmony标准系统mipi摄像头适配 本文档以rk3568为例&#xff0c;讲述如何在OpenHarmony 标准系统rk设备上适配mipi摄像头。 开发环境 OpenHarmony标准系统4.1rrk3568设备摄像头ov5648,ov8858 文档约定&#xff1a;4.1r_3568为OpenHarmony标准系统源码根目录 1.适配准备:得…

树莓派pico上手

0 介绍 不同于作为单板计算机的树莓派5&#xff0c;树莓派 pico 是一款低成本、高性能的微控制器板&#xff0c;具有灵活的数字接口。主要功能包括&#xff1a; 英国树莓派公司设计的 RP2040 微控制器芯片双核 Arm Cortex M0 处理器&#xff0c;弹性的时钟频率高达 133 MHz26…

Spring AOP的应用

目录 1、maven坐标配置与xml头配置 2、代理方式的选择与配置 3、AOP的三种配置方式 3.1、XML模式 3.1.1 创建目标类和方法 3.1.2 创建切面 3.1.3 切面xml配置与表达式说明 3.1.4 单测 3.2 纯注解模式 3.2.1 开启注解相关配置 3.2.2 创建目标类和方法 3.2.3 创建切面…

FGPA实验——触摸按键

本文系列都基于正点原子新起点开发板 FPGA系列 1&#xff0c;verlog基本语法&#xff08;随时更新&#xff09; 2&#xff0c;流水灯&#xff08;待定&#xff09; 3&#xff0c;FGPA实验——触摸按键 一、触摸操作原理实现 分类&#xff1a;电阻式&#xff08;不耐用&…

二叉树进阶

目录 1. 二叉搜索树实现 1.1 二叉搜索树概念 2.2 二叉搜索树操作 ​编辑 ​编辑 2.3 二叉搜索树的实现 2.3.0 Destroy() 析构 2.3.1 Insert&#xff08;&#xff09;插入 2.3.2 InOrder&#xff08;&#xff09; 打印搜索二叉树 ​编辑​编辑 2.3.3 Find() 查找 …

el-table表格点击该行任意位置时也勾选上其前面的复选框

需求&#xff1a;当双击表格某一行任意位置时&#xff0c;自动勾选上其前面的复选框 1、在el-table 组件的每一行添加row-dblclick事件&#xff0c;用于双击点击 <el-table:data"tableData"ref"tableRef"selection-change"handleSelectionChange&q…

如何在Chrome最新浏览器中调用ActiveX控件?

小编最近登陆工商银行网上银行&#xff0c;发现工商银行的个人网银网页&#xff0c;由于使用了ActiveX安全控件&#xff0c;导致不能用高版本Chrome浏览器打开&#xff0c;目前只有使用IE或基于IE内核的浏览器才能正常登录网上银行&#xff0c;而IE已经彻底停止更新了&#xff…

AI绘图网页版工具

https://chat.bushao.info/?inVitecodeCHBEPQQOOM 一款AI绘图工具&#xff0c;很好玩&#xff0c;推荐&#xff1b; 我自己根据文本生成的图&#xff0c;感觉还不错。

ROC、TPR、FPR的含义

1、ROC&#xff08;Receiver Operating Characteristic&#xff09; ROC&#xff08;Receiver Operating Characteristic&#xff09;曲线是一种用于评估分类模型性能的工具。它通过绘制真阳性率&#xff08;True Positive Rate, TPR&#xff09;与假阳性率&#xff08;False…

仪表放大器AD620

AD623 是一款低功耗、高精度的仪表放大器&#xff0c;而不是轨到轨运算放大器。它的输入电压范围并不覆盖整个电源电压&#xff08;轨到轨&#xff09;&#xff0c;但在单电源供电下可以处理接近地电位的输入信号。 AD620 和 AD623 都是仪表放大器&#xff0c;但它们在一些关键…

vscode【实用插件】Notes 便捷做笔记

安装 在 vscode 插件市场的搜索 Notes点 安装 安装成功后&#xff0c;vscode 左侧栏会出现 使用 初次使用 需先选择一个本地目录 重启 vscode 后&#xff0c;得到 切换笔记目录 新建笔记 快捷键为 Alt N 默认会创建 .md 文件 配合插件 Markdown Preview Enhanced 预览 .md…

2024中国新能源汽车零部件交易会,开源网安展示了什么?

近日&#xff0c;2024中国新能源汽车零部件交易会在十堰国际会展中心举行。开源网安车联网安全实验室携车联网安全相关产品及解决方案亮相本次交易会&#xff0c;保障智能网联汽车“车、路、云、网、图、边”安全&#xff0c;推动智能网联汽车技术突破与产业化发展。 中国新能源…

【深度学习】(7)--神经网络之保存最优模型

文章目录 保存最优模型一、两种保存方法1. 保存模型参数2. 保存完整模型 二、迭代模型 总结 保存最优模型 我们在迭代模型训练时&#xff0c;随着次数初始的增多&#xff0c;模型的准确率会逐渐的上升&#xff0c;但是同时也随着迭代次数越来越多&#xff0c;由于模型会开始学…