Skip to content

Commit 8ab0a80

Browse files
committed
release: 1.11.0
1 parent f6afeed commit 8ab0a80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+45035
-21543
lines changed
File renamed without changes.

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
node_modules
33
demo/node_modules
4+
demo-ssr/node_modules
45

56
# local env files
67
.env.local
@@ -20,3 +21,12 @@ pnpm-debug.log*
2021
*.njsproj
2122
*.sln
2223
*.sw?
24+
25+
# Test coverage
26+
coverage
27+
.nyc_output
28+
29+
# Demo SSR
30+
demo-ssr/.nuxt
31+
demo-ssr/.output
32+
demo-ssr/dist

README.md

Lines changed: 177 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@
1313

1414
<p align="center"><a href="https://apexcharts.com/vue-chart-demos/"><img src="https://apexcharts.com/media/apexcharts-banner.png"></a></p>
1515

16-
## Download and Installation
16+
## Features
17+
18+
- Reactive chart updates — change props and the chart re-renders automatically
19+
- **Tree-shaking** — import only the chart types and features you use via `vue3-apexcharts/core`
20+
- **Server-Side Rendering (SSR)** — render charts to HTML on the server with `<apexchart-server>` and hydrate on the client with `<apexchart-hydrate>`
21+
- Full TypeScript support
1722

18-
##### Installing via npm
23+
## Download and Installation
1924

2025
```bash
21-
npm install --save apexcharts
22-
npm install --save vue3-apexcharts
26+
npm install apexcharts vue3-apexcharts
2327
```
2428

25-
If you're looking for Vue 2.x.x compatibile component, check-out <a href="https://github.com/apexcharts/vue-apexcharts">vue-apexcharts</a>
29+
If you're looking for Vue 2.x.x compatible component, check-out <a href="https://github.com/apexcharts/vue-apexcharts">vue-apexcharts</a>
2630

2731
## Usage
2832

@@ -245,28 +249,190 @@ More info on the `.exec()` method can be found <a href="https://apexcharts.com/d
245249

246250
All other methods of ApexCharts can be called the same way.
247251

252+
## Tree-Shaking (Core Entry)
253+
254+
The default entry (`vue3-apexcharts`) bundles the full ApexCharts library. If you want to reduce your bundle size by importing only the chart types and features you need, use the **core** entry point:
255+
256+
```js
257+
import VueApexCharts from "vue3-apexcharts/core";
258+
259+
// Import only the chart types you need
260+
import "apexcharts/bar";
261+
import "apexcharts/line";
262+
263+
// Import only the features you need
264+
import "apexcharts/features/legend";
265+
import "apexcharts/features/toolbar";
266+
267+
const app = createApp(App);
268+
app.use(VueApexCharts);
269+
```
270+
271+
The core entry imports ApexCharts from `apexcharts/core`, which is the bare class with only tooltip included. You must explicitly import the chart types and optional features your app uses:
272+
273+
**Chart types:** `apexcharts/line`, `apexcharts/bar`, `apexcharts/pie`, `apexcharts/heatmap`, `apexcharts/candlestick`, `apexcharts/radial`, etc.
274+
275+
**Optional features:**
276+
| Import | Description |
277+
|--------|-------------|
278+
| `apexcharts/features/legend` | Chart legend |
279+
| `apexcharts/features/toolbar` | Toolbar (zoom, pan, download) |
280+
| `apexcharts/features/annotations` | X/Y-axis and point annotations |
281+
| `apexcharts/features/exports` | PNG/SVG/CSV export |
282+
| `apexcharts/features/keyboard` | Keyboard navigation & accessibility |
283+
284+
> **Note:** Tree-shaking requires ApexCharts v5.8.1+.
285+
286+
## Server-Side Rendering (SSR)
287+
288+
Vue3-ApexCharts includes dedicated components for SSR that work with Nuxt 3 and other Vue SSR frameworks.
289+
290+
> **Note:** SSR support requires ApexCharts v5.6.0+.
291+
292+
### Nuxt 3 Setup
293+
294+
Register the plugin so that components are available during both server and client render passes:
295+
296+
```ts
297+
// plugins/apexcharts.ts
298+
import VueApexCharts from "vue3-apexcharts";
299+
300+
export default defineNuxtPlugin({
301+
name: "apexcharts",
302+
parallel: true,
303+
setup(nuxtApp) {
304+
nuxtApp.vueApp.use(VueApexCharts);
305+
},
306+
});
307+
```
308+
309+
### Server-Side Rendering with `<apexchart-server>`
310+
311+
Render charts to HTML on the server — the chart markup is included in the initial page load for better SEO and faster perceived performance:
312+
313+
```vue
314+
<template>
315+
<apexchart-server
316+
type="bar"
317+
:series="series"
318+
:options="options"
319+
:width="500"
320+
:height="300"
321+
/>
322+
</template>
323+
324+
<script setup>
325+
const series = [{ data: [30, 40, 35, 50, 49, 60, 70] }];
326+
const options = {
327+
chart: { type: "bar" },
328+
xaxis: { categories: ["A", "B", "C", "D", "E", "F", "G"] },
329+
};
330+
</script>
331+
```
332+
333+
### SSR + Client Hydration
334+
335+
For interactive charts, pair server rendering with client-side hydration. The chart is rendered on the server, then `<apexchart-hydrate>` finds all server-rendered charts on the page and attaches client-side interactivity (tooltips, animations, click handlers):
336+
337+
```vue
338+
<template>
339+
<apexchart-server
340+
type="line"
341+
:series="series"
342+
:options="options"
343+
:width="700"
344+
:height="350"
345+
/>
346+
347+
<!-- Place once per page — hydrates all server-rendered charts -->
348+
<apexchart-hydrate
349+
:client-options="{
350+
chart: { animations: { enabled: true } },
351+
}"
352+
/>
353+
</template>
354+
355+
<script setup>
356+
const series = [{ name: "Sales", data: [30, 40, 35, 50, 49, 60, 70] }];
357+
const options = {
358+
chart: { type: "line" },
359+
xaxis: { categories: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] },
360+
};
361+
</script>
362+
```
363+
364+
### Client-Only Rendering (Traditional)
365+
366+
For purely client-side rendering in Nuxt, wrap the standard component in `<ClientOnly>`:
367+
368+
```vue
369+
<template>
370+
<ClientOnly>
371+
<apexchart
372+
type="bar"
373+
:series="series"
374+
:options="options"
375+
width="500"
376+
height="300"
377+
/>
378+
</ClientOnly>
379+
</template>
380+
```
381+
382+
### SSR Component Reference
383+
384+
#### `<apexchart-server>`
385+
386+
| Prop | Type | Default | Description |
387+
| ------------- | ------------- | -------- | --------------------------- |
388+
| **type** | String | `'line'` | Chart type |
389+
| **width** | Number/String | `400` | Chart width |
390+
| **height** | Number/String | `300` | Chart height |
391+
| **series** | Array | `[]` | Chart data series |
392+
| **options** | Object | `{}` | ApexCharts configuration |
393+
| **className** | String | `''` | CSS class for the container |
394+
395+
#### `<apexchart-hydrate>`
396+
397+
| Prop | Type | Default | Description |
398+
| ----------------- | ------ | ----------------------------- | ------------------------------------------- |
399+
| **clientOptions** | Object | `{}` | Client-side options merged during hydration |
400+
| **selector** | String | `'[data-apexcharts-hydrate]'` | CSS selector for charts to hydrate |
401+
248402
## Running the examples
249403

250404
Basic Examples are included to show how to get started using ApexCharts with Vue 3 easily.
251405

252-
To run the examples,
253-
254406
```bash
255407
cd demo
256-
yarn install
257-
yarn start
408+
npm install
409+
npm run dev
410+
```
411+
412+
An SSR demo using Nuxt 3 is also available:
413+
414+
```bash
415+
cd demo-ssr
416+
npm install
417+
npm run dev
258418
```
259419

260420
## Development
261421

262422
#### Install dependencies
263423

264424
```bash
265-
yarn install
425+
npm install
266426
```
267427

268428
#### Bundling
269429

270430
```bash
271-
yarn build
431+
npm run build
432+
```
433+
434+
#### Running tests
435+
436+
```bash
437+
npm test
272438
```

demo-ssr/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.nuxt
4+
.nitro
5+
.cache
6+
dist
7+
8+
# Node dependencies
9+
node_modules
10+
11+
# Logs
12+
logs
13+
*.log
14+
15+
# Misc
16+
.DS_Store
17+
.fleet
18+
.idea
19+
20+
# Local env files
21+
.env
22+
.env.*
23+
!.env.example

0 commit comments

Comments
 (0)