gladly-plot 0.0.7 → 0.0.9
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/package.json +1 -1
- package/src/core/Plot.js +21 -44
- package/src/data/Data.js +13 -1
package/package.json
CHANGED
package/src/core/Plot.js
CHANGED
|
@@ -98,55 +98,18 @@ function buildPlotSchema(data, config) {
|
|
|
98
98
|
},
|
|
99
99
|
axes: {
|
|
100
100
|
type: "object",
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
properties: {
|
|
105
|
-
min: { type: "number" },
|
|
106
|
-
max: { type: "number" },
|
|
107
|
-
label: { type: "string" },
|
|
108
|
-
scale: { type: "string", enum: ["linear", "log"] },
|
|
109
|
-
rotate: { type: "boolean" }
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
xaxis_top: {
|
|
113
|
-
type: "object",
|
|
114
|
-
properties: {
|
|
115
|
-
min: { type: "number" },
|
|
116
|
-
max: { type: "number" },
|
|
117
|
-
label: { type: "string" },
|
|
118
|
-
scale: { type: "string", enum: ["linear", "log"] },
|
|
119
|
-
rotate: { type: "boolean" }
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
yaxis_left: {
|
|
123
|
-
type: "object",
|
|
124
|
-
properties: {
|
|
125
|
-
min: { type: "number" },
|
|
126
|
-
max: { type: "number" },
|
|
127
|
-
label: { type: "string" },
|
|
128
|
-
scale: { type: "string", enum: ["linear", "log"] }
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
yaxis_right: {
|
|
132
|
-
type: "object",
|
|
133
|
-
properties: {
|
|
134
|
-
min: { type: "number" },
|
|
135
|
-
max: { type: "number" },
|
|
136
|
-
label: { type: "string" },
|
|
137
|
-
scale: { type: "string", enum: ["linear", "log"] }
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
101
|
+
// All axes (spatial, color, filter) are populated by getConfig() after the first render.
|
|
102
|
+
// Using only additionalProperties means no hardcoded axis list appears in the schema;
|
|
103
|
+
// the config editor shows exactly the axes declared by active layers.
|
|
141
104
|
additionalProperties: {
|
|
142
|
-
// Color/filter/quantity-kind axes.
|
|
143
|
-
// All fields from the quantity kind registration are valid here and override the registration.
|
|
144
105
|
type: "object",
|
|
145
106
|
properties: {
|
|
107
|
+
quantity_kind: { type: "string" },
|
|
146
108
|
min: { type: "number" },
|
|
147
109
|
max: { type: "number" },
|
|
148
110
|
label: { type: "string" },
|
|
149
111
|
scale: { type: "string", enum: ["linear", "log"] },
|
|
112
|
+
rotate: { type: "boolean" },
|
|
150
113
|
colorscale: {
|
|
151
114
|
type: "string",
|
|
152
115
|
enum: [
|
|
@@ -335,7 +298,7 @@ export class Plot extends GlBase {
|
|
|
335
298
|
const [min, max] = scale.domain()
|
|
336
299
|
const qk = this.axisRegistry.axisQuantityKinds[axisId]
|
|
337
300
|
const qkDef = qk ? getAxisQuantityKind(qk) : {}
|
|
338
|
-
axes[axisId] = { ...qkDef, ...(axes[axisId] ?? {}), min, max }
|
|
301
|
+
axes[axisId] = { ...qkDef, ...(axes[axisId] ?? {}), min, max, ...(qk ? { quantity_kind: qk } : {}) }
|
|
339
302
|
}
|
|
340
303
|
}
|
|
341
304
|
}
|
|
@@ -411,7 +374,21 @@ export class Plot extends GlBase {
|
|
|
411
374
|
if (this._initEpoch !== epoch) return
|
|
412
375
|
await this._processLayers(layers, this.currentData, epoch)
|
|
413
376
|
if (this._initEpoch !== epoch) return
|
|
414
|
-
|
|
377
|
+
|
|
378
|
+
// Discard any spatial axis config whose stored quantity_kind doesn't match
|
|
379
|
+
// Discard any spatial axis config whose stored quantity_kind doesn't match
|
|
380
|
+
// what the layers assigned — stale settings from a previous axis type.
|
|
381
|
+
const cleanAxes = { ...axes }
|
|
382
|
+
for (const axisId of AXES) {
|
|
383
|
+
const cfg = cleanAxes[axisId]
|
|
384
|
+
if (cfg?.quantity_kind != null &&
|
|
385
|
+
cfg.quantity_kind !== this.axisRegistry.axisQuantityKinds[axisId]) {
|
|
386
|
+
delete cleanAxes[axisId]
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
this.currentConfig = { ...this.currentConfig, axes: cleanAxes }
|
|
390
|
+
|
|
391
|
+
this._setDomains(cleanAxes)
|
|
415
392
|
|
|
416
393
|
// Detect 3D mode: any axis outside the 4 standard 2D positions has a scale.
|
|
417
394
|
this._is3D = AXES.some(a => !AXES_2D.includes(a) && this.axisRegistry.getScale(a) !== null)
|
package/src/data/Data.js
CHANGED
|
@@ -265,6 +265,18 @@ export class Data {
|
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
getDomain(col) {
|
|
268
|
-
|
|
268
|
+
const entry = this._entry(col)
|
|
269
|
+
if (entry.domain) return entry.domain
|
|
270
|
+
const arr = entry.data
|
|
271
|
+
if (!arr || arr.length === 0) return null
|
|
272
|
+
let min = Infinity, max = -Infinity
|
|
273
|
+
for (let i = 0; i < arr.length; i++) {
|
|
274
|
+
const v = arr[i]
|
|
275
|
+
if (isFinite(v)) {
|
|
276
|
+
if (v < min) min = v
|
|
277
|
+
if (v > max) max = v
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return min === Infinity ? null : [min, max]
|
|
269
281
|
}
|
|
270
282
|
}
|