apexcharts-skill 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,32 @@
1
- # Tree-Shaking & Bundle Optimization — ApexCharts
1
+ # Bundle Tiers, Tree-Shaking & Optimization: ApexCharts
2
+
3
+ ## ⚠️ What changed in v7.0
4
+
5
+ **In v6, the default bundle contained every feature. In v7 it does not.** Nine features are **Tier 2**: shipped in the package, absent from every bundle, and reachable only through an explicit import. This applies to the default `apexcharts` bundle, not just to tree-shaken builds, and it is the most common v6 → v7 upgrade failure.
6
+
7
+ ```js
8
+ import ApexCharts from 'apexcharts'
9
+ import 'apexcharts/features/trellis' // Tier 2: required even on the default bundle
10
+ ```
11
+
12
+ | | gzip |
13
+ |---|---|
14
+ | 6.10.0 default bundle | 291,654 B |
15
+ | 7.0.0 default bundle | 252,005 B (**-13.6%**) |
16
+ | 7.1.0 default bundle | 264,326 B (three new chart types) |
17
+
18
+ If you use none of the nine, upgrading is `npm install apexcharts@7` and nothing else.
2
19
 
3
20
  ## Overview
4
21
 
5
- ApexCharts supports three import strategies with different bundle sizes:
22
+ ApexCharts supports four import strategies with different bundle sizes:
6
23
 
7
24
  | Strategy | Import | Includes |
8
25
  |---|---|---|
9
- | Full bundle | `import ApexCharts from 'apexcharts'` | All chart types + all features |
10
- | Per-type entry | `import ApexCharts from 'apexcharts/line'` | Specific chart family + core (no optional features) |
26
+ | Default bundle | `import ApexCharts from 'apexcharts'` | Every chart type except `raincloud`, plus the **Tier 1** features. **Not** the nine Tier 2 features. |
27
+ | Per-type entry | `import ApexCharts from 'apexcharts/line'` | Specific chart family + core (no optional features at all) |
11
28
  | Bare core | `import ApexCharts from 'apexcharts/core'` | Core class only — must manually register everything |
29
+ | Lean core, no bundler *(v7.0)* | `<script src=".../dist/apexcharts.core.js">` | Script-tag equivalent of bare core, assembled from separate tags. See below. |
12
30
 
13
31
  ---
14
32
 
@@ -26,9 +44,14 @@ Each entry point registers a family of related chart types:
26
44
  | `apexcharts/bar` | bar, column, rangeBar |
27
45
  | `apexcharts/column` | same as /bar |
28
46
  | `apexcharts/rangeBar` | same as /bar |
47
+ | `apexcharts/waterfall` | waterfall *(new in v7.1)*: the bar engine plus the waterfall feature |
48
+ | `apexcharts/dumbbell` | dumbbell *(new in v7.1)*: the bar engine plus the dumbbell feature |
49
+ | `apexcharts/streamgraph` | streamgraph *(new in v7.1)*: the rangeArea engine plus the streamgraph feature |
29
50
  | `apexcharts/candlestick` | candlestick, boxPlot |
30
51
  | `apexcharts/boxPlot` | same as /candlestick |
31
52
  | `apexcharts/violin` | violin *(new in v6)* |
53
+ | `apexcharts/raincloud` | raincloud *(new in v7.1, premium)*: the violin engine plus the raincloud feature. **Tier 2**: the only chart type absent from the default bundle. |
54
+ | `apexcharts/histogram` | histogram *(new in v6.9)*: the bar engine plus the stats feature |
32
55
  | `apexcharts/pie` | pie, donut, polarArea |
33
56
  | `apexcharts/donut` | same as /pie |
34
57
  | `apexcharts/polarArea` | same as /pie |
@@ -38,8 +61,20 @@ Each entry point registers a family of related chart types:
38
61
  | `apexcharts/treemap` | treemap |
39
62
  | `apexcharts/sunburst` | sunburst *(new in v6.7, free)* |
40
63
  | `apexcharts/unit` | unit, **waffle** *(new in v6.6, premium: watermarked until licensed)* |
64
+ | `apexcharts/unit-shapes` | *(new in v6.10)* not a chart entry: named shape exports for the unit chart (`heart`, `house`, ... plus `outlined`, `glyphs`, `preview`), tree-shaken per shape (~4 KB gzipped each). See `references/circular-charts.md`. |
65
+ | `apexcharts/pictograms` | *(new in v7.0)* not a chart entry: a drawn glyph per unit for the unit chart (`person`, `house`, `heart`, `tree`, `droplet`, `star`, `car`, `bag`, `book`, `cup`, `bulb`, `plane`), plus `definePictogram` / `registerMarks` / `catalog`. Import the glyph you use, not `catalog`, which ships all of them. |
66
+
67
+ **First-class aliases:** `funnel` and `pyramid` render through the bar engine, so `apexcharts/bar` covers them. `gauge` renders through radialBar, so `apexcharts/radialBar` covers it. There is no separate `apexcharts/funnel`, `apexcharts/pyramid`, or `apexcharts/gauge` entry.
41
68
 
42
- **v6 first-class aliases:** `funnel` and `pyramid` render through the bar engine, so `apexcharts/bar` covers them. `gauge` renders through radialBar, so `apexcharts/radialBar` covers it. There is no separate `apexcharts/funnel`, `apexcharts/pyramid`, or `apexcharts/gauge` entry.
69
+ **Entries that bundle a feature.** Four types render through an existing engine but have their own entry because that entry also pulls in a feature module. Each is equivalent to the engine entry plus the feature:
70
+
71
+ | Entry | Equivalent to |
72
+ |---|---|
73
+ | `apexcharts/histogram` | `apexcharts/bar` + `import 'apexcharts/features/stats'` |
74
+ | `apexcharts/waterfall` | `apexcharts/bar` + `import 'apexcharts/features/waterfall'` |
75
+ | `apexcharts/dumbbell` | `apexcharts/bar` + `import 'apexcharts/features/dumbbell'` |
76
+ | `apexcharts/streamgraph` | `apexcharts/rangeArea` + `import 'apexcharts/features/streamgraph'` |
77
+ | `apexcharts/raincloud` | `apexcharts/violin` + `import 'apexcharts/features/raincloud'` |
43
78
 
44
79
  ### Using Multiple Chart Types
45
80
 
@@ -51,9 +86,16 @@ import 'apexcharts/bar' // side-effect: registers bar types onto the same clas
51
86
 
52
87
  ---
53
88
 
54
- ## Optional Features
89
+ ## Optional Features: Tier 1 vs Tier 2
90
+
91
+ Two questions decide whether you need a `features/*` import:
92
+
93
+ 1. **Which entry point did you start from?** `apexcharts/core` and the per-type entries carry no optional features at all, so every feature you want needs its import.
94
+ 2. **Which tier is the feature?** Tier 1 is in the default `apexcharts` bundle. **Tier 2 is in no bundle**, so it needs its import even there.
95
+
96
+ ### Tier 1: in the default `apexcharts` bundle
55
97
 
56
- Features are optional modules that add functionality. When using per-type entries or core, features must be explicitly imported.
98
+ Import these only when you started from `/core` or a per-type entry.
57
99
 
58
100
  | Feature | Import | What It Adds |
59
101
  |---|---|---|
@@ -62,31 +104,79 @@ Features are optional modules that add functionality. When using per-type entrie
62
104
  | Annotations | `import 'apexcharts/features/annotations'` | X/Y/point/text/image annotations |
63
105
  | Exports | `import 'apexcharts/features/exports'` | `dataURI()`, `getSvgString()`, `exportToCSV()` |
64
106
  | Keyboard | `import 'apexcharts/features/keyboard'` | Keyboard navigation (accessibility) |
65
- | Morph *(v6)* | `import 'apexcharts/features/morph'` | Animated chart-type morphs |
66
- | Drilldown *(v6)* | `import 'apexcharts/features/drilldown'` | Hierarchical drill-down |
67
- | History / Rewind *(v6)* | `import 'apexcharts/features/history'` | Undo/redo (`chart.history`) |
68
- | Perspectives *(v6)* | `import 'apexcharts/features/perspectives'` | Shareable view state |
69
- | Storyboard *(v6)* | `import 'apexcharts/features/storyboard'` | Scrollytelling (includes perspectives) |
70
- | Facet *(v6)* | `import 'apexcharts/features/facet'` | Design tokens + OS-aware themes |
71
- | Weave *(v6)* | `import 'apexcharts/features/weave'` | Public plugin platform |
72
- | Renderer / Strata *(v6)* | `import 'apexcharts/features/renderer-canvas'` | Hybrid SVG + canvas renderer |
73
- | Marks *(v6)* | `import 'apexcharts/features/marks'` | Custom series types (`registerSeriesType`) |
74
- | Link *(v6)* | `import 'apexcharts/features/link'` | Crossfilter / linked views |
75
- | Ink *(v6)* | `import 'apexcharts/features/ink'` | On-chart annotation authoring |
76
- | Measure *(v6)* | `import 'apexcharts/features/measure'` | Measure / delta ruler |
77
- | Context menu *(v6)* | `import 'apexcharts/features/context-menu'` | Right-click / long-press context menu |
78
- | All | `import 'apexcharts/features/all'` | All of the above |
79
-
80
- **Important:** Tooltip is always included in core (it cannot be tree-shaken). Easing (Cadence) and real-time streaming are also core, so they need no feature import. See `v6-features.md` for the config and API of each v6 feature.
107
+ | Stats *(v6.9)* | `import 'apexcharts/features/stats'` | Histogram binning, boxPlot/violin raw-sample summaries, `rowSeries()` |
108
+ | Morph | `import 'apexcharts/features/morph'` | Animated chart-type morphs |
109
+ | Drilldown | `import 'apexcharts/features/drilldown'` | Hierarchical drill-down |
110
+ | Facet | `import 'apexcharts/features/facet'` | Design tokens + OS-aware themes |
111
+ | Weave | `import 'apexcharts/features/weave'` | Public plugin platform |
112
+ | Marks | `import 'apexcharts/features/marks'` | Custom series types (`registerSeriesType`) |
113
+ | Waterfall *(v7.1)* | `import 'apexcharts/features/waterfall'` | The `waterfall` chart type |
114
+ | Dumbbell *(v7.1)* | `import 'apexcharts/features/dumbbell'` | The `dumbbell` chart type |
115
+ | Streamgraph *(v7.1)* | `import 'apexcharts/features/streamgraph'` | The `streamgraph` chart type |
116
+ | All Tier 1 | `import 'apexcharts/features/all'` | Every row above, and **only** those |
117
+
118
+ Tier 1 is a **budget, not an index**: upstream, a module earns a place only if it is under ~5 KB gzipped on top of core, needs no peer dependency or separate asset, and is useful to a majority of charts. The first seven predate the budget and are grandfathered.
119
+
120
+ ### Tier 2: in NO bundle; always an explicit import
121
+
122
+ Required whatever entry point you used, the default `apexcharts` bundle included.
123
+
124
+ | Feature | Import | gzip | Premium | What It Adds |
125
+ |---|---|---|---|---|
126
+ | Trellis *(v7.0)* | `import 'apexcharts/features/trellis'` | 25.7 KB | yes | Small multiples: a grid of real charts sharing scale, legend, toolbar, crosshair |
127
+ | Storyboard | `import 'apexcharts/features/storyboard'` | 8.0 KB | yes | Scrollytelling (registers Perspectives too) |
128
+ | Perspectives | `import 'apexcharts/features/perspectives'` | 6.7 KB | yes | Shareable view state |
129
+ | Ink | `import 'apexcharts/features/ink'` | 6.2 KB | yes | On-chart annotation authoring |
130
+ | Renderer / Strata | `import 'apexcharts/features/renderer-canvas'` | 6.0 KB | no | Hybrid SVG + canvas renderer |
131
+ | Link | `import 'apexcharts/features/link'` | 5.3 KB | yes | Crossfilter / linked views |
132
+ | Measure | `import 'apexcharts/features/measure'` | 4.6 KB | yes | Measure / delta ruler |
133
+ | History / Rewind | `import 'apexcharts/features/history'` | 3.2 KB | yes | Undo/redo (`chart.history`) |
134
+ | Context menu | `import 'apexcharts/features/context-menu'` | 2.3 KB | yes | Right-click / long-press context menu |
135
+ | Raincloud *(v7.1)* | `import 'apexcharts/features/raincloud'` | n/a | yes | The `raincloud` chart type (or use the `apexcharts/raincloud` entry) |
136
+
137
+ Storyboard registers Perspectives, so importing both costs no more than Storyboard alone.
138
+
139
+ **`apexcharts/features/all` does not include Tier 2**, by design: upstream has a tier-budget test that fails the build if a Tier 2 feature reappears in it.
140
+
141
+ **Nothing fails silently on Tier 2.** Each module warns in the console when its configuration is present but the module is not, and the warning names both the ESM and script-tag route. Where the chart can still draw something sensible it does and says what it did instead: a trellis renders as a single chart, `renderer: 'canvas'` falls back to SVG.
142
+
143
+ ---
144
+
145
+ ## Script tags: the lean core channel (v7.0)
146
+
147
+ Tree-shaking only ever helped people with a build step. A page using a `<script>` tag had one artifact and no way to decline any of it. `dist/apexcharts.core.js` is the chart class with no chart types and no optional features, assembled from separate tags:
148
+
149
+ ```html
150
+ <script src=".../dist/apexcharts.core.js"></script>
151
+ <script src=".../dist/line.js"></script>
152
+ <script src=".../dist/features/legend.js"></script>
153
+ ```
154
+
155
+ **136,921 B gzipped**, against 252,005 for the full bundle. Purely additive: `apexcharts.js` is unchanged, and a page that wants everything should keep loading it rather than assembling it from parts.
156
+
157
+ Every Tier 2 feature has a `dist/features/<name>.js` artifact for this channel too, and a full-bundle page still needs it:
158
+
159
+ ```html
160
+ <script src=".../dist/apexcharts.js"></script>
161
+ <script src=".../dist/features/trellis.js"></script>
162
+ ```
163
+
164
+ **Important:** Tooltip is always included in core (it cannot be tree-shaken). Easing (Cadence) and real-time streaming are also core, so they need no feature import. See `feature-platform.md` for the config and API of each feature.
165
+
166
+ **Runtime dependency (v6.9):** ApexCharts is no longer dependency-free: it depends on `apex-commons` at runtime (license manager, crossfilter engine, spring primitives shared across the ApexCharts family). npm resolves it automatically, and the browser (script-tag) bundles inline it, so no configuration is needed; bundlers just see one more resolvable package. The `apexcharts/unit` and `apexcharts/unit-shapes` sub-entry points resolve for bundlers and script tags alike (from a script tag, `dist/unit-shapes.js` exposes the global `ApexUnitShapes`).
81
167
 
82
168
  ### What Happens If You Forget a Feature
83
169
 
84
- Features fail **silently**. If you use a per-type entry without importing legend:
170
+ It depends on the tier.
171
+
172
+ **Tier 1 features fail silently.** If you use a per-type entry without importing legend:
85
173
  - No legend appears, no error thrown
86
174
  - `chart.toolbar` is undefined, toolbar doesn't render
87
175
  - `addXaxisAnnotation()` does nothing
88
176
  - `dataURI()` / `exportToCSV()` throw because the feature isn't registered
89
177
 
178
+ **Tier 2 features announce themselves.** Each warns in the console when its configuration is present but the module is not, naming both the ESM and the script-tag route, and degrades predictably where it can: a `trellis` config renders as one ordinary chart, `renderer: 'canvas'` falls back to SVG. If a v7 chart is quietly missing a feature you configured, **check the console before the config**.
179
+
90
180
  ---
91
181
 
92
182
  ## Bare Core Usage
@@ -166,7 +256,10 @@ export default {
166
256
 
167
257
  ## Common Pitfalls
168
258
 
169
- 1. **Missing feature imports** — features fail silently. If legend/toolbar/annotations don't appear, check imports.
170
- 2. **Importing `apexcharts` AND `apexcharts/line`** — creates duplicate bundles. Use one strategy.
171
- 3. **Vite duplicate bundle issue** — without `optimizeDeps.include`, Vite may bundle ApexCharts twice.
172
- 4. **Calling `dataURI()` without exports feature** — throws an error. Import `apexcharts/features/exports` first.
259
+ 1. **Assuming the default bundle still has everything *(v7)***: the nine Tier 2 features and the `raincloud` type need their own import on top of `import ApexCharts from 'apexcharts'`. This is the most common v6 → v7 upgrade failure.
260
+ 2. **Reaching for `apexcharts/features/all` to fix it**: that is the Tier 1 set by design and pulls in no Tier 2 module.
261
+ 3. **Missing feature imports on a tree-shaken build**: Tier 1 features fail silently. If legend/toolbar/annotations don't appear, check imports.
262
+ 4. **Importing `apexcharts` AND `apexcharts/line`**: creates duplicate bundles. Use one strategy. *(v7.0 fixed the related internal bug where the default bundle inlined its own core copy while add-ons resolved `apexcharts/core`, so an app importing both got two classes, ~130 KB gzipped of duplicate core, and a feature that never registered. They now share one core.)*
263
+ 5. **Vite duplicate bundle issue**: without `optimizeDeps.include`, Vite may bundle ApexCharts twice.
264
+ 6. **Calling `dataURI()` without exports feature**: throws an error. Import `apexcharts/features/exports` first.
265
+ 7. **`require('apexcharts/line')` used to throw** `h.use is not a function` in every published version with sub-path entries, because rollup's default CJS interop assumes `require()` returns the export itself. Fixed in **7.0.0**; below that, use ESM `import` for sub-path entries.