squarified 0.3.3 → 0.3.5
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.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +15 -17
- package/dist/index.mjs +15 -17
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -219,7 +219,6 @@ declare const defaultFontOptions: {
|
|
|
219
219
|
};
|
|
220
220
|
declare function presetDecorator(app: TreemapLayout): void;
|
|
221
221
|
|
|
222
|
-
type AnyObject = Record<keyof Any, Any>;
|
|
223
222
|
declare function sortChildrenByKey<T extends AnyObject, K extends keyof T = 'weight'>(data: T[], ...keys: K[]): T[];
|
|
224
223
|
declare function c2m<T extends AnyObject & {
|
|
225
224
|
groups: Any[];
|
package/dist/index.d.ts
CHANGED
|
@@ -219,7 +219,6 @@ declare const defaultFontOptions: {
|
|
|
219
219
|
};
|
|
220
220
|
declare function presetDecorator(app: TreemapLayout): void;
|
|
221
221
|
|
|
222
|
-
type AnyObject = Record<keyof Any, Any>;
|
|
223
222
|
declare function sortChildrenByKey<T extends AnyObject, K extends keyof T = 'weight'>(data: T[], ...keys: K[]): T[];
|
|
224
223
|
declare function c2m<T extends AnyObject & {
|
|
225
224
|
groups: Any[];
|
package/dist/index.js
CHANGED
|
@@ -874,7 +874,7 @@ function createEffectStop(c) {
|
|
|
874
874
|
}
|
|
875
875
|
};
|
|
876
876
|
}
|
|
877
|
-
function
|
|
877
|
+
function createSmoothFrame() {
|
|
878
878
|
const c = {
|
|
879
879
|
animationFrameID: null
|
|
880
880
|
};
|
|
@@ -1024,8 +1024,8 @@ const INTERNAL_EVENT_MAPPINGS = {
|
|
|
1024
1024
|
};
|
|
1025
1025
|
const ANIMATION_DURATION = 300;
|
|
1026
1026
|
const fill = { desc: { r: 255, g: 255, b: 255 }, mode: "rgb" };
|
|
1027
|
-
function
|
|
1028
|
-
const
|
|
1027
|
+
function smoothFrame(callback, opts) {
|
|
1028
|
+
const frame = createSmoothFrame();
|
|
1029
1029
|
const startTime = Date.now();
|
|
1030
1030
|
const condtion = (process) => {
|
|
1031
1031
|
if (Array.isArray(opts.deps)) {
|
|
@@ -1033,17 +1033,17 @@ function runEffect(callback, opts) {
|
|
|
1033
1033
|
}
|
|
1034
1034
|
return process >= 1;
|
|
1035
1035
|
};
|
|
1036
|
-
|
|
1036
|
+
frame.run(() => {
|
|
1037
1037
|
const elapsed = Date.now() - startTime;
|
|
1038
1038
|
const progress = Math.min(elapsed / opts.duration, 1);
|
|
1039
1039
|
if (condtion(progress)) {
|
|
1040
|
-
|
|
1040
|
+
frame.stop();
|
|
1041
1041
|
if (opts.onStop) {
|
|
1042
1042
|
opts.onStop();
|
|
1043
1043
|
}
|
|
1044
1044
|
return true;
|
|
1045
1045
|
}
|
|
1046
|
-
return callback(progress,
|
|
1046
|
+
return callback(progress, frame.stop);
|
|
1047
1047
|
});
|
|
1048
1048
|
}
|
|
1049
1049
|
const HIGH_LIGHT_OPACITY = 0.3;
|
|
@@ -1052,7 +1052,7 @@ function drawHighlight(treemap, evt) {
|
|
|
1052
1052
|
const { currentNode } = evt.state;
|
|
1053
1053
|
if (currentNode) {
|
|
1054
1054
|
const [x, y, w, h] = currentNode.layout;
|
|
1055
|
-
|
|
1055
|
+
smoothFrame((_, cleanup) => {
|
|
1056
1056
|
cleanup();
|
|
1057
1057
|
highlight.reset();
|
|
1058
1058
|
const mask = createRoundBlock(x, y, w, h, { fill, opacity: HIGH_LIGHT_OPACITY, radius: 4, padding: 2 });
|
|
@@ -1120,7 +1120,7 @@ class TreemapEvent extends DOMEvent {
|
|
|
1120
1120
|
drawHighlight(ctx.treemap, this);
|
|
1121
1121
|
} else {
|
|
1122
1122
|
const { treemap } = ctx;
|
|
1123
|
-
|
|
1123
|
+
smoothFrame((_, cleanup) => {
|
|
1124
1124
|
cleanup();
|
|
1125
1125
|
const { offsetX: x, offsetY: y } = metadata.native;
|
|
1126
1126
|
const { dragX: lastX, dragY: lastY } = this.state;
|
|
@@ -1191,13 +1191,11 @@ class TreemapEvent extends DOMEvent {
|
|
|
1191
1191
|
const targetScaleRatio = this.matrix.a * delta;
|
|
1192
1192
|
const translateX = offsetX - (offsetX - this.matrix.e) * delta;
|
|
1193
1193
|
const translateY = offsetY - (offsetY - this.matrix.f) * delta;
|
|
1194
|
-
|
|
1195
|
-
this.silent("mousedown");
|
|
1194
|
+
smoothFrame((progress, cleanup) => {
|
|
1196
1195
|
this.exposedEvent.silent("mousemove");
|
|
1197
1196
|
this.silent("mousemove");
|
|
1198
1197
|
this.silent("click");
|
|
1199
1198
|
this.exposedEvent.silent("click");
|
|
1200
|
-
cleanup();
|
|
1201
1199
|
treemap.highlight.reset();
|
|
1202
1200
|
treemap.highlight.setZIndexForHighlight();
|
|
1203
1201
|
treemap.fontCache.flush(treemap, this.matrix);
|
|
@@ -1214,12 +1212,12 @@ class TreemapEvent extends DOMEvent {
|
|
|
1214
1212
|
);
|
|
1215
1213
|
stackMatrixTransformWithGraphAndLayer(treemap.elements, this.matrix.e, this.matrix.f, 1);
|
|
1216
1214
|
treemap.update();
|
|
1215
|
+
cleanup();
|
|
1217
1216
|
}, {
|
|
1218
1217
|
duration: ANIMATION_DURATION,
|
|
1219
1218
|
onStop: () => {
|
|
1220
1219
|
this.state.forceDestroy = false;
|
|
1221
1220
|
this.state.isWheeling = false;
|
|
1222
|
-
this.active("mousedown");
|
|
1223
1221
|
this.active("mousemove");
|
|
1224
1222
|
this.exposedEvent.active("mousemove");
|
|
1225
1223
|
this.active("click");
|
|
@@ -1256,7 +1254,7 @@ function createOnZoom(treemap, evt) {
|
|
|
1256
1254
|
const targetScale = factor * evt.matrix.a;
|
|
1257
1255
|
const translateX = boundingClientRect.width / 2 - (mx + mw / 2) * factor;
|
|
1258
1256
|
const translateY = boundingClientRect.height / 2 - (my + mh / 2) * factor;
|
|
1259
|
-
|
|
1257
|
+
smoothFrame((progress, cleanup) => {
|
|
1260
1258
|
cleanup();
|
|
1261
1259
|
evt.silent("mousemove");
|
|
1262
1260
|
evt.exposedEvent.silent("mousemove");
|
|
@@ -1643,8 +1641,8 @@ function evaluateColorMappings(data) {
|
|
|
1643
1641
|
const hash = Math.abs(hashCode(id));
|
|
1644
1642
|
return hash % 360;
|
|
1645
1643
|
};
|
|
1646
|
-
const lightScale = (depth) =>
|
|
1647
|
-
const baseSaturation =
|
|
1644
|
+
const lightScale = (depth) => 50 - depth * 5;
|
|
1645
|
+
const baseSaturation = 80;
|
|
1648
1646
|
const siblingHueShift = 30;
|
|
1649
1647
|
const rc = 0.2126;
|
|
1650
1648
|
const gc = 0.7152;
|
|
@@ -1672,8 +1670,8 @@ function evaluateColorMappings(data) {
|
|
|
1672
1670
|
const { r, g, b } = hslToRgb(hslColor.h, hslColor.s / 100, hslColor.l);
|
|
1673
1671
|
const luminance = calculateLuminance(r, g, b);
|
|
1674
1672
|
if (luminance < 0.6) {
|
|
1675
|
-
hslColor.l += 0.
|
|
1676
|
-
} else if (luminance > 0.
|
|
1673
|
+
hslColor.l += 0.2;
|
|
1674
|
+
} else if (luminance > 0.8) {
|
|
1677
1675
|
hslColor.l -= 0.1;
|
|
1678
1676
|
}
|
|
1679
1677
|
hslColor.l *= 100;
|
package/dist/index.mjs
CHANGED
|
@@ -872,7 +872,7 @@ function createEffectStop(c) {
|
|
|
872
872
|
}
|
|
873
873
|
};
|
|
874
874
|
}
|
|
875
|
-
function
|
|
875
|
+
function createSmoothFrame() {
|
|
876
876
|
const c = {
|
|
877
877
|
animationFrameID: null
|
|
878
878
|
};
|
|
@@ -1022,8 +1022,8 @@ const INTERNAL_EVENT_MAPPINGS = {
|
|
|
1022
1022
|
};
|
|
1023
1023
|
const ANIMATION_DURATION = 300;
|
|
1024
1024
|
const fill = { desc: { r: 255, g: 255, b: 255 }, mode: "rgb" };
|
|
1025
|
-
function
|
|
1026
|
-
const
|
|
1025
|
+
function smoothFrame(callback, opts) {
|
|
1026
|
+
const frame = createSmoothFrame();
|
|
1027
1027
|
const startTime = Date.now();
|
|
1028
1028
|
const condtion = (process) => {
|
|
1029
1029
|
if (Array.isArray(opts.deps)) {
|
|
@@ -1031,17 +1031,17 @@ function runEffect(callback, opts) {
|
|
|
1031
1031
|
}
|
|
1032
1032
|
return process >= 1;
|
|
1033
1033
|
};
|
|
1034
|
-
|
|
1034
|
+
frame.run(() => {
|
|
1035
1035
|
const elapsed = Date.now() - startTime;
|
|
1036
1036
|
const progress = Math.min(elapsed / opts.duration, 1);
|
|
1037
1037
|
if (condtion(progress)) {
|
|
1038
|
-
|
|
1038
|
+
frame.stop();
|
|
1039
1039
|
if (opts.onStop) {
|
|
1040
1040
|
opts.onStop();
|
|
1041
1041
|
}
|
|
1042
1042
|
return true;
|
|
1043
1043
|
}
|
|
1044
|
-
return callback(progress,
|
|
1044
|
+
return callback(progress, frame.stop);
|
|
1045
1045
|
});
|
|
1046
1046
|
}
|
|
1047
1047
|
const HIGH_LIGHT_OPACITY = 0.3;
|
|
@@ -1050,7 +1050,7 @@ function drawHighlight(treemap, evt) {
|
|
|
1050
1050
|
const { currentNode } = evt.state;
|
|
1051
1051
|
if (currentNode) {
|
|
1052
1052
|
const [x, y, w, h] = currentNode.layout;
|
|
1053
|
-
|
|
1053
|
+
smoothFrame((_, cleanup) => {
|
|
1054
1054
|
cleanup();
|
|
1055
1055
|
highlight.reset();
|
|
1056
1056
|
const mask = createRoundBlock(x, y, w, h, { fill, opacity: HIGH_LIGHT_OPACITY, radius: 4, padding: 2 });
|
|
@@ -1118,7 +1118,7 @@ class TreemapEvent extends DOMEvent {
|
|
|
1118
1118
|
drawHighlight(ctx.treemap, this);
|
|
1119
1119
|
} else {
|
|
1120
1120
|
const { treemap } = ctx;
|
|
1121
|
-
|
|
1121
|
+
smoothFrame((_, cleanup) => {
|
|
1122
1122
|
cleanup();
|
|
1123
1123
|
const { offsetX: x, offsetY: y } = metadata.native;
|
|
1124
1124
|
const { dragX: lastX, dragY: lastY } = this.state;
|
|
@@ -1189,13 +1189,11 @@ class TreemapEvent extends DOMEvent {
|
|
|
1189
1189
|
const targetScaleRatio = this.matrix.a * delta;
|
|
1190
1190
|
const translateX = offsetX - (offsetX - this.matrix.e) * delta;
|
|
1191
1191
|
const translateY = offsetY - (offsetY - this.matrix.f) * delta;
|
|
1192
|
-
|
|
1193
|
-
this.silent("mousedown");
|
|
1192
|
+
smoothFrame((progress, cleanup) => {
|
|
1194
1193
|
this.exposedEvent.silent("mousemove");
|
|
1195
1194
|
this.silent("mousemove");
|
|
1196
1195
|
this.silent("click");
|
|
1197
1196
|
this.exposedEvent.silent("click");
|
|
1198
|
-
cleanup();
|
|
1199
1197
|
treemap.highlight.reset();
|
|
1200
1198
|
treemap.highlight.setZIndexForHighlight();
|
|
1201
1199
|
treemap.fontCache.flush(treemap, this.matrix);
|
|
@@ -1212,12 +1210,12 @@ class TreemapEvent extends DOMEvent {
|
|
|
1212
1210
|
);
|
|
1213
1211
|
stackMatrixTransformWithGraphAndLayer(treemap.elements, this.matrix.e, this.matrix.f, 1);
|
|
1214
1212
|
treemap.update();
|
|
1213
|
+
cleanup();
|
|
1215
1214
|
}, {
|
|
1216
1215
|
duration: ANIMATION_DURATION,
|
|
1217
1216
|
onStop: () => {
|
|
1218
1217
|
this.state.forceDestroy = false;
|
|
1219
1218
|
this.state.isWheeling = false;
|
|
1220
|
-
this.active("mousedown");
|
|
1221
1219
|
this.active("mousemove");
|
|
1222
1220
|
this.exposedEvent.active("mousemove");
|
|
1223
1221
|
this.active("click");
|
|
@@ -1254,7 +1252,7 @@ function createOnZoom(treemap, evt) {
|
|
|
1254
1252
|
const targetScale = factor * evt.matrix.a;
|
|
1255
1253
|
const translateX = boundingClientRect.width / 2 - (mx + mw / 2) * factor;
|
|
1256
1254
|
const translateY = boundingClientRect.height / 2 - (my + mh / 2) * factor;
|
|
1257
|
-
|
|
1255
|
+
smoothFrame((progress, cleanup) => {
|
|
1258
1256
|
cleanup();
|
|
1259
1257
|
evt.silent("mousemove");
|
|
1260
1258
|
evt.exposedEvent.silent("mousemove");
|
|
@@ -1641,8 +1639,8 @@ function evaluateColorMappings(data) {
|
|
|
1641
1639
|
const hash = Math.abs(hashCode(id));
|
|
1642
1640
|
return hash % 360;
|
|
1643
1641
|
};
|
|
1644
|
-
const lightScale = (depth) =>
|
|
1645
|
-
const baseSaturation =
|
|
1642
|
+
const lightScale = (depth) => 50 - depth * 5;
|
|
1643
|
+
const baseSaturation = 80;
|
|
1646
1644
|
const siblingHueShift = 30;
|
|
1647
1645
|
const rc = 0.2126;
|
|
1648
1646
|
const gc = 0.7152;
|
|
@@ -1670,8 +1668,8 @@ function evaluateColorMappings(data) {
|
|
|
1670
1668
|
const { r, g, b } = hslToRgb(hslColor.h, hslColor.s / 100, hslColor.l);
|
|
1671
1669
|
const luminance = calculateLuminance(r, g, b);
|
|
1672
1670
|
if (luminance < 0.6) {
|
|
1673
|
-
hslColor.l += 0.
|
|
1674
|
-
} else if (luminance > 0.
|
|
1671
|
+
hslColor.l += 0.2;
|
|
1672
|
+
} else if (luminance > 0.8) {
|
|
1675
1673
|
hslColor.l -= 0.1;
|
|
1676
1674
|
}
|
|
1677
1675
|
hslColor.l *= 100;
|