当前位置: 首页> 房产> 建材 > Vue3+Echarts+Setup实现动态曲线堆叠图+图例分页

Vue3+Echarts+Setup实现动态曲线堆叠图+图例分页

时间:2025/7/9 19:51:57来源:https://blog.csdn.net/weixin_72439307/article/details/141188857 浏览次数:0次

提前安装引入echarts

效果图

dom实例

<div id="rightCharterwang" style="height: 28vh"></div>

 配置项,将数据换成从接口请求回来的数据(这里是写死的假数据)

const rightCharterwang = () => {let namedata = ['a','b','c','d','e','ffffff','g','hhhhhhhhhhhhhhhhhhhh','i','g','k','l','m','n']const chartBox = echarts.init(document.getElementById('rightCharterwang'))const option = {title: {text: ''},//显示悬浮窗体// tooltip: {//   trigger: 'axis'// },// 纵向// legend: {//   type: 'scroll',//   orient: 'vertical',//   right: 10,//   top: 20,//   bottom: 20,//   data: namedata// },// 横向legend: {type: 'scroll',top: 10,data: namedata},grid: {left: '3%',right: '4%',bottom: '3%',containLabel: true},xAxis: {type: 'category',boundaryGap: false,data: ['1-1', '1-2', '1-3', '1-4', '1-5', '1-6', '1-7']},yAxis: {type: 'value',min: 0,max: 25,interval: 5},series: [{name: 'a',type: 'line',smooth: true,data: [12, 13, 10, 13, 9, 2, 21]},{name: 'b',type: 'line',smooth: true,data: [22, 18, 19, 23, 2, 3, 3]},{name: 'c',type: 'line',smooth: true,data: [15, 23, 20, 15, 19, 3, 4]},{name: 'd',type: 'line',smooth: true,data: [13, 23, 3, 14, 15, 16, 17]},{name: 'e',type: 'line',smooth: true,data: [8, 9, 11, 20, 12, 16, 13]},{name: 'ffffff',type: 'line',smooth: true,data: [8, 9, 11, 10, 12, 17, 13]},{name: 'g',type: 'line',smooth: true,data: [18, 19, 9, 11, 12, 15, 13]},{name: 'hhhhhhhhhhhhhhhhhhhh',type: 'line',smooth: true,data: [18, 19, 9, 13, 1, 14, 3]},{name: 'i',type: 'line',smooth: true,data: [18, 3, 9, 15, 1, 2, 0]},{name: 'j',type: 'line',smooth: true,data: [22, 19, 9, 17, 1, 0, 3]},{name: 'k',type: 'line',smooth: true,data: [23, 19, 0, 19, 1, 3, 3]},{name: 'l',type: 'line',smooth: true,data: [18, 0, 9, 21, 1, 3, 3]},{name: 'm',type: 'line',smooth: true,data: [0, 19, 9, 22, 1, 3, 3]},{name: 'n',type: 'line',smooth: true,data: [0, 0, 6, 9, 18, 13, 3]}]}option && chartBox.setOption(option)window.addEventListener('resize', function () {chartBox.resize()})
}rightCharterwang()

分页实现 就是配置legend,将type设置scroll并且配置图例的名字数组, orient: 'vertical',设置为纵向并调整位置,默认是横向

关键字:Vue3+Echarts+Setup实现动态曲线堆叠图+图例分页

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: