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 CHANGED
@@ -1,4 +1,6 @@
1
- # BlazePlot
1
+ <p align="center">
2
+ <img src="assets/blazeplot.png" alt="BlazePlot" width="720" />
3
+ </p>
2
4
 
3
5
  [![npm version](https://img.shields.io/npm/v/blazeplot.svg)](https://www.npmjs.com/package/blazeplot)
4
6
  [![npm downloads](https://img.shields.io/npm/dt/blazeplot.svg)](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?` | — | Custom pan/zoom/viewport behavior hooks. |
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: [0.22,0.30,0.44,0.45] }` | Grid line color and width. |
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. They 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.
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, input, axis ticks
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 ES module
220
- dist/index.d.ts TypeScript declarations
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';
@@ -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,sBAA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