当前位置: 首页 > news >正文

多个DataV遍历生成

DataV是数据可视化工具 与Echart类似
相对Echart图标边框 装饰可选

官网DataV

在这里插入图片描述

安装

npm install @kjgl77/datav-vue3

main.ts

import DataVVue3 from '@kjgl77/datav-vue3'
app.use(DataVVue3)

多个DataV遍历生成

Vue3+vite+DataV为例:

在这里插入图片描述

<template><div w50rem h25rem flex="~ col" justify-center items-center bg-dark><!-- 使用 v-for 遍历 chartsData 数组 --><componentv-for="(chart, index) in chartsData":key="index":is="resolveComponent(chart.type)" :config="chart.config":style="chart.style"/><div pt5><button @click="addData">增加数据</button></div></div>
</template><script setup lang="ts">
import { ref, reactive } from 'vue';// 定义默认样式
const defaultChartStyle = {width: '25rem',height: '15rem',
};// 动态解析组件类型
const resolveComponent = (type: string) => {switch (type) {case 'bar':return 'dv-active-ring-chart'; // 假设这是 DataV 提供的组件名case 'line':return 'dv-capsule-chart';// 可以添加更多类型的组件解析default:console.warn(`未知的组件类型: ${type}`);return null;}
};// 数据源,包含各个图表组件的配置
const chartsData = reactive([{type: 'line', // 这里定义了组件类型config: {data: [{ name: '南阳', value: 167 },{ name: '周口', value: 123 },{ name: '漯河', value: 3 },{ name: '郑州', value: 75 },{ name: '西峡', value: 66 },],axisColor: '#ffffff'},style: defaultChartStyle,},{type: 'bar',config: {data: [{ name: '南阳', value: 167 },{ name: '周口', value: 123 },{ name: '漯河', value: 98 },{ name: '郑州', value: 75 },{ name: '西峡', value: 66 },],colors: ['#e062ae', '#fb7293', '#e690d1', '#32c5e9', '#96bfff'],unit: '万元',},style: defaultChartStyle,},// 可以添加更多图表配置对象
]);// 添加新数据到当前图表(可以根据需要调整)
const addData = () => {const chartIndex = 0; // 假设我们只向第一个图表添加数据if (chartsData[chartIndex]) {const newDataPoint = {name: '测试' + Math.floor(Math.random() * 100),value: Math.floor(Math.random() * 100)};if (chartsData[chartIndex].type === 'line') {newDataPoint.value = [newDataPoint.value, chartsData[chartIndex].config.data.length + 1];}chartsData[chartIndex].config.data.push(newDataPoint);}
};
</script><style scoped>
.chart-container {margin-bottom: 1rem;}
</style>
http://www.lryc.cn/news/514056.html

相关文章:

  • mysql_real_connect的概念和使用案例
  • Python性能分析深度解析:从`cProfile`到`line_profiler`的优化之路
  • Momentum Contrast for Unsupervised Visual Representation Learning论文笔记
  • 用户界面的UML建模07
  • Node.js中使用Joi 和 express-joi-validation进行数据验证和校验
  • InstructGPT:基于人类反馈训练语言模型遵从指令的能力
  • jrc水体分类对水体二值掩码修正
  • 营销/CDP/MA/SCRM
  • 免费CDN加速,零成本提升网站速度!
  • 2024-12-29-sklearn学习(25)无监督学习-神经网络模型(无监督) 烟笼寒水月笼沙,夜泊秦淮近酒家。
  • RSA e与phi不互质(AMM算法进行有限域开根)
  • 网络物理互连
  • 论文研读:Text2Video-Zero 无需微调,仅改动<文生图模型>推理函数实现文生视频(Arxiv 2023-03-23)
  • 服务端错误的处理和web安全检测
  • 鸿蒙TCPSocket通信模拟智能家居模拟案例
  • SQL-leetcode-197. 上升的温度
  • C++系列关键字static
  • 使用Fn Connect之后,如何访问到其他程序页面?原来一直都可以!
  • 探索Composable Architecture:小众但高效的现代框架技术
  • 改投论文时如何重构
  • P8打卡——YOLOv5-C3模块实现天气识别
  • 基于微信小程序的校园点餐平台的设计与实现(源码+SQL+LW+部署讲解)
  • PyTorch快速入门教程【小土堆】之完整模型训练套路
  • 【AIGC】 ChatGPT实战教程:如何高效撰写学术论文引言
  • TTL 传输中过期问题定位
  • 非docker方式部署openwebui过程记录
  • 大模型的prompt的应用二
  • ubuntu 22.04安装ollama
  • 从企业级 RAG 到 AI Assistant,阿里云 Elasticsearch AI 搜索技术实践
  • Redis--高可用(主从复制、哨兵模式、分片集群)