blazeplot 0.1.9 → 0.1.11
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 +49 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -119
- package/dist/index.js.map +1 -1
- package/dist/interaction/index.d.ts +0 -1
- package/dist/interaction/index.d.ts.map +1 -1
- package/dist/plugins/interactions.d.ts +3 -0
- package/dist/plugins/interactions.d.ts.map +1 -0
- package/dist/plugins/interactions.js +143 -0
- package/dist/plugins/interactions.js.map +1 -0
- package/dist/plugins/legend.js +22 -18
- package/dist/plugins/legend.js.map +1 -1
- package/dist/plugins/tooltip.js +1 -1
- package/dist/plugins/tooltip.js.map +1 -1
- package/dist/render/ReglBackend.d.ts.map +1 -1
- package/dist/ui/Chart.d.ts +18 -2
- package/dist/ui/Chart.d.ts.map +1 -1
- package/dist/ui/Interactions.d.ts +19 -0
- package/dist/ui/Interactions.d.ts.map +1 -0
- package/dist/ui/Legend.d.ts +5 -0
- package/dist/ui/Legend.d.ts.map +1 -1
- package/dist/ui/Tooltip.d.ts +3 -0
- package/dist/ui/Tooltip.d.ts.map +1 -1
- package/dist/ui/theme.d.ts +41 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/package.json +6 -1
- package/dist/interaction/InputController.d.ts +0 -23
- package/dist/interaction/InputController.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/blazeplot.png" alt="BlazePlot" width="720" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
5
|
[](https://www.npmjs.com/package/blazeplot)
|
|
4
6
|
[](https://www.npmjs.com/package/blazeplot)
|
|
@@ -76,10 +78,15 @@ push();
|
|
|
76
78
|
| `chart.addLine(config, style?)` / `addArea` / `addScatter` / `addBar` | Typed helpers that set the series mode for you. |
|
|
77
79
|
| `chart.removeSeries(series)` | Remove a previously added series. |
|
|
78
80
|
| `chart.setViewport({ xMin, xMax, yMin, yMax })` | Set the visible data range. |
|
|
81
|
+
| `chart.getViewport()` | Return the current visible data range. |
|
|
82
|
+
| `chart.pan(intent)` / `chart.zoom(intent)` | Plugin-facing camera interaction helpers. |
|
|
83
|
+
| `chart.clientToData(clientX, clientY)` / `chart.dataToPlot(x, y)` | Convert between client/plot coordinates and data coordinates. |
|
|
79
84
|
| `chart.resize(dpr?)` | Resize the internal plot canvas to match its CSS size × DPR. |
|
|
80
85
|
| `chart.start()` | Start the render loop (rAF). |
|
|
81
86
|
| `chart.stop()` | Stop the render loop. |
|
|
82
87
|
| `chart.canvas` | Read-only access to the internal plot canvas. |
|
|
88
|
+
| `chart.xAxisElement` / `chart.yAxisElement` | Plugin-facing access to outside axis gutter elements. |
|
|
89
|
+
| `chart.theme` | Resolved theme values used by the chart and built-in plugins. |
|
|
83
90
|
| `chart.getFrameStats(target?)` | Copy per-frame benchmark counters into a reusable object. |
|
|
84
91
|
| `chart.getSeriesState()` | Return public series metadata/state for plugins or custom UI. |
|
|
85
92
|
| `chart.setSeriesVisible(series, visible)` | Toggle visibility and notify series-state subscribers. |
|
|
@@ -92,13 +99,41 @@ push();
|
|
|
92
99
|
|
|
93
100
|
| Property | Default | Description |
|
|
94
101
|
|---|---|---|
|
|
95
|
-
| `viewportPolicy?` | — |
|
|
102
|
+
| `viewportPolicy?` | — | Optional `beforeRender` viewport hook. Pass the same policy to `interactionsPlugin({ viewportPolicy })` for pan/zoom hooks. |
|
|
96
103
|
| `hover?` | `{ mode: "nearest-x" }` | Default hover picking behavior. `mode` can be `"nearest-x"` or `"nearest-point"`. |
|
|
97
104
|
| `plugins?` | `[]` | Optional `ChartPlugin` instances, e.g. `legendPlugin()` and `tooltipPlugin()`. |
|
|
105
|
+
| `theme?` | built-in dark theme | Override chart, axis, palette, legend, and tooltip colors/fonts. |
|
|
98
106
|
| `grid?` | `true` | Show grid lines. |
|
|
99
|
-
| `gridStyle?` | `{ color:
|
|
107
|
+
| `gridStyle?` | `{ color: theme.gridColor }` | Grid line color and width; overrides the theme grid color. |
|
|
100
108
|
| `axes?` | `true` | Show axis tick labels. `true`/`false`, or per-axis `{ x?: boolean \| AxisConfig, y?: boolean \| AxisConfig }`. |
|
|
101
109
|
|
|
110
|
+
### `ChartTheme`
|
|
111
|
+
|
|
112
|
+
```css
|
|
113
|
+
:root {
|
|
114
|
+
--plot-bg: #050816;
|
|
115
|
+
--plot-grid: rgb(148 163 184 / 0.22);
|
|
116
|
+
--plot-axis: #cbd5e1;
|
|
117
|
+
--series-a: #38bdf8;
|
|
118
|
+
--series-b: oklch(70% 0.19 22);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
new Chart(container, {
|
|
124
|
+
theme: {
|
|
125
|
+
backgroundColor: "var(--plot-bg)",
|
|
126
|
+
gridColor: "var(--plot-grid)",
|
|
127
|
+
axisColor: "var(--plot-axis)",
|
|
128
|
+
seriesColors: ["var(--series-a)", "var(--series-b)"],
|
|
129
|
+
tooltipBackgroundColor: "rgb(4 8 16 / 0.85)",
|
|
130
|
+
legendBackgroundColor: "rgb(4 8 16 / 0.85)",
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
WebGL-facing colors (`backgroundColor`, `gridColor`, `seriesColors`) accept either normalized RGBA tuples (`[r,g,b,a]`) or CSS colors, including CSS variables inherited by the chart container. BlazePlot resolves CSS colors internally to WebGL-compatible RGBA floats while preserving CSS strings for DOM styling where appropriate. Per-series styles and plugin options still override theme defaults.
|
|
136
|
+
|
|
102
137
|
### `AxisConfig`
|
|
103
138
|
|
|
104
139
|
| Property | Default | Description |
|
|
@@ -128,19 +163,21 @@ new Chart(canvas, {
|
|
|
128
163
|
|
|
129
164
|
```js
|
|
130
165
|
import { Chart } from "blazeplot";
|
|
166
|
+
import { interactionsPlugin } from "blazeplot/plugins/interactions";
|
|
131
167
|
import { legendPlugin } from "blazeplot/plugins/legend";
|
|
132
168
|
import { tooltipPlugin } from "blazeplot/plugins/tooltip";
|
|
133
169
|
|
|
134
170
|
const chart = new Chart(container, {
|
|
135
171
|
hover: { mode: "nearest-x" },
|
|
136
172
|
plugins: [
|
|
173
|
+
interactionsPlugin({ axis: "xy" }),
|
|
137
174
|
legendPlugin(),
|
|
138
175
|
tooltipPlugin({ mode: "nearest-point" }),
|
|
139
176
|
],
|
|
140
177
|
});
|
|
141
178
|
```
|
|
142
179
|
|
|
143
|
-
Built-in plugins are optional.
|
|
180
|
+
Built-in plugins are optional. `interactionsPlugin()` provides plain-drag box zoom, Shift+drag plot pan, wheel zoom, double-click reset, and `axis: "x" | "y" | "xy"`. When outside axes are visible, scrolling an axis zooms that axis and dragging an axis pans that axis; the plugin also applies a subtle axis hover color/filter configurable with `axisHover`, `axisHoverColor`, and `axisHoverFilter`. Legend/tooltip consume public APIs (`getSeriesState`, `setSeriesVisible`, `pick`, and `subscribe`) so custom UI can use the same contract. The default tooltip updates while the cursor is still on live charts and highlights the raw sample(s) it is reporting.
|
|
144
181
|
|
|
145
182
|
### `SeriesStore`
|
|
146
183
|
|
|
@@ -174,6 +211,8 @@ Built-in plugins are optional. They consume public APIs (`getSeriesState`, `setS
|
|
|
174
211
|
|
|
175
212
|
### `ViewportPolicy`
|
|
176
213
|
|
|
214
|
+
`beforeRender` is consumed by `Chart`; `beforePan` and `beforeZoom` are consumed by `interactionsPlugin({ viewportPolicy })`.
|
|
215
|
+
|
|
177
216
|
```ts
|
|
178
217
|
interface ViewportPolicy {
|
|
179
218
|
beforePan?(camera: Camera2D, intent: PanIntent): PanIntent | null;
|
|
@@ -192,7 +231,7 @@ interface ViewportPolicy {
|
|
|
192
231
|
src/
|
|
193
232
|
core/ # Data model — series, datasets, LOD
|
|
194
233
|
render/ # GPU abstraction + regl backend
|
|
195
|
-
interaction/ # Camera,
|
|
234
|
+
interaction/ # Camera, axis ticks, interaction intent types
|
|
196
235
|
ui/ # Orchestrator (Chart)
|
|
197
236
|
```
|
|
198
237
|
|
|
@@ -216,8 +255,11 @@ bun run build
|
|
|
216
255
|
Output:
|
|
217
256
|
|
|
218
257
|
```
|
|
219
|
-
dist/index.js
|
|
220
|
-
dist/index.d.ts
|
|
258
|
+
dist/index.js ES module
|
|
259
|
+
dist/index.d.ts TypeScript declarations
|
|
260
|
+
dist/plugins/interactions.js Optional interactions plugin
|
|
261
|
+
dist/plugins/legend.js Optional legend plugin
|
|
262
|
+
dist/plugins/tooltip.js Optional tooltip plugin
|
|
221
263
|
```
|
|
222
264
|
|
|
223
265
|
## Why WebGL2?
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { Chart } from './ui/Chart.js';
|
|
2
2
|
export type { ChartFrameStats, ChartOptions, ChartScreenshotOptions, AxisConfig, TypedSeriesConfig, ChartHoverState, ChartPickItem, ChartPickMode, ChartPickOptions, ChartPlugin, ChartPluginHandle, ChartSeriesState } from './ui/Chart.js';
|
|
3
|
+
export { DEFAULT_CHART_THEME } from './ui/theme.js';
|
|
4
|
+
export type { ChartTheme, ResolvedChartTheme, RgbaColor, CssColor, ThemeColor } from './ui/theme.js';
|
|
3
5
|
export type { AxisPosition } from './ui/ChartLayout.js';
|
|
4
6
|
export { SeriesStore } from './core/SeriesStore.js';
|
|
5
7
|
export { RingBuffer } from './core/RingBuffer.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe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