feat: add Plotly.js usage page
Some checks failed
/ build-and-deploy-to-vercel (push) Successful in 5m48s
/ lint-build-and-check (push) Successful in 7m13s
/ surge (push) Successful in 5m5s
/ playwright (push) Failing after 2m27s

This commit is contained in:
严浩
2025-04-17 14:57:17 +08:00
parent 784c5ff56d
commit 95d5087b5e
4 changed files with 729 additions and 78 deletions

View File

@ -0,0 +1,40 @@
<script setup lang="ts">
import Plotly from 'plotly.js-dist-min';
const plotRef = useTemplateRef<import('plotly.js-dist-min').PlotlyHTMLElement | null>('plotRef');
// 数据
const trace1 = {
x: [1, 2, 3, 4, 5],
y: [2, 4, 1, 5, 3],
type: 'scatter',
} satisfies import('plotly.js-dist-min').Data;
const data = [trace1];
// 布局
const layout = {
title: '简单折线图',
xaxis: {
title: 'X 轴',
},
yaxis: {
title: 'Y 轴',
},
} satisfies Partial<import('plotly.js-dist-min').Layout>;
onMounted(async () => {
// 绘制图表
Plotly.newPlot(plotRef.value!, data, layout);
plotRef.value?.on('plotly_relayout', (eventData) => {
console.debug(`eventData :>> `, eventData);
});
});
</script>
<template>
<div ref="plotRef" style="width: 600px; height: 400px"></div>
</template>
<style scoped></style>