gladly-plot 0.0.9 → 0.0.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/core/Plot.js +12 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gladly-plot",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "GPU-powered multi-axis plotting library with regl + d3",
5
5
  "type": "module",
6
6
  "exports": {
package/src/core/Plot.js CHANGED
@@ -222,18 +222,18 @@ export class Plot extends GlBase {
222
222
  const plotWidth = width - this.margin.left - this.margin.right
223
223
  const plotHeight = height - this.margin.top - this.margin.bottom
224
224
 
225
- // Container is hidden, not yet laid out, or too small to fit the margins.
226
- // Store config/data and return; ResizeObserver will call forceUpdate() once
227
- // the container gets real dimensions.
228
- if (width === 0 || height === 0 || plotWidth <= 0 || plotHeight <= 0) return
229
-
230
- this.canvas.width = width
231
- this.canvas.height = height
232
-
233
- this.width = width
234
- this.height = height
235
- this.plotWidth = plotWidth
236
- this.plotHeight = plotHeight
225
+ // Clamp to at least 1×1 so _initialize() always runs and getConfig() stays
226
+ // accurate even when the container is hidden or too small to fit the margins.
227
+ // The canvas backing store and WebGL context update synchronously; the D3
228
+ // axis pixel ranges will be corrected when the ResizeObserver fires on
229
+ // becoming visible.
230
+ this.canvas.width = Math.max(1, width)
231
+ this.canvas.height = Math.max(1, height)
232
+
233
+ this.width = Math.max(1, width)
234
+ this.height = Math.max(1, height)
235
+ this.plotWidth = Math.max(1, plotWidth)
236
+ this.plotHeight = Math.max(1, plotHeight)
237
237
 
238
238
  this._warnedMissingDomains = false
239
239
  await this._initialize()