@classic-homes/charts-core 0.4.1 → 0.4.2
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/dist/index.cjs +26 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +26 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -573,14 +573,39 @@ function generateDataTable(headers, rows) {
|
|
|
573
573
|
}
|
|
574
574
|
|
|
575
575
|
// src/utils/merge.ts
|
|
576
|
-
var ALWAYS_REPLACE = ["
|
|
576
|
+
var ALWAYS_REPLACE = ["graphic"];
|
|
577
577
|
function countComponents(value) {
|
|
578
578
|
if (value == null || value === false) return 0;
|
|
579
579
|
if (Array.isArray(value)) return value.filter((item) => item != null).length;
|
|
580
580
|
return 1;
|
|
581
581
|
}
|
|
582
|
+
function isRecord(value) {
|
|
583
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
584
|
+
}
|
|
585
|
+
function sameShape(a, b) {
|
|
586
|
+
if (!isRecord(a) || !isRecord(b)) return !isRecord(a) && !isRecord(b);
|
|
587
|
+
const keys = Object.keys(a).filter((key) => a[key] !== void 0);
|
|
588
|
+
const other = Object.keys(b).filter((key) => b[key] !== void 0);
|
|
589
|
+
if (keys.length !== other.length) return false;
|
|
590
|
+
return keys.every(
|
|
591
|
+
(key) => key in b && b[key] !== void 0 && (key === "type" || key === "id" ? a[key] === b[key] : sameShape(a[key], b[key]))
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
function asList(value) {
|
|
595
|
+
if (value == null || value === false) return [];
|
|
596
|
+
return Array.isArray(value) ? value : [value];
|
|
597
|
+
}
|
|
598
|
+
function sameSeriesShape(prev, next) {
|
|
599
|
+
const before = asList(prev);
|
|
600
|
+
const after = asList(next);
|
|
601
|
+
return before.length === after.length && before.every((item, i) => sameShape(item, after[i]));
|
|
602
|
+
}
|
|
582
603
|
function getReplaceMerge(prev, next, isComponentType) {
|
|
583
604
|
const types = new Set(ALWAYS_REPLACE);
|
|
605
|
+
const prior = prev;
|
|
606
|
+
if (!prior || !sameSeriesShape(prior.series, next.series)) {
|
|
607
|
+
types.add("series");
|
|
608
|
+
}
|
|
584
609
|
if (prev) {
|
|
585
610
|
const before = prev;
|
|
586
611
|
const after = next;
|
package/dist/index.d.cts
CHANGED
|
@@ -125,8 +125,12 @@ declare function generateDataTable(headers: string[], rows: (string | number)[][
|
|
|
125
125
|
* rebuilds every component, so legend selection, dataZoom ranges and other
|
|
126
126
|
* interaction state reset on each data update. Instead this replaces only:
|
|
127
127
|
*
|
|
128
|
-
* - `
|
|
129
|
-
*
|
|
128
|
+
* - `graphic`, so removed centre labels disappear;
|
|
129
|
+
* - `series`, unless every series keeps its keys and type and only its
|
|
130
|
+
* values change. A replaced series is a new model, which ECharts animates
|
|
131
|
+
* in from scratch, so a data refresh with the same shape (often the same
|
|
132
|
+
* data) must merge to avoid re-animating the chart; a changed shape is
|
|
133
|
+
* replaced so removed series, mark lines and options disappear;
|
|
130
134
|
* - any component type that `next` has fewer of than `prev` (a hidden legend
|
|
131
135
|
* or tooltip, a dropped volume grid and its axes).
|
|
132
136
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -125,8 +125,12 @@ declare function generateDataTable(headers: string[], rows: (string | number)[][
|
|
|
125
125
|
* rebuilds every component, so legend selection, dataZoom ranges and other
|
|
126
126
|
* interaction state reset on each data update. Instead this replaces only:
|
|
127
127
|
*
|
|
128
|
-
* - `
|
|
129
|
-
*
|
|
128
|
+
* - `graphic`, so removed centre labels disappear;
|
|
129
|
+
* - `series`, unless every series keeps its keys and type and only its
|
|
130
|
+
* values change. A replaced series is a new model, which ECharts animates
|
|
131
|
+
* in from scratch, so a data refresh with the same shape (often the same
|
|
132
|
+
* data) must merge to avoid re-animating the chart; a changed shape is
|
|
133
|
+
* replaced so removed series, mark lines and options disappear;
|
|
130
134
|
* - any component type that `next` has fewer of than `prev` (a hidden legend
|
|
131
135
|
* or tooltip, a dropped volume grid and its axes).
|
|
132
136
|
*
|
package/dist/index.js
CHANGED
|
@@ -252,14 +252,39 @@ function generateDataTable(headers, rows) {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
// src/utils/merge.ts
|
|
255
|
-
var ALWAYS_REPLACE = ["
|
|
255
|
+
var ALWAYS_REPLACE = ["graphic"];
|
|
256
256
|
function countComponents(value) {
|
|
257
257
|
if (value == null || value === false) return 0;
|
|
258
258
|
if (Array.isArray(value)) return value.filter((item) => item != null).length;
|
|
259
259
|
return 1;
|
|
260
260
|
}
|
|
261
|
+
function isRecord(value) {
|
|
262
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
263
|
+
}
|
|
264
|
+
function sameShape(a, b) {
|
|
265
|
+
if (!isRecord(a) || !isRecord(b)) return !isRecord(a) && !isRecord(b);
|
|
266
|
+
const keys = Object.keys(a).filter((key) => a[key] !== void 0);
|
|
267
|
+
const other = Object.keys(b).filter((key) => b[key] !== void 0);
|
|
268
|
+
if (keys.length !== other.length) return false;
|
|
269
|
+
return keys.every(
|
|
270
|
+
(key) => key in b && b[key] !== void 0 && (key === "type" || key === "id" ? a[key] === b[key] : sameShape(a[key], b[key]))
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
function asList(value) {
|
|
274
|
+
if (value == null || value === false) return [];
|
|
275
|
+
return Array.isArray(value) ? value : [value];
|
|
276
|
+
}
|
|
277
|
+
function sameSeriesShape(prev, next) {
|
|
278
|
+
const before = asList(prev);
|
|
279
|
+
const after = asList(next);
|
|
280
|
+
return before.length === after.length && before.every((item, i) => sameShape(item, after[i]));
|
|
281
|
+
}
|
|
261
282
|
function getReplaceMerge(prev, next, isComponentType) {
|
|
262
283
|
const types = new Set(ALWAYS_REPLACE);
|
|
284
|
+
const prior = prev;
|
|
285
|
+
if (!prior || !sameSeriesShape(prior.series, next.series)) {
|
|
286
|
+
types.add("series");
|
|
287
|
+
}
|
|
263
288
|
if (prev) {
|
|
264
289
|
const before = prev;
|
|
265
290
|
const after = next;
|