apexcharts-skill 1.2.1 → 1.2.2
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.
- package/.cursorrules +245 -0
- package/install/claude-code.md +25 -0
- package/install/copilot.md +23 -0
- package/install/cursor.md +27 -0
- package/package.json +4 -2
package/.cursorrules
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# ApexCharts.js — AI Coding Rules
|
|
2
|
+
|
|
3
|
+
You are working with ApexCharts.js, a JavaScript charting library.
|
|
4
|
+
Documentation: https://apexcharts.com/docs/
|
|
5
|
+
NPM: apexcharts
|
|
6
|
+
GitHub: https://github.com/apexcharts/apexcharts.js
|
|
7
|
+
|
|
8
|
+
## Framework wrapper detection — check `package.json` first
|
|
9
|
+
|
|
10
|
+
- `react` → use **`react-apexcharts`** instead of the core API.
|
|
11
|
+
- `vue` (Vue 3) → use **`vue3-apexcharts`**. Vue 2 → **`vue-apexcharts`**.
|
|
12
|
+
- `@angular/core` → use **`ng-apexcharts`**.
|
|
13
|
+
|
|
14
|
+
Wrappers handle `destroy()` automatically on unmount, accept reactive props, and forward events idiomatically. Use the core API directly only when no framework is detected, or when the user explicitly asks for vanilla.
|
|
15
|
+
|
|
16
|
+
## Critical Rules
|
|
17
|
+
|
|
18
|
+
1. **Always call `chart.render()`** after `new ApexCharts(el, options)`. The constructor does not render.
|
|
19
|
+
2. **Always call `chart.destroy()`** before creating a new chart on the same element.
|
|
20
|
+
3. **Series data format is chart-type-specific.** See the Data Format Table below.
|
|
21
|
+
4. **`yaxis` must be an array** when using multiple y-axes. Each entry needs `seriesName`.
|
|
22
|
+
5. **`tooltip.shared` and `tooltip.intersect` are mutually exclusive.**
|
|
23
|
+
6. **Use `null` (not `undefined`)** for missing data points.
|
|
24
|
+
7. **`chart.stacked: true`** only works with `bar` and `area` chart types.
|
|
25
|
+
8. **Responsive breakpoints** must be in ascending order.
|
|
26
|
+
9. **For mixed/combo charts**, set `type` on each series object.
|
|
27
|
+
10. **RadialBar values must be 0–100** (percentages).
|
|
28
|
+
11. **Color hex values must include `#`** (e.g., `'#FF5733'`).
|
|
29
|
+
12. **Tree-shaking**: `apexcharts/core` requires separate chart-type + feature imports.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Series Data Format Table
|
|
34
|
+
|
|
35
|
+
### Axis Charts
|
|
36
|
+
|
|
37
|
+
| Chart Type | `chart.type` | Series Format | Example |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| Line | `'line'` | `[{ name, data: [num\|null] }]` or `[{ name, data: [{ x, y }] }]` | `[{ data: [30, 40, null, 50] }]` |
|
|
40
|
+
| Area | `'area'` | Same as line | `[{ data: [10, 20, 30] }]` |
|
|
41
|
+
| Bar/Column | `'bar'` | Same as line. `plotOptions.bar.horizontal: false` for columns. | `[{ data: [44, 55, 41] }]` |
|
|
42
|
+
| Scatter | `'scatter'` | `[{ name, data: [{ x, y }] }]` | `[{ data: [{ x: 1, y: 5 }] }]` |
|
|
43
|
+
| Bubble | `'bubble'` | `[{ name, data: [{ x, y, z }] }]` — z required | `[{ data: [{ x: 1, y: 30, z: 10 }] }]` |
|
|
44
|
+
| Range Area | `'rangeArea'` | `[{ data: [{ x, y: [low, high] }] }]` | `[{ data: [{ x: 'Jan', y: [5, 15] }] }]` |
|
|
45
|
+
| Range Bar | `'rangeBar'` | `[{ data: [{ x, y: [start, end] }] }]` | `[{ data: [{ x: 'Task', y: [1, 5] }] }]` |
|
|
46
|
+
| Candlestick | `'candlestick'` | `[{ data: [{ x, y: [O,H,L,C] }] }]` — 4 values | `[{ data: [{ x: new Date(), y: [51,56,48,53] }] }]` |
|
|
47
|
+
| Box Plot | `'boxPlot'` | `[{ data: [{ x, y: [min,Q1,med,Q3,max] }] }]` — 5 values | `[{ data: [{ x: 'A', y: [10,20,30,40,50] }] }]` |
|
|
48
|
+
| Heatmap | `'heatmap'` | `[{ name, data: [{ x, y: number }] }]` — y is intensity | `[{ name: 'Mon', data: [{ x: '10am', y: 45 }] }]` |
|
|
49
|
+
| Treemap | `'treemap'` | `[{ data: [{ x, y: number }] }]` — y is area value | `[{ data: [{ x: 'Item', y: 100 }] }]` |
|
|
50
|
+
| Radar | `'radar'` | `[{ name, data: [num] }]` + `xaxis.categories` | `[{ data: [80, 50, 30] }]` |
|
|
51
|
+
|
|
52
|
+
### Non-Axis Charts (flat number array — NOT object format)
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
// Pie, Donut, Polar Area
|
|
56
|
+
{ chart: { type: 'pie' }, series: [44, 55, 13], labels: ['A', 'B', 'C'] }
|
|
57
|
+
|
|
58
|
+
// Radial Bar (values 0–100)
|
|
59
|
+
{ chart: { type: 'radialBar' }, series: [76, 67, 61], labels: ['X', 'Y', 'Z'] }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Core Lifecycle
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
import ApexCharts from 'apexcharts'
|
|
68
|
+
|
|
69
|
+
const chart = new ApexCharts(document.querySelector('#chart'), {
|
|
70
|
+
chart: { type: 'line', height: 350 },
|
|
71
|
+
series: [{ name: 'Sales', data: [30, 40, 35, 50] }],
|
|
72
|
+
xaxis: { categories: ['Q1', 'Q2', 'Q3', 'Q4'] }
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
await chart.render() // REQUIRED
|
|
76
|
+
await chart.updateSeries([{ data: [10, 20, 30, 40] }]) // update data
|
|
77
|
+
await chart.updateOptions({ title: { text: 'New' } }) // update config
|
|
78
|
+
chart.destroy() // cleanup
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Import Paths
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
apexcharts # Full bundle (all types + features)
|
|
87
|
+
apexcharts/core # Bare core (must register types + features manually)
|
|
88
|
+
apexcharts/line # line, area, scatter, bubble, rangeArea
|
|
89
|
+
apexcharts/bar # bar, column, rangeBar
|
|
90
|
+
apexcharts/candlestick # candlestick, boxPlot
|
|
91
|
+
apexcharts/pie # pie, donut, polarArea
|
|
92
|
+
apexcharts/radialBar # radialBar
|
|
93
|
+
apexcharts/radar # radar
|
|
94
|
+
apexcharts/heatmap # heatmap
|
|
95
|
+
apexcharts/treemap # treemap
|
|
96
|
+
apexcharts/ssr # Server-side rendering (Node.js)
|
|
97
|
+
apexcharts/client # Explicit browser import
|
|
98
|
+
|
|
99
|
+
# Optional features (side-effect imports)
|
|
100
|
+
apexcharts/features/exports # dataURI(), exportToCSV()
|
|
101
|
+
apexcharts/features/legend # Legend component
|
|
102
|
+
apexcharts/features/toolbar # Zoom, pan, download
|
|
103
|
+
apexcharts/features/annotations # X/Y/point annotations
|
|
104
|
+
apexcharts/features/keyboard # Keyboard navigation
|
|
105
|
+
apexcharts/features/all # All features
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Formatter Signatures
|
|
111
|
+
|
|
112
|
+
| Config Path | Signature |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `xaxis.labels.formatter` | `(value, timestamp?, opts?) => string` |
|
|
115
|
+
| `yaxis.labels.formatter` | `(value, opts?) => string` |
|
|
116
|
+
| `tooltip.x.formatter` | `(value, opts?) => string` |
|
|
117
|
+
| `tooltip.y.formatter` | `(value, opts?) => string` |
|
|
118
|
+
| `tooltip.y.title.formatter` | `(seriesName, opts?) => string` |
|
|
119
|
+
| `dataLabels.formatter` | `(value, opts?) => string \| number` |
|
|
120
|
+
| `legend.formatter` | `(legendName, opts?) => string` |
|
|
121
|
+
| `plotOptions.pie.donut.labels.total.formatter` | `(w) => string` |
|
|
122
|
+
| `plotOptions.radialBar.dataLabels.value.formatter` | `(val) => string` |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Pitfalls — ❌ Wrong vs ✅ Correct
|
|
127
|
+
|
|
128
|
+
### 1. Pie/donut data format
|
|
129
|
+
❌ `{ chart: { type: 'pie' }, series: [{ name: 'A', data: [44, 55] }] }`
|
|
130
|
+
✅ `{ chart: { type: 'pie' }, series: [44, 55], labels: ['A', 'B'] }`
|
|
131
|
+
|
|
132
|
+
### 2. Missing render()
|
|
133
|
+
❌ `const chart = new ApexCharts(el, opts)` — nothing displays
|
|
134
|
+
✅ `const chart = new ApexCharts(el, opts); await chart.render()`
|
|
135
|
+
|
|
136
|
+
### 3. React/Vue memory leak
|
|
137
|
+
❌ No cleanup on unmount
|
|
138
|
+
✅ `useEffect(() => { const c = new ApexCharts(el, opts); c.render(); return () => c.destroy() }, [])`
|
|
139
|
+
|
|
140
|
+
### 4. Datetime axis with strings
|
|
141
|
+
❌ `xaxis: { type: 'datetime' }, data: [{ x: 'January 2024', y: 30 }]`
|
|
142
|
+
✅ `xaxis: { type: 'datetime' }, data: [{ x: new Date('2024-01-01').getTime(), y: 30 }]`
|
|
143
|
+
|
|
144
|
+
### 5. Multiple y-axes as object
|
|
145
|
+
❌ `yaxis: { title: { text: 'Value' } }`
|
|
146
|
+
✅ `yaxis: [{ seriesName: 'Revenue', title: {...} }, { seriesName: 'Profit', opposite: true }]`
|
|
147
|
+
|
|
148
|
+
### 6. Both shared and intersect tooltips
|
|
149
|
+
❌ `tooltip: { shared: true, intersect: true }`
|
|
150
|
+
✅ `tooltip: { shared: true, intersect: false }` or `{ shared: false, intersect: true }`
|
|
151
|
+
|
|
152
|
+
### 7. undefined for missing data
|
|
153
|
+
❌ `data: [10, undefined, 30]`
|
|
154
|
+
✅ `data: [10, null, 30]`
|
|
155
|
+
|
|
156
|
+
### 8. Stacking on unsupported types
|
|
157
|
+
❌ `chart: { type: 'scatter', stacked: true }`
|
|
158
|
+
✅ `chart: { type: 'bar', stacked: true }` (or area)
|
|
159
|
+
|
|
160
|
+
### 9. Mixed chart without per-series type
|
|
161
|
+
❌ `series: [{ name: 'A', data: [...] }, { name: 'B', data: [...] }]` — all same type
|
|
162
|
+
✅ `series: [{ name: 'A', type: 'column', data: [...] }, { name: 'B', type: 'line', data: [...] }]`
|
|
163
|
+
|
|
164
|
+
### 10. RadialBar > 100
|
|
165
|
+
❌ `series: [340, 520]`
|
|
166
|
+
✅ `series: [76, 67]` (percentages 0–100)
|
|
167
|
+
|
|
168
|
+
### 11. Colors without #
|
|
169
|
+
❌ `colors: ['FF5733']`
|
|
170
|
+
✅ `colors: ['#FF5733']`
|
|
171
|
+
|
|
172
|
+
### 12. Tree-shaking without features
|
|
173
|
+
❌ `import ApexCharts from 'apexcharts/line'` — no legend/toolbar
|
|
174
|
+
✅ `import ApexCharts from 'apexcharts/line'; import 'apexcharts/features/legend'`
|
|
175
|
+
|
|
176
|
+
### 13. SSR with wrong import
|
|
177
|
+
❌ Server: `import ApexCharts from 'apexcharts'; ApexCharts.renderToString(opts)` — method missing
|
|
178
|
+
✅ Server: `import ApexCharts from 'apexcharts/ssr'; await ApexCharts.renderToString(opts)`
|
|
179
|
+
|
|
180
|
+
### 14. updateOptions just to change data
|
|
181
|
+
❌ `chart.updateOptions({ series: [{ data: newData }] })`
|
|
182
|
+
✅ `chart.updateSeries([{ name: 'Sales', data: newData }])`
|
|
183
|
+
|
|
184
|
+
### 15. Bar chart defaults to vertical columns
|
|
185
|
+
❌ Expecting horizontal bars with just `type: 'bar'`
|
|
186
|
+
✅ `plotOptions: { bar: { horizontal: true } }` for horizontal bars
|
|
187
|
+
|
|
188
|
+
### 16. Categories with {x,y} data
|
|
189
|
+
❌ `xaxis: { categories: ['A','B'] }, series: [{ data: [{ x: 'A', y: 10 }] }]` — categories ignored
|
|
190
|
+
✅ Either use categories + simple array, OR use {x,y} without categories
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## API Methods
|
|
195
|
+
|
|
196
|
+
| Method | Description |
|
|
197
|
+
|---|---|
|
|
198
|
+
| `render()` | Render chart. Returns Promise. |
|
|
199
|
+
| `destroy()` | Destroy and clean up. |
|
|
200
|
+
| `updateOptions(opts)` | Merge options and re-render. |
|
|
201
|
+
| `updateSeries(series)` | Replace series data. |
|
|
202
|
+
| `appendSeries(series)` | Add new series. |
|
|
203
|
+
| `appendData(data)` | Append data points. |
|
|
204
|
+
| `toggleSeries(name)` | Show/hide series. |
|
|
205
|
+
| `resetSeries()` | Reset to initial data. |
|
|
206
|
+
| `zoomX(min, max)` | Programmatic zoom. |
|
|
207
|
+
| `addXaxisAnnotation(opts)` | Dynamic annotation. |
|
|
208
|
+
| `addYaxisAnnotation(opts)` | Dynamic annotation. |
|
|
209
|
+
| `addPointAnnotation(opts)` | Dynamic annotation. |
|
|
210
|
+
| `removeAnnotation(id)` | Remove by id. |
|
|
211
|
+
| `clearAnnotations()` | Remove all. |
|
|
212
|
+
| `dataURI()` | Export as image (needs features/exports). |
|
|
213
|
+
| `exportToCSV()` | Export as CSV (needs features/exports). |
|
|
214
|
+
|
|
215
|
+
### Static Methods
|
|
216
|
+
|
|
217
|
+
| Method | Description |
|
|
218
|
+
|---|---|
|
|
219
|
+
| `ApexCharts.exec(id, fn, ...args)` | Call method on chart by id. |
|
|
220
|
+
| `ApexCharts.getChartByID(id)` | Get instance by id. |
|
|
221
|
+
|
|
222
|
+
### SSR Methods (apexcharts/ssr only)
|
|
223
|
+
|
|
224
|
+
| Method | Description |
|
|
225
|
+
|---|---|
|
|
226
|
+
| `ApexCharts.renderToString(opts)` | SVG string (server). |
|
|
227
|
+
| `ApexCharts.renderToHTML(opts)` | HTML wrapper + SVG (server). |
|
|
228
|
+
| `ApexCharts.hydrate(el)` | Hydrate SSR chart (client). |
|
|
229
|
+
| `ApexCharts.hydrateAll()` | Hydrate all SSR charts. |
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Framework Wrappers
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
npm install react-apexcharts apexcharts # React
|
|
237
|
+
npm install vue3-apexcharts apexcharts # Vue 3
|
|
238
|
+
npm install ng-apexcharts apexcharts # Angular
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
React: `<Chart options={opts} series={series} type="line" height={350} />`
|
|
242
|
+
Vue 3: `<apexchart type="bar" :options="opts" :series="series" height="350" />`
|
|
243
|
+
Angular: `<apx-chart [series]="series" [chart]="chart" [xaxis]="xaxis" />`
|
|
244
|
+
|
|
245
|
+
All wrappers handle destroy() on unmount automatically.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Installing ApexCharts Skill for Claude Code
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Navigate to your project's Claude config
|
|
7
|
+
mkdir -p .claude/skills
|
|
8
|
+
cd .claude/skills
|
|
9
|
+
|
|
10
|
+
# Clone the skill
|
|
11
|
+
git clone https://github.com/apexcharts/apexcharts-skill.git
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Claude Code will automatically detect and use the skill files when working on ApexCharts code.
|
|
15
|
+
|
|
16
|
+
## Verification
|
|
17
|
+
|
|
18
|
+
Ask Claude to create a simple chart:
|
|
19
|
+
|
|
20
|
+
> Create a line chart with ApexCharts showing monthly sales data
|
|
21
|
+
|
|
22
|
+
Claude should generate code that:
|
|
23
|
+
- Calls `new ApexCharts(el, options)` followed by `chart.render()`
|
|
24
|
+
- Uses the correct series data format
|
|
25
|
+
- Includes proper cleanup patterns for your framework
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Installing ApexCharts Skill for GitHub Copilot
|
|
2
|
+
|
|
3
|
+
## VS Code + Copilot Chat
|
|
4
|
+
|
|
5
|
+
### Option 1: Add as Workspace Context
|
|
6
|
+
|
|
7
|
+
1. Clone this repository or download `SKILL.md` into your project
|
|
8
|
+
2. In Copilot Chat, reference the file: `@workspace #file:SKILL.md`
|
|
9
|
+
3. Ask your charting question
|
|
10
|
+
|
|
11
|
+
### Option 2: Custom Instructions
|
|
12
|
+
|
|
13
|
+
1. Open VS Code Settings (Cmd/Ctrl + ,)
|
|
14
|
+
2. Search for "Copilot Custom Instructions"
|
|
15
|
+
3. Paste the contents of `.cursorrules` into the custom instructions field
|
|
16
|
+
|
|
17
|
+
## Copilot in GitHub.com
|
|
18
|
+
|
|
19
|
+
When working in GitHub's web editor with Copilot, paste the relevant sections from `SKILL.md` into your prompt for accurate ApexCharts code generation.
|
|
20
|
+
|
|
21
|
+
## Verification
|
|
22
|
+
|
|
23
|
+
Ask Copilot to generate a chart. It should use the correct series data format and call `render()` after construction.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Installing ApexCharts Skill for Cursor
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
1. Copy the `.cursorrules` file from this repository into the root of your project:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cp /path/to/apexcharts-skill/.cursorrules /path/to/your-project/.cursorrules
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or download it directly:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
curl -o .cursorrules https://raw.githubusercontent.com/apexcharts/apexcharts-skill/main/.cursorrules
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
2. Restart Cursor or open a new Cursor window.
|
|
18
|
+
|
|
19
|
+
Cursor automatically reads `.cursorrules` files in the project root and uses them as context for AI-assisted coding.
|
|
20
|
+
|
|
21
|
+
## For Windsurf
|
|
22
|
+
|
|
23
|
+
Same approach — Windsurf also supports `.cursorrules` files in the project root.
|
|
24
|
+
|
|
25
|
+
## Verification
|
|
26
|
+
|
|
27
|
+
Ask Cursor to generate a chart. It should follow the correct data format patterns and lifecycle (render/destroy).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apexcharts-skill",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "AI coding skill for ApexCharts.js — structured reference docs that help AI assistants (Claude, Cursor, Copilot, etc.) generate correct ApexCharts code.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apexcharts",
|
|
@@ -35,7 +35,9 @@
|
|
|
35
35
|
"files": [
|
|
36
36
|
"index.js",
|
|
37
37
|
"SKILL.md",
|
|
38
|
-
"references"
|
|
38
|
+
"references",
|
|
39
|
+
"install",
|
|
40
|
+
".cursorrules"
|
|
39
41
|
],
|
|
40
42
|
"engines": {
|
|
41
43
|
"node": ">=18"
|