-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat!: remove vue 2 #830
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
feat!: remove vue 2 #830
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0d7a7eb
feat!: remove vue 2
kingyue737 49e2639
docs: remove vue 2 related content
kingyue737 d1ea0fb
feat: support getter in provide/inject
kingyue737 44a4a6c
refactor: simplify render function
kingyue737 667ef7b
docs: update provide/inject section
kingyue737 ea4325e
refactor: rename realListeners to listeners
kingyue737 ed91e2a
refactor: change listeners from object to Map
kingyue737 4bceb23
chore: remove @vue/runtime-core from peerDependencies
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,100 +96,6 @@ const option = ref({ | |
|
||
</details> | ||
|
||
<details> | ||
<summary>Vue 2 <a href="https://stackblitz.com/edit/vue-echarts-vue-2?file=src%2FApp.vue">Demo →</a></summary> | ||
|
||
```vue | ||
<template> | ||
<v-chart class="chart" :option="option" /> | ||
</template> | ||
|
||
<script> | ||
import { use } from "echarts/core"; | ||
import { CanvasRenderer } from "echarts/renderers"; | ||
import { PieChart } from "echarts/charts"; | ||
import { | ||
TitleComponent, | ||
TooltipComponent, | ||
LegendComponent | ||
} from "echarts/components"; | ||
import VChart, { THEME_KEY } from "vue-echarts"; | ||
|
||
use([ | ||
CanvasRenderer, | ||
PieChart, | ||
TitleComponent, | ||
TooltipComponent, | ||
LegendComponent | ||
]); | ||
|
||
export default { | ||
name: "HelloWorld", | ||
components: { | ||
VChart | ||
}, | ||
provide: { | ||
[THEME_KEY]: "dark" | ||
}, | ||
data() { | ||
return { | ||
option: { | ||
title: { | ||
text: "Traffic Sources", | ||
left: "center" | ||
}, | ||
tooltip: { | ||
trigger: "item", | ||
formatter: "{a} <br/>{b} : {c} ({d}%)" | ||
}, | ||
legend: { | ||
orient: "vertical", | ||
left: "left", | ||
data: [ | ||
"Direct", | ||
"Email", | ||
"Ad Networks", | ||
"Video Ads", | ||
"Search Engines" | ||
] | ||
}, | ||
series: [ | ||
{ | ||
name: "Traffic Sources", | ||
type: "pie", | ||
radius: "55%", | ||
center: ["50%", "60%"], | ||
data: [ | ||
{ value: 335, name: "Direct" }, | ||
{ value: 310, name: "Email" }, | ||
{ value: 234, name: "Ad Networks" }, | ||
{ value: 135, name: "Video Ads" }, | ||
{ value: 1548, name: "Search Engines" } | ||
], | ||
emphasis: { | ||
itemStyle: { | ||
shadowBlur: 10, | ||
shadowOffsetX: 0, | ||
shadowColor: "rgba(0, 0, 0, 0.5)" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}; | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.chart { | ||
height: 400px; | ||
} | ||
</style> | ||
``` | ||
|
||
</details> | ||
|
||
> [!IMPORTANT] | ||
> We encourage manually importing components and charts from ECharts for smaller bundle size. We've built an [import code generator](https://vue-echarts.dev/#codegen) to help you with that. You can just paste in your `option` code and we'll generate the precise import code for you. | ||
> | ||
|
@@ -212,7 +118,7 @@ Drop `<script>` inside your HTML file and access the component via `window.VueEC | |
|
||
<!-- vue3Scripts:start --> | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/vue@3.4.33"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue@3.5.13"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
``` | ||
|
@@ -227,24 +133,6 @@ app.component('v-chart', VueECharts) | |
|
||
</details> | ||
|
||
<details> | ||
<summary>Vue 2 <a href="https://stackblitz.com/edit/vue-echarts-vue-2-global?file=index.html">Demo →</a></summary> | ||
|
||
<!-- vue2Scripts:start --> | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
``` | ||
<!-- vue2Scripts:end --> | ||
|
||
```js | ||
// register globally (or you can do it locally) | ||
Vue.component("v-chart", VueECharts); | ||
``` | ||
|
||
</details> | ||
|
||
See more examples [here](https://github.com/ecomfe/vue-echarts/tree/main/src/demo). | ||
|
||
### Props | ||
|
@@ -359,7 +247,7 @@ See supported events [here →](https://echarts.apache.org/en/api.html#events) | |
|
||
#### Native DOM Events | ||
|
||
As Vue-ECharts binds events to the ECharts instance by default, there is some caveat when using native DOM events. You need to prefix the event name with `native:` to bind native DOM events (or you can use the `.native` modifier in Vue 2, which is dropped in Vue 3). | ||
As Vue-ECharts binds events to the ECharts instance by default, there is some caveat when using native DOM events. You need to prefix the event name with `native:` to bind native DOM events. | ||
|
||
```vue | ||
<template> | ||
|
@@ -369,61 +257,56 @@ As Vue-ECharts binds events to the ECharts instance by default, there is some ca | |
|
||
### Provide / Inject | ||
|
||
Vue-ECharts provides provide/inject API for `theme`, `init-options`, `update-options` and `loading-options` to help configuring contextual options. eg. for `init-options` you can use the provide API like this: | ||
Vue-ECharts provides provide/inject API for `theme`, `init-options`, `update-options` and `loading-options` to help configuring contextual options. eg. for `theme` you can use the provide API like this: | ||
|
||
<details> | ||
<summary>Vue 3</summary> | ||
<summary>Composition API</summary> | ||
|
||
```js | ||
import { THEME_KEY } from 'vue-echarts' | ||
import { provide } from 'vue' | ||
|
||
// composition API | ||
provide(THEME_KEY, 'dark') | ||
|
||
// options API | ||
{ | ||
provide: { | ||
[THEME_KEY]: 'dark' | ||
} | ||
} | ||
// or provide a ref | ||
const theme = ref('dark') | ||
provide(THEME_KEY, theme) | ||
|
||
// getter is also supported | ||
provide(THEME_KEY, () => theme.value) | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>Vue 2</summary> | ||
<summary>Options API</summary> | ||
|
||
```js | ||
import { THEME_KEY } from 'vue-echarts' | ||
import { computed } from 'vue' | ||
|
||
// in component options | ||
{ | ||
provide: { | ||
[THEME_KEY]: 'dark' | ||
export default { | ||
{ | ||
provide: { | ||
[THEME_KEY]: 'dark' | ||
} | ||
} | ||
} | ||
``` | ||
|
||
> **Note** | ||
> | ||
> You need to provide an object for Vue 2 if you want to change it dynamically. | ||
> | ||
> ```js | ||
> // in component options | ||
> { | ||
> data () { | ||
> return { | ||
> theme: { value: 'dark' } | ||
> } | ||
> }, | ||
> provide () { | ||
> return { | ||
> [THEME_KEY]: this.theme | ||
> } | ||
> } | ||
> } | ||
> ``` | ||
// Or make injections reactive | ||
export default { | ||
data() { | ||
return { | ||
theme: 'dark' | ||
} | ||
}, | ||
provide() { | ||
return { | ||
[THEME_KEY]: computed(() => this.theme) | ||
} | ||
} | ||
} | ||
``` | ||
kingyue737 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
</details> | ||
|
||
|
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.