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

图表

上级 d267c520
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
</template> </template>
<script setup> <script setup>
import { Chart } from 'chart.js/auto'; import { Chart } from 'chart.js/auto';
const colorMode = useColorMode()
const props = defineProps({ const props = defineProps({
type: { type: {
type: String, type: String,
...@@ -23,18 +25,27 @@ const props = defineProps({ ...@@ -23,18 +25,27 @@ const props = defineProps({
default: () => [] default: () => []
} }
}) })
let chart
onMounted(() => { onMounted(() => {
new Chart(document.getElementById('chart'), { chart = new Chart(document.getElementById('chart'), {
type: props.type, type: props.type,
data: { data: {
labels: props.labels, labels: props.labels,
datasets: [ datasets: props.data
{ },
label: props.title, options: {
data: props.data plugins: {
title: {
display: true,
text: props.title,
} }
] }
} }
}) })
}) })
watch(()=> colorMode.value, (value) => {
let color = '#e5e7eb'
if (value === 'dark') color = '#1f2937'
Chart.defaults.borderColor = color
}, { immediate: true, deep: true })
</script> </script>
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
</template> </template>
<script setup> <script setup>
const mdStr = ` const mdStr = `
::ProseChart{title='langchain-ai/langchain [2023-06-05,2024-06-04] Star Data' :labels='["2023-06-05","2023-06-12"]' :data='[43071,44946]'} ::ProseChart{type='line' title='langchain-ai/langchain [2023-06-05,2024-06-04] Star Data' :labels='["2023-06-05","2023-06-12"]' :data='[{"label": "star数量", "data": [43071,44946]}]' }
` `
</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.
先完成此消息的编辑!
想要评论请 注册