-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Rendering tooltips and dataView with slots #838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
34e04a7
feat: experimental component rendered tooltip
kingyue737 79a1d7d
revert slot in VChart
kingyue737 42c3569
feat: use tooltip composable
kingyue737 978317e
feat: try createApp
kingyue737 89743cf
feat: use pie chart as tooltip
kingyue737 585279e
feat: switch to createVNode
kingyue737 c6bab0d
feat: try component with teleport
kingyue737 2072c3b
wip
kingyue737 177e875
add xAxis example
kingyue737 117df61
refactor with shallowReactive
kingyue737 2dccfdb
Support dynamic slot
kingyue737 322fda4
fix: fill empty elements with object in array
kingyue737 49ad09b
shallow copy option along the path
kingyue737 9c2f431
ssr friendly
kingyue737 0acb7b2
vibe docs
kingyue737 3556afe
typo
kingyue737 6aa8d6d
update according to the review
kingyue737 887102d
add dataView slot
kingyue737 c1b76d5
Merge branch '8.0' into tooltip-slot
kingyue737 429943a
fix docs typo
kingyue737 c8a8869
update according to the review
kingyue737 f5fdc88
small fix
kingyue737 49d807b
remove wrapper around slotProp
kingyue737 fe3040a
update comments
kingyue737 c7d9f45
remove anys
kingyue737 7e6132f
add tooltip slot prop type
kingyue737 00f222a
target to vue 3.3
kingyue737 f356f89
move slot related codes to slot.ts
kingyue737 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
export default function getData() { | ||
return { | ||
textStyle: { | ||
fontFamily: 'Inter, "Helvetica Neue", Arial, sans-serif', | ||
fontWeight: 300, | ||
}, | ||
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" }, | ||
}, | ||
], | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<script setup> | ||
import { use } from "echarts/core"; | ||
import { LineChart, PieChart } from "echarts/charts"; | ||
import { | ||
GridComponent, | ||
DatasetComponent, | ||
LegendComponent, | ||
TooltipComponent, | ||
ToolboxComponent, | ||
} from "echarts/components"; | ||
import { shallowRef } from "vue"; | ||
import VChart from "../../src/ECharts"; | ||
import VExample from "./Example.vue"; | ||
import getData from "../data/line"; | ||
|
||
use([ | ||
DatasetComponent, | ||
GridComponent, | ||
LegendComponent, | ||
LineChart, | ||
TooltipComponent, | ||
ToolboxComponent, | ||
PieChart, | ||
]); | ||
|
||
const option = shallowRef(getData()); | ||
const axis = shallowRef("xAxis"); | ||
|
||
function getPieOption(params) { | ||
const option = { | ||
dataset: { source: [params[0].dimensionNames, params[0].data] }, | ||
series: [ | ||
{ | ||
type: "pie", | ||
radius: ["60%", "100%"], | ||
seriesLayoutBy: "row", | ||
itemStyle: { | ||
borderRadius: 5, | ||
borderColor: "#fff", | ||
borderWidth: 2, | ||
}, | ||
label: { | ||
position: "center", | ||
formatter: params[0].name, | ||
fontFamily: 'Inter, "Helvetica Neue", Arial, sans-serif', | ||
fontWeight: 300, | ||
}, | ||
}, | ||
], | ||
}; | ||
return option; | ||
} | ||
</script> | ||
|
||
<template> | ||
<v-example | ||
id="line" | ||
title="Line chart" | ||
desc="(with tooltip and dataView slots)" | ||
> | ||
<v-chart :option="option" autoresize> | ||
<template #tooltip="params"> | ||
<v-chart | ||
:style="{ width: '100px', height: '100px' }" | ||
:option="getPieOption(params)" | ||
autoresize | ||
/> | ||
</template> | ||
<template #[`tooltip-${axis}`]="params"> | ||
{{ axis === "xAxis" ? "Year" : "Value" }}: | ||
<b>{{ params.name }}</b> | ||
</template> | ||
<template #dataView="option"> | ||
<table style="margin: 20px auto"> | ||
<thead> | ||
<tr> | ||
<th v-for="(t, i) in option.dataset[0].source[0]" :key="i"> | ||
{{ t }} | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="(row, i) in option.dataset[0].source.slice(1)" :key="i"> | ||
<th>{{ row[0] }}</th> | ||
<td v-for="(v, i) in row.slice(1)" :key="i">{{ v }}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</template> | ||
</v-chart> | ||
<template #extra> | ||
<p class="actions"> | ||
Custom tooltip on | ||
<select v-model="axis"> | ||
<option value="xAxis">X Axis</option> | ||
<option value="yAxis">Y Axis</option> | ||
</select> | ||
</p> | ||
</template> | ||
</v-example> | ||
</template> | ||
|
||
<style scoped> | ||
th, | ||
td { | ||
padding: 4px 8px; | ||
} | ||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.