blazeplot 0.1.10 → 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 +46 -6
- 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 +5 -1
- package/dist/interaction/InputController.d.ts +0 -23
- package/dist/interaction/InputController.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -78,10 +78,15 @@ push();
|
|
|
78
78
|
| `chart.addLine(config, style?)` / `addArea` / `addScatter` / `addBar` | Typed helpers that set the series mode for you. |
|
|
79
79
|
| `chart.removeSeries(series)` | Remove a previously added series. |
|
|
80
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. |
|
|
81
84
|
| `chart.resize(dpr?)` | Resize the internal plot canvas to match its CSS size × DPR. |
|
|
82
85
|
| `chart.start()` | Start the render loop (rAF). |
|
|
83
86
|
| `chart.stop()` | Stop the render loop. |
|
|
84
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. |
|
|
85
90
|
| `chart.getFrameStats(target?)` | Copy per-frame benchmark counters into a reusable object. |
|
|
86
91
|
| `chart.getSeriesState()` | Return public series metadata/state for plugins or custom UI. |
|
|
87
92
|
| `chart.setSeriesVisible(series, visible)` | Toggle visibility and notify series-state subscribers. |
|
|
@@ -94,13 +99,41 @@ push();
|
|
|
94
99
|
|
|
95
100
|
| Property | Default | Description |
|
|
96
101
|
|---|---|---|
|
|
97
|
-
| `viewportPolicy?` | — |
|
|
102
|
+
| `viewportPolicy?` | — | Optional `beforeRender` viewport hook. Pass the same policy to `interactionsPlugin({ viewportPolicy })` for pan/zoom hooks. |
|
|
98
103
|
| `hover?` | `{ mode: "nearest-x" }` | Default hover picking behavior. `mode` can be `"nearest-x"` or `"nearest-point"`. |
|
|
99
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. |
|
|
100
106
|
| `grid?` | `true` | Show grid lines. |
|
|
101
|
-
| `gridStyle?` | `{ color:
|
|
107
|
+
| `gridStyle?` | `{ color: theme.gridColor }` | Grid line color and width; overrides the theme grid color. |
|
|
102
108
|
| `axes?` | `true` | Show axis tick labels. `true`/`false`, or per-axis `{ x?: boolean \| AxisConfig, y?: boolean \| AxisConfig }`. |
|
|
103
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
|
+
|
|
104
137
|
### `AxisConfig`
|
|
105
138
|
|
|
106
139
|
| Property | Default | Description |
|
|
@@ -130,19 +163,21 @@ new Chart(canvas, {
|
|
|
130
163
|
|
|
131
164
|
```js
|
|
132
165
|
import { Chart } from "blazeplot";
|
|
166
|
+
import { interactionsPlugin } from "blazeplot/plugins/interactions";
|
|
133
167
|
import { legendPlugin } from "blazeplot/plugins/legend";
|
|
134
168
|
import { tooltipPlugin } from "blazeplot/plugins/tooltip";
|
|
135
169
|
|
|
136
170
|
const chart = new Chart(container, {
|
|
137
171
|
hover: { mode: "nearest-x" },
|
|
138
172
|
plugins: [
|
|
173
|
+
interactionsPlugin({ axis: "xy" }),
|
|
139
174
|
legendPlugin(),
|
|
140
175
|
tooltipPlugin({ mode: "nearest-point" }),
|
|
141
176
|
],
|
|
142
177
|
});
|
|
143
178
|
```
|
|
144
179
|
|
|
145
|
-
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.
|
|
146
181
|
|
|
147
182
|
### `SeriesStore`
|
|
148
183
|
|
|
@@ -176,6 +211,8 @@ Built-in plugins are optional. They consume public APIs (`getSeriesState`, `setS
|
|
|
176
211
|
|
|
177
212
|
### `ViewportPolicy`
|
|
178
213
|
|
|
214
|
+
`beforeRender` is consumed by `Chart`; `beforePan` and `beforeZoom` are consumed by `interactionsPlugin({ viewportPolicy })`.
|
|
215
|
+
|
|
179
216
|
```ts
|
|
180
217
|
interface ViewportPolicy {
|
|
181
218
|
beforePan?(camera: Camera2D, intent: PanIntent): PanIntent | null;
|
|
@@ -194,7 +231,7 @@ interface ViewportPolicy {
|
|
|
194
231
|
src/
|
|
195
232
|
core/ # Data model — series, datasets, LOD
|
|
196
233
|
render/ # GPU abstraction + regl backend
|
|
197
|
-
interaction/ # Camera,
|
|
234
|
+
interaction/ # Camera, axis ticks, interaction intent types
|
|
198
235
|
ui/ # Orchestrator (Chart)
|
|
199
236
|
```
|
|
200
237
|
|
|
@@ -218,8 +255,11 @@ bun run build
|
|
|
218
255
|
Output:
|
|
219
256
|
|
|
220
257
|
```
|
|
221
|
-
dist/index.js
|
|
222
|
-
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
|
|
223
263
|
```
|
|
224
264
|
|
|
225
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,CAAC;AAC7O,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACx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