@wick-charts/vue 0.1.2 → 0.2.1
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/README.md +200 -0
- package/dist/index.d.ts +1247 -109
- package/dist/index.js +4298 -1898
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<!-- Generated from README.tmpl.md — edit the template, not this file. -->
|
|
2
|
+
|
|
3
|
+
# Wick Charts
|
|
4
|
+
|
|
5
|
+
High-performance timeseries charts for **React**, **Vue**, and **Svelte**. Canvas-rendered, tree-shakeable, ~25KB gzipped.
|
|
6
|
+
|
|
7
|
+
[Live Demo](https://mo4islona.github.io/wick-charts/)
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Candlestick, Line, Bar, Pie** — all from one package
|
|
12
|
+
- **Real-time streaming** — append/update data at 60fps
|
|
13
|
+
- **22 built-in themes** — dark, light, and custom
|
|
14
|
+
- **Interactive** — zoom, pan, crosshair, tooltips
|
|
15
|
+
- **Stacking** — normal and percent modes for line/bar
|
|
16
|
+
- **Custom-render helpers** — `buildHoverSnapshots` / `buildLastSnapshots` / `computeTooltipPosition` for overlays that need to escape the built-in UI (structural-equality cache included)
|
|
17
|
+
- **Tree-shakeable** — import only what you use
|
|
18
|
+
- **Zero dependencies** — just your framework
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @wick-charts/vue
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<script setup>
|
|
30
|
+
import {
|
|
31
|
+
ChartContainer, CandlestickSeries, Tooltip,
|
|
32
|
+
Crosshair, YAxis, TimeAxis
|
|
33
|
+
} from '@wick-charts/vue';
|
|
34
|
+
|
|
35
|
+
const props = defineProps(['data']);
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<template>
|
|
39
|
+
<ChartContainer>
|
|
40
|
+
<CandlestickSeries :data="props.data" />
|
|
41
|
+
<Tooltip />
|
|
42
|
+
<Crosshair />
|
|
43
|
+
<YAxis />
|
|
44
|
+
<TimeAxis />
|
|
45
|
+
</ChartContainer>
|
|
46
|
+
</template>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Series Types
|
|
50
|
+
|
|
51
|
+
| Component | Data Format | Description |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| `CandlestickSeries` | `{ time, open, high, low, close, volume? }[]` | OHLC candlesticks with volume bars |
|
|
54
|
+
| `LineSeries` | `{ time, value }[][]` | Line/area charts, multi-layer, stacking |
|
|
55
|
+
| `BarSeries` | `{ time, value }[][]` | Histogram/bar charts, stacking |
|
|
56
|
+
| `PieSeries` | `{ label, value, color? }[]` | Pie and donut charts |
|
|
57
|
+
|
|
58
|
+
## UI Overlays
|
|
59
|
+
|
|
60
|
+
Every DOM overlay ships a default UI **and** a scoped slot / render-prop so you can replace the contents with your own layout. Positioning, crosshair wiring, and data computation stay in the library — the slot just hands you the already-computed data.
|
|
61
|
+
|
|
62
|
+
| Component | Description | Slot ctx |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| `Tooltip` | Floating glass tooltip near cursor on hover | `{ snapshots, time }` |
|
|
65
|
+
| `InfoBar` | Compact OHLC / values info bar hoisted above the canvas | `{ snapshots, time, isHover }` |
|
|
66
|
+
| `Title` | Chart title / subtitle bar hoisted above the canvas | — |
|
|
67
|
+
| `Crosshair` | Axis labels at cursor position | — |
|
|
68
|
+
| `YAxis` | Vertical price/value axis with animated ticks | — |
|
|
69
|
+
| `TimeAxis` | Horizontal time axis with animated ticks | — |
|
|
70
|
+
| `YLabel` | Floating price badge with dashed line | `{ value, y, bgColor, isLive, direction, format }` |
|
|
71
|
+
| `Legend` | Clickable legend with toggle/isolate modes | `{ items: LegendItem[] }` |
|
|
72
|
+
| `PieTooltip` | Tooltip for pie/donut hover | `{ info, format }` |
|
|
73
|
+
| `PieLegend` | Slice labels with values or percentages | `{ slices, mode, format }` |
|
|
74
|
+
|
|
75
|
+
> `TooltipLegend` is the former name of `InfoBar` and is still exported as a deprecated alias.
|
|
76
|
+
|
|
77
|
+
## Custom render (slots / render-props)
|
|
78
|
+
|
|
79
|
+
```vue
|
|
80
|
+
<!-- Vue — same context, different syntax -->
|
|
81
|
+
<Tooltip v-slot="{ snapshots, time }">
|
|
82
|
+
<div
|
|
83
|
+
v-for="s in snapshots.filter((x) => x.seriesId === 'btc' || x.seriesId === 'eth')"
|
|
84
|
+
:key="s.id"
|
|
85
|
+
:style="{ color: s.color }"
|
|
86
|
+
>
|
|
87
|
+
{{ s.label }}: {{ s.data.close ?? s.data.value }}
|
|
88
|
+
</div>
|
|
89
|
+
</Tooltip>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Each overlay has its own slot context (see the Slot ctx column above); the shape is consistent across frameworks for the same overlay.
|
|
93
|
+
|
|
94
|
+
### Public helpers (re-exported from each framework package)
|
|
95
|
+
|
|
96
|
+
- `buildHoverSnapshots(chart, { time, sort?, cacheKey })` / `buildLastSnapshots(chart, { sort?, cacheKey })` — structural-equality-cached snapshot arrays for building your own floating widgets. Calls with the same args return the **same reference** while the chart's overlay version is unchanged, so `React.memo` / Vue `computed` / Svelte `$:` skip renders on no-op mousemoves.
|
|
97
|
+
- `computeTooltipPosition({ x, y, chartWidth, chartHeight, tooltipWidth, tooltipHeight, offsetX?, offsetY? })` — flip + clamp positioning for a tooltip container you own.
|
|
98
|
+
- Types: `SeriesSnapshot`, `LegendItem`, `SliceInfo`, `HoverInfo`.
|
|
99
|
+
|
|
100
|
+
## Custom number formatting
|
|
101
|
+
|
|
102
|
+
Every numeric overlay accepts a `format` prop so you can override the default label rendering. Two shared helpers ship in each framework package (`@wick-charts/react`, `@wick-charts/vue`, `@wick-charts/svelte`):
|
|
103
|
+
|
|
104
|
+
- `formatCompact(v)` — K/M/B/T suffixes with adaptive precision. Default for `YAxis` (at ranges ≥ 1e6), `PieLegend`, `PieTooltip`, `Sparkline`.
|
|
105
|
+
- `formatPriceAdaptive(v)` — full-precision display that scales decimals to the value's magnitude. Default for `Tooltip` / `TooltipLegend` OHLC and line-value cells. Handles sub-cent prices (`0.00001234` → `"0.00001234"`, not `"0.00"`).
|
|
106
|
+
|
|
107
|
+
```vue
|
|
108
|
+
<script setup>
|
|
109
|
+
import { Tooltip, YAxis, formatCompact } from '@wick-charts/vue';
|
|
110
|
+
|
|
111
|
+
const yFormat = (v) => `$${formatCompact(v)}`;
|
|
112
|
+
const tipFormat = (v, field) => (field === 'volume' ? formatCompact(v) : v.toFixed(4));
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<template>
|
|
116
|
+
<YAxis :format="yFormat" />
|
|
117
|
+
<Tooltip :format="tipFormat" />
|
|
118
|
+
</template>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Tooltip / TooltipLegend pass a `field` arg (`'open' | 'high' | 'low' | 'close' | 'volume' | 'value'`) so you can branch on which cell you're formatting. All other overlays receive a single `value: number`.
|
|
122
|
+
|
|
123
|
+
## Themes
|
|
124
|
+
|
|
125
|
+
22 built-in themes. Import only the ones you need (tree-shakable) and pass them to `ChartContainer` or `ThemeProvider` for global theming.
|
|
126
|
+
|
|
127
|
+
```vue
|
|
128
|
+
<script setup>
|
|
129
|
+
import { catppuccin } from '@wick-charts/vue';
|
|
130
|
+
// Dark: andromeda, ayuMirage, catppuccin, dracula, gruvbox, highContrast,
|
|
131
|
+
// materialPalenight, monokaiPro, nightOwl, oneDarkPro, panda
|
|
132
|
+
// Light: githubLight, handwritten, lavenderMist, lightPink, minimalLight, mintBreeze,
|
|
133
|
+
// peachCream, quietLight, rosePineDawn, sandDune, solarizedLight
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<template>
|
|
137
|
+
<ChartContainer :theme="catppuccin.theme" />
|
|
138
|
+
</template>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Create custom themes with `createTheme()`:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { createTheme } from '@wick-charts/vue';
|
|
145
|
+
|
|
146
|
+
const myTheme = createTheme({
|
|
147
|
+
background: '#1a1b2e',
|
|
148
|
+
upColor: '#00d4aa',
|
|
149
|
+
downColor: '#ff5577',
|
|
150
|
+
textColor: '#8888aa',
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Real-Time Data
|
|
155
|
+
|
|
156
|
+
```vue
|
|
157
|
+
<template>
|
|
158
|
+
<!-- Full replace (initial load) -->
|
|
159
|
+
<CandlestickSeries :data="allCandles" />
|
|
160
|
+
</template>
|
|
161
|
+
|
|
162
|
+
<!--
|
|
163
|
+
The component auto-detects changes:
|
|
164
|
+
- data.length grew by 1-5 → append
|
|
165
|
+
- data.length same → update last point
|
|
166
|
+
- data.length shrunk or grew by >5 → full replace
|
|
167
|
+
-->
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Configuration
|
|
171
|
+
|
|
172
|
+
```vue
|
|
173
|
+
<template>
|
|
174
|
+
<ChartContainer
|
|
175
|
+
:theme="theme"
|
|
176
|
+
:axis="{
|
|
177
|
+
y: { visible: true, width: 55, min: 0, max: 'auto' },
|
|
178
|
+
x: { visible: true, height: 30 },
|
|
179
|
+
}"
|
|
180
|
+
/>
|
|
181
|
+
</template>
|
|
182
|
+
|
|
183
|
+
<!-- Vue ChartContainer currently accepts theme + axis; padding/gradient/grid/interactive are React-only. -->
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Bundle Size
|
|
187
|
+
|
|
188
|
+
Full `dist/index.js` (minified + gzipped):
|
|
189
|
+
|
|
190
|
+
| Package | Raw | Gzip |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| `@wick-charts/vue` | 176 KB | 44.2 KB |
|
|
193
|
+
|
|
194
|
+
## Migration
|
|
195
|
+
|
|
196
|
+
Upgrading across versions? See [MIGRATION.md](https://github.com/mo4islona/wick-charts/blob/main/MIGRATION.md) for per-version breaking-change notes and code snippets.
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
MIT
|