diff --git a/demo/Demo.vue b/demo/Demo.vue index 9270f02..9e33e98 100644 --- a/demo/Demo.vue +++ b/demo/Demo.vue @@ -8,6 +8,7 @@ import { track } from "@vercel/analytics"; import LogoChart from "./examples/LogoChart.vue"; import BarChart from "./examples/BarChart.vue"; +import LineChart from "./examples/LineChart.vue"; import PieChart from "./examples/PieChart.vue"; import PolarChart from "./examples/PolarChart.vue"; import ScatterChart from "./examples/ScatterChart.vue"; @@ -74,6 +75,7 @@ watch(codeOpen, (open) => {

+ diff --git a/demo/data/line.js b/demo/data/line.js new file mode 100644 index 0000000..64371c5 --- /dev/null +++ b/demo/data/line.js @@ -0,0 +1,52 @@ +export default function getData() { + return { + legend: { top: 20 }, + tooltip: { + trigger: "axis", + }, + dataset: { + source: [ + ["product", "2012", "2013", "2014", "2015", "2016", "2017"], + ["Milk Tea", 56.5, 82.1, 88.7, 70.1, 53.4, 85.1], + ["Matcha Latte", 51.1, 51.4, 55.1, 53.3, 73.8, 68.7], + ["Cheese Cocoa", 40.1, 62.2, 69.5, 36.4, 45.2, 32.5], + ["Walnut Brownie", 25.2, 37.1, 41.2, 18, 33.9, 49.1], + ], + }, + xAxis: { + type: "category", + triggerEvent: true, + tooltip: { show: true, formatter: "" }, + }, + yAxis: { + triggerEvent: true, + tooltip: { show: true, formatter: "" }, + }, + series: [ + { + type: "line", + smooth: true, + seriesLayoutBy: "row", + emphasis: { focus: "series" }, + }, + { + type: "line", + smooth: true, + seriesLayoutBy: "row", + emphasis: { focus: "series" }, + }, + { + type: "line", + smooth: true, + seriesLayoutBy: "row", + emphasis: { focus: "series" }, + }, + { + type: "line", + smooth: true, + seriesLayoutBy: "row", + emphasis: { focus: "series" }, + }, + ], + }; +} diff --git a/demo/examples/Example.vue b/demo/examples/Example.vue index 88fa11e..3e36779 100644 --- a/demo/examples/Example.vue +++ b/demo/examples/Example.vue @@ -43,7 +43,7 @@ defineProps({ width: fit-content; margin: 2em auto; - .echarts { + > .echarts { width: calc(60vw + 4em); height: 360px; max-width: 720px; diff --git a/demo/examples/LineChart.vue b/demo/examples/LineChart.vue new file mode 100644 index 0000000..b1404a5 --- /dev/null +++ b/demo/examples/LineChart.vue @@ -0,0 +1,77 @@ + + + diff --git a/package.json b/package.json index e11bc79..a45bddd 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "docs": "node ./scripts/docs.mjs", "prepublishOnly": "pnpm run typecheck && pnpm run dev:typecheck && pnpm run build && publint" }, - "packageManager": "pnpm@10.11.0", + "packageManager": "pnpm@10.12.1", "type": "module", "main": "dist/index.js", "unpkg": "dist/index.min.js", @@ -50,7 +50,7 @@ "@vue/tsconfig": "^0.7.0", "@vueuse/core": "^13.1.0", "comment-mark": "^2.0.1", - "echarts": "^5.5.1", + "echarts": "^5.6.0", "echarts-gl": "^2.0.9", "echarts-liquidfill": "^3.1.0", "esbuild-wasm": "^0.23.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 192fa13..64e3b65 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,14 +39,14 @@ importers: specifier: ^2.0.1 version: 2.0.1 echarts: - specifier: ^5.5.1 - version: 5.5.1 + specifier: ^5.6.0 + version: 5.6.0 echarts-gl: specifier: ^2.0.9 - version: 2.0.9(echarts@5.5.1) + version: 2.0.9(echarts@5.6.0) echarts-liquidfill: specifier: ^3.1.0 - version: 3.1.0(echarts@5.5.1) + version: 3.1.0(echarts@5.6.0) esbuild-wasm: specifier: ^0.23.0 version: 0.23.0 @@ -820,8 +820,8 @@ packages: peerDependencies: echarts: ^5.0.1 - echarts@5.5.1: - resolution: {integrity: sha512-Fce8upazaAXUVUVsjgV6mBnGuqgO+JNDlcgF79Dksy4+wgGpQB2lmYoO4TSweFg/mZITdpGHomw/cNBJZj1icA==} + echarts@5.6.0: + resolution: {integrity: sha512-oTbVTsXfKuEhxftHqL5xprgLoc0k7uScAwtryCgWF6hPYFLRwOUHiFmHGCBKP5NPFNkDVopOieyUqYGH8Fa3kA==} emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -1511,6 +1511,9 @@ packages: zrender@5.6.0: resolution: {integrity: sha512-uzgraf4njmmHAbEUxMJ8Oxg+P3fT04O+9p7gY+wJRVxo8Ge+KmYv0WJev945EH4wFuc4OY2NLXz46FZrWS9xJg==} + zrender@5.6.1: + resolution: {integrity: sha512-OFXkDJKcrlx5su2XbzJvj/34Q3m6PvyCZkVPHGYpcCJ52ek4U/ymZyfuV1nKE23AyBJ51E/6Yr0mhZ7xGTO4ag==} + snapshots: '@aashutoshrathi/word-wrap@1.2.6': {} @@ -2134,20 +2137,20 @@ snapshots: eastasianwidth@0.2.0: {} - echarts-gl@2.0.9(echarts@5.5.1): + echarts-gl@2.0.9(echarts@5.6.0): dependencies: claygl: 1.3.0 - echarts: 5.5.1 + echarts: 5.6.0 zrender: 5.6.0 - echarts-liquidfill@3.1.0(echarts@5.5.1): + echarts-liquidfill@3.1.0(echarts@5.6.0): dependencies: - echarts: 5.5.1 + echarts: 5.6.0 - echarts@5.5.1: + echarts@5.6.0: dependencies: tslib: 2.3.0 - zrender: 5.6.0 + zrender: 5.6.1 emoji-regex@8.0.0: {} @@ -2819,3 +2822,7 @@ snapshots: zrender@5.6.0: dependencies: tslib: 2.3.0 + + zrender@5.6.1: + dependencies: + tslib: 2.3.0 diff --git a/src/ECharts.ts b/src/ECharts.ts index 66e2646..743f7a9 100644 --- a/src/ECharts.ts +++ b/src/ECharts.ts @@ -24,7 +24,7 @@ import { import { isOn, omitOn, toValue } from "./utils"; import { register, TAG_NAME } from "./wc"; -import type { PropType, InjectionKey } from "vue"; +import type { PropType, InjectionKey, SlotsType } from "vue"; import type { EChartsType, SetOptionType, @@ -40,6 +40,7 @@ import type { import type { EChartsElement } from "./wc"; import "./style.css"; +import { useTooltip } from "./composables/tooltip"; const wcRegistered = register(); @@ -64,8 +65,11 @@ export default defineComponent({ ...loadingProps, }, emits: {} as unknown as Emits, + slots: Object as SlotsType< + Record<"tooltip" | `tooltip:${string}`, { params: any }> + >, inheritAttrs: false, - setup(props, { attrs, expose }) { + setup(props, { attrs, expose, slots }) { const root = shallowRef(); const chart = shallowRef(); const manualOption = shallowRef