提交 d5e932a8 编写于 作者: View Design's avatar View Design

add LineChart

上级 626c0ee8
<template>
<div class="w-full">
<canvas id="chart"></canvas>
</div>
</template>
<script setup>
import { Chart } from 'chart.js/auto';
const props = defineProps({
title: {
type: String,
default: ''
},
labels: {
type: Array,
default: () => []
},
data: {
type: Array,
default: () => []
}
})
onMounted(() => {
new Chart(document.getElementById('chart'), {
type: 'line',
data: {
labels: props.labels,
datasets: [
{
label: props.title,
data: props.data
}
]
}
})
})
</script>
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"@pinia/nuxt": "^0.5.1", "@pinia/nuxt": "^0.5.1",
"@vite-pwa/nuxt": "^0.7.0", "@vite-pwa/nuxt": "^0.7.0",
"@vueuse/nuxt": "^10.9.0", "@vueuse/nuxt": "^10.9.0",
"chart.js": "^4.4.3",
"highlight.js": "^11.9.0", "highlight.js": "^11.9.0",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"nuxt": "^3.11.2", "nuxt": "^3.11.2",
...@@ -2736,6 +2737,11 @@ ...@@ -2736,6 +2737,11 @@
"node": ">= 12" "node": ">= 12"
} }
}, },
"node_modules/@kurkle/color": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz",
"integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw=="
},
"node_modules/@kwsites/file-exists": { "node_modules/@kwsites/file-exists": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz",
...@@ -6981,6 +6987,17 @@ ...@@ -6981,6 +6987,17 @@
"url": "https://github.com/sponsors/wooorm" "url": "https://github.com/sponsors/wooorm"
} }
}, },
"node_modules/chart.js": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.3.tgz",
"integrity": "sha512-qK1gkGSRYcJzqrrzdR6a+I0vQ4/R+SoODXyAjscQ/4mzuNzySaMCd+hyVxitSY1+L2fjPD1Gbn+ibNqRmwQeLw==",
"dependencies": {
"@kurkle/color": "^0.3.0"
},
"engines": {
"pnpm": ">=8"
}
},
"node_modules/chokidar": { "node_modules/chokidar": {
"version": "3.6.0", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
...@@ -19718,6 +19735,11 @@ ...@@ -19718,6 +19735,11 @@
"path-to-regexp": "^6.2.1" "path-to-regexp": "^6.2.1"
} }
}, },
"@kurkle/color": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz",
"integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw=="
},
"@kwsites/file-exists": { "@kwsites/file-exists": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz",
...@@ -22610,6 +22632,14 @@ ...@@ -22610,6 +22632,14 @@
"resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz", "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz",
"integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==" "integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw=="
}, },
"chart.js": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.3.tgz",
"integrity": "sha512-qK1gkGSRYcJzqrrzdR6a+I0vQ4/R+SoODXyAjscQ/4mzuNzySaMCd+hyVxitSY1+L2fjPD1Gbn+ibNqRmwQeLw==",
"requires": {
"@kurkle/color": "^0.3.0"
}
},
"chokidar": { "chokidar": {
"version": "3.6.0", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
<template> <template>
<IMdMdc :content="mdStr" /> <IMdMdc :content="mdStr"/>
</template> </template>
<script setup> <script setup>
const mdStr = ref(`| 列1 | 列2 | 列3 | 列4 | 列5 | 列6 | 列7 | 列8 | 列9 | 列10 | const mdStr = `
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ::ProseLineChart{title='langchain-ai/langchain [2023-06-05,2024-06-04] Star Data' :labels='["2023-06-05","2023-06-12"]' :data='[43071,44946]'}
| 行1数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J | `
| 行2数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行3数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行4数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行5数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行6数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行7数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行8数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行9数据A | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 行10数据A | 数据B | 数据C | 数据D | 数据E | 数据F | 数据G | 数据H | 数据I | 数据J |
`)
</script> </script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册