在项目开发过程中,需要实现以下的效果
图表左右两边需要自定义文本,刚开始使用lengend配置项的时候会出现重复渲染的现象,后来用的是graphic
graphic功能比较强大,不止文字,可以看文档:https://www.w3cschool.cn/echarts_tutorial/echarts_tutorial-3u872dym.html
下面直接上关键代码
lineOption.graphic.push({
type: "text",
left: "11%",
top: 95 + index * 158,
style: {
text: [`缺失率=${item.missRate}`, `最小值=${item.minNum}`, `最大值=${item.maxNum}`].join("\n"),
font: "500 14px sy",
fill: "#1D2F2E",
textLineHeight: 20,
},
});
lineOption.graphic.push({
type: "text",
left: "79%",
top: 95 + index * 158,
style: {
text: [`平均数=${item.averageValue}`, `中位数=${item.median}`, `95%置信大小=${item.trueSize}`].join("\n"),
font: "500 14px sy",
fill: "#1D2F2E",
textLineHeight: 22,
}
});