@opendata-ai/openchart-engine 2.7.0 → 2.8.1
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.js +3410 -252
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/compile-chart.test.ts +78 -0
- package/src/__tests__/legend.test.ts +24 -0
- package/src/compile.ts +52 -5
- package/src/legend/compute.ts +19 -0
package/dist/index.js
CHANGED
|
@@ -26,9 +26,9 @@ function resolvePosition(value, scale) {
|
|
|
26
26
|
const s = scale.scale;
|
|
27
27
|
const type = scale.type;
|
|
28
28
|
if (type === "time") {
|
|
29
|
-
const
|
|
30
|
-
if (Number.isNaN(
|
|
31
|
-
return s(
|
|
29
|
+
const date2 = new Date(String(value));
|
|
30
|
+
if (Number.isNaN(date2.getTime())) return null;
|
|
31
|
+
return s(date2);
|
|
32
32
|
}
|
|
33
33
|
if (type === "linear" || type === "log") {
|
|
34
34
|
const num = typeof value === "number" ? value : Number(value);
|
|
@@ -61,11 +61,11 @@ function makeAnnotationLabelStyle(fontSize, fontWeight, fill, isDark) {
|
|
|
61
61
|
function computeTextBounds(labelX, labelY, text, fontSize, fontWeight) {
|
|
62
62
|
const lines = text.split("\n");
|
|
63
63
|
const isMultiLine = lines.length > 1;
|
|
64
|
-
const maxWidth = Math.max(...lines.map((
|
|
64
|
+
const maxWidth = Math.max(...lines.map((line) => estimateTextWidth(line, fontSize, fontWeight)));
|
|
65
65
|
const totalHeight = lines.length * fontSize * DEFAULT_LINE_HEIGHT;
|
|
66
|
-
const
|
|
66
|
+
const x2 = isMultiLine ? labelX - maxWidth / 2 : labelX;
|
|
67
67
|
return {
|
|
68
|
-
x,
|
|
68
|
+
x: x2,
|
|
69
69
|
y: labelY - fontSize,
|
|
70
70
|
width: maxWidth,
|
|
71
71
|
height: totalHeight
|
|
@@ -181,25 +181,25 @@ function resolveTextAnnotation(annotation, scales, chartArea, isDark) {
|
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
183
|
function resolveRangeAnnotation(annotation, scales, chartArea, isDark) {
|
|
184
|
-
let
|
|
185
|
-
let
|
|
184
|
+
let x2 = chartArea.x;
|
|
185
|
+
let y2 = chartArea.y;
|
|
186
186
|
let width = chartArea.width;
|
|
187
187
|
let height = chartArea.height;
|
|
188
188
|
if (annotation.x1 !== void 0 && annotation.x2 !== void 0) {
|
|
189
189
|
const x1px = resolvePosition(annotation.x1, scales.x);
|
|
190
190
|
const x2px = resolvePosition(annotation.x2, scales.x);
|
|
191
191
|
if (x1px === null || x2px === null) return null;
|
|
192
|
-
|
|
192
|
+
x2 = Math.min(x1px, x2px);
|
|
193
193
|
width = Math.abs(x2px - x1px);
|
|
194
194
|
}
|
|
195
195
|
if (annotation.y1 !== void 0 && annotation.y2 !== void 0) {
|
|
196
196
|
const y1px = resolvePosition(annotation.y1, scales.y);
|
|
197
197
|
const y2px = resolvePosition(annotation.y2, scales.y);
|
|
198
198
|
if (y1px === null || y2px === null) return null;
|
|
199
|
-
|
|
199
|
+
y2 = Math.min(y1px, y2px);
|
|
200
200
|
height = Math.abs(y2px - y1px);
|
|
201
201
|
}
|
|
202
|
-
const rect = { x, y, width, height };
|
|
202
|
+
const rect = { x: x2, y: y2, width, height };
|
|
203
203
|
let label;
|
|
204
204
|
if (annotation.label) {
|
|
205
205
|
const anchor = annotation.labelAnchor ?? "left";
|
|
@@ -213,11 +213,11 @@ function resolveRangeAnnotation(annotation, scales, chartArea, isDark) {
|
|
|
213
213
|
} else if (anchor === "right") {
|
|
214
214
|
style.textAnchor = "end";
|
|
215
215
|
}
|
|
216
|
-
const baseX = centered ?
|
|
216
|
+
const baseX = centered ? x2 + width / 2 : anchor === "right" ? x2 + width : x2;
|
|
217
217
|
label = {
|
|
218
218
|
text: annotation.label,
|
|
219
219
|
x: baseX + labelDelta.dx,
|
|
220
|
-
y:
|
|
220
|
+
y: y2 + labelDelta.dy,
|
|
221
221
|
style,
|
|
222
222
|
visible: true
|
|
223
223
|
};
|
|
@@ -410,9 +410,9 @@ var DEFAULT_COLOR = "#1b7fa3";
|
|
|
410
410
|
function scaleValue(scale, scaleType, value) {
|
|
411
411
|
if (value == null) return null;
|
|
412
412
|
if (scaleType === "time") {
|
|
413
|
-
const
|
|
414
|
-
if (Number.isNaN(
|
|
415
|
-
return scale(
|
|
413
|
+
const date2 = value instanceof Date ? value : new Date(String(value));
|
|
414
|
+
if (Number.isNaN(date2.getTime())) return null;
|
|
415
|
+
return scale(date2);
|
|
416
416
|
}
|
|
417
417
|
if (scaleType === "point" || scaleType === "band" || scaleType === "ordinal") {
|
|
418
418
|
const result = scale(String(value));
|
|
@@ -536,7 +536,7 @@ function computeStackedBars(data, valueField, categoryField, colorField, xScale,
|
|
|
536
536
|
const groupKey = String(row[colorField] ?? "");
|
|
537
537
|
const value = Number(row[valueField] ?? 0);
|
|
538
538
|
if (!Number.isFinite(value) || value <= 0) continue;
|
|
539
|
-
const
|
|
539
|
+
const color2 = getColor(scales, groupKey);
|
|
540
540
|
const xLeft = xScale(cumulativeValue);
|
|
541
541
|
const xRight = xScale(cumulativeValue + value);
|
|
542
542
|
const barWidth = Math.max(Math.abs(xRight - xLeft), MIN_BAR_WIDTH);
|
|
@@ -549,7 +549,7 @@ function computeStackedBars(data, valueField, categoryField, colorField, xScale,
|
|
|
549
549
|
y: bandY,
|
|
550
550
|
width: barWidth,
|
|
551
551
|
height: bandwidth,
|
|
552
|
-
fill:
|
|
552
|
+
fill: color2,
|
|
553
553
|
cornerRadius: 0,
|
|
554
554
|
data: row,
|
|
555
555
|
aria
|
|
@@ -567,7 +567,7 @@ function computeSimpleBars(data, valueField, categoryField, xScale, yScale, band
|
|
|
567
567
|
if (!Number.isFinite(value)) continue;
|
|
568
568
|
const bandY = yScale(category);
|
|
569
569
|
if (bandY === void 0) continue;
|
|
570
|
-
const
|
|
570
|
+
const color2 = sequentialColor ? getSequentialColor(scales, value) : getColor(scales, "__default__");
|
|
571
571
|
const xPos = value >= 0 ? baseline : xScale(value);
|
|
572
572
|
const barWidth = Math.max(Math.abs(xScale(value) - baseline), MIN_BAR_WIDTH);
|
|
573
573
|
const aria = {
|
|
@@ -579,7 +579,7 @@ function computeSimpleBars(data, valueField, categoryField, xScale, yScale, band
|
|
|
579
579
|
y: bandY,
|
|
580
580
|
width: barWidth,
|
|
581
581
|
height: bandwidth,
|
|
582
|
-
fill:
|
|
582
|
+
fill: color2,
|
|
583
583
|
cornerRadius: 2,
|
|
584
584
|
data: row,
|
|
585
585
|
aria
|
|
@@ -746,20 +746,20 @@ function computeSimpleColumns(data, categoryField, valueField, xScale, yScale, b
|
|
|
746
746
|
if (!Number.isFinite(value)) continue;
|
|
747
747
|
const bandX = xScale(category);
|
|
748
748
|
if (bandX === void 0) continue;
|
|
749
|
-
const
|
|
749
|
+
const color2 = sequentialColor ? getSequentialColor(scales, value) : getColor(scales, "__default__");
|
|
750
750
|
const yPos = yScale(value);
|
|
751
751
|
const columnHeight = Math.max(Math.abs(baseline - yPos), MIN_COLUMN_HEIGHT);
|
|
752
|
-
const
|
|
752
|
+
const y2 = value >= 0 ? yPos : baseline;
|
|
753
753
|
const aria = {
|
|
754
754
|
label: `${category}: ${formatColumnValue(value)}`
|
|
755
755
|
};
|
|
756
756
|
marks.push({
|
|
757
757
|
type: "rect",
|
|
758
758
|
x: bandX,
|
|
759
|
-
y,
|
|
759
|
+
y: y2,
|
|
760
760
|
width: bandwidth,
|
|
761
761
|
height: columnHeight,
|
|
762
|
-
fill:
|
|
762
|
+
fill: color2,
|
|
763
763
|
cornerRadius: 2,
|
|
764
764
|
data: row,
|
|
765
765
|
aria
|
|
@@ -776,20 +776,20 @@ function computeColoredColumns(data, categoryField, valueField, colorField, xSca
|
|
|
776
776
|
const bandX = xScale(category);
|
|
777
777
|
if (bandX === void 0) continue;
|
|
778
778
|
const groupKey = String(row[colorField] ?? "");
|
|
779
|
-
const
|
|
779
|
+
const color2 = getColor(scales, groupKey);
|
|
780
780
|
const yPos = yScale(value);
|
|
781
781
|
const columnHeight = Math.max(Math.abs(baseline - yPos), MIN_COLUMN_HEIGHT);
|
|
782
|
-
const
|
|
782
|
+
const y2 = value >= 0 ? yPos : baseline;
|
|
783
783
|
const aria = {
|
|
784
784
|
label: `${category}, ${groupKey}: ${formatColumnValue(value)}`
|
|
785
785
|
};
|
|
786
786
|
marks.push({
|
|
787
787
|
type: "rect",
|
|
788
788
|
x: bandX,
|
|
789
|
-
y,
|
|
789
|
+
y: y2,
|
|
790
790
|
width: bandwidth,
|
|
791
791
|
height: columnHeight,
|
|
792
|
-
fill:
|
|
792
|
+
fill: color2,
|
|
793
793
|
cornerRadius: 2,
|
|
794
794
|
data: row,
|
|
795
795
|
aria
|
|
@@ -808,7 +808,7 @@ function computeStackedColumns(data, categoryField, valueField, colorField, xSca
|
|
|
808
808
|
const groupKey = String(row[colorField] ?? "");
|
|
809
809
|
const value = Number(row[valueField] ?? 0);
|
|
810
810
|
if (!Number.isFinite(value) || value <= 0) continue;
|
|
811
|
-
const
|
|
811
|
+
const color2 = getColor(scales, groupKey);
|
|
812
812
|
const yTop = yScale(cumulativeValue + value);
|
|
813
813
|
const yBottom = yScale(cumulativeValue);
|
|
814
814
|
const columnHeight = Math.max(Math.abs(yBottom - yTop), MIN_COLUMN_HEIGHT);
|
|
@@ -821,7 +821,7 @@ function computeStackedColumns(data, categoryField, valueField, colorField, xSca
|
|
|
821
821
|
y: yTop,
|
|
822
822
|
width: bandwidth,
|
|
823
823
|
height: columnHeight,
|
|
824
|
-
fill:
|
|
824
|
+
fill: color2,
|
|
825
825
|
cornerRadius: 0,
|
|
826
826
|
data: row,
|
|
827
827
|
aria
|
|
@@ -983,7 +983,7 @@ function computeDumbbellMarks(data, valueField, categoryField, colorField, xScal
|
|
|
983
983
|
if (!Number.isFinite(value)) continue;
|
|
984
984
|
const cx = xScale(value);
|
|
985
985
|
const colorCategory = String(row[colorField] ?? "");
|
|
986
|
-
const
|
|
986
|
+
const color2 = getColor(scales, colorCategory);
|
|
987
987
|
const dotAria = {
|
|
988
988
|
label: `${category}, ${colorCategory}: ${value}`
|
|
989
989
|
};
|
|
@@ -992,7 +992,7 @@ function computeDumbbellMarks(data, valueField, categoryField, colorField, xScal
|
|
|
992
992
|
cx,
|
|
993
993
|
cy,
|
|
994
994
|
r: DOT_RADIUS,
|
|
995
|
-
fill:
|
|
995
|
+
fill: color2,
|
|
996
996
|
stroke: "#ffffff",
|
|
997
997
|
strokeWidth: 2,
|
|
998
998
|
data: row,
|
|
@@ -1012,7 +1012,7 @@ function computeLollipopMarks(data, valueField, categoryField, xScale, yScale, b
|
|
|
1012
1012
|
if (bandY === void 0) continue;
|
|
1013
1013
|
const cx = xScale(value);
|
|
1014
1014
|
const cy = bandY + bandwidth / 2;
|
|
1015
|
-
const
|
|
1015
|
+
const color2 = getColor(scales, "__default__");
|
|
1016
1016
|
const stemX = Math.min(baseline, cx);
|
|
1017
1017
|
const stemWidth = Math.abs(cx - baseline);
|
|
1018
1018
|
if (stemWidth > 0) {
|
|
@@ -1038,7 +1038,7 @@ function computeLollipopMarks(data, valueField, categoryField, xScale, yScale, b
|
|
|
1038
1038
|
cx,
|
|
1039
1039
|
cy,
|
|
1040
1040
|
r: DOT_RADIUS,
|
|
1041
|
-
fill:
|
|
1041
|
+
fill: color2,
|
|
1042
1042
|
stroke: "#ffffff",
|
|
1043
1043
|
strokeWidth: 2,
|
|
1044
1044
|
data: row,
|
|
@@ -1110,8 +1110,644 @@ var dotRenderer = (spec, scales, chartArea, strategy, _theme) => {
|
|
|
1110
1110
|
return marks;
|
|
1111
1111
|
};
|
|
1112
1112
|
|
|
1113
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/constant.js
|
|
1114
|
+
function constant_default(x2) {
|
|
1115
|
+
return function constant() {
|
|
1116
|
+
return x2;
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/math.js
|
|
1121
|
+
var abs = Math.abs;
|
|
1122
|
+
var atan2 = Math.atan2;
|
|
1123
|
+
var cos = Math.cos;
|
|
1124
|
+
var max = Math.max;
|
|
1125
|
+
var min = Math.min;
|
|
1126
|
+
var sin = Math.sin;
|
|
1127
|
+
var sqrt = Math.sqrt;
|
|
1128
|
+
var epsilon = 1e-12;
|
|
1129
|
+
var pi = Math.PI;
|
|
1130
|
+
var halfPi = pi / 2;
|
|
1131
|
+
var tau = 2 * pi;
|
|
1132
|
+
function acos(x2) {
|
|
1133
|
+
return x2 > 1 ? 0 : x2 < -1 ? pi : Math.acos(x2);
|
|
1134
|
+
}
|
|
1135
|
+
function asin(x2) {
|
|
1136
|
+
return x2 >= 1 ? halfPi : x2 <= -1 ? -halfPi : Math.asin(x2);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// ../../node_modules/.bun/d3-path@3.1.0/node_modules/d3-path/src/path.js
|
|
1140
|
+
var pi2 = Math.PI;
|
|
1141
|
+
var tau2 = 2 * pi2;
|
|
1142
|
+
var epsilon2 = 1e-6;
|
|
1143
|
+
var tauEpsilon = tau2 - epsilon2;
|
|
1144
|
+
function append(strings) {
|
|
1145
|
+
this._ += strings[0];
|
|
1146
|
+
for (let i = 1, n = strings.length; i < n; ++i) {
|
|
1147
|
+
this._ += arguments[i] + strings[i];
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
function appendRound(digits) {
|
|
1151
|
+
let d = Math.floor(digits);
|
|
1152
|
+
if (!(d >= 0)) throw new Error(`invalid digits: ${digits}`);
|
|
1153
|
+
if (d > 15) return append;
|
|
1154
|
+
const k = 10 ** d;
|
|
1155
|
+
return function(strings) {
|
|
1156
|
+
this._ += strings[0];
|
|
1157
|
+
for (let i = 1, n = strings.length; i < n; ++i) {
|
|
1158
|
+
this._ += Math.round(arguments[i] * k) / k + strings[i];
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
var Path = class {
|
|
1163
|
+
constructor(digits) {
|
|
1164
|
+
this._x0 = this._y0 = // start of current subpath
|
|
1165
|
+
this._x1 = this._y1 = null;
|
|
1166
|
+
this._ = "";
|
|
1167
|
+
this._append = digits == null ? append : appendRound(digits);
|
|
1168
|
+
}
|
|
1169
|
+
moveTo(x2, y2) {
|
|
1170
|
+
this._append`M${this._x0 = this._x1 = +x2},${this._y0 = this._y1 = +y2}`;
|
|
1171
|
+
}
|
|
1172
|
+
closePath() {
|
|
1173
|
+
if (this._x1 !== null) {
|
|
1174
|
+
this._x1 = this._x0, this._y1 = this._y0;
|
|
1175
|
+
this._append`Z`;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
lineTo(x2, y2) {
|
|
1179
|
+
this._append`L${this._x1 = +x2},${this._y1 = +y2}`;
|
|
1180
|
+
}
|
|
1181
|
+
quadraticCurveTo(x1, y1, x2, y2) {
|
|
1182
|
+
this._append`Q${+x1},${+y1},${this._x1 = +x2},${this._y1 = +y2}`;
|
|
1183
|
+
}
|
|
1184
|
+
bezierCurveTo(x1, y1, x2, y2, x3, y3) {
|
|
1185
|
+
this._append`C${+x1},${+y1},${+x2},${+y2},${this._x1 = +x3},${this._y1 = +y3}`;
|
|
1186
|
+
}
|
|
1187
|
+
arcTo(x1, y1, x2, y2, r) {
|
|
1188
|
+
x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
|
|
1189
|
+
if (r < 0) throw new Error(`negative radius: ${r}`);
|
|
1190
|
+
let x0 = this._x1, y0 = this._y1, x21 = x2 - x1, y21 = y2 - y1, x01 = x0 - x1, y01 = y0 - y1, l01_2 = x01 * x01 + y01 * y01;
|
|
1191
|
+
if (this._x1 === null) {
|
|
1192
|
+
this._append`M${this._x1 = x1},${this._y1 = y1}`;
|
|
1193
|
+
} else if (!(l01_2 > epsilon2)) ;
|
|
1194
|
+
else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon2) || !r) {
|
|
1195
|
+
this._append`L${this._x1 = x1},${this._y1 = y1}`;
|
|
1196
|
+
} else {
|
|
1197
|
+
let x20 = x2 - x0, y20 = y2 - y0, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi2 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21;
|
|
1198
|
+
if (Math.abs(t01 - 1) > epsilon2) {
|
|
1199
|
+
this._append`L${x1 + t01 * x01},${y1 + t01 * y01}`;
|
|
1200
|
+
}
|
|
1201
|
+
this._append`A${r},${r},0,0,${+(y01 * x20 > x01 * y20)},${this._x1 = x1 + t21 * x21},${this._y1 = y1 + t21 * y21}`;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
arc(x2, y2, r, a0, a1, ccw) {
|
|
1205
|
+
x2 = +x2, y2 = +y2, r = +r, ccw = !!ccw;
|
|
1206
|
+
if (r < 0) throw new Error(`negative radius: ${r}`);
|
|
1207
|
+
let dx = r * Math.cos(a0), dy = r * Math.sin(a0), x0 = x2 + dx, y0 = y2 + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0;
|
|
1208
|
+
if (this._x1 === null) {
|
|
1209
|
+
this._append`M${x0},${y0}`;
|
|
1210
|
+
} else if (Math.abs(this._x1 - x0) > epsilon2 || Math.abs(this._y1 - y0) > epsilon2) {
|
|
1211
|
+
this._append`L${x0},${y0}`;
|
|
1212
|
+
}
|
|
1213
|
+
if (!r) return;
|
|
1214
|
+
if (da < 0) da = da % tau2 + tau2;
|
|
1215
|
+
if (da > tauEpsilon) {
|
|
1216
|
+
this._append`A${r},${r},0,1,${cw},${x2 - dx},${y2 - dy}A${r},${r},0,1,${cw},${this._x1 = x0},${this._y1 = y0}`;
|
|
1217
|
+
} else if (da > epsilon2) {
|
|
1218
|
+
this._append`A${r},${r},0,${+(da >= pi2)},${cw},${this._x1 = x2 + r * Math.cos(a1)},${this._y1 = y2 + r * Math.sin(a1)}`;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
rect(x2, y2, w, h) {
|
|
1222
|
+
this._append`M${this._x0 = this._x1 = +x2},${this._y0 = this._y1 = +y2}h${w = +w}v${+h}h${-w}Z`;
|
|
1223
|
+
}
|
|
1224
|
+
toString() {
|
|
1225
|
+
return this._;
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
function path() {
|
|
1229
|
+
return new Path();
|
|
1230
|
+
}
|
|
1231
|
+
path.prototype = Path.prototype;
|
|
1232
|
+
|
|
1233
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/path.js
|
|
1234
|
+
function withPath(shape) {
|
|
1235
|
+
let digits = 3;
|
|
1236
|
+
shape.digits = function(_) {
|
|
1237
|
+
if (!arguments.length) return digits;
|
|
1238
|
+
if (_ == null) {
|
|
1239
|
+
digits = null;
|
|
1240
|
+
} else {
|
|
1241
|
+
const d = Math.floor(_);
|
|
1242
|
+
if (!(d >= 0)) throw new RangeError(`invalid digits: ${_}`);
|
|
1243
|
+
digits = d;
|
|
1244
|
+
}
|
|
1245
|
+
return shape;
|
|
1246
|
+
};
|
|
1247
|
+
return () => new Path(digits);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/arc.js
|
|
1251
|
+
function arcInnerRadius(d) {
|
|
1252
|
+
return d.innerRadius;
|
|
1253
|
+
}
|
|
1254
|
+
function arcOuterRadius(d) {
|
|
1255
|
+
return d.outerRadius;
|
|
1256
|
+
}
|
|
1257
|
+
function arcStartAngle(d) {
|
|
1258
|
+
return d.startAngle;
|
|
1259
|
+
}
|
|
1260
|
+
function arcEndAngle(d) {
|
|
1261
|
+
return d.endAngle;
|
|
1262
|
+
}
|
|
1263
|
+
function arcPadAngle(d) {
|
|
1264
|
+
return d && d.padAngle;
|
|
1265
|
+
}
|
|
1266
|
+
function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
|
|
1267
|
+
var x10 = x1 - x0, y10 = y1 - y0, x32 = x3 - x2, y32 = y3 - y2, t = y32 * x10 - x32 * y10;
|
|
1268
|
+
if (t * t < epsilon) return;
|
|
1269
|
+
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
|
|
1270
|
+
return [x0 + t * x10, y0 + t * y10];
|
|
1271
|
+
}
|
|
1272
|
+
function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
|
|
1273
|
+
var x01 = x0 - x1, y01 = y0 - y1, lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x11 = x0 + ox, y11 = y0 + oy, x10 = x1 + ox, y10 = y1 + oy, x00 = (x11 + x10) / 2, y00 = (y11 + y10) / 2, dx = x10 - x11, dy = y10 - y11, d2 = dx * dx + dy * dy, r = r1 - rc, D = x11 * y10 - x10 * y11, d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x00, dy0 = cy0 - y00, dx1 = cx1 - x00, dy1 = cy1 - y00;
|
|
1274
|
+
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
|
|
1275
|
+
return {
|
|
1276
|
+
cx: cx0,
|
|
1277
|
+
cy: cy0,
|
|
1278
|
+
x01: -ox,
|
|
1279
|
+
y01: -oy,
|
|
1280
|
+
x11: cx0 * (r1 / r - 1),
|
|
1281
|
+
y11: cy0 * (r1 / r - 1)
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
function arc_default() {
|
|
1285
|
+
var innerRadius = arcInnerRadius, outerRadius = arcOuterRadius, cornerRadius = constant_default(0), padRadius = null, startAngle = arcStartAngle, endAngle = arcEndAngle, padAngle = arcPadAngle, context = null, path2 = withPath(arc);
|
|
1286
|
+
function arc() {
|
|
1287
|
+
var buffer, r, r0 = +innerRadius.apply(this, arguments), r1 = +outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) - halfPi, a1 = endAngle.apply(this, arguments) - halfPi, da = abs(a1 - a0), cw = a1 > a0;
|
|
1288
|
+
if (!context) context = buffer = path2();
|
|
1289
|
+
if (r1 < r0) r = r1, r1 = r0, r0 = r;
|
|
1290
|
+
if (!(r1 > epsilon)) context.moveTo(0, 0);
|
|
1291
|
+
else if (da > tau - epsilon) {
|
|
1292
|
+
context.moveTo(r1 * cos(a0), r1 * sin(a0));
|
|
1293
|
+
context.arc(0, 0, r1, a0, a1, !cw);
|
|
1294
|
+
if (r0 > epsilon) {
|
|
1295
|
+
context.moveTo(r0 * cos(a1), r0 * sin(a1));
|
|
1296
|
+
context.arc(0, 0, r0, a1, a0, cw);
|
|
1297
|
+
}
|
|
1298
|
+
} else {
|
|
1299
|
+
var a01 = a0, a11 = a1, a00 = a0, a10 = a1, da0 = da, da1 = da, ap = padAngle.apply(this, arguments) / 2, rp = ap > epsilon && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)), rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), rc0 = rc, rc1 = rc, t02, t12;
|
|
1300
|
+
if (rp > epsilon) {
|
|
1301
|
+
var p0 = asin(rp / r0 * sin(ap)), p1 = asin(rp / r1 * sin(ap));
|
|
1302
|
+
if ((da0 -= p0 * 2) > epsilon) p0 *= cw ? 1 : -1, a00 += p0, a10 -= p0;
|
|
1303
|
+
else da0 = 0, a00 = a10 = (a0 + a1) / 2;
|
|
1304
|
+
if ((da1 -= p1 * 2) > epsilon) p1 *= cw ? 1 : -1, a01 += p1, a11 -= p1;
|
|
1305
|
+
else da1 = 0, a01 = a11 = (a0 + a1) / 2;
|
|
1306
|
+
}
|
|
1307
|
+
var x01 = r1 * cos(a01), y01 = r1 * sin(a01), x10 = r0 * cos(a10), y10 = r0 * sin(a10);
|
|
1308
|
+
if (rc > epsilon) {
|
|
1309
|
+
var x11 = r1 * cos(a11), y11 = r1 * sin(a11), x00 = r0 * cos(a00), y00 = r0 * sin(a00), oc;
|
|
1310
|
+
if (da < pi) {
|
|
1311
|
+
if (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10)) {
|
|
1312
|
+
var ax = x01 - oc[0], ay = y01 - oc[1], bx = x11 - oc[0], by = y11 - oc[1], kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2), lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
|
|
1313
|
+
rc0 = min(rc, (r0 - lc) / (kc - 1));
|
|
1314
|
+
rc1 = min(rc, (r1 - lc) / (kc + 1));
|
|
1315
|
+
} else {
|
|
1316
|
+
rc0 = rc1 = 0;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
if (!(da1 > epsilon)) context.moveTo(x01, y01);
|
|
1321
|
+
else if (rc1 > epsilon) {
|
|
1322
|
+
t02 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
|
|
1323
|
+
t12 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
|
|
1324
|
+
context.moveTo(t02.cx + t02.x01, t02.cy + t02.y01);
|
|
1325
|
+
if (rc1 < rc) context.arc(t02.cx, t02.cy, rc1, atan2(t02.y01, t02.x01), atan2(t12.y01, t12.x01), !cw);
|
|
1326
|
+
else {
|
|
1327
|
+
context.arc(t02.cx, t02.cy, rc1, atan2(t02.y01, t02.x01), atan2(t02.y11, t02.x11), !cw);
|
|
1328
|
+
context.arc(0, 0, r1, atan2(t02.cy + t02.y11, t02.cx + t02.x11), atan2(t12.cy + t12.y11, t12.cx + t12.x11), !cw);
|
|
1329
|
+
context.arc(t12.cx, t12.cy, rc1, atan2(t12.y11, t12.x11), atan2(t12.y01, t12.x01), !cw);
|
|
1330
|
+
}
|
|
1331
|
+
} else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
|
|
1332
|
+
if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10);
|
|
1333
|
+
else if (rc0 > epsilon) {
|
|
1334
|
+
t02 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
|
|
1335
|
+
t12 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
|
|
1336
|
+
context.lineTo(t02.cx + t02.x01, t02.cy + t02.y01);
|
|
1337
|
+
if (rc0 < rc) context.arc(t02.cx, t02.cy, rc0, atan2(t02.y01, t02.x01), atan2(t12.y01, t12.x01), !cw);
|
|
1338
|
+
else {
|
|
1339
|
+
context.arc(t02.cx, t02.cy, rc0, atan2(t02.y01, t02.x01), atan2(t02.y11, t02.x11), !cw);
|
|
1340
|
+
context.arc(0, 0, r0, atan2(t02.cy + t02.y11, t02.cx + t02.x11), atan2(t12.cy + t12.y11, t12.cx + t12.x11), cw);
|
|
1341
|
+
context.arc(t12.cx, t12.cy, rc0, atan2(t12.y11, t12.x11), atan2(t12.y01, t12.x01), !cw);
|
|
1342
|
+
}
|
|
1343
|
+
} else context.arc(0, 0, r0, a10, a00, cw);
|
|
1344
|
+
}
|
|
1345
|
+
context.closePath();
|
|
1346
|
+
if (buffer) return context = null, buffer + "" || null;
|
|
1347
|
+
}
|
|
1348
|
+
arc.centroid = function() {
|
|
1349
|
+
var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2;
|
|
1350
|
+
return [cos(a) * r, sin(a) * r];
|
|
1351
|
+
};
|
|
1352
|
+
arc.innerRadius = function(_) {
|
|
1353
|
+
return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant_default(+_), arc) : innerRadius;
|
|
1354
|
+
};
|
|
1355
|
+
arc.outerRadius = function(_) {
|
|
1356
|
+
return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant_default(+_), arc) : outerRadius;
|
|
1357
|
+
};
|
|
1358
|
+
arc.cornerRadius = function(_) {
|
|
1359
|
+
return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant_default(+_), arc) : cornerRadius;
|
|
1360
|
+
};
|
|
1361
|
+
arc.padRadius = function(_) {
|
|
1362
|
+
return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant_default(+_), arc) : padRadius;
|
|
1363
|
+
};
|
|
1364
|
+
arc.startAngle = function(_) {
|
|
1365
|
+
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant_default(+_), arc) : startAngle;
|
|
1366
|
+
};
|
|
1367
|
+
arc.endAngle = function(_) {
|
|
1368
|
+
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant_default(+_), arc) : endAngle;
|
|
1369
|
+
};
|
|
1370
|
+
arc.padAngle = function(_) {
|
|
1371
|
+
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant_default(+_), arc) : padAngle;
|
|
1372
|
+
};
|
|
1373
|
+
arc.context = function(_) {
|
|
1374
|
+
return arguments.length ? (context = _ == null ? null : _, arc) : context;
|
|
1375
|
+
};
|
|
1376
|
+
return arc;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/array.js
|
|
1380
|
+
var slice = Array.prototype.slice;
|
|
1381
|
+
function array_default(x2) {
|
|
1382
|
+
return typeof x2 === "object" && "length" in x2 ? x2 : Array.from(x2);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.js
|
|
1386
|
+
function Linear(context) {
|
|
1387
|
+
this._context = context;
|
|
1388
|
+
}
|
|
1389
|
+
Linear.prototype = {
|
|
1390
|
+
areaStart: function() {
|
|
1391
|
+
this._line = 0;
|
|
1392
|
+
},
|
|
1393
|
+
areaEnd: function() {
|
|
1394
|
+
this._line = NaN;
|
|
1395
|
+
},
|
|
1396
|
+
lineStart: function() {
|
|
1397
|
+
this._point = 0;
|
|
1398
|
+
},
|
|
1399
|
+
lineEnd: function() {
|
|
1400
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1401
|
+
this._line = 1 - this._line;
|
|
1402
|
+
},
|
|
1403
|
+
point: function(x2, y2) {
|
|
1404
|
+
x2 = +x2, y2 = +y2;
|
|
1405
|
+
switch (this._point) {
|
|
1406
|
+
case 0:
|
|
1407
|
+
this._point = 1;
|
|
1408
|
+
this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2);
|
|
1409
|
+
break;
|
|
1410
|
+
case 1:
|
|
1411
|
+
this._point = 2;
|
|
1412
|
+
// falls through
|
|
1413
|
+
default:
|
|
1414
|
+
this._context.lineTo(x2, y2);
|
|
1415
|
+
break;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
function linear_default(context) {
|
|
1420
|
+
return new Linear(context);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/point.js
|
|
1424
|
+
function x(p) {
|
|
1425
|
+
return p[0];
|
|
1426
|
+
}
|
|
1427
|
+
function y(p) {
|
|
1428
|
+
return p[1];
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/line.js
|
|
1432
|
+
function line_default(x2, y2) {
|
|
1433
|
+
var defined = constant_default(true), context = null, curve = linear_default, output = null, path2 = withPath(line);
|
|
1434
|
+
x2 = typeof x2 === "function" ? x2 : x2 === void 0 ? x : constant_default(x2);
|
|
1435
|
+
y2 = typeof y2 === "function" ? y2 : y2 === void 0 ? y : constant_default(y2);
|
|
1436
|
+
function line(data) {
|
|
1437
|
+
var i, n = (data = array_default(data)).length, d, defined0 = false, buffer;
|
|
1438
|
+
if (context == null) output = curve(buffer = path2());
|
|
1439
|
+
for (i = 0; i <= n; ++i) {
|
|
1440
|
+
if (!(i < n && defined(d = data[i], i, data)) === defined0) {
|
|
1441
|
+
if (defined0 = !defined0) output.lineStart();
|
|
1442
|
+
else output.lineEnd();
|
|
1443
|
+
}
|
|
1444
|
+
if (defined0) output.point(+x2(d, i, data), +y2(d, i, data));
|
|
1445
|
+
}
|
|
1446
|
+
if (buffer) return output = null, buffer + "" || null;
|
|
1447
|
+
}
|
|
1448
|
+
line.x = function(_) {
|
|
1449
|
+
return arguments.length ? (x2 = typeof _ === "function" ? _ : constant_default(+_), line) : x2;
|
|
1450
|
+
};
|
|
1451
|
+
line.y = function(_) {
|
|
1452
|
+
return arguments.length ? (y2 = typeof _ === "function" ? _ : constant_default(+_), line) : y2;
|
|
1453
|
+
};
|
|
1454
|
+
line.defined = function(_) {
|
|
1455
|
+
return arguments.length ? (defined = typeof _ === "function" ? _ : constant_default(!!_), line) : defined;
|
|
1456
|
+
};
|
|
1457
|
+
line.curve = function(_) {
|
|
1458
|
+
return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve;
|
|
1459
|
+
};
|
|
1460
|
+
line.context = function(_) {
|
|
1461
|
+
return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context;
|
|
1462
|
+
};
|
|
1463
|
+
return line;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/area.js
|
|
1467
|
+
function area_default(x0, y0, y1) {
|
|
1468
|
+
var x1 = null, defined = constant_default(true), context = null, curve = linear_default, output = null, path2 = withPath(area);
|
|
1469
|
+
x0 = typeof x0 === "function" ? x0 : x0 === void 0 ? x : constant_default(+x0);
|
|
1470
|
+
y0 = typeof y0 === "function" ? y0 : y0 === void 0 ? constant_default(0) : constant_default(+y0);
|
|
1471
|
+
y1 = typeof y1 === "function" ? y1 : y1 === void 0 ? y : constant_default(+y1);
|
|
1472
|
+
function area(data) {
|
|
1473
|
+
var i, j, k, n = (data = array_default(data)).length, d, defined0 = false, buffer, x0z = new Array(n), y0z = new Array(n);
|
|
1474
|
+
if (context == null) output = curve(buffer = path2());
|
|
1475
|
+
for (i = 0; i <= n; ++i) {
|
|
1476
|
+
if (!(i < n && defined(d = data[i], i, data)) === defined0) {
|
|
1477
|
+
if (defined0 = !defined0) {
|
|
1478
|
+
j = i;
|
|
1479
|
+
output.areaStart();
|
|
1480
|
+
output.lineStart();
|
|
1481
|
+
} else {
|
|
1482
|
+
output.lineEnd();
|
|
1483
|
+
output.lineStart();
|
|
1484
|
+
for (k = i - 1; k >= j; --k) {
|
|
1485
|
+
output.point(x0z[k], y0z[k]);
|
|
1486
|
+
}
|
|
1487
|
+
output.lineEnd();
|
|
1488
|
+
output.areaEnd();
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
if (defined0) {
|
|
1492
|
+
x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data);
|
|
1493
|
+
output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]);
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
if (buffer) return output = null, buffer + "" || null;
|
|
1497
|
+
}
|
|
1498
|
+
function arealine() {
|
|
1499
|
+
return line_default().defined(defined).curve(curve).context(context);
|
|
1500
|
+
}
|
|
1501
|
+
area.x = function(_) {
|
|
1502
|
+
return arguments.length ? (x0 = typeof _ === "function" ? _ : constant_default(+_), x1 = null, area) : x0;
|
|
1503
|
+
};
|
|
1504
|
+
area.x0 = function(_) {
|
|
1505
|
+
return arguments.length ? (x0 = typeof _ === "function" ? _ : constant_default(+_), area) : x0;
|
|
1506
|
+
};
|
|
1507
|
+
area.x1 = function(_) {
|
|
1508
|
+
return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : constant_default(+_), area) : x1;
|
|
1509
|
+
};
|
|
1510
|
+
area.y = function(_) {
|
|
1511
|
+
return arguments.length ? (y0 = typeof _ === "function" ? _ : constant_default(+_), y1 = null, area) : y0;
|
|
1512
|
+
};
|
|
1513
|
+
area.y0 = function(_) {
|
|
1514
|
+
return arguments.length ? (y0 = typeof _ === "function" ? _ : constant_default(+_), area) : y0;
|
|
1515
|
+
};
|
|
1516
|
+
area.y1 = function(_) {
|
|
1517
|
+
return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : constant_default(+_), area) : y1;
|
|
1518
|
+
};
|
|
1519
|
+
area.lineX0 = area.lineY0 = function() {
|
|
1520
|
+
return arealine().x(x0).y(y0);
|
|
1521
|
+
};
|
|
1522
|
+
area.lineY1 = function() {
|
|
1523
|
+
return arealine().x(x0).y(y1);
|
|
1524
|
+
};
|
|
1525
|
+
area.lineX1 = function() {
|
|
1526
|
+
return arealine().x(x1).y(y0);
|
|
1527
|
+
};
|
|
1528
|
+
area.defined = function(_) {
|
|
1529
|
+
return arguments.length ? (defined = typeof _ === "function" ? _ : constant_default(!!_), area) : defined;
|
|
1530
|
+
};
|
|
1531
|
+
area.curve = function(_) {
|
|
1532
|
+
return arguments.length ? (curve = _, context != null && (output = curve(context)), area) : curve;
|
|
1533
|
+
};
|
|
1534
|
+
area.context = function(_) {
|
|
1535
|
+
return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area) : context;
|
|
1536
|
+
};
|
|
1537
|
+
return area;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/descending.js
|
|
1541
|
+
function descending_default(a, b) {
|
|
1542
|
+
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/identity.js
|
|
1546
|
+
function identity_default(d) {
|
|
1547
|
+
return d;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/pie.js
|
|
1551
|
+
function pie_default() {
|
|
1552
|
+
var value = identity_default, sortValues = descending_default, sort = null, startAngle = constant_default(0), endAngle = constant_default(tau), padAngle = constant_default(0);
|
|
1553
|
+
function pie(data) {
|
|
1554
|
+
var i, n = (data = array_default(data)).length, j, k, sum = 0, index = new Array(n), arcs = new Array(n), a0 = +startAngle.apply(this, arguments), da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), a1, p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), pa = p * (da < 0 ? -1 : 1), v;
|
|
1555
|
+
for (i = 0; i < n; ++i) {
|
|
1556
|
+
if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {
|
|
1557
|
+
sum += v;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
if (sortValues != null) index.sort(function(i2, j2) {
|
|
1561
|
+
return sortValues(arcs[i2], arcs[j2]);
|
|
1562
|
+
});
|
|
1563
|
+
else if (sort != null) index.sort(function(i2, j2) {
|
|
1564
|
+
return sort(data[i2], data[j2]);
|
|
1565
|
+
});
|
|
1566
|
+
for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {
|
|
1567
|
+
j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {
|
|
1568
|
+
data: data[j],
|
|
1569
|
+
index: i,
|
|
1570
|
+
value: v,
|
|
1571
|
+
startAngle: a0,
|
|
1572
|
+
endAngle: a1,
|
|
1573
|
+
padAngle: p
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
return arcs;
|
|
1577
|
+
}
|
|
1578
|
+
pie.value = function(_) {
|
|
1579
|
+
return arguments.length ? (value = typeof _ === "function" ? _ : constant_default(+_), pie) : value;
|
|
1580
|
+
};
|
|
1581
|
+
pie.sortValues = function(_) {
|
|
1582
|
+
return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;
|
|
1583
|
+
};
|
|
1584
|
+
pie.sort = function(_) {
|
|
1585
|
+
return arguments.length ? (sort = _, sortValues = null, pie) : sort;
|
|
1586
|
+
};
|
|
1587
|
+
pie.startAngle = function(_) {
|
|
1588
|
+
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant_default(+_), pie) : startAngle;
|
|
1589
|
+
};
|
|
1590
|
+
pie.endAngle = function(_) {
|
|
1591
|
+
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant_default(+_), pie) : endAngle;
|
|
1592
|
+
};
|
|
1593
|
+
pie.padAngle = function(_) {
|
|
1594
|
+
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant_default(+_), pie) : padAngle;
|
|
1595
|
+
};
|
|
1596
|
+
return pie;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/curve/monotone.js
|
|
1600
|
+
function sign(x2) {
|
|
1601
|
+
return x2 < 0 ? -1 : 1;
|
|
1602
|
+
}
|
|
1603
|
+
function slope3(that, x2, y2) {
|
|
1604
|
+
var h0 = that._x1 - that._x0, h1 = x2 - that._x1, s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0), s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0), p = (s0 * h1 + s1 * h0) / (h0 + h1);
|
|
1605
|
+
return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;
|
|
1606
|
+
}
|
|
1607
|
+
function slope2(that, t) {
|
|
1608
|
+
var h = that._x1 - that._x0;
|
|
1609
|
+
return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t;
|
|
1610
|
+
}
|
|
1611
|
+
function point(that, t02, t12) {
|
|
1612
|
+
var x0 = that._x0, y0 = that._y0, x1 = that._x1, y1 = that._y1, dx = (x1 - x0) / 3;
|
|
1613
|
+
that._context.bezierCurveTo(x0 + dx, y0 + dx * t02, x1 - dx, y1 - dx * t12, x1, y1);
|
|
1614
|
+
}
|
|
1615
|
+
function MonotoneX(context) {
|
|
1616
|
+
this._context = context;
|
|
1617
|
+
}
|
|
1618
|
+
MonotoneX.prototype = {
|
|
1619
|
+
areaStart: function() {
|
|
1620
|
+
this._line = 0;
|
|
1621
|
+
},
|
|
1622
|
+
areaEnd: function() {
|
|
1623
|
+
this._line = NaN;
|
|
1624
|
+
},
|
|
1625
|
+
lineStart: function() {
|
|
1626
|
+
this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN;
|
|
1627
|
+
this._point = 0;
|
|
1628
|
+
},
|
|
1629
|
+
lineEnd: function() {
|
|
1630
|
+
switch (this._point) {
|
|
1631
|
+
case 2:
|
|
1632
|
+
this._context.lineTo(this._x1, this._y1);
|
|
1633
|
+
break;
|
|
1634
|
+
case 3:
|
|
1635
|
+
point(this, this._t0, slope2(this, this._t0));
|
|
1636
|
+
break;
|
|
1637
|
+
}
|
|
1638
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1639
|
+
this._line = 1 - this._line;
|
|
1640
|
+
},
|
|
1641
|
+
point: function(x2, y2) {
|
|
1642
|
+
var t12 = NaN;
|
|
1643
|
+
x2 = +x2, y2 = +y2;
|
|
1644
|
+
if (x2 === this._x1 && y2 === this._y1) return;
|
|
1645
|
+
switch (this._point) {
|
|
1646
|
+
case 0:
|
|
1647
|
+
this._point = 1;
|
|
1648
|
+
this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2);
|
|
1649
|
+
break;
|
|
1650
|
+
case 1:
|
|
1651
|
+
this._point = 2;
|
|
1652
|
+
break;
|
|
1653
|
+
case 2:
|
|
1654
|
+
this._point = 3;
|
|
1655
|
+
point(this, slope2(this, t12 = slope3(this, x2, y2)), t12);
|
|
1656
|
+
break;
|
|
1657
|
+
default:
|
|
1658
|
+
point(this, this._t0, t12 = slope3(this, x2, y2));
|
|
1659
|
+
break;
|
|
1660
|
+
}
|
|
1661
|
+
this._x0 = this._x1, this._x1 = x2;
|
|
1662
|
+
this._y0 = this._y1, this._y1 = y2;
|
|
1663
|
+
this._t0 = t12;
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
function MonotoneY(context) {
|
|
1667
|
+
this._context = new ReflectContext(context);
|
|
1668
|
+
}
|
|
1669
|
+
(MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x2, y2) {
|
|
1670
|
+
MonotoneX.prototype.point.call(this, y2, x2);
|
|
1671
|
+
};
|
|
1672
|
+
function ReflectContext(context) {
|
|
1673
|
+
this._context = context;
|
|
1674
|
+
}
|
|
1675
|
+
ReflectContext.prototype = {
|
|
1676
|
+
moveTo: function(x2, y2) {
|
|
1677
|
+
this._context.moveTo(y2, x2);
|
|
1678
|
+
},
|
|
1679
|
+
closePath: function() {
|
|
1680
|
+
this._context.closePath();
|
|
1681
|
+
},
|
|
1682
|
+
lineTo: function(x2, y2) {
|
|
1683
|
+
this._context.lineTo(y2, x2);
|
|
1684
|
+
},
|
|
1685
|
+
bezierCurveTo: function(x1, y1, x2, y2, x3, y3) {
|
|
1686
|
+
this._context.bezierCurveTo(y1, x1, y2, x2, y3, x3);
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
function monotoneX(context) {
|
|
1690
|
+
return new MonotoneX(context);
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/offset/none.js
|
|
1694
|
+
function none_default(series, order) {
|
|
1695
|
+
if (!((n = series.length) > 1)) return;
|
|
1696
|
+
for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
|
|
1697
|
+
s0 = s1, s1 = series[order[i]];
|
|
1698
|
+
for (j = 0; j < m; ++j) {
|
|
1699
|
+
s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/order/none.js
|
|
1705
|
+
function none_default2(series) {
|
|
1706
|
+
var n = series.length, o = new Array(n);
|
|
1707
|
+
while (--n >= 0) o[n] = n;
|
|
1708
|
+
return o;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
// ../../node_modules/.bun/d3-shape@3.2.0/node_modules/d3-shape/src/stack.js
|
|
1712
|
+
function stackValue(d, key) {
|
|
1713
|
+
return d[key];
|
|
1714
|
+
}
|
|
1715
|
+
function stackSeries(key) {
|
|
1716
|
+
const series = [];
|
|
1717
|
+
series.key = key;
|
|
1718
|
+
return series;
|
|
1719
|
+
}
|
|
1720
|
+
function stack_default() {
|
|
1721
|
+
var keys = constant_default([]), order = none_default2, offset = none_default, value = stackValue;
|
|
1722
|
+
function stack(data) {
|
|
1723
|
+
var sz = Array.from(keys.apply(this, arguments), stackSeries), i, n = sz.length, j = -1, oz;
|
|
1724
|
+
for (const d of data) {
|
|
1725
|
+
for (i = 0, ++j; i < n; ++i) {
|
|
1726
|
+
(sz[i][j] = [0, +value(d, sz[i].key, j, data)]).data = d;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
for (i = 0, oz = array_default(order(sz)); i < n; ++i) {
|
|
1730
|
+
sz[oz[i]].index = i;
|
|
1731
|
+
}
|
|
1732
|
+
offset(sz, oz);
|
|
1733
|
+
return sz;
|
|
1734
|
+
}
|
|
1735
|
+
stack.keys = function(_) {
|
|
1736
|
+
return arguments.length ? (keys = typeof _ === "function" ? _ : constant_default(Array.from(_)), stack) : keys;
|
|
1737
|
+
};
|
|
1738
|
+
stack.value = function(_) {
|
|
1739
|
+
return arguments.length ? (value = typeof _ === "function" ? _ : constant_default(+_), stack) : value;
|
|
1740
|
+
};
|
|
1741
|
+
stack.order = function(_) {
|
|
1742
|
+
return arguments.length ? (order = _ == null ? none_default2 : typeof _ === "function" ? _ : constant_default(Array.from(_)), stack) : order;
|
|
1743
|
+
};
|
|
1744
|
+
stack.offset = function(_) {
|
|
1745
|
+
return arguments.length ? (offset = _ == null ? none_default : _, stack) : offset;
|
|
1746
|
+
};
|
|
1747
|
+
return stack;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1113
1750
|
// src/charts/line/area.ts
|
|
1114
|
-
import { area, curveMonotoneX, line, stack, stackOffsetNone, stackOrderNone } from "d3-shape";
|
|
1115
1751
|
var DEFAULT_FILL_OPACITY = 0.15;
|
|
1116
1752
|
function computeSingleArea(spec, scales, _chartArea) {
|
|
1117
1753
|
const encoding = spec.encoding;
|
|
@@ -1138,7 +1774,7 @@ function computeSingleArea(spec, scales, _chartArea) {
|
|
|
1138
1774
|
}
|
|
1139
1775
|
const marks = [];
|
|
1140
1776
|
for (const [seriesKey, rows] of groups) {
|
|
1141
|
-
const
|
|
1777
|
+
const color2 = getColor(scales, seriesKey);
|
|
1142
1778
|
const sortedRows = sortByField(rows, xChannel.field);
|
|
1143
1779
|
const validPoints = [];
|
|
1144
1780
|
for (const row of sortedRows) {
|
|
@@ -1153,9 +1789,9 @@ function computeSingleArea(spec, scales, _chartArea) {
|
|
|
1153
1789
|
});
|
|
1154
1790
|
}
|
|
1155
1791
|
if (validPoints.length === 0) continue;
|
|
1156
|
-
const areaGenerator =
|
|
1792
|
+
const areaGenerator = area_default().x((d) => d.x).y0((d) => d.yBottom).y1((d) => d.yTop).curve(monotoneX);
|
|
1157
1793
|
const pathStr = areaGenerator(validPoints) ?? "";
|
|
1158
|
-
const topLineGenerator =
|
|
1794
|
+
const topLineGenerator = line_default().x((d) => d.x).y((d) => d.yTop).curve(monotoneX);
|
|
1159
1795
|
const topPathStr = topLineGenerator(validPoints) ?? "";
|
|
1160
1796
|
const topPoints = validPoints.map((p) => ({ x: p.x, y: p.yTop }));
|
|
1161
1797
|
const bottomPoints = validPoints.map((p) => ({ x: p.x, y: p.yBottom }));
|
|
@@ -1167,9 +1803,9 @@ function computeSingleArea(spec, scales, _chartArea) {
|
|
|
1167
1803
|
bottomPoints,
|
|
1168
1804
|
path: pathStr,
|
|
1169
1805
|
topPath: topPathStr,
|
|
1170
|
-
fill:
|
|
1806
|
+
fill: color2,
|
|
1171
1807
|
fillOpacity: DEFAULT_FILL_OPACITY,
|
|
1172
|
-
stroke:
|
|
1808
|
+
stroke: color2,
|
|
1173
1809
|
strokeWidth: 2,
|
|
1174
1810
|
seriesKey: seriesKey === "__default__" ? void 0 : seriesKey,
|
|
1175
1811
|
data: validPoints.map((p) => p.row),
|
|
@@ -1220,13 +1856,13 @@ function computeStackedArea(spec, scales, chartArea) {
|
|
|
1220
1856
|
}
|
|
1221
1857
|
return pivot;
|
|
1222
1858
|
});
|
|
1223
|
-
const stackGenerator =
|
|
1859
|
+
const stackGenerator = stack_default().keys(keys).order(none_default2).offset(none_default);
|
|
1224
1860
|
const stackedData = stackGenerator(pivotData);
|
|
1225
1861
|
const yScale = scales.y.scale;
|
|
1226
1862
|
const marks = [];
|
|
1227
1863
|
for (const layer of stackedData) {
|
|
1228
1864
|
const seriesKey = layer.key;
|
|
1229
|
-
const
|
|
1865
|
+
const color2 = getColor(scales, seriesKey);
|
|
1230
1866
|
const validPoints = [];
|
|
1231
1867
|
for (const d of layer) {
|
|
1232
1868
|
const xVal = scaleValue(scales.x.scale, scales.x.type, d.data.__x__);
|
|
@@ -1236,9 +1872,9 @@ function computeStackedArea(spec, scales, chartArea) {
|
|
|
1236
1872
|
validPoints.push({ x: xVal, yTop, yBottom });
|
|
1237
1873
|
}
|
|
1238
1874
|
if (validPoints.length === 0) continue;
|
|
1239
|
-
const areaGenerator =
|
|
1875
|
+
const areaGenerator = area_default().x((p) => p.x).y0((p) => p.yBottom).y1((p) => p.yTop).curve(monotoneX);
|
|
1240
1876
|
const pathStr = areaGenerator(validPoints) ?? "";
|
|
1241
|
-
const topLineGenerator =
|
|
1877
|
+
const topLineGenerator = line_default().x((p) => p.x).y((p) => p.yTop).curve(monotoneX);
|
|
1242
1878
|
const topPathStr = topLineGenerator(validPoints) ?? "";
|
|
1243
1879
|
const topPoints = validPoints.map((p) => ({ x: p.x, y: p.yTop }));
|
|
1244
1880
|
const bottomPoints = validPoints.map((p) => ({ x: p.x, y: p.yBottom }));
|
|
@@ -1251,10 +1887,10 @@ function computeStackedArea(spec, scales, chartArea) {
|
|
|
1251
1887
|
bottomPoints,
|
|
1252
1888
|
path: pathStr,
|
|
1253
1889
|
topPath: topPathStr,
|
|
1254
|
-
fill:
|
|
1890
|
+
fill: color2,
|
|
1255
1891
|
fillOpacity: 0.7,
|
|
1256
1892
|
// Higher opacity for stacked so layers are visible
|
|
1257
|
-
stroke:
|
|
1893
|
+
stroke: color2,
|
|
1258
1894
|
strokeWidth: 1,
|
|
1259
1895
|
seriesKey,
|
|
1260
1896
|
data: layer.map((d) => {
|
|
@@ -1276,7 +1912,6 @@ function computeAreaMarks(spec, scales, chartArea) {
|
|
|
1276
1912
|
}
|
|
1277
1913
|
|
|
1278
1914
|
// src/charts/line/compute.ts
|
|
1279
|
-
import { curveMonotoneX as curveMonotoneX2, line as line2 } from "d3-shape";
|
|
1280
1915
|
var DEFAULT_STROKE_WIDTH = 2.5;
|
|
1281
1916
|
var DEFAULT_POINT_RADIUS = 3;
|
|
1282
1917
|
function computeLineMarks(spec, scales, _chartArea, _strategy) {
|
|
@@ -1290,7 +1925,7 @@ function computeLineMarks(spec, scales, _chartArea, _strategy) {
|
|
|
1290
1925
|
const groups = groupByField(spec.data, colorField);
|
|
1291
1926
|
const marks = [];
|
|
1292
1927
|
for (const [seriesKey, rows] of groups) {
|
|
1293
|
-
const
|
|
1928
|
+
const color2 = getColor(scales, seriesKey);
|
|
1294
1929
|
const sortedRows = sortByField(rows, xChannel.field);
|
|
1295
1930
|
const pointsWithData = [];
|
|
1296
1931
|
const segments = [];
|
|
@@ -1305,14 +1940,14 @@ function computeLineMarks(spec, scales, _chartArea, _strategy) {
|
|
|
1305
1940
|
}
|
|
1306
1941
|
continue;
|
|
1307
1942
|
}
|
|
1308
|
-
const
|
|
1309
|
-
currentSegment.push(
|
|
1310
|
-
pointsWithData.push({ ...
|
|
1943
|
+
const point3 = { x: xVal, y: yVal };
|
|
1944
|
+
currentSegment.push(point3);
|
|
1945
|
+
pointsWithData.push({ ...point3, row });
|
|
1311
1946
|
}
|
|
1312
1947
|
if (currentSegment.length > 0) {
|
|
1313
1948
|
segments.push(currentSegment);
|
|
1314
1949
|
}
|
|
1315
|
-
const lineGenerator =
|
|
1950
|
+
const lineGenerator = line_default().x((d) => d.x).y((d) => d.y).curve(monotoneX);
|
|
1316
1951
|
const allPoints = [];
|
|
1317
1952
|
const pathParts = [];
|
|
1318
1953
|
for (const segment of segments) {
|
|
@@ -1338,7 +1973,7 @@ function computeLineMarks(spec, scales, _chartArea, _strategy) {
|
|
|
1338
1973
|
type: "line",
|
|
1339
1974
|
points: allPoints,
|
|
1340
1975
|
path: combinedPath,
|
|
1341
|
-
stroke:
|
|
1976
|
+
stroke: color2,
|
|
1342
1977
|
strokeWidth: styleOverride?.strokeWidth ?? DEFAULT_STROKE_WIDTH,
|
|
1343
1978
|
strokeDasharray,
|
|
1344
1979
|
opacity: styleOverride?.opacity,
|
|
@@ -1355,7 +1990,7 @@ function computeLineMarks(spec, scales, _chartArea, _strategy) {
|
|
|
1355
1990
|
cx: p.x,
|
|
1356
1991
|
cy: p.y,
|
|
1357
1992
|
r: showPoints ? DEFAULT_POINT_RADIUS : 0,
|
|
1358
|
-
fill:
|
|
1993
|
+
fill: color2,
|
|
1359
1994
|
stroke: showPoints ? "#ffffff" : "transparent",
|
|
1360
1995
|
strokeWidth: showPoints ? 1.5 : 0,
|
|
1361
1996
|
fillOpacity: 0,
|
|
@@ -1461,7 +2096,6 @@ var areaRenderer = (spec, scales, chartArea, strategy, _theme) => {
|
|
|
1461
2096
|
};
|
|
1462
2097
|
|
|
1463
2098
|
// src/charts/pie/compute.ts
|
|
1464
|
-
import { arc as d3Arc, pie as d3Pie } from "d3-shape";
|
|
1465
2099
|
var SMALL_SLICE_THRESHOLD = 0.03;
|
|
1466
2100
|
var DEFAULT_PALETTE = [
|
|
1467
2101
|
"#1b7fa3",
|
|
@@ -1480,11 +2114,11 @@ function groupSmallSlices(slices, threshold) {
|
|
|
1480
2114
|
if (total === 0) return slices;
|
|
1481
2115
|
const big = [];
|
|
1482
2116
|
let otherValue = 0;
|
|
1483
|
-
for (const
|
|
1484
|
-
if (
|
|
1485
|
-
otherValue +=
|
|
2117
|
+
for (const slice2 of slices) {
|
|
2118
|
+
if (slice2.value / total < threshold) {
|
|
2119
|
+
otherValue += slice2.value;
|
|
1486
2120
|
} else {
|
|
1487
|
-
big.push(
|
|
2121
|
+
big.push(slice2);
|
|
1488
2122
|
}
|
|
1489
2123
|
}
|
|
1490
2124
|
if (otherValue > 0) {
|
|
@@ -1536,35 +2170,35 @@ function computePieMarks(spec, scales, chartArea, _strategy, isDonut = false) {
|
|
|
1536
2170
|
if (slices.length === 0) return [];
|
|
1537
2171
|
slices.sort((a, b) => b.value - a.value);
|
|
1538
2172
|
slices = groupSmallSlices(slices, SMALL_SLICE_THRESHOLD);
|
|
1539
|
-
const pieGenerator =
|
|
2173
|
+
const pieGenerator = pie_default().value((d) => d.value).sort(null).padAngle(0.01);
|
|
1540
2174
|
const arcs = pieGenerator(slices);
|
|
1541
2175
|
const centerX = chartArea.x + chartArea.width / 2;
|
|
1542
2176
|
const centerY = chartArea.y + chartArea.height / 2;
|
|
1543
2177
|
const outerRadius = Math.min(chartArea.width, chartArea.height) / 2 * 0.85;
|
|
1544
2178
|
const innerRadius = isDonut ? outerRadius * 0.6 : 0;
|
|
1545
|
-
const arcGenerator =
|
|
2179
|
+
const arcGenerator = arc_default().innerRadius(innerRadius).outerRadius(outerRadius);
|
|
1546
2180
|
const marks = [];
|
|
1547
2181
|
const center = { x: centerX, y: centerY };
|
|
1548
2182
|
const total = slices.reduce((sum, s) => sum + s.value, 0);
|
|
1549
2183
|
for (let i = 0; i < arcs.length; i++) {
|
|
1550
2184
|
const arcDatum = arcs[i];
|
|
1551
|
-
const
|
|
1552
|
-
let
|
|
2185
|
+
const slice2 = arcDatum.data;
|
|
2186
|
+
let color2;
|
|
1553
2187
|
if (scales.color && categoryField) {
|
|
1554
2188
|
const colorScale = scales.color.scale;
|
|
1555
|
-
|
|
2189
|
+
color2 = colorScale(slice2.label);
|
|
1556
2190
|
} else {
|
|
1557
|
-
|
|
2191
|
+
color2 = DEFAULT_PALETTE[i % DEFAULT_PALETTE.length];
|
|
1558
2192
|
}
|
|
1559
|
-
const
|
|
2193
|
+
const path2 = arcGenerator(arcDatum) ?? "";
|
|
1560
2194
|
const centroidResult = arcGenerator.centroid(arcDatum);
|
|
1561
|
-
const percentage = total > 0 ? (
|
|
2195
|
+
const percentage = total > 0 ? (slice2.value / total * 100).toFixed(1) : "0";
|
|
1562
2196
|
const aria = {
|
|
1563
|
-
label: `${
|
|
2197
|
+
label: `${slice2.label}: ${slice2.value} (${percentage}%)`
|
|
1564
2198
|
};
|
|
1565
2199
|
marks.push({
|
|
1566
2200
|
type: "arc",
|
|
1567
|
-
path,
|
|
2201
|
+
path: path2,
|
|
1568
2202
|
centroid: {
|
|
1569
2203
|
x: centroidResult[0] + centerX,
|
|
1570
2204
|
y: centroidResult[1] + centerY
|
|
@@ -1574,122 +2208,2599 @@ function computePieMarks(spec, scales, chartArea, _strategy, isDonut = false) {
|
|
|
1574
2208
|
outerRadius,
|
|
1575
2209
|
startAngle: arcDatum.startAngle,
|
|
1576
2210
|
endAngle: arcDatum.endAngle,
|
|
1577
|
-
fill:
|
|
2211
|
+
fill: color2,
|
|
1578
2212
|
stroke: "#ffffff",
|
|
1579
2213
|
strokeWidth: 2,
|
|
1580
|
-
data:
|
|
2214
|
+
data: slice2.originalRow,
|
|
1581
2215
|
aria
|
|
1582
2216
|
});
|
|
1583
2217
|
}
|
|
1584
2218
|
return marks;
|
|
1585
2219
|
}
|
|
1586
2220
|
|
|
1587
|
-
// src/charts/pie/labels.ts
|
|
1588
|
-
import { estimateTextWidth as estimateTextWidth6, resolveCollisions as resolveCollisions5 } from "@opendata-ai/openchart-core";
|
|
1589
|
-
var LABEL_FONT_SIZE5 = 10;
|
|
1590
|
-
var LABEL_FONT_WEIGHT5 = 500;
|
|
1591
|
-
var LEADER_LINE_OFFSET = 12;
|
|
1592
|
-
function computePieLabels(marks, _chartArea, density = "auto", _textFill = "#333333") {
|
|
1593
|
-
if (marks.length === 0) return [];
|
|
1594
|
-
if (density === "none") return [];
|
|
1595
|
-
const centerX = marks[0].center.x;
|
|
1596
|
-
const centerY = marks[0].center.y;
|
|
1597
|
-
const targetMarks = density === "endpoints" && marks.length > 1 ? [marks[0], marks[marks.length - 1]] : marks;
|
|
1598
|
-
const candidates = [];
|
|
1599
|
-
const targetMarkIndices = [];
|
|
1600
|
-
for (let mi = 0; mi < targetMarks.length; mi++) {
|
|
1601
|
-
const mark = targetMarks[mi];
|
|
1602
|
-
const ariaLabel = mark.aria.label;
|
|
1603
|
-
const firstColon = ariaLabel.indexOf(":");
|
|
1604
|
-
const labelText = firstColon >= 0 ? ariaLabel.slice(0, firstColon).trim() : "";
|
|
1605
|
-
if (!labelText) continue;
|
|
1606
|
-
const textWidth = estimateTextWidth6(labelText, LABEL_FONT_SIZE5, LABEL_FONT_WEIGHT5);
|
|
1607
|
-
const textHeight = LABEL_FONT_SIZE5 * 1.2;
|
|
1608
|
-
const midAngle = (mark.startAngle + mark.endAngle) / 2;
|
|
1609
|
-
const labelRadius = mark.outerRadius + LEADER_LINE_OFFSET;
|
|
1610
|
-
const labelX = centerX + Math.sin(midAngle) * labelRadius;
|
|
1611
|
-
const labelY = centerY - Math.cos(midAngle) * labelRadius;
|
|
1612
|
-
const isRight = Math.sin(midAngle) > 0;
|
|
1613
|
-
candidates.push({
|
|
1614
|
-
text: labelText,
|
|
1615
|
-
anchorX: isRight ? labelX : labelX - textWidth,
|
|
1616
|
-
anchorY: labelY - textHeight / 2,
|
|
1617
|
-
width: textWidth,
|
|
1618
|
-
height: textHeight,
|
|
1619
|
-
priority: "data",
|
|
1620
|
-
style: {
|
|
1621
|
-
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
1622
|
-
fontSize: LABEL_FONT_SIZE5,
|
|
1623
|
-
fontWeight: LABEL_FONT_WEIGHT5,
|
|
1624
|
-
fill: _textFill,
|
|
1625
|
-
lineHeight: 1.2,
|
|
1626
|
-
textAnchor: isRight ? "start" : "end",
|
|
1627
|
-
dominantBaseline: "central"
|
|
2221
|
+
// src/charts/pie/labels.ts
|
|
2222
|
+
import { estimateTextWidth as estimateTextWidth6, resolveCollisions as resolveCollisions5 } from "@opendata-ai/openchart-core";
|
|
2223
|
+
var LABEL_FONT_SIZE5 = 10;
|
|
2224
|
+
var LABEL_FONT_WEIGHT5 = 500;
|
|
2225
|
+
var LEADER_LINE_OFFSET = 12;
|
|
2226
|
+
function computePieLabels(marks, _chartArea, density = "auto", _textFill = "#333333") {
|
|
2227
|
+
if (marks.length === 0) return [];
|
|
2228
|
+
if (density === "none") return [];
|
|
2229
|
+
const centerX = marks[0].center.x;
|
|
2230
|
+
const centerY = marks[0].center.y;
|
|
2231
|
+
const targetMarks = density === "endpoints" && marks.length > 1 ? [marks[0], marks[marks.length - 1]] : marks;
|
|
2232
|
+
const candidates = [];
|
|
2233
|
+
const targetMarkIndices = [];
|
|
2234
|
+
for (let mi = 0; mi < targetMarks.length; mi++) {
|
|
2235
|
+
const mark = targetMarks[mi];
|
|
2236
|
+
const ariaLabel = mark.aria.label;
|
|
2237
|
+
const firstColon = ariaLabel.indexOf(":");
|
|
2238
|
+
const labelText = firstColon >= 0 ? ariaLabel.slice(0, firstColon).trim() : "";
|
|
2239
|
+
if (!labelText) continue;
|
|
2240
|
+
const textWidth = estimateTextWidth6(labelText, LABEL_FONT_SIZE5, LABEL_FONT_WEIGHT5);
|
|
2241
|
+
const textHeight = LABEL_FONT_SIZE5 * 1.2;
|
|
2242
|
+
const midAngle = (mark.startAngle + mark.endAngle) / 2;
|
|
2243
|
+
const labelRadius = mark.outerRadius + LEADER_LINE_OFFSET;
|
|
2244
|
+
const labelX = centerX + Math.sin(midAngle) * labelRadius;
|
|
2245
|
+
const labelY = centerY - Math.cos(midAngle) * labelRadius;
|
|
2246
|
+
const isRight = Math.sin(midAngle) > 0;
|
|
2247
|
+
candidates.push({
|
|
2248
|
+
text: labelText,
|
|
2249
|
+
anchorX: isRight ? labelX : labelX - textWidth,
|
|
2250
|
+
anchorY: labelY - textHeight / 2,
|
|
2251
|
+
width: textWidth,
|
|
2252
|
+
height: textHeight,
|
|
2253
|
+
priority: "data",
|
|
2254
|
+
style: {
|
|
2255
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
2256
|
+
fontSize: LABEL_FONT_SIZE5,
|
|
2257
|
+
fontWeight: LABEL_FONT_WEIGHT5,
|
|
2258
|
+
fill: _textFill,
|
|
2259
|
+
lineHeight: 1.2,
|
|
2260
|
+
textAnchor: isRight ? "start" : "end",
|
|
2261
|
+
dominantBaseline: "central"
|
|
2262
|
+
}
|
|
2263
|
+
});
|
|
2264
|
+
targetMarkIndices.push(mi);
|
|
2265
|
+
}
|
|
2266
|
+
if (candidates.length === 0) return [];
|
|
2267
|
+
let resolved;
|
|
2268
|
+
if (density === "all") {
|
|
2269
|
+
resolved = candidates.map((c) => ({
|
|
2270
|
+
text: c.text,
|
|
2271
|
+
x: c.anchorX,
|
|
2272
|
+
y: c.anchorY,
|
|
2273
|
+
style: c.style,
|
|
2274
|
+
visible: true
|
|
2275
|
+
}));
|
|
2276
|
+
} else {
|
|
2277
|
+
resolved = resolveCollisions5(candidates);
|
|
2278
|
+
}
|
|
2279
|
+
for (let i = 0; i < resolved.length && i < targetMarks.length; i++) {
|
|
2280
|
+
const label = resolved[i];
|
|
2281
|
+
const mark = targetMarks[i];
|
|
2282
|
+
if (label.visible) {
|
|
2283
|
+
label.connector = {
|
|
2284
|
+
from: { x: label.x, y: label.y },
|
|
2285
|
+
to: { x: mark.centroid.x, y: mark.centroid.y },
|
|
2286
|
+
stroke: _textFill,
|
|
2287
|
+
style: "straight"
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
return resolved;
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
// src/charts/pie/index.ts
|
|
2295
|
+
var pieRenderer = (spec, scales, chartArea, strategy, theme) => {
|
|
2296
|
+
const marks = computePieMarks(spec, scales, chartArea, strategy, false);
|
|
2297
|
+
const labels = computePieLabels(marks, chartArea, spec.labels.density, theme.colors.text);
|
|
2298
|
+
for (let i = 0; i < marks.length && i < labels.length; i++) {
|
|
2299
|
+
marks[i].label = labels[i];
|
|
2300
|
+
}
|
|
2301
|
+
return marks;
|
|
2302
|
+
};
|
|
2303
|
+
var donutRenderer = (spec, scales, chartArea, strategy, theme) => {
|
|
2304
|
+
const marks = computePieMarks(spec, scales, chartArea, strategy, true);
|
|
2305
|
+
const labels = computePieLabels(marks, chartArea, spec.labels.density, theme.colors.text);
|
|
2306
|
+
for (let i = 0; i < marks.length && i < labels.length; i++) {
|
|
2307
|
+
marks[i].label = labels[i];
|
|
2308
|
+
}
|
|
2309
|
+
return marks;
|
|
2310
|
+
};
|
|
2311
|
+
|
|
2312
|
+
// src/charts/registry.ts
|
|
2313
|
+
var renderers = /* @__PURE__ */ new Map();
|
|
2314
|
+
function registerChartRenderer(type, renderer) {
|
|
2315
|
+
renderers.set(type, renderer);
|
|
2316
|
+
}
|
|
2317
|
+
function getChartRenderer(type) {
|
|
2318
|
+
return renderers.get(type);
|
|
2319
|
+
}
|
|
2320
|
+
function clearRenderers() {
|
|
2321
|
+
renderers.clear();
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/ascending.js
|
|
2325
|
+
function ascending(a, b) {
|
|
2326
|
+
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/descending.js
|
|
2330
|
+
function descending(a, b) {
|
|
2331
|
+
return a == null || b == null ? NaN : b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/bisector.js
|
|
2335
|
+
function bisector(f) {
|
|
2336
|
+
let compare1, compare2, delta;
|
|
2337
|
+
if (f.length !== 2) {
|
|
2338
|
+
compare1 = ascending;
|
|
2339
|
+
compare2 = (d, x2) => ascending(f(d), x2);
|
|
2340
|
+
delta = (d, x2) => f(d) - x2;
|
|
2341
|
+
} else {
|
|
2342
|
+
compare1 = f === ascending || f === descending ? f : zero;
|
|
2343
|
+
compare2 = f;
|
|
2344
|
+
delta = f;
|
|
2345
|
+
}
|
|
2346
|
+
function left(a, x2, lo = 0, hi = a.length) {
|
|
2347
|
+
if (lo < hi) {
|
|
2348
|
+
if (compare1(x2, x2) !== 0) return hi;
|
|
2349
|
+
do {
|
|
2350
|
+
const mid = lo + hi >>> 1;
|
|
2351
|
+
if (compare2(a[mid], x2) < 0) lo = mid + 1;
|
|
2352
|
+
else hi = mid;
|
|
2353
|
+
} while (lo < hi);
|
|
2354
|
+
}
|
|
2355
|
+
return lo;
|
|
2356
|
+
}
|
|
2357
|
+
function right(a, x2, lo = 0, hi = a.length) {
|
|
2358
|
+
if (lo < hi) {
|
|
2359
|
+
if (compare1(x2, x2) !== 0) return hi;
|
|
2360
|
+
do {
|
|
2361
|
+
const mid = lo + hi >>> 1;
|
|
2362
|
+
if (compare2(a[mid], x2) <= 0) lo = mid + 1;
|
|
2363
|
+
else hi = mid;
|
|
2364
|
+
} while (lo < hi);
|
|
2365
|
+
}
|
|
2366
|
+
return lo;
|
|
2367
|
+
}
|
|
2368
|
+
function center(a, x2, lo = 0, hi = a.length) {
|
|
2369
|
+
const i = left(a, x2, lo, hi - 1);
|
|
2370
|
+
return i > lo && delta(a[i - 1], x2) > -delta(a[i], x2) ? i - 1 : i;
|
|
2371
|
+
}
|
|
2372
|
+
return { left, center, right };
|
|
2373
|
+
}
|
|
2374
|
+
function zero() {
|
|
2375
|
+
return 0;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/number.js
|
|
2379
|
+
function number(x2) {
|
|
2380
|
+
return x2 === null ? NaN : +x2;
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/bisect.js
|
|
2384
|
+
var ascendingBisect = bisector(ascending);
|
|
2385
|
+
var bisectRight = ascendingBisect.right;
|
|
2386
|
+
var bisectLeft = ascendingBisect.left;
|
|
2387
|
+
var bisectCenter = bisector(number).center;
|
|
2388
|
+
var bisect_default = bisectRight;
|
|
2389
|
+
|
|
2390
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/extent.js
|
|
2391
|
+
function extent(values, valueof) {
|
|
2392
|
+
let min3;
|
|
2393
|
+
let max3;
|
|
2394
|
+
if (valueof === void 0) {
|
|
2395
|
+
for (const value of values) {
|
|
2396
|
+
if (value != null) {
|
|
2397
|
+
if (min3 === void 0) {
|
|
2398
|
+
if (value >= value) min3 = max3 = value;
|
|
2399
|
+
} else {
|
|
2400
|
+
if (min3 > value) min3 = value;
|
|
2401
|
+
if (max3 < value) max3 = value;
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
} else {
|
|
2406
|
+
let index = -1;
|
|
2407
|
+
for (let value of values) {
|
|
2408
|
+
if ((value = valueof(value, ++index, values)) != null) {
|
|
2409
|
+
if (min3 === void 0) {
|
|
2410
|
+
if (value >= value) min3 = max3 = value;
|
|
2411
|
+
} else {
|
|
2412
|
+
if (min3 > value) min3 = value;
|
|
2413
|
+
if (max3 < value) max3 = value;
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
return [min3, max3];
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
// ../../node_modules/.bun/internmap@2.0.3/node_modules/internmap/src/index.js
|
|
2422
|
+
var InternMap = class extends Map {
|
|
2423
|
+
constructor(entries, key = keyof) {
|
|
2424
|
+
super();
|
|
2425
|
+
Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
|
|
2426
|
+
if (entries != null) for (const [key2, value] of entries) this.set(key2, value);
|
|
2427
|
+
}
|
|
2428
|
+
get(key) {
|
|
2429
|
+
return super.get(intern_get(this, key));
|
|
2430
|
+
}
|
|
2431
|
+
has(key) {
|
|
2432
|
+
return super.has(intern_get(this, key));
|
|
2433
|
+
}
|
|
2434
|
+
set(key, value) {
|
|
2435
|
+
return super.set(intern_set(this, key), value);
|
|
2436
|
+
}
|
|
2437
|
+
delete(key) {
|
|
2438
|
+
return super.delete(intern_delete(this, key));
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
function intern_get({ _intern, _key }, value) {
|
|
2442
|
+
const key = _key(value);
|
|
2443
|
+
return _intern.has(key) ? _intern.get(key) : value;
|
|
2444
|
+
}
|
|
2445
|
+
function intern_set({ _intern, _key }, value) {
|
|
2446
|
+
const key = _key(value);
|
|
2447
|
+
if (_intern.has(key)) return _intern.get(key);
|
|
2448
|
+
_intern.set(key, value);
|
|
2449
|
+
return value;
|
|
2450
|
+
}
|
|
2451
|
+
function intern_delete({ _intern, _key }, value) {
|
|
2452
|
+
const key = _key(value);
|
|
2453
|
+
if (_intern.has(key)) {
|
|
2454
|
+
value = _intern.get(key);
|
|
2455
|
+
_intern.delete(key);
|
|
2456
|
+
}
|
|
2457
|
+
return value;
|
|
2458
|
+
}
|
|
2459
|
+
function keyof(value) {
|
|
2460
|
+
return value !== null && typeof value === "object" ? value.valueOf() : value;
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/ticks.js
|
|
2464
|
+
var e10 = Math.sqrt(50);
|
|
2465
|
+
var e5 = Math.sqrt(10);
|
|
2466
|
+
var e2 = Math.sqrt(2);
|
|
2467
|
+
function tickSpec(start, stop, count) {
|
|
2468
|
+
const step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1;
|
|
2469
|
+
let i1, i2, inc;
|
|
2470
|
+
if (power < 0) {
|
|
2471
|
+
inc = Math.pow(10, -power) / factor;
|
|
2472
|
+
i1 = Math.round(start * inc);
|
|
2473
|
+
i2 = Math.round(stop * inc);
|
|
2474
|
+
if (i1 / inc < start) ++i1;
|
|
2475
|
+
if (i2 / inc > stop) --i2;
|
|
2476
|
+
inc = -inc;
|
|
2477
|
+
} else {
|
|
2478
|
+
inc = Math.pow(10, power) * factor;
|
|
2479
|
+
i1 = Math.round(start / inc);
|
|
2480
|
+
i2 = Math.round(stop / inc);
|
|
2481
|
+
if (i1 * inc < start) ++i1;
|
|
2482
|
+
if (i2 * inc > stop) --i2;
|
|
2483
|
+
}
|
|
2484
|
+
if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2);
|
|
2485
|
+
return [i1, i2, inc];
|
|
2486
|
+
}
|
|
2487
|
+
function ticks(start, stop, count) {
|
|
2488
|
+
stop = +stop, start = +start, count = +count;
|
|
2489
|
+
if (!(count > 0)) return [];
|
|
2490
|
+
if (start === stop) return [start];
|
|
2491
|
+
const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count);
|
|
2492
|
+
if (!(i2 >= i1)) return [];
|
|
2493
|
+
const n = i2 - i1 + 1, ticks2 = new Array(n);
|
|
2494
|
+
if (reverse) {
|
|
2495
|
+
if (inc < 0) for (let i = 0; i < n; ++i) ticks2[i] = (i2 - i) / -inc;
|
|
2496
|
+
else for (let i = 0; i < n; ++i) ticks2[i] = (i2 - i) * inc;
|
|
2497
|
+
} else {
|
|
2498
|
+
if (inc < 0) for (let i = 0; i < n; ++i) ticks2[i] = (i1 + i) / -inc;
|
|
2499
|
+
else for (let i = 0; i < n; ++i) ticks2[i] = (i1 + i) * inc;
|
|
2500
|
+
}
|
|
2501
|
+
return ticks2;
|
|
2502
|
+
}
|
|
2503
|
+
function tickIncrement(start, stop, count) {
|
|
2504
|
+
stop = +stop, start = +start, count = +count;
|
|
2505
|
+
return tickSpec(start, stop, count)[2];
|
|
2506
|
+
}
|
|
2507
|
+
function tickStep(start, stop, count) {
|
|
2508
|
+
stop = +stop, start = +start, count = +count;
|
|
2509
|
+
const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count);
|
|
2510
|
+
return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/max.js
|
|
2514
|
+
function max2(values, valueof) {
|
|
2515
|
+
let max3;
|
|
2516
|
+
if (valueof === void 0) {
|
|
2517
|
+
for (const value of values) {
|
|
2518
|
+
if (value != null && (max3 < value || max3 === void 0 && value >= value)) {
|
|
2519
|
+
max3 = value;
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
} else {
|
|
2523
|
+
let index = -1;
|
|
2524
|
+
for (let value of values) {
|
|
2525
|
+
if ((value = valueof(value, ++index, values)) != null && (max3 < value || max3 === void 0 && value >= value)) {
|
|
2526
|
+
max3 = value;
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
return max3;
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/min.js
|
|
2534
|
+
function min2(values, valueof) {
|
|
2535
|
+
let min3;
|
|
2536
|
+
if (valueof === void 0) {
|
|
2537
|
+
for (const value of values) {
|
|
2538
|
+
if (value != null && (min3 > value || min3 === void 0 && value >= value)) {
|
|
2539
|
+
min3 = value;
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
} else {
|
|
2543
|
+
let index = -1;
|
|
2544
|
+
for (let value of values) {
|
|
2545
|
+
if ((value = valueof(value, ++index, values)) != null && (min3 > value || min3 === void 0 && value >= value)) {
|
|
2546
|
+
min3 = value;
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
return min3;
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/range.js
|
|
2554
|
+
function range(start, stop, step) {
|
|
2555
|
+
start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
|
|
2556
|
+
var i = -1, n = Math.max(0, Math.ceil((stop - start) / step)) | 0, range2 = new Array(n);
|
|
2557
|
+
while (++i < n) {
|
|
2558
|
+
range2[i] = start + i * step;
|
|
2559
|
+
}
|
|
2560
|
+
return range2;
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/init.js
|
|
2564
|
+
function initRange(domain, range2) {
|
|
2565
|
+
switch (arguments.length) {
|
|
2566
|
+
case 0:
|
|
2567
|
+
break;
|
|
2568
|
+
case 1:
|
|
2569
|
+
this.range(domain);
|
|
2570
|
+
break;
|
|
2571
|
+
default:
|
|
2572
|
+
this.range(range2).domain(domain);
|
|
2573
|
+
break;
|
|
2574
|
+
}
|
|
2575
|
+
return this;
|
|
2576
|
+
}
|
|
2577
|
+
function initInterpolator(domain, interpolator) {
|
|
2578
|
+
switch (arguments.length) {
|
|
2579
|
+
case 0:
|
|
2580
|
+
break;
|
|
2581
|
+
case 1: {
|
|
2582
|
+
if (typeof domain === "function") this.interpolator(domain);
|
|
2583
|
+
else this.range(domain);
|
|
2584
|
+
break;
|
|
2585
|
+
}
|
|
2586
|
+
default: {
|
|
2587
|
+
this.domain(domain);
|
|
2588
|
+
if (typeof interpolator === "function") this.interpolator(interpolator);
|
|
2589
|
+
else this.range(interpolator);
|
|
2590
|
+
break;
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
return this;
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js
|
|
2597
|
+
var implicit = /* @__PURE__ */ Symbol("implicit");
|
|
2598
|
+
function ordinal() {
|
|
2599
|
+
var index = new InternMap(), domain = [], range2 = [], unknown = implicit;
|
|
2600
|
+
function scale(d) {
|
|
2601
|
+
let i = index.get(d);
|
|
2602
|
+
if (i === void 0) {
|
|
2603
|
+
if (unknown !== implicit) return unknown;
|
|
2604
|
+
index.set(d, i = domain.push(d) - 1);
|
|
2605
|
+
}
|
|
2606
|
+
return range2[i % range2.length];
|
|
2607
|
+
}
|
|
2608
|
+
scale.domain = function(_) {
|
|
2609
|
+
if (!arguments.length) return domain.slice();
|
|
2610
|
+
domain = [], index = new InternMap();
|
|
2611
|
+
for (const value of _) {
|
|
2612
|
+
if (index.has(value)) continue;
|
|
2613
|
+
index.set(value, domain.push(value) - 1);
|
|
2614
|
+
}
|
|
2615
|
+
return scale;
|
|
2616
|
+
};
|
|
2617
|
+
scale.range = function(_) {
|
|
2618
|
+
return arguments.length ? (range2 = Array.from(_), scale) : range2.slice();
|
|
2619
|
+
};
|
|
2620
|
+
scale.unknown = function(_) {
|
|
2621
|
+
return arguments.length ? (unknown = _, scale) : unknown;
|
|
2622
|
+
};
|
|
2623
|
+
scale.copy = function() {
|
|
2624
|
+
return ordinal(domain, range2).unknown(unknown);
|
|
2625
|
+
};
|
|
2626
|
+
initRange.apply(scale, arguments);
|
|
2627
|
+
return scale;
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/band.js
|
|
2631
|
+
function band() {
|
|
2632
|
+
var scale = ordinal().unknown(void 0), domain = scale.domain, ordinalRange = scale.range, r0 = 0, r1 = 1, step, bandwidth, round = false, paddingInner = 0, paddingOuter = 0, align = 0.5;
|
|
2633
|
+
delete scale.unknown;
|
|
2634
|
+
function rescale() {
|
|
2635
|
+
var n = domain().length, reverse = r1 < r0, start = reverse ? r1 : r0, stop = reverse ? r0 : r1;
|
|
2636
|
+
step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2);
|
|
2637
|
+
if (round) step = Math.floor(step);
|
|
2638
|
+
start += (stop - start - step * (n - paddingInner)) * align;
|
|
2639
|
+
bandwidth = step * (1 - paddingInner);
|
|
2640
|
+
if (round) start = Math.round(start), bandwidth = Math.round(bandwidth);
|
|
2641
|
+
var values = range(n).map(function(i) {
|
|
2642
|
+
return start + step * i;
|
|
2643
|
+
});
|
|
2644
|
+
return ordinalRange(reverse ? values.reverse() : values);
|
|
2645
|
+
}
|
|
2646
|
+
scale.domain = function(_) {
|
|
2647
|
+
return arguments.length ? (domain(_), rescale()) : domain();
|
|
2648
|
+
};
|
|
2649
|
+
scale.range = function(_) {
|
|
2650
|
+
return arguments.length ? ([r0, r1] = _, r0 = +r0, r1 = +r1, rescale()) : [r0, r1];
|
|
2651
|
+
};
|
|
2652
|
+
scale.rangeRound = function(_) {
|
|
2653
|
+
return [r0, r1] = _, r0 = +r0, r1 = +r1, round = true, rescale();
|
|
2654
|
+
};
|
|
2655
|
+
scale.bandwidth = function() {
|
|
2656
|
+
return bandwidth;
|
|
2657
|
+
};
|
|
2658
|
+
scale.step = function() {
|
|
2659
|
+
return step;
|
|
2660
|
+
};
|
|
2661
|
+
scale.round = function(_) {
|
|
2662
|
+
return arguments.length ? (round = !!_, rescale()) : round;
|
|
2663
|
+
};
|
|
2664
|
+
scale.padding = function(_) {
|
|
2665
|
+
return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner;
|
|
2666
|
+
};
|
|
2667
|
+
scale.paddingInner = function(_) {
|
|
2668
|
+
return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner;
|
|
2669
|
+
};
|
|
2670
|
+
scale.paddingOuter = function(_) {
|
|
2671
|
+
return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter;
|
|
2672
|
+
};
|
|
2673
|
+
scale.align = function(_) {
|
|
2674
|
+
return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
|
|
2675
|
+
};
|
|
2676
|
+
scale.copy = function() {
|
|
2677
|
+
return band(domain(), [r0, r1]).round(round).paddingInner(paddingInner).paddingOuter(paddingOuter).align(align);
|
|
2678
|
+
};
|
|
2679
|
+
return initRange.apply(rescale(), arguments);
|
|
2680
|
+
}
|
|
2681
|
+
function pointish(scale) {
|
|
2682
|
+
var copy3 = scale.copy;
|
|
2683
|
+
scale.padding = scale.paddingOuter;
|
|
2684
|
+
delete scale.paddingInner;
|
|
2685
|
+
delete scale.paddingOuter;
|
|
2686
|
+
scale.copy = function() {
|
|
2687
|
+
return pointish(copy3());
|
|
2688
|
+
};
|
|
2689
|
+
return scale;
|
|
2690
|
+
}
|
|
2691
|
+
function point2() {
|
|
2692
|
+
return pointish(band.apply(null, arguments).paddingInner(1));
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// ../../node_modules/.bun/d3-color@3.1.0/node_modules/d3-color/src/define.js
|
|
2696
|
+
function define_default(constructor, factory, prototype) {
|
|
2697
|
+
constructor.prototype = factory.prototype = prototype;
|
|
2698
|
+
prototype.constructor = constructor;
|
|
2699
|
+
}
|
|
2700
|
+
function extend(parent, definition) {
|
|
2701
|
+
var prototype = Object.create(parent.prototype);
|
|
2702
|
+
for (var key in definition) prototype[key] = definition[key];
|
|
2703
|
+
return prototype;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
// ../../node_modules/.bun/d3-color@3.1.0/node_modules/d3-color/src/color.js
|
|
2707
|
+
function Color() {
|
|
2708
|
+
}
|
|
2709
|
+
var darker = 0.7;
|
|
2710
|
+
var brighter = 1 / darker;
|
|
2711
|
+
var reI = "\\s*([+-]?\\d+)\\s*";
|
|
2712
|
+
var reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*";
|
|
2713
|
+
var reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*";
|
|
2714
|
+
var reHex = /^#([0-9a-f]{3,8})$/;
|
|
2715
|
+
var reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`);
|
|
2716
|
+
var reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`);
|
|
2717
|
+
var reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`);
|
|
2718
|
+
var reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`);
|
|
2719
|
+
var reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`);
|
|
2720
|
+
var reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
|
|
2721
|
+
var named = {
|
|
2722
|
+
aliceblue: 15792383,
|
|
2723
|
+
antiquewhite: 16444375,
|
|
2724
|
+
aqua: 65535,
|
|
2725
|
+
aquamarine: 8388564,
|
|
2726
|
+
azure: 15794175,
|
|
2727
|
+
beige: 16119260,
|
|
2728
|
+
bisque: 16770244,
|
|
2729
|
+
black: 0,
|
|
2730
|
+
blanchedalmond: 16772045,
|
|
2731
|
+
blue: 255,
|
|
2732
|
+
blueviolet: 9055202,
|
|
2733
|
+
brown: 10824234,
|
|
2734
|
+
burlywood: 14596231,
|
|
2735
|
+
cadetblue: 6266528,
|
|
2736
|
+
chartreuse: 8388352,
|
|
2737
|
+
chocolate: 13789470,
|
|
2738
|
+
coral: 16744272,
|
|
2739
|
+
cornflowerblue: 6591981,
|
|
2740
|
+
cornsilk: 16775388,
|
|
2741
|
+
crimson: 14423100,
|
|
2742
|
+
cyan: 65535,
|
|
2743
|
+
darkblue: 139,
|
|
2744
|
+
darkcyan: 35723,
|
|
2745
|
+
darkgoldenrod: 12092939,
|
|
2746
|
+
darkgray: 11119017,
|
|
2747
|
+
darkgreen: 25600,
|
|
2748
|
+
darkgrey: 11119017,
|
|
2749
|
+
darkkhaki: 12433259,
|
|
2750
|
+
darkmagenta: 9109643,
|
|
2751
|
+
darkolivegreen: 5597999,
|
|
2752
|
+
darkorange: 16747520,
|
|
2753
|
+
darkorchid: 10040012,
|
|
2754
|
+
darkred: 9109504,
|
|
2755
|
+
darksalmon: 15308410,
|
|
2756
|
+
darkseagreen: 9419919,
|
|
2757
|
+
darkslateblue: 4734347,
|
|
2758
|
+
darkslategray: 3100495,
|
|
2759
|
+
darkslategrey: 3100495,
|
|
2760
|
+
darkturquoise: 52945,
|
|
2761
|
+
darkviolet: 9699539,
|
|
2762
|
+
deeppink: 16716947,
|
|
2763
|
+
deepskyblue: 49151,
|
|
2764
|
+
dimgray: 6908265,
|
|
2765
|
+
dimgrey: 6908265,
|
|
2766
|
+
dodgerblue: 2003199,
|
|
2767
|
+
firebrick: 11674146,
|
|
2768
|
+
floralwhite: 16775920,
|
|
2769
|
+
forestgreen: 2263842,
|
|
2770
|
+
fuchsia: 16711935,
|
|
2771
|
+
gainsboro: 14474460,
|
|
2772
|
+
ghostwhite: 16316671,
|
|
2773
|
+
gold: 16766720,
|
|
2774
|
+
goldenrod: 14329120,
|
|
2775
|
+
gray: 8421504,
|
|
2776
|
+
green: 32768,
|
|
2777
|
+
greenyellow: 11403055,
|
|
2778
|
+
grey: 8421504,
|
|
2779
|
+
honeydew: 15794160,
|
|
2780
|
+
hotpink: 16738740,
|
|
2781
|
+
indianred: 13458524,
|
|
2782
|
+
indigo: 4915330,
|
|
2783
|
+
ivory: 16777200,
|
|
2784
|
+
khaki: 15787660,
|
|
2785
|
+
lavender: 15132410,
|
|
2786
|
+
lavenderblush: 16773365,
|
|
2787
|
+
lawngreen: 8190976,
|
|
2788
|
+
lemonchiffon: 16775885,
|
|
2789
|
+
lightblue: 11393254,
|
|
2790
|
+
lightcoral: 15761536,
|
|
2791
|
+
lightcyan: 14745599,
|
|
2792
|
+
lightgoldenrodyellow: 16448210,
|
|
2793
|
+
lightgray: 13882323,
|
|
2794
|
+
lightgreen: 9498256,
|
|
2795
|
+
lightgrey: 13882323,
|
|
2796
|
+
lightpink: 16758465,
|
|
2797
|
+
lightsalmon: 16752762,
|
|
2798
|
+
lightseagreen: 2142890,
|
|
2799
|
+
lightskyblue: 8900346,
|
|
2800
|
+
lightslategray: 7833753,
|
|
2801
|
+
lightslategrey: 7833753,
|
|
2802
|
+
lightsteelblue: 11584734,
|
|
2803
|
+
lightyellow: 16777184,
|
|
2804
|
+
lime: 65280,
|
|
2805
|
+
limegreen: 3329330,
|
|
2806
|
+
linen: 16445670,
|
|
2807
|
+
magenta: 16711935,
|
|
2808
|
+
maroon: 8388608,
|
|
2809
|
+
mediumaquamarine: 6737322,
|
|
2810
|
+
mediumblue: 205,
|
|
2811
|
+
mediumorchid: 12211667,
|
|
2812
|
+
mediumpurple: 9662683,
|
|
2813
|
+
mediumseagreen: 3978097,
|
|
2814
|
+
mediumslateblue: 8087790,
|
|
2815
|
+
mediumspringgreen: 64154,
|
|
2816
|
+
mediumturquoise: 4772300,
|
|
2817
|
+
mediumvioletred: 13047173,
|
|
2818
|
+
midnightblue: 1644912,
|
|
2819
|
+
mintcream: 16121850,
|
|
2820
|
+
mistyrose: 16770273,
|
|
2821
|
+
moccasin: 16770229,
|
|
2822
|
+
navajowhite: 16768685,
|
|
2823
|
+
navy: 128,
|
|
2824
|
+
oldlace: 16643558,
|
|
2825
|
+
olive: 8421376,
|
|
2826
|
+
olivedrab: 7048739,
|
|
2827
|
+
orange: 16753920,
|
|
2828
|
+
orangered: 16729344,
|
|
2829
|
+
orchid: 14315734,
|
|
2830
|
+
palegoldenrod: 15657130,
|
|
2831
|
+
palegreen: 10025880,
|
|
2832
|
+
paleturquoise: 11529966,
|
|
2833
|
+
palevioletred: 14381203,
|
|
2834
|
+
papayawhip: 16773077,
|
|
2835
|
+
peachpuff: 16767673,
|
|
2836
|
+
peru: 13468991,
|
|
2837
|
+
pink: 16761035,
|
|
2838
|
+
plum: 14524637,
|
|
2839
|
+
powderblue: 11591910,
|
|
2840
|
+
purple: 8388736,
|
|
2841
|
+
rebeccapurple: 6697881,
|
|
2842
|
+
red: 16711680,
|
|
2843
|
+
rosybrown: 12357519,
|
|
2844
|
+
royalblue: 4286945,
|
|
2845
|
+
saddlebrown: 9127187,
|
|
2846
|
+
salmon: 16416882,
|
|
2847
|
+
sandybrown: 16032864,
|
|
2848
|
+
seagreen: 3050327,
|
|
2849
|
+
seashell: 16774638,
|
|
2850
|
+
sienna: 10506797,
|
|
2851
|
+
silver: 12632256,
|
|
2852
|
+
skyblue: 8900331,
|
|
2853
|
+
slateblue: 6970061,
|
|
2854
|
+
slategray: 7372944,
|
|
2855
|
+
slategrey: 7372944,
|
|
2856
|
+
snow: 16775930,
|
|
2857
|
+
springgreen: 65407,
|
|
2858
|
+
steelblue: 4620980,
|
|
2859
|
+
tan: 13808780,
|
|
2860
|
+
teal: 32896,
|
|
2861
|
+
thistle: 14204888,
|
|
2862
|
+
tomato: 16737095,
|
|
2863
|
+
turquoise: 4251856,
|
|
2864
|
+
violet: 15631086,
|
|
2865
|
+
wheat: 16113331,
|
|
2866
|
+
white: 16777215,
|
|
2867
|
+
whitesmoke: 16119285,
|
|
2868
|
+
yellow: 16776960,
|
|
2869
|
+
yellowgreen: 10145074
|
|
2870
|
+
};
|
|
2871
|
+
define_default(Color, color, {
|
|
2872
|
+
copy(channels) {
|
|
2873
|
+
return Object.assign(new this.constructor(), this, channels);
|
|
2874
|
+
},
|
|
2875
|
+
displayable() {
|
|
2876
|
+
return this.rgb().displayable();
|
|
2877
|
+
},
|
|
2878
|
+
hex: color_formatHex,
|
|
2879
|
+
// Deprecated! Use color.formatHex.
|
|
2880
|
+
formatHex: color_formatHex,
|
|
2881
|
+
formatHex8: color_formatHex8,
|
|
2882
|
+
formatHsl: color_formatHsl,
|
|
2883
|
+
formatRgb: color_formatRgb,
|
|
2884
|
+
toString: color_formatRgb
|
|
2885
|
+
});
|
|
2886
|
+
function color_formatHex() {
|
|
2887
|
+
return this.rgb().formatHex();
|
|
2888
|
+
}
|
|
2889
|
+
function color_formatHex8() {
|
|
2890
|
+
return this.rgb().formatHex8();
|
|
2891
|
+
}
|
|
2892
|
+
function color_formatHsl() {
|
|
2893
|
+
return hslConvert(this).formatHsl();
|
|
2894
|
+
}
|
|
2895
|
+
function color_formatRgb() {
|
|
2896
|
+
return this.rgb().formatRgb();
|
|
2897
|
+
}
|
|
2898
|
+
function color(format2) {
|
|
2899
|
+
var m, l;
|
|
2900
|
+
format2 = (format2 + "").trim().toLowerCase();
|
|
2901
|
+
return (m = reHex.exec(format2)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) : l === 3 ? new Rgb(m >> 8 & 15 | m >> 4 & 240, m >> 4 & 15 | m & 240, (m & 15) << 4 | m & 15, 1) : l === 8 ? rgba(m >> 24 & 255, m >> 16 & 255, m >> 8 & 255, (m & 255) / 255) : l === 4 ? rgba(m >> 12 & 15 | m >> 8 & 240, m >> 8 & 15 | m >> 4 & 240, m >> 4 & 15 | m & 240, ((m & 15) << 4 | m & 15) / 255) : null) : (m = reRgbInteger.exec(format2)) ? new Rgb(m[1], m[2], m[3], 1) : (m = reRgbPercent.exec(format2)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) : (m = reRgbaInteger.exec(format2)) ? rgba(m[1], m[2], m[3], m[4]) : (m = reRgbaPercent.exec(format2)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) : (m = reHslPercent.exec(format2)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) : (m = reHslaPercent.exec(format2)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) : named.hasOwnProperty(format2) ? rgbn(named[format2]) : format2 === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null;
|
|
2902
|
+
}
|
|
2903
|
+
function rgbn(n) {
|
|
2904
|
+
return new Rgb(n >> 16 & 255, n >> 8 & 255, n & 255, 1);
|
|
2905
|
+
}
|
|
2906
|
+
function rgba(r, g, b, a) {
|
|
2907
|
+
if (a <= 0) r = g = b = NaN;
|
|
2908
|
+
return new Rgb(r, g, b, a);
|
|
2909
|
+
}
|
|
2910
|
+
function rgbConvert(o) {
|
|
2911
|
+
if (!(o instanceof Color)) o = color(o);
|
|
2912
|
+
if (!o) return new Rgb();
|
|
2913
|
+
o = o.rgb();
|
|
2914
|
+
return new Rgb(o.r, o.g, o.b, o.opacity);
|
|
2915
|
+
}
|
|
2916
|
+
function rgb(r, g, b, opacity) {
|
|
2917
|
+
return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
|
|
2918
|
+
}
|
|
2919
|
+
function Rgb(r, g, b, opacity) {
|
|
2920
|
+
this.r = +r;
|
|
2921
|
+
this.g = +g;
|
|
2922
|
+
this.b = +b;
|
|
2923
|
+
this.opacity = +opacity;
|
|
2924
|
+
}
|
|
2925
|
+
define_default(Rgb, rgb, extend(Color, {
|
|
2926
|
+
brighter(k) {
|
|
2927
|
+
k = k == null ? brighter : Math.pow(brighter, k);
|
|
2928
|
+
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
2929
|
+
},
|
|
2930
|
+
darker(k) {
|
|
2931
|
+
k = k == null ? darker : Math.pow(darker, k);
|
|
2932
|
+
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
2933
|
+
},
|
|
2934
|
+
rgb() {
|
|
2935
|
+
return this;
|
|
2936
|
+
},
|
|
2937
|
+
clamp() {
|
|
2938
|
+
return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
|
|
2939
|
+
},
|
|
2940
|
+
displayable() {
|
|
2941
|
+
return -0.5 <= this.r && this.r < 255.5 && (-0.5 <= this.g && this.g < 255.5) && (-0.5 <= this.b && this.b < 255.5) && (0 <= this.opacity && this.opacity <= 1);
|
|
2942
|
+
},
|
|
2943
|
+
hex: rgb_formatHex,
|
|
2944
|
+
// Deprecated! Use color.formatHex.
|
|
2945
|
+
formatHex: rgb_formatHex,
|
|
2946
|
+
formatHex8: rgb_formatHex8,
|
|
2947
|
+
formatRgb: rgb_formatRgb,
|
|
2948
|
+
toString: rgb_formatRgb
|
|
2949
|
+
}));
|
|
2950
|
+
function rgb_formatHex() {
|
|
2951
|
+
return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
|
|
2952
|
+
}
|
|
2953
|
+
function rgb_formatHex8() {
|
|
2954
|
+
return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
|
|
2955
|
+
}
|
|
2956
|
+
function rgb_formatRgb() {
|
|
2957
|
+
const a = clampa(this.opacity);
|
|
2958
|
+
return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`;
|
|
2959
|
+
}
|
|
2960
|
+
function clampa(opacity) {
|
|
2961
|
+
return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
|
|
2962
|
+
}
|
|
2963
|
+
function clampi(value) {
|
|
2964
|
+
return Math.max(0, Math.min(255, Math.round(value) || 0));
|
|
2965
|
+
}
|
|
2966
|
+
function hex(value) {
|
|
2967
|
+
value = clampi(value);
|
|
2968
|
+
return (value < 16 ? "0" : "") + value.toString(16);
|
|
2969
|
+
}
|
|
2970
|
+
function hsla(h, s, l, a) {
|
|
2971
|
+
if (a <= 0) h = s = l = NaN;
|
|
2972
|
+
else if (l <= 0 || l >= 1) h = s = NaN;
|
|
2973
|
+
else if (s <= 0) h = NaN;
|
|
2974
|
+
return new Hsl(h, s, l, a);
|
|
2975
|
+
}
|
|
2976
|
+
function hslConvert(o) {
|
|
2977
|
+
if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
|
|
2978
|
+
if (!(o instanceof Color)) o = color(o);
|
|
2979
|
+
if (!o) return new Hsl();
|
|
2980
|
+
if (o instanceof Hsl) return o;
|
|
2981
|
+
o = o.rgb();
|
|
2982
|
+
var r = o.r / 255, g = o.g / 255, b = o.b / 255, min3 = Math.min(r, g, b), max3 = Math.max(r, g, b), h = NaN, s = max3 - min3, l = (max3 + min3) / 2;
|
|
2983
|
+
if (s) {
|
|
2984
|
+
if (r === max3) h = (g - b) / s + (g < b) * 6;
|
|
2985
|
+
else if (g === max3) h = (b - r) / s + 2;
|
|
2986
|
+
else h = (r - g) / s + 4;
|
|
2987
|
+
s /= l < 0.5 ? max3 + min3 : 2 - max3 - min3;
|
|
2988
|
+
h *= 60;
|
|
2989
|
+
} else {
|
|
2990
|
+
s = l > 0 && l < 1 ? 0 : h;
|
|
2991
|
+
}
|
|
2992
|
+
return new Hsl(h, s, l, o.opacity);
|
|
2993
|
+
}
|
|
2994
|
+
function hsl(h, s, l, opacity) {
|
|
2995
|
+
return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
|
|
2996
|
+
}
|
|
2997
|
+
function Hsl(h, s, l, opacity) {
|
|
2998
|
+
this.h = +h;
|
|
2999
|
+
this.s = +s;
|
|
3000
|
+
this.l = +l;
|
|
3001
|
+
this.opacity = +opacity;
|
|
3002
|
+
}
|
|
3003
|
+
define_default(Hsl, hsl, extend(Color, {
|
|
3004
|
+
brighter(k) {
|
|
3005
|
+
k = k == null ? brighter : Math.pow(brighter, k);
|
|
3006
|
+
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
3007
|
+
},
|
|
3008
|
+
darker(k) {
|
|
3009
|
+
k = k == null ? darker : Math.pow(darker, k);
|
|
3010
|
+
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
3011
|
+
},
|
|
3012
|
+
rgb() {
|
|
3013
|
+
var h = this.h % 360 + (this.h < 0) * 360, s = isNaN(h) || isNaN(this.s) ? 0 : this.s, l = this.l, m2 = l + (l < 0.5 ? l : 1 - l) * s, m1 = 2 * l - m2;
|
|
3014
|
+
return new Rgb(
|
|
3015
|
+
hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
|
|
3016
|
+
hsl2rgb(h, m1, m2),
|
|
3017
|
+
hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
|
|
3018
|
+
this.opacity
|
|
3019
|
+
);
|
|
3020
|
+
},
|
|
3021
|
+
clamp() {
|
|
3022
|
+
return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
|
|
3023
|
+
},
|
|
3024
|
+
displayable() {
|
|
3025
|
+
return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1);
|
|
3026
|
+
},
|
|
3027
|
+
formatHsl() {
|
|
3028
|
+
const a = clampa(this.opacity);
|
|
3029
|
+
return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
|
|
3030
|
+
}
|
|
3031
|
+
}));
|
|
3032
|
+
function clamph(value) {
|
|
3033
|
+
value = (value || 0) % 360;
|
|
3034
|
+
return value < 0 ? value + 360 : value;
|
|
3035
|
+
}
|
|
3036
|
+
function clampt(value) {
|
|
3037
|
+
return Math.max(0, Math.min(1, value || 0));
|
|
3038
|
+
}
|
|
3039
|
+
function hsl2rgb(h, m1, m2) {
|
|
3040
|
+
return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255;
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/basis.js
|
|
3044
|
+
function basis(t12, v0, v1, v2, v3) {
|
|
3045
|
+
var t2 = t12 * t12, t3 = t2 * t12;
|
|
3046
|
+
return ((1 - 3 * t12 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t12 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6;
|
|
3047
|
+
}
|
|
3048
|
+
function basis_default(values) {
|
|
3049
|
+
var n = values.length - 1;
|
|
3050
|
+
return function(t) {
|
|
3051
|
+
var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n), v1 = values[i], v2 = values[i + 1], v0 = i > 0 ? values[i - 1] : 2 * v1 - v2, v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
|
|
3052
|
+
return basis((t - i / n) * n, v0, v1, v2, v3);
|
|
3053
|
+
};
|
|
3054
|
+
}
|
|
3055
|
+
|
|
3056
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/basisClosed.js
|
|
3057
|
+
function basisClosed_default(values) {
|
|
3058
|
+
var n = values.length;
|
|
3059
|
+
return function(t) {
|
|
3060
|
+
var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n), v0 = values[(i + n - 1) % n], v1 = values[i % n], v2 = values[(i + 1) % n], v3 = values[(i + 2) % n];
|
|
3061
|
+
return basis((t - i / n) * n, v0, v1, v2, v3);
|
|
3062
|
+
};
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/constant.js
|
|
3066
|
+
var constant_default2 = (x2) => () => x2;
|
|
3067
|
+
|
|
3068
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/color.js
|
|
3069
|
+
function linear(a, d) {
|
|
3070
|
+
return function(t) {
|
|
3071
|
+
return a + t * d;
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
function exponential(a, b, y2) {
|
|
3075
|
+
return a = Math.pow(a, y2), b = Math.pow(b, y2) - a, y2 = 1 / y2, function(t) {
|
|
3076
|
+
return Math.pow(a + t * b, y2);
|
|
3077
|
+
};
|
|
3078
|
+
}
|
|
3079
|
+
function gamma(y2) {
|
|
3080
|
+
return (y2 = +y2) === 1 ? nogamma : function(a, b) {
|
|
3081
|
+
return b - a ? exponential(a, b, y2) : constant_default2(isNaN(a) ? b : a);
|
|
3082
|
+
};
|
|
3083
|
+
}
|
|
3084
|
+
function nogamma(a, b) {
|
|
3085
|
+
var d = b - a;
|
|
3086
|
+
return d ? linear(a, d) : constant_default2(isNaN(a) ? b : a);
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/rgb.js
|
|
3090
|
+
var rgb_default = (function rgbGamma(y2) {
|
|
3091
|
+
var color2 = gamma(y2);
|
|
3092
|
+
function rgb2(start, end) {
|
|
3093
|
+
var r = color2((start = rgb(start)).r, (end = rgb(end)).r), g = color2(start.g, end.g), b = color2(start.b, end.b), opacity = nogamma(start.opacity, end.opacity);
|
|
3094
|
+
return function(t) {
|
|
3095
|
+
start.r = r(t);
|
|
3096
|
+
start.g = g(t);
|
|
3097
|
+
start.b = b(t);
|
|
3098
|
+
start.opacity = opacity(t);
|
|
3099
|
+
return start + "";
|
|
3100
|
+
};
|
|
3101
|
+
}
|
|
3102
|
+
rgb2.gamma = rgbGamma;
|
|
3103
|
+
return rgb2;
|
|
3104
|
+
})(1);
|
|
3105
|
+
function rgbSpline(spline) {
|
|
3106
|
+
return function(colors) {
|
|
3107
|
+
var n = colors.length, r = new Array(n), g = new Array(n), b = new Array(n), i, color2;
|
|
3108
|
+
for (i = 0; i < n; ++i) {
|
|
3109
|
+
color2 = rgb(colors[i]);
|
|
3110
|
+
r[i] = color2.r || 0;
|
|
3111
|
+
g[i] = color2.g || 0;
|
|
3112
|
+
b[i] = color2.b || 0;
|
|
3113
|
+
}
|
|
3114
|
+
r = spline(r);
|
|
3115
|
+
g = spline(g);
|
|
3116
|
+
b = spline(b);
|
|
3117
|
+
color2.opacity = 1;
|
|
3118
|
+
return function(t) {
|
|
3119
|
+
color2.r = r(t);
|
|
3120
|
+
color2.g = g(t);
|
|
3121
|
+
color2.b = b(t);
|
|
3122
|
+
return color2 + "";
|
|
3123
|
+
};
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3126
|
+
var rgbBasis = rgbSpline(basis_default);
|
|
3127
|
+
var rgbBasisClosed = rgbSpline(basisClosed_default);
|
|
3128
|
+
|
|
3129
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/numberArray.js
|
|
3130
|
+
function numberArray_default(a, b) {
|
|
3131
|
+
if (!b) b = [];
|
|
3132
|
+
var n = a ? Math.min(b.length, a.length) : 0, c = b.slice(), i;
|
|
3133
|
+
return function(t) {
|
|
3134
|
+
for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
|
|
3135
|
+
return c;
|
|
3136
|
+
};
|
|
3137
|
+
}
|
|
3138
|
+
function isNumberArray(x2) {
|
|
3139
|
+
return ArrayBuffer.isView(x2) && !(x2 instanceof DataView);
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/array.js
|
|
3143
|
+
function genericArray(a, b) {
|
|
3144
|
+
var nb = b ? b.length : 0, na = a ? Math.min(nb, a.length) : 0, x2 = new Array(na), c = new Array(nb), i;
|
|
3145
|
+
for (i = 0; i < na; ++i) x2[i] = value_default(a[i], b[i]);
|
|
3146
|
+
for (; i < nb; ++i) c[i] = b[i];
|
|
3147
|
+
return function(t) {
|
|
3148
|
+
for (i = 0; i < na; ++i) c[i] = x2[i](t);
|
|
3149
|
+
return c;
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/date.js
|
|
3154
|
+
function date_default(a, b) {
|
|
3155
|
+
var d = /* @__PURE__ */ new Date();
|
|
3156
|
+
return a = +a, b = +b, function(t) {
|
|
3157
|
+
return d.setTime(a * (1 - t) + b * t), d;
|
|
3158
|
+
};
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/number.js
|
|
3162
|
+
function number_default(a, b) {
|
|
3163
|
+
return a = +a, b = +b, function(t) {
|
|
3164
|
+
return a * (1 - t) + b * t;
|
|
3165
|
+
};
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/object.js
|
|
3169
|
+
function object_default(a, b) {
|
|
3170
|
+
var i = {}, c = {}, k;
|
|
3171
|
+
if (a === null || typeof a !== "object") a = {};
|
|
3172
|
+
if (b === null || typeof b !== "object") b = {};
|
|
3173
|
+
for (k in b) {
|
|
3174
|
+
if (k in a) {
|
|
3175
|
+
i[k] = value_default(a[k], b[k]);
|
|
3176
|
+
} else {
|
|
3177
|
+
c[k] = b[k];
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
return function(t) {
|
|
3181
|
+
for (k in i) c[k] = i[k](t);
|
|
3182
|
+
return c;
|
|
3183
|
+
};
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/string.js
|
|
3187
|
+
var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
|
|
3188
|
+
var reB = new RegExp(reA.source, "g");
|
|
3189
|
+
function zero2(b) {
|
|
3190
|
+
return function() {
|
|
3191
|
+
return b;
|
|
3192
|
+
};
|
|
3193
|
+
}
|
|
3194
|
+
function one(b) {
|
|
3195
|
+
return function(t) {
|
|
3196
|
+
return b(t) + "";
|
|
3197
|
+
};
|
|
3198
|
+
}
|
|
3199
|
+
function string_default(a, b) {
|
|
3200
|
+
var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = [];
|
|
3201
|
+
a = a + "", b = b + "";
|
|
3202
|
+
while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
|
|
3203
|
+
if ((bs = bm.index) > bi) {
|
|
3204
|
+
bs = b.slice(bi, bs);
|
|
3205
|
+
if (s[i]) s[i] += bs;
|
|
3206
|
+
else s[++i] = bs;
|
|
3207
|
+
}
|
|
3208
|
+
if ((am = am[0]) === (bm = bm[0])) {
|
|
3209
|
+
if (s[i]) s[i] += bm;
|
|
3210
|
+
else s[++i] = bm;
|
|
3211
|
+
} else {
|
|
3212
|
+
s[++i] = null;
|
|
3213
|
+
q.push({ i, x: number_default(am, bm) });
|
|
3214
|
+
}
|
|
3215
|
+
bi = reB.lastIndex;
|
|
3216
|
+
}
|
|
3217
|
+
if (bi < b.length) {
|
|
3218
|
+
bs = b.slice(bi);
|
|
3219
|
+
if (s[i]) s[i] += bs;
|
|
3220
|
+
else s[++i] = bs;
|
|
3221
|
+
}
|
|
3222
|
+
return s.length < 2 ? q[0] ? one(q[0].x) : zero2(b) : (b = q.length, function(t) {
|
|
3223
|
+
for (var i2 = 0, o; i2 < b; ++i2) s[(o = q[i2]).i] = o.x(t);
|
|
3224
|
+
return s.join("");
|
|
3225
|
+
});
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/value.js
|
|
3229
|
+
function value_default(a, b) {
|
|
3230
|
+
var t = typeof b, c;
|
|
3231
|
+
return b == null || t === "boolean" ? constant_default2(b) : (t === "number" ? number_default : t === "string" ? (c = color(b)) ? (b = c, rgb_default) : string_default : b instanceof color ? rgb_default : b instanceof Date ? date_default : isNumberArray(b) ? numberArray_default : Array.isArray(b) ? genericArray : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object_default : number_default)(a, b);
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
// ../../node_modules/.bun/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/round.js
|
|
3235
|
+
function round_default(a, b) {
|
|
3236
|
+
return a = +a, b = +b, function(t) {
|
|
3237
|
+
return Math.round(a * (1 - t) + b * t);
|
|
3238
|
+
};
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/constant.js
|
|
3242
|
+
function constants(x2) {
|
|
3243
|
+
return function() {
|
|
3244
|
+
return x2;
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
|
|
3248
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/number.js
|
|
3249
|
+
function number2(x2) {
|
|
3250
|
+
return +x2;
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/continuous.js
|
|
3254
|
+
var unit = [0, 1];
|
|
3255
|
+
function identity(x2) {
|
|
3256
|
+
return x2;
|
|
3257
|
+
}
|
|
3258
|
+
function normalize(a, b) {
|
|
3259
|
+
return (b -= a = +a) ? function(x2) {
|
|
3260
|
+
return (x2 - a) / b;
|
|
3261
|
+
} : constants(isNaN(b) ? NaN : 0.5);
|
|
3262
|
+
}
|
|
3263
|
+
function clamper(a, b) {
|
|
3264
|
+
var t;
|
|
3265
|
+
if (a > b) t = a, a = b, b = t;
|
|
3266
|
+
return function(x2) {
|
|
3267
|
+
return Math.max(a, Math.min(b, x2));
|
|
3268
|
+
};
|
|
3269
|
+
}
|
|
3270
|
+
function bimap(domain, range2, interpolate) {
|
|
3271
|
+
var d0 = domain[0], d1 = domain[1], r0 = range2[0], r1 = range2[1];
|
|
3272
|
+
if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
|
|
3273
|
+
else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
|
|
3274
|
+
return function(x2) {
|
|
3275
|
+
return r0(d0(x2));
|
|
3276
|
+
};
|
|
3277
|
+
}
|
|
3278
|
+
function polymap(domain, range2, interpolate) {
|
|
3279
|
+
var j = Math.min(domain.length, range2.length) - 1, d = new Array(j), r = new Array(j), i = -1;
|
|
3280
|
+
if (domain[j] < domain[0]) {
|
|
3281
|
+
domain = domain.slice().reverse();
|
|
3282
|
+
range2 = range2.slice().reverse();
|
|
3283
|
+
}
|
|
3284
|
+
while (++i < j) {
|
|
3285
|
+
d[i] = normalize(domain[i], domain[i + 1]);
|
|
3286
|
+
r[i] = interpolate(range2[i], range2[i + 1]);
|
|
3287
|
+
}
|
|
3288
|
+
return function(x2) {
|
|
3289
|
+
var i2 = bisect_default(domain, x2, 1, j) - 1;
|
|
3290
|
+
return r[i2](d[i2](x2));
|
|
3291
|
+
};
|
|
3292
|
+
}
|
|
3293
|
+
function copy(source, target) {
|
|
3294
|
+
return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
|
|
3295
|
+
}
|
|
3296
|
+
function transformer() {
|
|
3297
|
+
var domain = unit, range2 = unit, interpolate = value_default, transform, untransform, unknown, clamp = identity, piecewise, output, input;
|
|
3298
|
+
function rescale() {
|
|
3299
|
+
var n = Math.min(domain.length, range2.length);
|
|
3300
|
+
if (clamp !== identity) clamp = clamper(domain[0], domain[n - 1]);
|
|
3301
|
+
piecewise = n > 2 ? polymap : bimap;
|
|
3302
|
+
output = input = null;
|
|
3303
|
+
return scale;
|
|
3304
|
+
}
|
|
3305
|
+
function scale(x2) {
|
|
3306
|
+
return x2 == null || isNaN(x2 = +x2) ? unknown : (output || (output = piecewise(domain.map(transform), range2, interpolate)))(transform(clamp(x2)));
|
|
3307
|
+
}
|
|
3308
|
+
scale.invert = function(y2) {
|
|
3309
|
+
return clamp(untransform((input || (input = piecewise(range2, domain.map(transform), number_default)))(y2)));
|
|
3310
|
+
};
|
|
3311
|
+
scale.domain = function(_) {
|
|
3312
|
+
return arguments.length ? (domain = Array.from(_, number2), rescale()) : domain.slice();
|
|
3313
|
+
};
|
|
3314
|
+
scale.range = function(_) {
|
|
3315
|
+
return arguments.length ? (range2 = Array.from(_), rescale()) : range2.slice();
|
|
3316
|
+
};
|
|
3317
|
+
scale.rangeRound = function(_) {
|
|
3318
|
+
return range2 = Array.from(_), interpolate = round_default, rescale();
|
|
3319
|
+
};
|
|
3320
|
+
scale.clamp = function(_) {
|
|
3321
|
+
return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity;
|
|
3322
|
+
};
|
|
3323
|
+
scale.interpolate = function(_) {
|
|
3324
|
+
return arguments.length ? (interpolate = _, rescale()) : interpolate;
|
|
3325
|
+
};
|
|
3326
|
+
scale.unknown = function(_) {
|
|
3327
|
+
return arguments.length ? (unknown = _, scale) : unknown;
|
|
3328
|
+
};
|
|
3329
|
+
return function(t, u) {
|
|
3330
|
+
transform = t, untransform = u;
|
|
3331
|
+
return rescale();
|
|
3332
|
+
};
|
|
3333
|
+
}
|
|
3334
|
+
function continuous() {
|
|
3335
|
+
return transformer()(identity, identity);
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatDecimal.js
|
|
3339
|
+
function formatDecimal_default(x2) {
|
|
3340
|
+
return Math.abs(x2 = Math.round(x2)) >= 1e21 ? x2.toLocaleString("en").replace(/,/g, "") : x2.toString(10);
|
|
3341
|
+
}
|
|
3342
|
+
function formatDecimalParts(x2, p) {
|
|
3343
|
+
if (!isFinite(x2) || x2 === 0) return null;
|
|
3344
|
+
var i = (x2 = p ? x2.toExponential(p - 1) : x2.toExponential()).indexOf("e"), coefficient = x2.slice(0, i);
|
|
3345
|
+
return [
|
|
3346
|
+
coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
|
|
3347
|
+
+x2.slice(i + 1)
|
|
3348
|
+
];
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/exponent.js
|
|
3352
|
+
function exponent_default(x2) {
|
|
3353
|
+
return x2 = formatDecimalParts(Math.abs(x2)), x2 ? x2[1] : NaN;
|
|
3354
|
+
}
|
|
3355
|
+
|
|
3356
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatGroup.js
|
|
3357
|
+
function formatGroup_default(grouping, thousands) {
|
|
3358
|
+
return function(value, width) {
|
|
3359
|
+
var i = value.length, t = [], j = 0, g = grouping[0], length = 0;
|
|
3360
|
+
while (i > 0 && g > 0) {
|
|
3361
|
+
if (length + g + 1 > width) g = Math.max(1, width - length);
|
|
3362
|
+
t.push(value.substring(i -= g, i + g));
|
|
3363
|
+
if ((length += g + 1) > width) break;
|
|
3364
|
+
g = grouping[j = (j + 1) % grouping.length];
|
|
3365
|
+
}
|
|
3366
|
+
return t.reverse().join(thousands);
|
|
3367
|
+
};
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatNumerals.js
|
|
3371
|
+
function formatNumerals_default(numerals) {
|
|
3372
|
+
return function(value) {
|
|
3373
|
+
return value.replace(/[0-9]/g, function(i) {
|
|
3374
|
+
return numerals[+i];
|
|
3375
|
+
});
|
|
3376
|
+
};
|
|
3377
|
+
}
|
|
3378
|
+
|
|
3379
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatSpecifier.js
|
|
3380
|
+
var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
|
|
3381
|
+
function formatSpecifier(specifier) {
|
|
3382
|
+
if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
|
|
3383
|
+
var match;
|
|
3384
|
+
return new FormatSpecifier({
|
|
3385
|
+
fill: match[1],
|
|
3386
|
+
align: match[2],
|
|
3387
|
+
sign: match[3],
|
|
3388
|
+
symbol: match[4],
|
|
3389
|
+
zero: match[5],
|
|
3390
|
+
width: match[6],
|
|
3391
|
+
comma: match[7],
|
|
3392
|
+
precision: match[8] && match[8].slice(1),
|
|
3393
|
+
trim: match[9],
|
|
3394
|
+
type: match[10]
|
|
3395
|
+
});
|
|
3396
|
+
}
|
|
3397
|
+
formatSpecifier.prototype = FormatSpecifier.prototype;
|
|
3398
|
+
function FormatSpecifier(specifier) {
|
|
3399
|
+
this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
|
|
3400
|
+
this.align = specifier.align === void 0 ? ">" : specifier.align + "";
|
|
3401
|
+
this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
|
|
3402
|
+
this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
|
|
3403
|
+
this.zero = !!specifier.zero;
|
|
3404
|
+
this.width = specifier.width === void 0 ? void 0 : +specifier.width;
|
|
3405
|
+
this.comma = !!specifier.comma;
|
|
3406
|
+
this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
|
|
3407
|
+
this.trim = !!specifier.trim;
|
|
3408
|
+
this.type = specifier.type === void 0 ? "" : specifier.type + "";
|
|
3409
|
+
}
|
|
3410
|
+
FormatSpecifier.prototype.toString = function() {
|
|
3411
|
+
return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
|
|
3412
|
+
};
|
|
3413
|
+
|
|
3414
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatTrim.js
|
|
3415
|
+
function formatTrim_default(s) {
|
|
3416
|
+
out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
|
|
3417
|
+
switch (s[i]) {
|
|
3418
|
+
case ".":
|
|
3419
|
+
i0 = i1 = i;
|
|
3420
|
+
break;
|
|
3421
|
+
case "0":
|
|
3422
|
+
if (i0 === 0) i0 = i;
|
|
3423
|
+
i1 = i;
|
|
3424
|
+
break;
|
|
3425
|
+
default:
|
|
3426
|
+
if (!+s[i]) break out;
|
|
3427
|
+
if (i0 > 0) i0 = 0;
|
|
3428
|
+
break;
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatPrefixAuto.js
|
|
3435
|
+
var prefixExponent;
|
|
3436
|
+
function formatPrefixAuto_default(x2, p) {
|
|
3437
|
+
var d = formatDecimalParts(x2, p);
|
|
3438
|
+
if (!d) return prefixExponent = void 0, x2.toPrecision(p);
|
|
3439
|
+
var coefficient = d[0], exponent = d[1], i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n = coefficient.length;
|
|
3440
|
+
return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + formatDecimalParts(x2, Math.max(0, p + i - 1))[0];
|
|
3441
|
+
}
|
|
3442
|
+
|
|
3443
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatRounded.js
|
|
3444
|
+
function formatRounded_default(x2, p) {
|
|
3445
|
+
var d = formatDecimalParts(x2, p);
|
|
3446
|
+
if (!d) return x2 + "";
|
|
3447
|
+
var coefficient = d[0], exponent = d[1];
|
|
3448
|
+
return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0");
|
|
3449
|
+
}
|
|
3450
|
+
|
|
3451
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatTypes.js
|
|
3452
|
+
var formatTypes_default = {
|
|
3453
|
+
"%": (x2, p) => (x2 * 100).toFixed(p),
|
|
3454
|
+
"b": (x2) => Math.round(x2).toString(2),
|
|
3455
|
+
"c": (x2) => x2 + "",
|
|
3456
|
+
"d": formatDecimal_default,
|
|
3457
|
+
"e": (x2, p) => x2.toExponential(p),
|
|
3458
|
+
"f": (x2, p) => x2.toFixed(p),
|
|
3459
|
+
"g": (x2, p) => x2.toPrecision(p),
|
|
3460
|
+
"o": (x2) => Math.round(x2).toString(8),
|
|
3461
|
+
"p": (x2, p) => formatRounded_default(x2 * 100, p),
|
|
3462
|
+
"r": formatRounded_default,
|
|
3463
|
+
"s": formatPrefixAuto_default,
|
|
3464
|
+
"X": (x2) => Math.round(x2).toString(16).toUpperCase(),
|
|
3465
|
+
"x": (x2) => Math.round(x2).toString(16)
|
|
3466
|
+
};
|
|
3467
|
+
|
|
3468
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/identity.js
|
|
3469
|
+
function identity_default2(x2) {
|
|
3470
|
+
return x2;
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3473
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/locale.js
|
|
3474
|
+
var map = Array.prototype.map;
|
|
3475
|
+
var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
3476
|
+
function locale_default(locale3) {
|
|
3477
|
+
var group = locale3.grouping === void 0 || locale3.thousands === void 0 ? identity_default2 : formatGroup_default(map.call(locale3.grouping, Number), locale3.thousands + ""), currencyPrefix = locale3.currency === void 0 ? "" : locale3.currency[0] + "", currencySuffix = locale3.currency === void 0 ? "" : locale3.currency[1] + "", decimal = locale3.decimal === void 0 ? "." : locale3.decimal + "", numerals = locale3.numerals === void 0 ? identity_default2 : formatNumerals_default(map.call(locale3.numerals, String)), percent = locale3.percent === void 0 ? "%" : locale3.percent + "", minus = locale3.minus === void 0 ? "\u2212" : locale3.minus + "", nan = locale3.nan === void 0 ? "NaN" : locale3.nan + "";
|
|
3478
|
+
function newFormat(specifier, options) {
|
|
3479
|
+
specifier = formatSpecifier(specifier);
|
|
3480
|
+
var fill = specifier.fill, align = specifier.align, sign2 = specifier.sign, symbol = specifier.symbol, zero3 = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type = specifier.type;
|
|
3481
|
+
if (type === "n") comma = true, type = "g";
|
|
3482
|
+
else if (!formatTypes_default[type]) precision === void 0 && (precision = 12), trim = true, type = "g";
|
|
3483
|
+
if (zero3 || fill === "0" && align === "=") zero3 = true, fill = "0", align = "=";
|
|
3484
|
+
var prefix = (options && options.prefix !== void 0 ? options.prefix : "") + (symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : ""), suffix = (symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "") + (options && options.suffix !== void 0 ? options.suffix : "");
|
|
3485
|
+
var formatType = formatTypes_default[type], maybeSuffix = /[defgprs%]/.test(type);
|
|
3486
|
+
precision = precision === void 0 ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision));
|
|
3487
|
+
function format2(value) {
|
|
3488
|
+
var valuePrefix = prefix, valueSuffix = suffix, i, n, c;
|
|
3489
|
+
if (type === "c") {
|
|
3490
|
+
valueSuffix = formatType(value) + valueSuffix;
|
|
3491
|
+
value = "";
|
|
3492
|
+
} else {
|
|
3493
|
+
value = +value;
|
|
3494
|
+
var valueNegative = value < 0 || 1 / value < 0;
|
|
3495
|
+
value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
|
|
3496
|
+
if (trim) value = formatTrim_default(value);
|
|
3497
|
+
if (valueNegative && +value === 0 && sign2 !== "+") valueNegative = false;
|
|
3498
|
+
valuePrefix = (valueNegative ? sign2 === "(" ? sign2 : minus : sign2 === "-" || sign2 === "(" ? "" : sign2) + valuePrefix;
|
|
3499
|
+
valueSuffix = (type === "s" && !isNaN(value) && prefixExponent !== void 0 ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign2 === "(" ? ")" : "");
|
|
3500
|
+
if (maybeSuffix) {
|
|
3501
|
+
i = -1, n = value.length;
|
|
3502
|
+
while (++i < n) {
|
|
3503
|
+
if (c = value.charCodeAt(i), 48 > c || c > 57) {
|
|
3504
|
+
valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
|
|
3505
|
+
value = value.slice(0, i);
|
|
3506
|
+
break;
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
if (comma && !zero3) value = group(value, Infinity);
|
|
3512
|
+
var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : "";
|
|
3513
|
+
if (comma && zero3) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
|
|
3514
|
+
switch (align) {
|
|
3515
|
+
case "<":
|
|
3516
|
+
value = valuePrefix + value + valueSuffix + padding;
|
|
3517
|
+
break;
|
|
3518
|
+
case "=":
|
|
3519
|
+
value = valuePrefix + padding + value + valueSuffix;
|
|
3520
|
+
break;
|
|
3521
|
+
case "^":
|
|
3522
|
+
value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length);
|
|
3523
|
+
break;
|
|
3524
|
+
default:
|
|
3525
|
+
value = padding + valuePrefix + value + valueSuffix;
|
|
3526
|
+
break;
|
|
3527
|
+
}
|
|
3528
|
+
return numerals(value);
|
|
3529
|
+
}
|
|
3530
|
+
format2.toString = function() {
|
|
3531
|
+
return specifier + "";
|
|
3532
|
+
};
|
|
3533
|
+
return format2;
|
|
3534
|
+
}
|
|
3535
|
+
function formatPrefix2(specifier, value) {
|
|
3536
|
+
var e = Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3, k = Math.pow(10, -e), f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier), { suffix: prefixes[8 + e / 3] });
|
|
3537
|
+
return function(value2) {
|
|
3538
|
+
return f(k * value2);
|
|
3539
|
+
};
|
|
3540
|
+
}
|
|
3541
|
+
return {
|
|
3542
|
+
format: newFormat,
|
|
3543
|
+
formatPrefix: formatPrefix2
|
|
3544
|
+
};
|
|
3545
|
+
}
|
|
3546
|
+
|
|
3547
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/defaultLocale.js
|
|
3548
|
+
var locale;
|
|
3549
|
+
var format;
|
|
3550
|
+
var formatPrefix;
|
|
3551
|
+
defaultLocale({
|
|
3552
|
+
thousands: ",",
|
|
3553
|
+
grouping: [3],
|
|
3554
|
+
currency: ["$", ""]
|
|
3555
|
+
});
|
|
3556
|
+
function defaultLocale(definition) {
|
|
3557
|
+
locale = locale_default(definition);
|
|
3558
|
+
format = locale.format;
|
|
3559
|
+
formatPrefix = locale.formatPrefix;
|
|
3560
|
+
return locale;
|
|
3561
|
+
}
|
|
3562
|
+
|
|
3563
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/precisionFixed.js
|
|
3564
|
+
function precisionFixed_default(step) {
|
|
3565
|
+
return Math.max(0, -exponent_default(Math.abs(step)));
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/precisionPrefix.js
|
|
3569
|
+
function precisionPrefix_default(step, value) {
|
|
3570
|
+
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3 - exponent_default(Math.abs(step)));
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/precisionRound.js
|
|
3574
|
+
function precisionRound_default(step, max3) {
|
|
3575
|
+
step = Math.abs(step), max3 = Math.abs(max3) - step;
|
|
3576
|
+
return Math.max(0, exponent_default(max3) - exponent_default(step)) + 1;
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/tickFormat.js
|
|
3580
|
+
function tickFormat(start, stop, count, specifier) {
|
|
3581
|
+
var step = tickStep(start, stop, count), precision;
|
|
3582
|
+
specifier = formatSpecifier(specifier == null ? ",f" : specifier);
|
|
3583
|
+
switch (specifier.type) {
|
|
3584
|
+
case "s": {
|
|
3585
|
+
var value = Math.max(Math.abs(start), Math.abs(stop));
|
|
3586
|
+
if (specifier.precision == null && !isNaN(precision = precisionPrefix_default(step, value))) specifier.precision = precision;
|
|
3587
|
+
return formatPrefix(specifier, value);
|
|
3588
|
+
}
|
|
3589
|
+
case "":
|
|
3590
|
+
case "e":
|
|
3591
|
+
case "g":
|
|
3592
|
+
case "p":
|
|
3593
|
+
case "r": {
|
|
3594
|
+
if (specifier.precision == null && !isNaN(precision = precisionRound_default(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
|
|
3595
|
+
break;
|
|
3596
|
+
}
|
|
3597
|
+
case "f":
|
|
3598
|
+
case "%": {
|
|
3599
|
+
if (specifier.precision == null && !isNaN(precision = precisionFixed_default(step))) specifier.precision = precision - (specifier.type === "%") * 2;
|
|
3600
|
+
break;
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
return format(specifier);
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/linear.js
|
|
3607
|
+
function linearish(scale) {
|
|
3608
|
+
var domain = scale.domain;
|
|
3609
|
+
scale.ticks = function(count) {
|
|
3610
|
+
var d = domain();
|
|
3611
|
+
return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
|
|
3612
|
+
};
|
|
3613
|
+
scale.tickFormat = function(count, specifier) {
|
|
3614
|
+
var d = domain();
|
|
3615
|
+
return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
|
|
3616
|
+
};
|
|
3617
|
+
scale.nice = function(count) {
|
|
3618
|
+
if (count == null) count = 10;
|
|
3619
|
+
var d = domain();
|
|
3620
|
+
var i0 = 0;
|
|
3621
|
+
var i1 = d.length - 1;
|
|
3622
|
+
var start = d[i0];
|
|
3623
|
+
var stop = d[i1];
|
|
3624
|
+
var prestep;
|
|
3625
|
+
var step;
|
|
3626
|
+
var maxIter = 10;
|
|
3627
|
+
if (stop < start) {
|
|
3628
|
+
step = start, start = stop, stop = step;
|
|
3629
|
+
step = i0, i0 = i1, i1 = step;
|
|
3630
|
+
}
|
|
3631
|
+
while (maxIter-- > 0) {
|
|
3632
|
+
step = tickIncrement(start, stop, count);
|
|
3633
|
+
if (step === prestep) {
|
|
3634
|
+
d[i0] = start;
|
|
3635
|
+
d[i1] = stop;
|
|
3636
|
+
return domain(d);
|
|
3637
|
+
} else if (step > 0) {
|
|
3638
|
+
start = Math.floor(start / step) * step;
|
|
3639
|
+
stop = Math.ceil(stop / step) * step;
|
|
3640
|
+
} else if (step < 0) {
|
|
3641
|
+
start = Math.ceil(start * step) / step;
|
|
3642
|
+
stop = Math.floor(stop * step) / step;
|
|
3643
|
+
} else {
|
|
3644
|
+
break;
|
|
3645
|
+
}
|
|
3646
|
+
prestep = step;
|
|
3647
|
+
}
|
|
3648
|
+
return scale;
|
|
3649
|
+
};
|
|
3650
|
+
return scale;
|
|
3651
|
+
}
|
|
3652
|
+
function linear2() {
|
|
3653
|
+
var scale = continuous();
|
|
3654
|
+
scale.copy = function() {
|
|
3655
|
+
return copy(scale, linear2());
|
|
3656
|
+
};
|
|
3657
|
+
initRange.apply(scale, arguments);
|
|
3658
|
+
return linearish(scale);
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/nice.js
|
|
3662
|
+
function nice(domain, interval) {
|
|
3663
|
+
domain = domain.slice();
|
|
3664
|
+
var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], t;
|
|
3665
|
+
if (x1 < x0) {
|
|
3666
|
+
t = i0, i0 = i1, i1 = t;
|
|
3667
|
+
t = x0, x0 = x1, x1 = t;
|
|
3668
|
+
}
|
|
3669
|
+
domain[i0] = interval.floor(x0);
|
|
3670
|
+
domain[i1] = interval.ceil(x1);
|
|
3671
|
+
return domain;
|
|
3672
|
+
}
|
|
3673
|
+
|
|
3674
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/log.js
|
|
3675
|
+
function transformLog(x2) {
|
|
3676
|
+
return Math.log(x2);
|
|
3677
|
+
}
|
|
3678
|
+
function transformExp(x2) {
|
|
3679
|
+
return Math.exp(x2);
|
|
3680
|
+
}
|
|
3681
|
+
function transformLogn(x2) {
|
|
3682
|
+
return -Math.log(-x2);
|
|
3683
|
+
}
|
|
3684
|
+
function transformExpn(x2) {
|
|
3685
|
+
return -Math.exp(-x2);
|
|
3686
|
+
}
|
|
3687
|
+
function pow10(x2) {
|
|
3688
|
+
return isFinite(x2) ? +("1e" + x2) : x2 < 0 ? 0 : x2;
|
|
3689
|
+
}
|
|
3690
|
+
function powp(base) {
|
|
3691
|
+
return base === 10 ? pow10 : base === Math.E ? Math.exp : (x2) => Math.pow(base, x2);
|
|
3692
|
+
}
|
|
3693
|
+
function logp(base) {
|
|
3694
|
+
return base === Math.E ? Math.log : base === 10 && Math.log10 || base === 2 && Math.log2 || (base = Math.log(base), (x2) => Math.log(x2) / base);
|
|
3695
|
+
}
|
|
3696
|
+
function reflect(f) {
|
|
3697
|
+
return (x2, k) => -f(-x2, k);
|
|
3698
|
+
}
|
|
3699
|
+
function loggish(transform) {
|
|
3700
|
+
const scale = transform(transformLog, transformExp);
|
|
3701
|
+
const domain = scale.domain;
|
|
3702
|
+
let base = 10;
|
|
3703
|
+
let logs;
|
|
3704
|
+
let pows;
|
|
3705
|
+
function rescale() {
|
|
3706
|
+
logs = logp(base), pows = powp(base);
|
|
3707
|
+
if (domain()[0] < 0) {
|
|
3708
|
+
logs = reflect(logs), pows = reflect(pows);
|
|
3709
|
+
transform(transformLogn, transformExpn);
|
|
3710
|
+
} else {
|
|
3711
|
+
transform(transformLog, transformExp);
|
|
3712
|
+
}
|
|
3713
|
+
return scale;
|
|
3714
|
+
}
|
|
3715
|
+
scale.base = function(_) {
|
|
3716
|
+
return arguments.length ? (base = +_, rescale()) : base;
|
|
3717
|
+
};
|
|
3718
|
+
scale.domain = function(_) {
|
|
3719
|
+
return arguments.length ? (domain(_), rescale()) : domain();
|
|
3720
|
+
};
|
|
3721
|
+
scale.ticks = (count) => {
|
|
3722
|
+
const d = domain();
|
|
3723
|
+
let u = d[0];
|
|
3724
|
+
let v = d[d.length - 1];
|
|
3725
|
+
const r = v < u;
|
|
3726
|
+
if (r) [u, v] = [v, u];
|
|
3727
|
+
let i = logs(u);
|
|
3728
|
+
let j = logs(v);
|
|
3729
|
+
let k;
|
|
3730
|
+
let t;
|
|
3731
|
+
const n = count == null ? 10 : +count;
|
|
3732
|
+
let z = [];
|
|
3733
|
+
if (!(base % 1) && j - i < n) {
|
|
3734
|
+
i = Math.floor(i), j = Math.ceil(j);
|
|
3735
|
+
if (u > 0) for (; i <= j; ++i) {
|
|
3736
|
+
for (k = 1; k < base; ++k) {
|
|
3737
|
+
t = i < 0 ? k / pows(-i) : k * pows(i);
|
|
3738
|
+
if (t < u) continue;
|
|
3739
|
+
if (t > v) break;
|
|
3740
|
+
z.push(t);
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
else for (; i <= j; ++i) {
|
|
3744
|
+
for (k = base - 1; k >= 1; --k) {
|
|
3745
|
+
t = i > 0 ? k / pows(-i) : k * pows(i);
|
|
3746
|
+
if (t < u) continue;
|
|
3747
|
+
if (t > v) break;
|
|
3748
|
+
z.push(t);
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
if (z.length * 2 < n) z = ticks(u, v, n);
|
|
3752
|
+
} else {
|
|
3753
|
+
z = ticks(i, j, Math.min(j - i, n)).map(pows);
|
|
3754
|
+
}
|
|
3755
|
+
return r ? z.reverse() : z;
|
|
3756
|
+
};
|
|
3757
|
+
scale.tickFormat = (count, specifier) => {
|
|
3758
|
+
if (count == null) count = 10;
|
|
3759
|
+
if (specifier == null) specifier = base === 10 ? "s" : ",";
|
|
3760
|
+
if (typeof specifier !== "function") {
|
|
3761
|
+
if (!(base % 1) && (specifier = formatSpecifier(specifier)).precision == null) specifier.trim = true;
|
|
3762
|
+
specifier = format(specifier);
|
|
3763
|
+
}
|
|
3764
|
+
if (count === Infinity) return specifier;
|
|
3765
|
+
const k = Math.max(1, base * count / scale.ticks().length);
|
|
3766
|
+
return (d) => {
|
|
3767
|
+
let i = d / pows(Math.round(logs(d)));
|
|
3768
|
+
if (i * base < base - 0.5) i *= base;
|
|
3769
|
+
return i <= k ? specifier(d) : "";
|
|
3770
|
+
};
|
|
3771
|
+
};
|
|
3772
|
+
scale.nice = () => {
|
|
3773
|
+
return domain(nice(domain(), {
|
|
3774
|
+
floor: (x2) => pows(Math.floor(logs(x2))),
|
|
3775
|
+
ceil: (x2) => pows(Math.ceil(logs(x2)))
|
|
3776
|
+
}));
|
|
3777
|
+
};
|
|
3778
|
+
return scale;
|
|
3779
|
+
}
|
|
3780
|
+
function log() {
|
|
3781
|
+
const scale = loggish(transformer()).domain([1, 10]);
|
|
3782
|
+
scale.copy = () => copy(scale, log()).base(scale.base());
|
|
3783
|
+
initRange.apply(scale, arguments);
|
|
3784
|
+
return scale;
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/pow.js
|
|
3788
|
+
function transformPow(exponent) {
|
|
3789
|
+
return function(x2) {
|
|
3790
|
+
return x2 < 0 ? -Math.pow(-x2, exponent) : Math.pow(x2, exponent);
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3793
|
+
function transformSqrt(x2) {
|
|
3794
|
+
return x2 < 0 ? -Math.sqrt(-x2) : Math.sqrt(x2);
|
|
3795
|
+
}
|
|
3796
|
+
function transformSquare(x2) {
|
|
3797
|
+
return x2 < 0 ? -x2 * x2 : x2 * x2;
|
|
3798
|
+
}
|
|
3799
|
+
function powish(transform) {
|
|
3800
|
+
var scale = transform(identity, identity), exponent = 1;
|
|
3801
|
+
function rescale() {
|
|
3802
|
+
return exponent === 1 ? transform(identity, identity) : exponent === 0.5 ? transform(transformSqrt, transformSquare) : transform(transformPow(exponent), transformPow(1 / exponent));
|
|
3803
|
+
}
|
|
3804
|
+
scale.exponent = function(_) {
|
|
3805
|
+
return arguments.length ? (exponent = +_, rescale()) : exponent;
|
|
3806
|
+
};
|
|
3807
|
+
return linearish(scale);
|
|
3808
|
+
}
|
|
3809
|
+
function pow() {
|
|
3810
|
+
var scale = powish(transformer());
|
|
3811
|
+
scale.copy = function() {
|
|
3812
|
+
return copy(scale, pow()).exponent(scale.exponent());
|
|
3813
|
+
};
|
|
3814
|
+
initRange.apply(scale, arguments);
|
|
3815
|
+
return scale;
|
|
3816
|
+
}
|
|
3817
|
+
function sqrt2() {
|
|
3818
|
+
return pow.apply(null, arguments).exponent(0.5);
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/interval.js
|
|
3822
|
+
var t0 = /* @__PURE__ */ new Date();
|
|
3823
|
+
var t1 = /* @__PURE__ */ new Date();
|
|
3824
|
+
function timeInterval(floori, offseti, count, field) {
|
|
3825
|
+
function interval(date2) {
|
|
3826
|
+
return floori(date2 = arguments.length === 0 ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date(+date2)), date2;
|
|
3827
|
+
}
|
|
3828
|
+
interval.floor = (date2) => {
|
|
3829
|
+
return floori(date2 = /* @__PURE__ */ new Date(+date2)), date2;
|
|
3830
|
+
};
|
|
3831
|
+
interval.ceil = (date2) => {
|
|
3832
|
+
return floori(date2 = new Date(date2 - 1)), offseti(date2, 1), floori(date2), date2;
|
|
3833
|
+
};
|
|
3834
|
+
interval.round = (date2) => {
|
|
3835
|
+
const d0 = interval(date2), d1 = interval.ceil(date2);
|
|
3836
|
+
return date2 - d0 < d1 - date2 ? d0 : d1;
|
|
3837
|
+
};
|
|
3838
|
+
interval.offset = (date2, step) => {
|
|
3839
|
+
return offseti(date2 = /* @__PURE__ */ new Date(+date2), step == null ? 1 : Math.floor(step)), date2;
|
|
3840
|
+
};
|
|
3841
|
+
interval.range = (start, stop, step) => {
|
|
3842
|
+
const range2 = [];
|
|
3843
|
+
start = interval.ceil(start);
|
|
3844
|
+
step = step == null ? 1 : Math.floor(step);
|
|
3845
|
+
if (!(start < stop) || !(step > 0)) return range2;
|
|
3846
|
+
let previous;
|
|
3847
|
+
do
|
|
3848
|
+
range2.push(previous = /* @__PURE__ */ new Date(+start)), offseti(start, step), floori(start);
|
|
3849
|
+
while (previous < start && start < stop);
|
|
3850
|
+
return range2;
|
|
3851
|
+
};
|
|
3852
|
+
interval.filter = (test) => {
|
|
3853
|
+
return timeInterval((date2) => {
|
|
3854
|
+
if (date2 >= date2) while (floori(date2), !test(date2)) date2.setTime(date2 - 1);
|
|
3855
|
+
}, (date2, step) => {
|
|
3856
|
+
if (date2 >= date2) {
|
|
3857
|
+
if (step < 0) while (++step <= 0) {
|
|
3858
|
+
while (offseti(date2, -1), !test(date2)) {
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
else while (--step >= 0) {
|
|
3862
|
+
while (offseti(date2, 1), !test(date2)) {
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
});
|
|
3867
|
+
};
|
|
3868
|
+
if (count) {
|
|
3869
|
+
interval.count = (start, end) => {
|
|
3870
|
+
t0.setTime(+start), t1.setTime(+end);
|
|
3871
|
+
floori(t0), floori(t1);
|
|
3872
|
+
return Math.floor(count(t0, t1));
|
|
3873
|
+
};
|
|
3874
|
+
interval.every = (step) => {
|
|
3875
|
+
step = Math.floor(step);
|
|
3876
|
+
return !isFinite(step) || !(step > 0) ? null : !(step > 1) ? interval : interval.filter(field ? (d) => field(d) % step === 0 : (d) => interval.count(0, d) % step === 0);
|
|
3877
|
+
};
|
|
3878
|
+
}
|
|
3879
|
+
return interval;
|
|
3880
|
+
}
|
|
3881
|
+
|
|
3882
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/millisecond.js
|
|
3883
|
+
var millisecond = timeInterval(() => {
|
|
3884
|
+
}, (date2, step) => {
|
|
3885
|
+
date2.setTime(+date2 + step);
|
|
3886
|
+
}, (start, end) => {
|
|
3887
|
+
return end - start;
|
|
3888
|
+
});
|
|
3889
|
+
millisecond.every = (k) => {
|
|
3890
|
+
k = Math.floor(k);
|
|
3891
|
+
if (!isFinite(k) || !(k > 0)) return null;
|
|
3892
|
+
if (!(k > 1)) return millisecond;
|
|
3893
|
+
return timeInterval((date2) => {
|
|
3894
|
+
date2.setTime(Math.floor(date2 / k) * k);
|
|
3895
|
+
}, (date2, step) => {
|
|
3896
|
+
date2.setTime(+date2 + step * k);
|
|
3897
|
+
}, (start, end) => {
|
|
3898
|
+
return (end - start) / k;
|
|
3899
|
+
});
|
|
3900
|
+
};
|
|
3901
|
+
var milliseconds = millisecond.range;
|
|
3902
|
+
|
|
3903
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/duration.js
|
|
3904
|
+
var durationSecond = 1e3;
|
|
3905
|
+
var durationMinute = durationSecond * 60;
|
|
3906
|
+
var durationHour = durationMinute * 60;
|
|
3907
|
+
var durationDay = durationHour * 24;
|
|
3908
|
+
var durationWeek = durationDay * 7;
|
|
3909
|
+
var durationMonth = durationDay * 30;
|
|
3910
|
+
var durationYear = durationDay * 365;
|
|
3911
|
+
|
|
3912
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/second.js
|
|
3913
|
+
var second = timeInterval((date2) => {
|
|
3914
|
+
date2.setTime(date2 - date2.getMilliseconds());
|
|
3915
|
+
}, (date2, step) => {
|
|
3916
|
+
date2.setTime(+date2 + step * durationSecond);
|
|
3917
|
+
}, (start, end) => {
|
|
3918
|
+
return (end - start) / durationSecond;
|
|
3919
|
+
}, (date2) => {
|
|
3920
|
+
return date2.getUTCSeconds();
|
|
3921
|
+
});
|
|
3922
|
+
var seconds = second.range;
|
|
3923
|
+
|
|
3924
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/minute.js
|
|
3925
|
+
var timeMinute = timeInterval((date2) => {
|
|
3926
|
+
date2.setTime(date2 - date2.getMilliseconds() - date2.getSeconds() * durationSecond);
|
|
3927
|
+
}, (date2, step) => {
|
|
3928
|
+
date2.setTime(+date2 + step * durationMinute);
|
|
3929
|
+
}, (start, end) => {
|
|
3930
|
+
return (end - start) / durationMinute;
|
|
3931
|
+
}, (date2) => {
|
|
3932
|
+
return date2.getMinutes();
|
|
3933
|
+
});
|
|
3934
|
+
var timeMinutes = timeMinute.range;
|
|
3935
|
+
var utcMinute = timeInterval((date2) => {
|
|
3936
|
+
date2.setUTCSeconds(0, 0);
|
|
3937
|
+
}, (date2, step) => {
|
|
3938
|
+
date2.setTime(+date2 + step * durationMinute);
|
|
3939
|
+
}, (start, end) => {
|
|
3940
|
+
return (end - start) / durationMinute;
|
|
3941
|
+
}, (date2) => {
|
|
3942
|
+
return date2.getUTCMinutes();
|
|
3943
|
+
});
|
|
3944
|
+
var utcMinutes = utcMinute.range;
|
|
3945
|
+
|
|
3946
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/hour.js
|
|
3947
|
+
var timeHour = timeInterval((date2) => {
|
|
3948
|
+
date2.setTime(date2 - date2.getMilliseconds() - date2.getSeconds() * durationSecond - date2.getMinutes() * durationMinute);
|
|
3949
|
+
}, (date2, step) => {
|
|
3950
|
+
date2.setTime(+date2 + step * durationHour);
|
|
3951
|
+
}, (start, end) => {
|
|
3952
|
+
return (end - start) / durationHour;
|
|
3953
|
+
}, (date2) => {
|
|
3954
|
+
return date2.getHours();
|
|
3955
|
+
});
|
|
3956
|
+
var timeHours = timeHour.range;
|
|
3957
|
+
var utcHour = timeInterval((date2) => {
|
|
3958
|
+
date2.setUTCMinutes(0, 0, 0);
|
|
3959
|
+
}, (date2, step) => {
|
|
3960
|
+
date2.setTime(+date2 + step * durationHour);
|
|
3961
|
+
}, (start, end) => {
|
|
3962
|
+
return (end - start) / durationHour;
|
|
3963
|
+
}, (date2) => {
|
|
3964
|
+
return date2.getUTCHours();
|
|
3965
|
+
});
|
|
3966
|
+
var utcHours = utcHour.range;
|
|
3967
|
+
|
|
3968
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/day.js
|
|
3969
|
+
var timeDay = timeInterval(
|
|
3970
|
+
(date2) => date2.setHours(0, 0, 0, 0),
|
|
3971
|
+
(date2, step) => date2.setDate(date2.getDate() + step),
|
|
3972
|
+
(start, end) => (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay,
|
|
3973
|
+
(date2) => date2.getDate() - 1
|
|
3974
|
+
);
|
|
3975
|
+
var timeDays = timeDay.range;
|
|
3976
|
+
var utcDay = timeInterval((date2) => {
|
|
3977
|
+
date2.setUTCHours(0, 0, 0, 0);
|
|
3978
|
+
}, (date2, step) => {
|
|
3979
|
+
date2.setUTCDate(date2.getUTCDate() + step);
|
|
3980
|
+
}, (start, end) => {
|
|
3981
|
+
return (end - start) / durationDay;
|
|
3982
|
+
}, (date2) => {
|
|
3983
|
+
return date2.getUTCDate() - 1;
|
|
3984
|
+
});
|
|
3985
|
+
var utcDays = utcDay.range;
|
|
3986
|
+
var unixDay = timeInterval((date2) => {
|
|
3987
|
+
date2.setUTCHours(0, 0, 0, 0);
|
|
3988
|
+
}, (date2, step) => {
|
|
3989
|
+
date2.setUTCDate(date2.getUTCDate() + step);
|
|
3990
|
+
}, (start, end) => {
|
|
3991
|
+
return (end - start) / durationDay;
|
|
3992
|
+
}, (date2) => {
|
|
3993
|
+
return Math.floor(date2 / durationDay);
|
|
3994
|
+
});
|
|
3995
|
+
var unixDays = unixDay.range;
|
|
3996
|
+
|
|
3997
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/week.js
|
|
3998
|
+
function timeWeekday(i) {
|
|
3999
|
+
return timeInterval((date2) => {
|
|
4000
|
+
date2.setDate(date2.getDate() - (date2.getDay() + 7 - i) % 7);
|
|
4001
|
+
date2.setHours(0, 0, 0, 0);
|
|
4002
|
+
}, (date2, step) => {
|
|
4003
|
+
date2.setDate(date2.getDate() + step * 7);
|
|
4004
|
+
}, (start, end) => {
|
|
4005
|
+
return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
|
|
4006
|
+
});
|
|
4007
|
+
}
|
|
4008
|
+
var timeSunday = timeWeekday(0);
|
|
4009
|
+
var timeMonday = timeWeekday(1);
|
|
4010
|
+
var timeTuesday = timeWeekday(2);
|
|
4011
|
+
var timeWednesday = timeWeekday(3);
|
|
4012
|
+
var timeThursday = timeWeekday(4);
|
|
4013
|
+
var timeFriday = timeWeekday(5);
|
|
4014
|
+
var timeSaturday = timeWeekday(6);
|
|
4015
|
+
var timeSundays = timeSunday.range;
|
|
4016
|
+
var timeMondays = timeMonday.range;
|
|
4017
|
+
var timeTuesdays = timeTuesday.range;
|
|
4018
|
+
var timeWednesdays = timeWednesday.range;
|
|
4019
|
+
var timeThursdays = timeThursday.range;
|
|
4020
|
+
var timeFridays = timeFriday.range;
|
|
4021
|
+
var timeSaturdays = timeSaturday.range;
|
|
4022
|
+
function utcWeekday(i) {
|
|
4023
|
+
return timeInterval((date2) => {
|
|
4024
|
+
date2.setUTCDate(date2.getUTCDate() - (date2.getUTCDay() + 7 - i) % 7);
|
|
4025
|
+
date2.setUTCHours(0, 0, 0, 0);
|
|
4026
|
+
}, (date2, step) => {
|
|
4027
|
+
date2.setUTCDate(date2.getUTCDate() + step * 7);
|
|
4028
|
+
}, (start, end) => {
|
|
4029
|
+
return (end - start) / durationWeek;
|
|
4030
|
+
});
|
|
4031
|
+
}
|
|
4032
|
+
var utcSunday = utcWeekday(0);
|
|
4033
|
+
var utcMonday = utcWeekday(1);
|
|
4034
|
+
var utcTuesday = utcWeekday(2);
|
|
4035
|
+
var utcWednesday = utcWeekday(3);
|
|
4036
|
+
var utcThursday = utcWeekday(4);
|
|
4037
|
+
var utcFriday = utcWeekday(5);
|
|
4038
|
+
var utcSaturday = utcWeekday(6);
|
|
4039
|
+
var utcSundays = utcSunday.range;
|
|
4040
|
+
var utcMondays = utcMonday.range;
|
|
4041
|
+
var utcTuesdays = utcTuesday.range;
|
|
4042
|
+
var utcWednesdays = utcWednesday.range;
|
|
4043
|
+
var utcThursdays = utcThursday.range;
|
|
4044
|
+
var utcFridays = utcFriday.range;
|
|
4045
|
+
var utcSaturdays = utcSaturday.range;
|
|
4046
|
+
|
|
4047
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/month.js
|
|
4048
|
+
var timeMonth = timeInterval((date2) => {
|
|
4049
|
+
date2.setDate(1);
|
|
4050
|
+
date2.setHours(0, 0, 0, 0);
|
|
4051
|
+
}, (date2, step) => {
|
|
4052
|
+
date2.setMonth(date2.getMonth() + step);
|
|
4053
|
+
}, (start, end) => {
|
|
4054
|
+
return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
|
|
4055
|
+
}, (date2) => {
|
|
4056
|
+
return date2.getMonth();
|
|
4057
|
+
});
|
|
4058
|
+
var timeMonths = timeMonth.range;
|
|
4059
|
+
var utcMonth = timeInterval((date2) => {
|
|
4060
|
+
date2.setUTCDate(1);
|
|
4061
|
+
date2.setUTCHours(0, 0, 0, 0);
|
|
4062
|
+
}, (date2, step) => {
|
|
4063
|
+
date2.setUTCMonth(date2.getUTCMonth() + step);
|
|
4064
|
+
}, (start, end) => {
|
|
4065
|
+
return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
|
|
4066
|
+
}, (date2) => {
|
|
4067
|
+
return date2.getUTCMonth();
|
|
4068
|
+
});
|
|
4069
|
+
var utcMonths = utcMonth.range;
|
|
4070
|
+
|
|
4071
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/year.js
|
|
4072
|
+
var timeYear = timeInterval((date2) => {
|
|
4073
|
+
date2.setMonth(0, 1);
|
|
4074
|
+
date2.setHours(0, 0, 0, 0);
|
|
4075
|
+
}, (date2, step) => {
|
|
4076
|
+
date2.setFullYear(date2.getFullYear() + step);
|
|
4077
|
+
}, (start, end) => {
|
|
4078
|
+
return end.getFullYear() - start.getFullYear();
|
|
4079
|
+
}, (date2) => {
|
|
4080
|
+
return date2.getFullYear();
|
|
4081
|
+
});
|
|
4082
|
+
timeYear.every = (k) => {
|
|
4083
|
+
return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date2) => {
|
|
4084
|
+
date2.setFullYear(Math.floor(date2.getFullYear() / k) * k);
|
|
4085
|
+
date2.setMonth(0, 1);
|
|
4086
|
+
date2.setHours(0, 0, 0, 0);
|
|
4087
|
+
}, (date2, step) => {
|
|
4088
|
+
date2.setFullYear(date2.getFullYear() + step * k);
|
|
4089
|
+
});
|
|
4090
|
+
};
|
|
4091
|
+
var timeYears = timeYear.range;
|
|
4092
|
+
var utcYear = timeInterval((date2) => {
|
|
4093
|
+
date2.setUTCMonth(0, 1);
|
|
4094
|
+
date2.setUTCHours(0, 0, 0, 0);
|
|
4095
|
+
}, (date2, step) => {
|
|
4096
|
+
date2.setUTCFullYear(date2.getUTCFullYear() + step);
|
|
4097
|
+
}, (start, end) => {
|
|
4098
|
+
return end.getUTCFullYear() - start.getUTCFullYear();
|
|
4099
|
+
}, (date2) => {
|
|
4100
|
+
return date2.getUTCFullYear();
|
|
4101
|
+
});
|
|
4102
|
+
utcYear.every = (k) => {
|
|
4103
|
+
return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date2) => {
|
|
4104
|
+
date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / k) * k);
|
|
4105
|
+
date2.setUTCMonth(0, 1);
|
|
4106
|
+
date2.setUTCHours(0, 0, 0, 0);
|
|
4107
|
+
}, (date2, step) => {
|
|
4108
|
+
date2.setUTCFullYear(date2.getUTCFullYear() + step * k);
|
|
4109
|
+
});
|
|
4110
|
+
};
|
|
4111
|
+
var utcYears = utcYear.range;
|
|
4112
|
+
|
|
4113
|
+
// ../../node_modules/.bun/d3-time@3.1.0/node_modules/d3-time/src/ticks.js
|
|
4114
|
+
function ticker(year, month, week, day, hour, minute) {
|
|
4115
|
+
const tickIntervals = [
|
|
4116
|
+
[second, 1, durationSecond],
|
|
4117
|
+
[second, 5, 5 * durationSecond],
|
|
4118
|
+
[second, 15, 15 * durationSecond],
|
|
4119
|
+
[second, 30, 30 * durationSecond],
|
|
4120
|
+
[minute, 1, durationMinute],
|
|
4121
|
+
[minute, 5, 5 * durationMinute],
|
|
4122
|
+
[minute, 15, 15 * durationMinute],
|
|
4123
|
+
[minute, 30, 30 * durationMinute],
|
|
4124
|
+
[hour, 1, durationHour],
|
|
4125
|
+
[hour, 3, 3 * durationHour],
|
|
4126
|
+
[hour, 6, 6 * durationHour],
|
|
4127
|
+
[hour, 12, 12 * durationHour],
|
|
4128
|
+
[day, 1, durationDay],
|
|
4129
|
+
[day, 2, 2 * durationDay],
|
|
4130
|
+
[week, 1, durationWeek],
|
|
4131
|
+
[month, 1, durationMonth],
|
|
4132
|
+
[month, 3, 3 * durationMonth],
|
|
4133
|
+
[year, 1, durationYear]
|
|
4134
|
+
];
|
|
4135
|
+
function ticks2(start, stop, count) {
|
|
4136
|
+
const reverse = stop < start;
|
|
4137
|
+
if (reverse) [start, stop] = [stop, start];
|
|
4138
|
+
const interval = count && typeof count.range === "function" ? count : tickInterval(start, stop, count);
|
|
4139
|
+
const ticks3 = interval ? interval.range(start, +stop + 1) : [];
|
|
4140
|
+
return reverse ? ticks3.reverse() : ticks3;
|
|
4141
|
+
}
|
|
4142
|
+
function tickInterval(start, stop, count) {
|
|
4143
|
+
const target = Math.abs(stop - start) / count;
|
|
4144
|
+
const i = bisector(([, , step2]) => step2).right(tickIntervals, target);
|
|
4145
|
+
if (i === tickIntervals.length) return year.every(tickStep(start / durationYear, stop / durationYear, count));
|
|
4146
|
+
if (i === 0) return millisecond.every(Math.max(tickStep(start, stop, count), 1));
|
|
4147
|
+
const [t, step] = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i];
|
|
4148
|
+
return t.every(step);
|
|
4149
|
+
}
|
|
4150
|
+
return [ticks2, tickInterval];
|
|
4151
|
+
}
|
|
4152
|
+
var [utcTicks, utcTickInterval] = ticker(utcYear, utcMonth, utcSunday, unixDay, utcHour, utcMinute);
|
|
4153
|
+
var [timeTicks, timeTickInterval] = ticker(timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute);
|
|
4154
|
+
|
|
4155
|
+
// ../../node_modules/.bun/d3-time-format@4.1.0/node_modules/d3-time-format/src/locale.js
|
|
4156
|
+
function localDate(d) {
|
|
4157
|
+
if (0 <= d.y && d.y < 100) {
|
|
4158
|
+
var date2 = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L);
|
|
4159
|
+
date2.setFullYear(d.y);
|
|
4160
|
+
return date2;
|
|
4161
|
+
}
|
|
4162
|
+
return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L);
|
|
4163
|
+
}
|
|
4164
|
+
function utcDate(d) {
|
|
4165
|
+
if (0 <= d.y && d.y < 100) {
|
|
4166
|
+
var date2 = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L));
|
|
4167
|
+
date2.setUTCFullYear(d.y);
|
|
4168
|
+
return date2;
|
|
4169
|
+
}
|
|
4170
|
+
return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L));
|
|
4171
|
+
}
|
|
4172
|
+
function newDate(y2, m, d) {
|
|
4173
|
+
return { y: y2, m, d, H: 0, M: 0, S: 0, L: 0 };
|
|
4174
|
+
}
|
|
4175
|
+
function formatLocale(locale3) {
|
|
4176
|
+
var locale_dateTime = locale3.dateTime, locale_date = locale3.date, locale_time = locale3.time, locale_periods = locale3.periods, locale_weekdays = locale3.days, locale_shortWeekdays = locale3.shortDays, locale_months = locale3.months, locale_shortMonths = locale3.shortMonths;
|
|
4177
|
+
var periodRe = formatRe(locale_periods), periodLookup = formatLookup(locale_periods), weekdayRe = formatRe(locale_weekdays), weekdayLookup = formatLookup(locale_weekdays), shortWeekdayRe = formatRe(locale_shortWeekdays), shortWeekdayLookup = formatLookup(locale_shortWeekdays), monthRe = formatRe(locale_months), monthLookup = formatLookup(locale_months), shortMonthRe = formatRe(locale_shortMonths), shortMonthLookup = formatLookup(locale_shortMonths);
|
|
4178
|
+
var formats = {
|
|
4179
|
+
"a": formatShortWeekday,
|
|
4180
|
+
"A": formatWeekday,
|
|
4181
|
+
"b": formatShortMonth,
|
|
4182
|
+
"B": formatMonth,
|
|
4183
|
+
"c": null,
|
|
4184
|
+
"d": formatDayOfMonth,
|
|
4185
|
+
"e": formatDayOfMonth,
|
|
4186
|
+
"f": formatMicroseconds,
|
|
4187
|
+
"g": formatYearISO,
|
|
4188
|
+
"G": formatFullYearISO,
|
|
4189
|
+
"H": formatHour24,
|
|
4190
|
+
"I": formatHour12,
|
|
4191
|
+
"j": formatDayOfYear,
|
|
4192
|
+
"L": formatMilliseconds,
|
|
4193
|
+
"m": formatMonthNumber,
|
|
4194
|
+
"M": formatMinutes,
|
|
4195
|
+
"p": formatPeriod,
|
|
4196
|
+
"q": formatQuarter,
|
|
4197
|
+
"Q": formatUnixTimestamp,
|
|
4198
|
+
"s": formatUnixTimestampSeconds,
|
|
4199
|
+
"S": formatSeconds,
|
|
4200
|
+
"u": formatWeekdayNumberMonday,
|
|
4201
|
+
"U": formatWeekNumberSunday,
|
|
4202
|
+
"V": formatWeekNumberISO,
|
|
4203
|
+
"w": formatWeekdayNumberSunday,
|
|
4204
|
+
"W": formatWeekNumberMonday,
|
|
4205
|
+
"x": null,
|
|
4206
|
+
"X": null,
|
|
4207
|
+
"y": formatYear,
|
|
4208
|
+
"Y": formatFullYear,
|
|
4209
|
+
"Z": formatZone,
|
|
4210
|
+
"%": formatLiteralPercent
|
|
4211
|
+
};
|
|
4212
|
+
var utcFormats = {
|
|
4213
|
+
"a": formatUTCShortWeekday,
|
|
4214
|
+
"A": formatUTCWeekday,
|
|
4215
|
+
"b": formatUTCShortMonth,
|
|
4216
|
+
"B": formatUTCMonth,
|
|
4217
|
+
"c": null,
|
|
4218
|
+
"d": formatUTCDayOfMonth,
|
|
4219
|
+
"e": formatUTCDayOfMonth,
|
|
4220
|
+
"f": formatUTCMicroseconds,
|
|
4221
|
+
"g": formatUTCYearISO,
|
|
4222
|
+
"G": formatUTCFullYearISO,
|
|
4223
|
+
"H": formatUTCHour24,
|
|
4224
|
+
"I": formatUTCHour12,
|
|
4225
|
+
"j": formatUTCDayOfYear,
|
|
4226
|
+
"L": formatUTCMilliseconds,
|
|
4227
|
+
"m": formatUTCMonthNumber,
|
|
4228
|
+
"M": formatUTCMinutes,
|
|
4229
|
+
"p": formatUTCPeriod,
|
|
4230
|
+
"q": formatUTCQuarter,
|
|
4231
|
+
"Q": formatUnixTimestamp,
|
|
4232
|
+
"s": formatUnixTimestampSeconds,
|
|
4233
|
+
"S": formatUTCSeconds,
|
|
4234
|
+
"u": formatUTCWeekdayNumberMonday,
|
|
4235
|
+
"U": formatUTCWeekNumberSunday,
|
|
4236
|
+
"V": formatUTCWeekNumberISO,
|
|
4237
|
+
"w": formatUTCWeekdayNumberSunday,
|
|
4238
|
+
"W": formatUTCWeekNumberMonday,
|
|
4239
|
+
"x": null,
|
|
4240
|
+
"X": null,
|
|
4241
|
+
"y": formatUTCYear,
|
|
4242
|
+
"Y": formatUTCFullYear,
|
|
4243
|
+
"Z": formatUTCZone,
|
|
4244
|
+
"%": formatLiteralPercent
|
|
4245
|
+
};
|
|
4246
|
+
var parses = {
|
|
4247
|
+
"a": parseShortWeekday,
|
|
4248
|
+
"A": parseWeekday,
|
|
4249
|
+
"b": parseShortMonth,
|
|
4250
|
+
"B": parseMonth,
|
|
4251
|
+
"c": parseLocaleDateTime,
|
|
4252
|
+
"d": parseDayOfMonth,
|
|
4253
|
+
"e": parseDayOfMonth,
|
|
4254
|
+
"f": parseMicroseconds,
|
|
4255
|
+
"g": parseYear,
|
|
4256
|
+
"G": parseFullYear,
|
|
4257
|
+
"H": parseHour24,
|
|
4258
|
+
"I": parseHour24,
|
|
4259
|
+
"j": parseDayOfYear,
|
|
4260
|
+
"L": parseMilliseconds,
|
|
4261
|
+
"m": parseMonthNumber,
|
|
4262
|
+
"M": parseMinutes,
|
|
4263
|
+
"p": parsePeriod,
|
|
4264
|
+
"q": parseQuarter,
|
|
4265
|
+
"Q": parseUnixTimestamp,
|
|
4266
|
+
"s": parseUnixTimestampSeconds,
|
|
4267
|
+
"S": parseSeconds,
|
|
4268
|
+
"u": parseWeekdayNumberMonday,
|
|
4269
|
+
"U": parseWeekNumberSunday,
|
|
4270
|
+
"V": parseWeekNumberISO,
|
|
4271
|
+
"w": parseWeekdayNumberSunday,
|
|
4272
|
+
"W": parseWeekNumberMonday,
|
|
4273
|
+
"x": parseLocaleDate,
|
|
4274
|
+
"X": parseLocaleTime,
|
|
4275
|
+
"y": parseYear,
|
|
4276
|
+
"Y": parseFullYear,
|
|
4277
|
+
"Z": parseZone,
|
|
4278
|
+
"%": parseLiteralPercent
|
|
4279
|
+
};
|
|
4280
|
+
formats.x = newFormat(locale_date, formats);
|
|
4281
|
+
formats.X = newFormat(locale_time, formats);
|
|
4282
|
+
formats.c = newFormat(locale_dateTime, formats);
|
|
4283
|
+
utcFormats.x = newFormat(locale_date, utcFormats);
|
|
4284
|
+
utcFormats.X = newFormat(locale_time, utcFormats);
|
|
4285
|
+
utcFormats.c = newFormat(locale_dateTime, utcFormats);
|
|
4286
|
+
function newFormat(specifier, formats2) {
|
|
4287
|
+
return function(date2) {
|
|
4288
|
+
var string = [], i = -1, j = 0, n = specifier.length, c, pad2, format2;
|
|
4289
|
+
if (!(date2 instanceof Date)) date2 = /* @__PURE__ */ new Date(+date2);
|
|
4290
|
+
while (++i < n) {
|
|
4291
|
+
if (specifier.charCodeAt(i) === 37) {
|
|
4292
|
+
string.push(specifier.slice(j, i));
|
|
4293
|
+
if ((pad2 = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i);
|
|
4294
|
+
else pad2 = c === "e" ? " " : "0";
|
|
4295
|
+
if (format2 = formats2[c]) c = format2(date2, pad2);
|
|
4296
|
+
string.push(c);
|
|
4297
|
+
j = i + 1;
|
|
4298
|
+
}
|
|
1628
4299
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
4300
|
+
string.push(specifier.slice(j, i));
|
|
4301
|
+
return string.join("");
|
|
4302
|
+
};
|
|
1631
4303
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
4304
|
+
function newParse(specifier, Z) {
|
|
4305
|
+
return function(string) {
|
|
4306
|
+
var d = newDate(1900, void 0, 1), i = parseSpecifier(d, specifier, string += "", 0), week, day;
|
|
4307
|
+
if (i != string.length) return null;
|
|
4308
|
+
if ("Q" in d) return new Date(d.Q);
|
|
4309
|
+
if ("s" in d) return new Date(d.s * 1e3 + ("L" in d ? d.L : 0));
|
|
4310
|
+
if (Z && !("Z" in d)) d.Z = 0;
|
|
4311
|
+
if ("p" in d) d.H = d.H % 12 + d.p * 12;
|
|
4312
|
+
if (d.m === void 0) d.m = "q" in d ? d.q : 0;
|
|
4313
|
+
if ("V" in d) {
|
|
4314
|
+
if (d.V < 1 || d.V > 53) return null;
|
|
4315
|
+
if (!("w" in d)) d.w = 1;
|
|
4316
|
+
if ("Z" in d) {
|
|
4317
|
+
week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay();
|
|
4318
|
+
week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week);
|
|
4319
|
+
week = utcDay.offset(week, (d.V - 1) * 7);
|
|
4320
|
+
d.y = week.getUTCFullYear();
|
|
4321
|
+
d.m = week.getUTCMonth();
|
|
4322
|
+
d.d = week.getUTCDate() + (d.w + 6) % 7;
|
|
4323
|
+
} else {
|
|
4324
|
+
week = localDate(newDate(d.y, 0, 1)), day = week.getDay();
|
|
4325
|
+
week = day > 4 || day === 0 ? timeMonday.ceil(week) : timeMonday(week);
|
|
4326
|
+
week = timeDay.offset(week, (d.V - 1) * 7);
|
|
4327
|
+
d.y = week.getFullYear();
|
|
4328
|
+
d.m = week.getMonth();
|
|
4329
|
+
d.d = week.getDate() + (d.w + 6) % 7;
|
|
4330
|
+
}
|
|
4331
|
+
} else if ("W" in d || "U" in d) {
|
|
4332
|
+
if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0;
|
|
4333
|
+
day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay();
|
|
4334
|
+
d.m = 0;
|
|
4335
|
+
d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7;
|
|
4336
|
+
}
|
|
4337
|
+
if ("Z" in d) {
|
|
4338
|
+
d.H += d.Z / 100 | 0;
|
|
4339
|
+
d.M += d.Z % 100;
|
|
4340
|
+
return utcDate(d);
|
|
4341
|
+
}
|
|
4342
|
+
return localDate(d);
|
|
4343
|
+
};
|
|
1644
4344
|
}
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
}
|
|
4345
|
+
function parseSpecifier(d, specifier, string, j) {
|
|
4346
|
+
var i = 0, n = specifier.length, m = string.length, c, parse;
|
|
4347
|
+
while (i < n) {
|
|
4348
|
+
if (j >= m) return -1;
|
|
4349
|
+
c = specifier.charCodeAt(i++);
|
|
4350
|
+
if (c === 37) {
|
|
4351
|
+
c = specifier.charAt(i++);
|
|
4352
|
+
parse = parses[c in pads ? specifier.charAt(i++) : c];
|
|
4353
|
+
if (!parse || (j = parse(d, string, j)) < 0) return -1;
|
|
4354
|
+
} else if (c != string.charCodeAt(j++)) {
|
|
4355
|
+
return -1;
|
|
4356
|
+
}
|
|
1655
4357
|
}
|
|
4358
|
+
return j;
|
|
1656
4359
|
}
|
|
1657
|
-
|
|
4360
|
+
function parsePeriod(d, string, i) {
|
|
4361
|
+
var n = periodRe.exec(string.slice(i));
|
|
4362
|
+
return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
|
|
4363
|
+
}
|
|
4364
|
+
function parseShortWeekday(d, string, i) {
|
|
4365
|
+
var n = shortWeekdayRe.exec(string.slice(i));
|
|
4366
|
+
return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
|
|
4367
|
+
}
|
|
4368
|
+
function parseWeekday(d, string, i) {
|
|
4369
|
+
var n = weekdayRe.exec(string.slice(i));
|
|
4370
|
+
return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
|
|
4371
|
+
}
|
|
4372
|
+
function parseShortMonth(d, string, i) {
|
|
4373
|
+
var n = shortMonthRe.exec(string.slice(i));
|
|
4374
|
+
return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
|
|
4375
|
+
}
|
|
4376
|
+
function parseMonth(d, string, i) {
|
|
4377
|
+
var n = monthRe.exec(string.slice(i));
|
|
4378
|
+
return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
|
|
4379
|
+
}
|
|
4380
|
+
function parseLocaleDateTime(d, string, i) {
|
|
4381
|
+
return parseSpecifier(d, locale_dateTime, string, i);
|
|
4382
|
+
}
|
|
4383
|
+
function parseLocaleDate(d, string, i) {
|
|
4384
|
+
return parseSpecifier(d, locale_date, string, i);
|
|
4385
|
+
}
|
|
4386
|
+
function parseLocaleTime(d, string, i) {
|
|
4387
|
+
return parseSpecifier(d, locale_time, string, i);
|
|
4388
|
+
}
|
|
4389
|
+
function formatShortWeekday(d) {
|
|
4390
|
+
return locale_shortWeekdays[d.getDay()];
|
|
4391
|
+
}
|
|
4392
|
+
function formatWeekday(d) {
|
|
4393
|
+
return locale_weekdays[d.getDay()];
|
|
4394
|
+
}
|
|
4395
|
+
function formatShortMonth(d) {
|
|
4396
|
+
return locale_shortMonths[d.getMonth()];
|
|
4397
|
+
}
|
|
4398
|
+
function formatMonth(d) {
|
|
4399
|
+
return locale_months[d.getMonth()];
|
|
4400
|
+
}
|
|
4401
|
+
function formatPeriod(d) {
|
|
4402
|
+
return locale_periods[+(d.getHours() >= 12)];
|
|
4403
|
+
}
|
|
4404
|
+
function formatQuarter(d) {
|
|
4405
|
+
return 1 + ~~(d.getMonth() / 3);
|
|
4406
|
+
}
|
|
4407
|
+
function formatUTCShortWeekday(d) {
|
|
4408
|
+
return locale_shortWeekdays[d.getUTCDay()];
|
|
4409
|
+
}
|
|
4410
|
+
function formatUTCWeekday(d) {
|
|
4411
|
+
return locale_weekdays[d.getUTCDay()];
|
|
4412
|
+
}
|
|
4413
|
+
function formatUTCShortMonth(d) {
|
|
4414
|
+
return locale_shortMonths[d.getUTCMonth()];
|
|
4415
|
+
}
|
|
4416
|
+
function formatUTCMonth(d) {
|
|
4417
|
+
return locale_months[d.getUTCMonth()];
|
|
4418
|
+
}
|
|
4419
|
+
function formatUTCPeriod(d) {
|
|
4420
|
+
return locale_periods[+(d.getUTCHours() >= 12)];
|
|
4421
|
+
}
|
|
4422
|
+
function formatUTCQuarter(d) {
|
|
4423
|
+
return 1 + ~~(d.getUTCMonth() / 3);
|
|
4424
|
+
}
|
|
4425
|
+
return {
|
|
4426
|
+
format: function(specifier) {
|
|
4427
|
+
var f = newFormat(specifier += "", formats);
|
|
4428
|
+
f.toString = function() {
|
|
4429
|
+
return specifier;
|
|
4430
|
+
};
|
|
4431
|
+
return f;
|
|
4432
|
+
},
|
|
4433
|
+
parse: function(specifier) {
|
|
4434
|
+
var p = newParse(specifier += "", false);
|
|
4435
|
+
p.toString = function() {
|
|
4436
|
+
return specifier;
|
|
4437
|
+
};
|
|
4438
|
+
return p;
|
|
4439
|
+
},
|
|
4440
|
+
utcFormat: function(specifier) {
|
|
4441
|
+
var f = newFormat(specifier += "", utcFormats);
|
|
4442
|
+
f.toString = function() {
|
|
4443
|
+
return specifier;
|
|
4444
|
+
};
|
|
4445
|
+
return f;
|
|
4446
|
+
},
|
|
4447
|
+
utcParse: function(specifier) {
|
|
4448
|
+
var p = newParse(specifier += "", true);
|
|
4449
|
+
p.toString = function() {
|
|
4450
|
+
return specifier;
|
|
4451
|
+
};
|
|
4452
|
+
return p;
|
|
4453
|
+
}
|
|
4454
|
+
};
|
|
4455
|
+
}
|
|
4456
|
+
var pads = { "-": "", "_": " ", "0": "0" };
|
|
4457
|
+
var numberRe = /^\s*\d+/;
|
|
4458
|
+
var percentRe = /^%/;
|
|
4459
|
+
var requoteRe = /[\\^$*+?|[\]().{}]/g;
|
|
4460
|
+
function pad(value, fill, width) {
|
|
4461
|
+
var sign2 = value < 0 ? "-" : "", string = (sign2 ? -value : value) + "", length = string.length;
|
|
4462
|
+
return sign2 + (length < width ? new Array(width - length + 1).join(fill) + string : string);
|
|
4463
|
+
}
|
|
4464
|
+
function requote(s) {
|
|
4465
|
+
return s.replace(requoteRe, "\\$&");
|
|
4466
|
+
}
|
|
4467
|
+
function formatRe(names) {
|
|
4468
|
+
return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i");
|
|
4469
|
+
}
|
|
4470
|
+
function formatLookup(names) {
|
|
4471
|
+
return new Map(names.map((name, i) => [name.toLowerCase(), i]));
|
|
4472
|
+
}
|
|
4473
|
+
function parseWeekdayNumberSunday(d, string, i) {
|
|
4474
|
+
var n = numberRe.exec(string.slice(i, i + 1));
|
|
4475
|
+
return n ? (d.w = +n[0], i + n[0].length) : -1;
|
|
4476
|
+
}
|
|
4477
|
+
function parseWeekdayNumberMonday(d, string, i) {
|
|
4478
|
+
var n = numberRe.exec(string.slice(i, i + 1));
|
|
4479
|
+
return n ? (d.u = +n[0], i + n[0].length) : -1;
|
|
4480
|
+
}
|
|
4481
|
+
function parseWeekNumberSunday(d, string, i) {
|
|
4482
|
+
var n = numberRe.exec(string.slice(i, i + 2));
|
|
4483
|
+
return n ? (d.U = +n[0], i + n[0].length) : -1;
|
|
4484
|
+
}
|
|
4485
|
+
function parseWeekNumberISO(d, string, i) {
|
|
4486
|
+
var n = numberRe.exec(string.slice(i, i + 2));
|
|
4487
|
+
return n ? (d.V = +n[0], i + n[0].length) : -1;
|
|
4488
|
+
}
|
|
4489
|
+
function parseWeekNumberMonday(d, string, i) {
|
|
4490
|
+
var n = numberRe.exec(string.slice(i, i + 2));
|
|
4491
|
+
return n ? (d.W = +n[0], i + n[0].length) : -1;
|
|
4492
|
+
}
|
|
4493
|
+
function parseFullYear(d, string, i) {
|
|
4494
|
+
var n = numberRe.exec(string.slice(i, i + 4));
|
|
4495
|
+
return n ? (d.y = +n[0], i + n[0].length) : -1;
|
|
4496
|
+
}
|
|
4497
|
+
function parseYear(d, string, i) {
|
|
4498
|
+
var n = numberRe.exec(string.slice(i, i + 2));
|
|
4499
|
+
return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2e3), i + n[0].length) : -1;
|
|
4500
|
+
}
|
|
4501
|
+
function parseZone(d, string, i) {
|
|
4502
|
+
var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6));
|
|
4503
|
+
return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1;
|
|
4504
|
+
}
|
|
4505
|
+
function parseQuarter(d, string, i) {
|
|
4506
|
+
var n = numberRe.exec(string.slice(i, i + 1));
|
|
4507
|
+
return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1;
|
|
4508
|
+
}
|
|
4509
|
+
function parseMonthNumber(d, string, i) {
|
|
4510
|
+
var n = numberRe.exec(string.slice(i, i + 2));
|
|
4511
|
+
return n ? (d.m = n[0] - 1, i + n[0].length) : -1;
|
|
4512
|
+
}
|
|
4513
|
+
function parseDayOfMonth(d, string, i) {
|
|
4514
|
+
var n = numberRe.exec(string.slice(i, i + 2));
|
|
4515
|
+
return n ? (d.d = +n[0], i + n[0].length) : -1;
|
|
4516
|
+
}
|
|
4517
|
+
function parseDayOfYear(d, string, i) {
|
|
4518
|
+
var n = numberRe.exec(string.slice(i, i + 3));
|
|
4519
|
+
return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1;
|
|
4520
|
+
}
|
|
4521
|
+
function parseHour24(d, string, i) {
|
|
4522
|
+
var n = numberRe.exec(string.slice(i, i + 2));
|
|
4523
|
+
return n ? (d.H = +n[0], i + n[0].length) : -1;
|
|
4524
|
+
}
|
|
4525
|
+
function parseMinutes(d, string, i) {
|
|
4526
|
+
var n = numberRe.exec(string.slice(i, i + 2));
|
|
4527
|
+
return n ? (d.M = +n[0], i + n[0].length) : -1;
|
|
4528
|
+
}
|
|
4529
|
+
function parseSeconds(d, string, i) {
|
|
4530
|
+
var n = numberRe.exec(string.slice(i, i + 2));
|
|
4531
|
+
return n ? (d.S = +n[0], i + n[0].length) : -1;
|
|
4532
|
+
}
|
|
4533
|
+
function parseMilliseconds(d, string, i) {
|
|
4534
|
+
var n = numberRe.exec(string.slice(i, i + 3));
|
|
4535
|
+
return n ? (d.L = +n[0], i + n[0].length) : -1;
|
|
4536
|
+
}
|
|
4537
|
+
function parseMicroseconds(d, string, i) {
|
|
4538
|
+
var n = numberRe.exec(string.slice(i, i + 6));
|
|
4539
|
+
return n ? (d.L = Math.floor(n[0] / 1e3), i + n[0].length) : -1;
|
|
4540
|
+
}
|
|
4541
|
+
function parseLiteralPercent(d, string, i) {
|
|
4542
|
+
var n = percentRe.exec(string.slice(i, i + 1));
|
|
4543
|
+
return n ? i + n[0].length : -1;
|
|
4544
|
+
}
|
|
4545
|
+
function parseUnixTimestamp(d, string, i) {
|
|
4546
|
+
var n = numberRe.exec(string.slice(i));
|
|
4547
|
+
return n ? (d.Q = +n[0], i + n[0].length) : -1;
|
|
4548
|
+
}
|
|
4549
|
+
function parseUnixTimestampSeconds(d, string, i) {
|
|
4550
|
+
var n = numberRe.exec(string.slice(i));
|
|
4551
|
+
return n ? (d.s = +n[0], i + n[0].length) : -1;
|
|
4552
|
+
}
|
|
4553
|
+
function formatDayOfMonth(d, p) {
|
|
4554
|
+
return pad(d.getDate(), p, 2);
|
|
4555
|
+
}
|
|
4556
|
+
function formatHour24(d, p) {
|
|
4557
|
+
return pad(d.getHours(), p, 2);
|
|
4558
|
+
}
|
|
4559
|
+
function formatHour12(d, p) {
|
|
4560
|
+
return pad(d.getHours() % 12 || 12, p, 2);
|
|
4561
|
+
}
|
|
4562
|
+
function formatDayOfYear(d, p) {
|
|
4563
|
+
return pad(1 + timeDay.count(timeYear(d), d), p, 3);
|
|
4564
|
+
}
|
|
4565
|
+
function formatMilliseconds(d, p) {
|
|
4566
|
+
return pad(d.getMilliseconds(), p, 3);
|
|
4567
|
+
}
|
|
4568
|
+
function formatMicroseconds(d, p) {
|
|
4569
|
+
return formatMilliseconds(d, p) + "000";
|
|
4570
|
+
}
|
|
4571
|
+
function formatMonthNumber(d, p) {
|
|
4572
|
+
return pad(d.getMonth() + 1, p, 2);
|
|
4573
|
+
}
|
|
4574
|
+
function formatMinutes(d, p) {
|
|
4575
|
+
return pad(d.getMinutes(), p, 2);
|
|
4576
|
+
}
|
|
4577
|
+
function formatSeconds(d, p) {
|
|
4578
|
+
return pad(d.getSeconds(), p, 2);
|
|
4579
|
+
}
|
|
4580
|
+
function formatWeekdayNumberMonday(d) {
|
|
4581
|
+
var day = d.getDay();
|
|
4582
|
+
return day === 0 ? 7 : day;
|
|
4583
|
+
}
|
|
4584
|
+
function formatWeekNumberSunday(d, p) {
|
|
4585
|
+
return pad(timeSunday.count(timeYear(d) - 1, d), p, 2);
|
|
4586
|
+
}
|
|
4587
|
+
function dISO(d) {
|
|
4588
|
+
var day = d.getDay();
|
|
4589
|
+
return day >= 4 || day === 0 ? timeThursday(d) : timeThursday.ceil(d);
|
|
4590
|
+
}
|
|
4591
|
+
function formatWeekNumberISO(d, p) {
|
|
4592
|
+
d = dISO(d);
|
|
4593
|
+
return pad(timeThursday.count(timeYear(d), d) + (timeYear(d).getDay() === 4), p, 2);
|
|
4594
|
+
}
|
|
4595
|
+
function formatWeekdayNumberSunday(d) {
|
|
4596
|
+
return d.getDay();
|
|
4597
|
+
}
|
|
4598
|
+
function formatWeekNumberMonday(d, p) {
|
|
4599
|
+
return pad(timeMonday.count(timeYear(d) - 1, d), p, 2);
|
|
4600
|
+
}
|
|
4601
|
+
function formatYear(d, p) {
|
|
4602
|
+
return pad(d.getFullYear() % 100, p, 2);
|
|
4603
|
+
}
|
|
4604
|
+
function formatYearISO(d, p) {
|
|
4605
|
+
d = dISO(d);
|
|
4606
|
+
return pad(d.getFullYear() % 100, p, 2);
|
|
4607
|
+
}
|
|
4608
|
+
function formatFullYear(d, p) {
|
|
4609
|
+
return pad(d.getFullYear() % 1e4, p, 4);
|
|
4610
|
+
}
|
|
4611
|
+
function formatFullYearISO(d, p) {
|
|
4612
|
+
var day = d.getDay();
|
|
4613
|
+
d = day >= 4 || day === 0 ? timeThursday(d) : timeThursday.ceil(d);
|
|
4614
|
+
return pad(d.getFullYear() % 1e4, p, 4);
|
|
4615
|
+
}
|
|
4616
|
+
function formatZone(d) {
|
|
4617
|
+
var z = d.getTimezoneOffset();
|
|
4618
|
+
return (z > 0 ? "-" : (z *= -1, "+")) + pad(z / 60 | 0, "0", 2) + pad(z % 60, "0", 2);
|
|
4619
|
+
}
|
|
4620
|
+
function formatUTCDayOfMonth(d, p) {
|
|
4621
|
+
return pad(d.getUTCDate(), p, 2);
|
|
4622
|
+
}
|
|
4623
|
+
function formatUTCHour24(d, p) {
|
|
4624
|
+
return pad(d.getUTCHours(), p, 2);
|
|
4625
|
+
}
|
|
4626
|
+
function formatUTCHour12(d, p) {
|
|
4627
|
+
return pad(d.getUTCHours() % 12 || 12, p, 2);
|
|
4628
|
+
}
|
|
4629
|
+
function formatUTCDayOfYear(d, p) {
|
|
4630
|
+
return pad(1 + utcDay.count(utcYear(d), d), p, 3);
|
|
4631
|
+
}
|
|
4632
|
+
function formatUTCMilliseconds(d, p) {
|
|
4633
|
+
return pad(d.getUTCMilliseconds(), p, 3);
|
|
4634
|
+
}
|
|
4635
|
+
function formatUTCMicroseconds(d, p) {
|
|
4636
|
+
return formatUTCMilliseconds(d, p) + "000";
|
|
4637
|
+
}
|
|
4638
|
+
function formatUTCMonthNumber(d, p) {
|
|
4639
|
+
return pad(d.getUTCMonth() + 1, p, 2);
|
|
4640
|
+
}
|
|
4641
|
+
function formatUTCMinutes(d, p) {
|
|
4642
|
+
return pad(d.getUTCMinutes(), p, 2);
|
|
4643
|
+
}
|
|
4644
|
+
function formatUTCSeconds(d, p) {
|
|
4645
|
+
return pad(d.getUTCSeconds(), p, 2);
|
|
4646
|
+
}
|
|
4647
|
+
function formatUTCWeekdayNumberMonday(d) {
|
|
4648
|
+
var dow = d.getUTCDay();
|
|
4649
|
+
return dow === 0 ? 7 : dow;
|
|
4650
|
+
}
|
|
4651
|
+
function formatUTCWeekNumberSunday(d, p) {
|
|
4652
|
+
return pad(utcSunday.count(utcYear(d) - 1, d), p, 2);
|
|
4653
|
+
}
|
|
4654
|
+
function UTCdISO(d) {
|
|
4655
|
+
var day = d.getUTCDay();
|
|
4656
|
+
return day >= 4 || day === 0 ? utcThursday(d) : utcThursday.ceil(d);
|
|
4657
|
+
}
|
|
4658
|
+
function formatUTCWeekNumberISO(d, p) {
|
|
4659
|
+
d = UTCdISO(d);
|
|
4660
|
+
return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2);
|
|
4661
|
+
}
|
|
4662
|
+
function formatUTCWeekdayNumberSunday(d) {
|
|
4663
|
+
return d.getUTCDay();
|
|
4664
|
+
}
|
|
4665
|
+
function formatUTCWeekNumberMonday(d, p) {
|
|
4666
|
+
return pad(utcMonday.count(utcYear(d) - 1, d), p, 2);
|
|
4667
|
+
}
|
|
4668
|
+
function formatUTCYear(d, p) {
|
|
4669
|
+
return pad(d.getUTCFullYear() % 100, p, 2);
|
|
4670
|
+
}
|
|
4671
|
+
function formatUTCYearISO(d, p) {
|
|
4672
|
+
d = UTCdISO(d);
|
|
4673
|
+
return pad(d.getUTCFullYear() % 100, p, 2);
|
|
4674
|
+
}
|
|
4675
|
+
function formatUTCFullYear(d, p) {
|
|
4676
|
+
return pad(d.getUTCFullYear() % 1e4, p, 4);
|
|
4677
|
+
}
|
|
4678
|
+
function formatUTCFullYearISO(d, p) {
|
|
4679
|
+
var day = d.getUTCDay();
|
|
4680
|
+
d = day >= 4 || day === 0 ? utcThursday(d) : utcThursday.ceil(d);
|
|
4681
|
+
return pad(d.getUTCFullYear() % 1e4, p, 4);
|
|
4682
|
+
}
|
|
4683
|
+
function formatUTCZone() {
|
|
4684
|
+
return "+0000";
|
|
4685
|
+
}
|
|
4686
|
+
function formatLiteralPercent() {
|
|
4687
|
+
return "%";
|
|
4688
|
+
}
|
|
4689
|
+
function formatUnixTimestamp(d) {
|
|
4690
|
+
return +d;
|
|
4691
|
+
}
|
|
4692
|
+
function formatUnixTimestampSeconds(d) {
|
|
4693
|
+
return Math.floor(+d / 1e3);
|
|
1658
4694
|
}
|
|
1659
4695
|
|
|
1660
|
-
//
|
|
1661
|
-
var
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
4696
|
+
// ../../node_modules/.bun/d3-time-format@4.1.0/node_modules/d3-time-format/src/defaultLocale.js
|
|
4697
|
+
var locale2;
|
|
4698
|
+
var timeFormat;
|
|
4699
|
+
var timeParse;
|
|
4700
|
+
var utcFormat;
|
|
4701
|
+
var utcParse;
|
|
4702
|
+
defaultLocale2({
|
|
4703
|
+
dateTime: "%x, %X",
|
|
4704
|
+
date: "%-m/%-d/%Y",
|
|
4705
|
+
time: "%-I:%M:%S %p",
|
|
4706
|
+
periods: ["AM", "PM"],
|
|
4707
|
+
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
|
4708
|
+
shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
4709
|
+
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
|
4710
|
+
shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
|
4711
|
+
});
|
|
4712
|
+
function defaultLocale2(definition) {
|
|
4713
|
+
locale2 = formatLocale(definition);
|
|
4714
|
+
timeFormat = locale2.format;
|
|
4715
|
+
timeParse = locale2.parse;
|
|
4716
|
+
utcFormat = locale2.utcFormat;
|
|
4717
|
+
utcParse = locale2.utcParse;
|
|
4718
|
+
return locale2;
|
|
4719
|
+
}
|
|
4720
|
+
|
|
4721
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/time.js
|
|
4722
|
+
function date(t) {
|
|
4723
|
+
return new Date(t);
|
|
4724
|
+
}
|
|
4725
|
+
function number3(t) {
|
|
4726
|
+
return t instanceof Date ? +t : +/* @__PURE__ */ new Date(+t);
|
|
4727
|
+
}
|
|
4728
|
+
function calendar(ticks2, tickInterval, year, month, week, day, hour, minute, second2, format2) {
|
|
4729
|
+
var scale = continuous(), invert = scale.invert, domain = scale.domain;
|
|
4730
|
+
var formatMillisecond = format2(".%L"), formatSecond = format2(":%S"), formatMinute = format2("%I:%M"), formatHour = format2("%I %p"), formatDay = format2("%a %d"), formatWeek = format2("%b %d"), formatMonth = format2("%B"), formatYear2 = format2("%Y");
|
|
4731
|
+
function tickFormat2(date2) {
|
|
4732
|
+
return (second2(date2) < date2 ? formatMillisecond : minute(date2) < date2 ? formatSecond : hour(date2) < date2 ? formatMinute : day(date2) < date2 ? formatHour : month(date2) < date2 ? week(date2) < date2 ? formatDay : formatWeek : year(date2) < date2 ? formatMonth : formatYear2)(date2);
|
|
1674
4733
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
4734
|
+
scale.invert = function(y2) {
|
|
4735
|
+
return new Date(invert(y2));
|
|
4736
|
+
};
|
|
4737
|
+
scale.domain = function(_) {
|
|
4738
|
+
return arguments.length ? domain(Array.from(_, number3)) : domain().map(date);
|
|
4739
|
+
};
|
|
4740
|
+
scale.ticks = function(interval) {
|
|
4741
|
+
var d = domain();
|
|
4742
|
+
return ticks2(d[0], d[d.length - 1], interval == null ? 10 : interval);
|
|
4743
|
+
};
|
|
4744
|
+
scale.tickFormat = function(count, specifier) {
|
|
4745
|
+
return specifier == null ? tickFormat2 : format2(specifier);
|
|
4746
|
+
};
|
|
4747
|
+
scale.nice = function(interval) {
|
|
4748
|
+
var d = domain();
|
|
4749
|
+
if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval);
|
|
4750
|
+
return interval ? domain(nice(d, interval)) : scale;
|
|
4751
|
+
};
|
|
4752
|
+
scale.copy = function() {
|
|
4753
|
+
return copy(scale, calendar(ticks2, tickInterval, year, month, week, day, hour, minute, second2, format2));
|
|
4754
|
+
};
|
|
4755
|
+
return scale;
|
|
4756
|
+
}
|
|
4757
|
+
function time() {
|
|
4758
|
+
return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute, second, timeFormat).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
|
|
4759
|
+
}
|
|
1677
4760
|
|
|
1678
|
-
// src/
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
4761
|
+
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/sequential.js
|
|
4762
|
+
function transformer2() {
|
|
4763
|
+
var x0 = 0, x1 = 1, t02, t12, k10, transform, interpolator = identity, clamp = false, unknown;
|
|
4764
|
+
function scale(x2) {
|
|
4765
|
+
return x2 == null || isNaN(x2 = +x2) ? unknown : interpolator(k10 === 0 ? 0.5 : (x2 = (transform(x2) - t02) * k10, clamp ? Math.max(0, Math.min(1, x2)) : x2));
|
|
4766
|
+
}
|
|
4767
|
+
scale.domain = function(_) {
|
|
4768
|
+
return arguments.length ? ([x0, x1] = _, t02 = transform(x0 = +x0), t12 = transform(x1 = +x1), k10 = t02 === t12 ? 0 : 1 / (t12 - t02), scale) : [x0, x1];
|
|
4769
|
+
};
|
|
4770
|
+
scale.clamp = function(_) {
|
|
4771
|
+
return arguments.length ? (clamp = !!_, scale) : clamp;
|
|
4772
|
+
};
|
|
4773
|
+
scale.interpolator = function(_) {
|
|
4774
|
+
return arguments.length ? (interpolator = _, scale) : interpolator;
|
|
4775
|
+
};
|
|
4776
|
+
function range2(interpolate) {
|
|
4777
|
+
return function(_) {
|
|
4778
|
+
var r0, r1;
|
|
4779
|
+
return arguments.length ? ([r0, r1] = _, interpolator = interpolate(r0, r1), scale) : [interpolator(0), interpolator(1)];
|
|
4780
|
+
};
|
|
4781
|
+
}
|
|
4782
|
+
scale.range = range2(value_default);
|
|
4783
|
+
scale.rangeRound = range2(round_default);
|
|
4784
|
+
scale.unknown = function(_) {
|
|
4785
|
+
return arguments.length ? (unknown = _, scale) : unknown;
|
|
4786
|
+
};
|
|
4787
|
+
return function(t) {
|
|
4788
|
+
transform = t, t02 = t(x0), t12 = t(x1), k10 = t02 === t12 ? 0 : 1 / (t12 - t02);
|
|
4789
|
+
return scale;
|
|
4790
|
+
};
|
|
1682
4791
|
}
|
|
1683
|
-
function
|
|
1684
|
-
return
|
|
4792
|
+
function copy2(source, target) {
|
|
4793
|
+
return target.domain(source.domain()).interpolator(source.interpolator()).clamp(source.clamp()).unknown(source.unknown());
|
|
1685
4794
|
}
|
|
1686
|
-
function
|
|
1687
|
-
|
|
4795
|
+
function sequential() {
|
|
4796
|
+
var scale = linearish(transformer2()(identity));
|
|
4797
|
+
scale.copy = function() {
|
|
4798
|
+
return copy2(scale, sequential());
|
|
4799
|
+
};
|
|
4800
|
+
return initInterpolator.apply(scale, arguments);
|
|
1688
4801
|
}
|
|
1689
4802
|
|
|
1690
4803
|
// src/charts/scatter/compute.ts
|
|
1691
|
-
import { max, min } from "d3-array";
|
|
1692
|
-
import { scaleSqrt } from "d3-scale";
|
|
1693
4804
|
var DEFAULT_POINT_RADIUS2 = 5;
|
|
1694
4805
|
var MIN_BUBBLE_RADIUS = 3;
|
|
1695
4806
|
var MAX_BUBBLE_RADIUS = 30;
|
|
@@ -1707,9 +4818,9 @@ function computeScatterMarks(spec, scales, _chartArea, _strategy) {
|
|
|
1707
4818
|
let sizeScale;
|
|
1708
4819
|
if (sizeField) {
|
|
1709
4820
|
const sizeValues = spec.data.map((d) => Number(d[sizeField])).filter((v) => Number.isFinite(v));
|
|
1710
|
-
const sizeMin =
|
|
1711
|
-
const sizeMax =
|
|
1712
|
-
sizeScale =
|
|
4821
|
+
const sizeMin = min2(sizeValues) ?? 0;
|
|
4822
|
+
const sizeMax = max2(sizeValues) ?? 1;
|
|
4823
|
+
sizeScale = sqrt2().domain([sizeMin, sizeMax]).range([MIN_BUBBLE_RADIUS, MAX_BUBBLE_RADIUS]);
|
|
1713
4824
|
}
|
|
1714
4825
|
const marks = [];
|
|
1715
4826
|
for (const row of spec.data) {
|
|
@@ -1719,7 +4830,7 @@ function computeScatterMarks(spec, scales, _chartArea, _strategy) {
|
|
|
1719
4830
|
const cx = xScale(xVal);
|
|
1720
4831
|
const cy = yScale(yVal);
|
|
1721
4832
|
const category = colorField ? String(row[colorField] ?? "") : void 0;
|
|
1722
|
-
const
|
|
4833
|
+
const color2 = getColor(scales, category ?? "__default__");
|
|
1723
4834
|
let radius = DEFAULT_POINT_RADIUS2;
|
|
1724
4835
|
if (sizeScale && sizeField) {
|
|
1725
4836
|
const sizeVal = Number(row[sizeField]);
|
|
@@ -1740,7 +4851,7 @@ function computeScatterMarks(spec, scales, _chartArea, _strategy) {
|
|
|
1740
4851
|
cx,
|
|
1741
4852
|
cy,
|
|
1742
4853
|
r: radius,
|
|
1743
|
-
fill:
|
|
4854
|
+
fill: color2,
|
|
1744
4855
|
stroke: "#ffffff",
|
|
1745
4856
|
strokeWidth: 1,
|
|
1746
4857
|
fillOpacity: 0.7,
|
|
@@ -1852,8 +4963,8 @@ function inferFieldType(data, field) {
|
|
|
1852
4963
|
numericCount++;
|
|
1853
4964
|
continue;
|
|
1854
4965
|
}
|
|
1855
|
-
const
|
|
1856
|
-
if (!Number.isNaN(
|
|
4966
|
+
const date2 = new Date(value);
|
|
4967
|
+
if (!Number.isNaN(date2.getTime())) {
|
|
1857
4968
|
dateCount++;
|
|
1858
4969
|
continue;
|
|
1859
4970
|
}
|
|
@@ -2464,8 +5575,6 @@ ${errorMessages}`);
|
|
|
2464
5575
|
import { adaptTheme, computeChrome, resolveTheme } from "@opendata-ai/openchart-core";
|
|
2465
5576
|
|
|
2466
5577
|
// src/graphs/encoding.ts
|
|
2467
|
-
import { max as max2, min as min2 } from "d3-array";
|
|
2468
|
-
import { scaleLinear, scaleOrdinal, scaleSqrt as scaleSqrt2 } from "d3-scale";
|
|
2469
5578
|
var DEFAULT_NODE_RADIUS = 5;
|
|
2470
5579
|
var MIN_NODE_RADIUS = 3;
|
|
2471
5580
|
var MAX_NODE_RADIUS = 12;
|
|
@@ -2473,19 +5582,19 @@ var DEFAULT_EDGE_WIDTH = 1;
|
|
|
2473
5582
|
var MIN_EDGE_WIDTH = 0.5;
|
|
2474
5583
|
var MAX_EDGE_WIDTH = 4;
|
|
2475
5584
|
var DEFAULT_STROKE_WIDTH2 = 1;
|
|
2476
|
-
function darkenColor(
|
|
2477
|
-
const clean =
|
|
2478
|
-
if (clean.length !== 6 && clean.length !== 3) return
|
|
5585
|
+
function darkenColor(hex2, amount = 0.2) {
|
|
5586
|
+
const clean = hex2.replace(/^#/, "");
|
|
5587
|
+
if (clean.length !== 6 && clean.length !== 3) return hex2;
|
|
2479
5588
|
const full = clean.length === 3 ? clean.split("").map((c) => c + c).join("") : clean;
|
|
2480
5589
|
const r = Math.max(0, Math.round(parseInt(full.substring(0, 2), 16) * (1 - amount)));
|
|
2481
5590
|
const g = Math.max(0, Math.round(parseInt(full.substring(2, 4), 16) * (1 - amount)));
|
|
2482
5591
|
const b = Math.max(0, Math.round(parseInt(full.substring(4, 6), 16) * (1 - amount)));
|
|
2483
5592
|
return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`;
|
|
2484
5593
|
}
|
|
2485
|
-
function hexWithOpacity(
|
|
2486
|
-
const clean =
|
|
5594
|
+
function hexWithOpacity(hex2, opacity) {
|
|
5595
|
+
const clean = hex2.replace(/^#/, "");
|
|
2487
5596
|
if (clean.length !== 6 && clean.length !== 3) {
|
|
2488
|
-
return
|
|
5597
|
+
return hex2;
|
|
2489
5598
|
}
|
|
2490
5599
|
const full = clean.length === 3 ? clean.split("").map((c) => c + c).join("") : clean;
|
|
2491
5600
|
const r = parseInt(full.substring(0, 2), 16);
|
|
@@ -2513,7 +5622,7 @@ function resolveNodeVisuals(nodes, encoding, edges, theme, nodeOverrides) {
|
|
|
2513
5622
|
const values = nodes.map((n) => Number(n[field])).filter((v) => Number.isFinite(v));
|
|
2514
5623
|
const sizeMin = min2(values) ?? 0;
|
|
2515
5624
|
const sizeMax = max2(values) ?? 1;
|
|
2516
|
-
sizeScale =
|
|
5625
|
+
sizeScale = sqrt2().domain([sizeMin, sizeMax]).range([MIN_NODE_RADIUS, MAX_NODE_RADIUS]);
|
|
2517
5626
|
}
|
|
2518
5627
|
let colorFn;
|
|
2519
5628
|
if (encoding.nodeColor?.field) {
|
|
@@ -2525,14 +5634,14 @@ function resolveNodeVisuals(nodes, encoding, edges, theme, nodeOverrides) {
|
|
|
2525
5634
|
const colorMax = max2(values) ?? 1;
|
|
2526
5635
|
const seqPalettes = Object.values(theme.colors.sequential);
|
|
2527
5636
|
const palette = seqPalettes.length > 0 ? seqPalettes[0] : ["#ccc", "#333"];
|
|
2528
|
-
const colorScale =
|
|
5637
|
+
const colorScale = linear2().domain([colorMin, colorMax]).range([palette[0], palette[palette.length - 1]]);
|
|
2529
5638
|
colorFn = (node) => {
|
|
2530
5639
|
const val = Number(node[field]);
|
|
2531
5640
|
return Number.isFinite(val) ? colorScale(val) : theme.colors.categorical[0];
|
|
2532
5641
|
};
|
|
2533
5642
|
} else {
|
|
2534
5643
|
const uniqueValues = [...new Set(nodes.map((n) => String(n[field] ?? "")))];
|
|
2535
|
-
const ordinalScale =
|
|
5644
|
+
const ordinalScale = ordinal().domain(uniqueValues).range(theme.colors.categorical);
|
|
2536
5645
|
colorFn = (node) => ordinalScale(String(node[field] ?? ""));
|
|
2537
5646
|
}
|
|
2538
5647
|
}
|
|
@@ -2584,7 +5693,7 @@ function resolveEdgeVisuals(edges, encoding, theme) {
|
|
|
2584
5693
|
const values = edges.map((e) => Number(e[field])).filter((v) => Number.isFinite(v));
|
|
2585
5694
|
const widthMin = min2(values) ?? 0;
|
|
2586
5695
|
const widthMax = max2(values) ?? 1;
|
|
2587
|
-
widthScale =
|
|
5696
|
+
widthScale = linear2().domain([widthMin, widthMax]).range([MIN_EDGE_WIDTH, MAX_EDGE_WIDTH]);
|
|
2588
5697
|
}
|
|
2589
5698
|
let edgeColorFn;
|
|
2590
5699
|
if (encoding.edgeColor?.field) {
|
|
@@ -2596,14 +5705,14 @@ function resolveEdgeVisuals(edges, encoding, theme) {
|
|
|
2596
5705
|
const colorMax = max2(values) ?? 1;
|
|
2597
5706
|
const seqPalettes = Object.values(theme.colors.sequential);
|
|
2598
5707
|
const palette = seqPalettes.length > 0 ? seqPalettes[0] : ["#ccc", "#333"];
|
|
2599
|
-
const colorScale =
|
|
5708
|
+
const colorScale = linear2().domain([colorMin, colorMax]).range([palette[0], palette[palette.length - 1]]);
|
|
2600
5709
|
edgeColorFn = (edge) => {
|
|
2601
5710
|
const val = Number(edge[field]);
|
|
2602
5711
|
return Number.isFinite(val) ? colorScale(val) : hexWithOpacity(theme.colors.axis, 0.4);
|
|
2603
5712
|
};
|
|
2604
5713
|
} else {
|
|
2605
5714
|
const uniqueValues = [...new Set(edges.map((e) => String(e[field] ?? "")))];
|
|
2606
|
-
const ordinalScale =
|
|
5715
|
+
const ordinalScale = ordinal().domain(uniqueValues).range(theme.colors.categorical);
|
|
2607
5716
|
edgeColorFn = (edge) => ordinalScale(String(edge[field] ?? ""));
|
|
2608
5717
|
}
|
|
2609
5718
|
}
|
|
@@ -2687,9 +5796,9 @@ function buildGraphLegend(nodes, communityColorMap, hasCommunities, theme) {
|
|
|
2687
5796
|
};
|
|
2688
5797
|
let entries;
|
|
2689
5798
|
if (hasCommunities && communityColorMap.size > 0) {
|
|
2690
|
-
entries = [...communityColorMap.entries()].map(([label,
|
|
5799
|
+
entries = [...communityColorMap.entries()].map(([label, color2]) => ({
|
|
2691
5800
|
label,
|
|
2692
|
-
color,
|
|
5801
|
+
color: color2,
|
|
2693
5802
|
shape: "circle",
|
|
2694
5803
|
active: true
|
|
2695
5804
|
}));
|
|
@@ -2703,9 +5812,9 @@ function buildGraphLegend(nodes, communityColorMap, hasCommunities, theme) {
|
|
|
2703
5812
|
if (colorLabels.size <= 1) {
|
|
2704
5813
|
entries = [];
|
|
2705
5814
|
} else {
|
|
2706
|
-
entries = [...colorLabels.entries()].map(([
|
|
5815
|
+
entries = [...colorLabels.entries()].map(([color2, label]) => ({
|
|
2707
5816
|
label,
|
|
2708
|
-
color,
|
|
5817
|
+
color: color2,
|
|
2709
5818
|
shape: "circle",
|
|
2710
5819
|
active: true
|
|
2711
5820
|
}));
|
|
@@ -2864,8 +5973,8 @@ function effectiveDensity(baseDensity, axisLength, minimalThreshold, reducedThre
|
|
|
2864
5973
|
function continuousTicks(resolvedScale, density) {
|
|
2865
5974
|
const scale = resolvedScale.scale;
|
|
2866
5975
|
const count = resolvedScale.channel.axis?.tickCount ?? TICK_COUNTS[density];
|
|
2867
|
-
const
|
|
2868
|
-
return
|
|
5976
|
+
const ticks2 = scale.ticks(count);
|
|
5977
|
+
return ticks2.map((value) => ({
|
|
2869
5978
|
value,
|
|
2870
5979
|
position: scale(value),
|
|
2871
5980
|
label: formatTickLabel(value, resolvedScale)
|
|
@@ -2939,13 +6048,13 @@ function computeAxes(scales, chartArea, strategy, theme) {
|
|
|
2939
6048
|
lineHeight: 1.3
|
|
2940
6049
|
};
|
|
2941
6050
|
if (scales.x) {
|
|
2942
|
-
const
|
|
2943
|
-
const gridlines =
|
|
6051
|
+
const ticks2 = scales.x.type === "band" || scales.x.type === "point" || scales.x.type === "ordinal" ? categoricalTicks(scales.x, xDensity) : continuousTicks(scales.x, xDensity);
|
|
6052
|
+
const gridlines = ticks2.map((t) => ({
|
|
2944
6053
|
position: t.position,
|
|
2945
6054
|
major: true
|
|
2946
6055
|
}));
|
|
2947
6056
|
result.x = {
|
|
2948
|
-
ticks,
|
|
6057
|
+
ticks: ticks2,
|
|
2949
6058
|
gridlines: scales.x.channel.axis?.grid ? gridlines : [],
|
|
2950
6059
|
label: scales.x.channel.axis?.label,
|
|
2951
6060
|
labelStyle: axisLabelStyle,
|
|
@@ -2956,13 +6065,13 @@ function computeAxes(scales, chartArea, strategy, theme) {
|
|
|
2956
6065
|
};
|
|
2957
6066
|
}
|
|
2958
6067
|
if (scales.y) {
|
|
2959
|
-
const
|
|
2960
|
-
const gridlines =
|
|
6068
|
+
const ticks2 = scales.y.type === "band" || scales.y.type === "point" || scales.y.type === "ordinal" ? categoricalTicks(scales.y, yDensity) : continuousTicks(scales.y, yDensity);
|
|
6069
|
+
const gridlines = ticks2.map((t) => ({
|
|
2961
6070
|
position: t.position,
|
|
2962
6071
|
major: true
|
|
2963
6072
|
}));
|
|
2964
6073
|
result.y = {
|
|
2965
|
-
ticks,
|
|
6074
|
+
ticks: ticks2,
|
|
2966
6075
|
// Y-axis gridlines are shown by default (standard editorial practice)
|
|
2967
6076
|
gridlines,
|
|
2968
6077
|
label: scales.y.channel.axis?.label,
|
|
@@ -3131,8 +6240,6 @@ function computeGridlines(axes, chartArea, showVertical = false) {
|
|
|
3131
6240
|
}
|
|
3132
6241
|
|
|
3133
6242
|
// src/layout/scales.ts
|
|
3134
|
-
import { extent, max as max3, min as min3 } from "d3-array";
|
|
3135
|
-
import { scaleBand, scaleLinear as scaleLinear2, scaleLog, scaleOrdinal as scaleOrdinal2, scalePoint, scaleTime } from "d3-scale";
|
|
3136
6243
|
function fieldValues(data, field) {
|
|
3137
6244
|
return data.map((d) => d[field]).filter((v) => v != null);
|
|
3138
6245
|
}
|
|
@@ -3157,7 +6264,7 @@ function uniqueStrings(values) {
|
|
|
3157
6264
|
function buildTimeScale(channel, data, rangeStart, rangeEnd) {
|
|
3158
6265
|
const values = parseDates(fieldValues(data, channel.field));
|
|
3159
6266
|
const domain = channel.scale?.domain ? [new Date(channel.scale.domain[0]), new Date(channel.scale.domain[1])] : extent(values);
|
|
3160
|
-
const scale =
|
|
6267
|
+
const scale = time().domain(domain).range([rangeStart, rangeEnd]);
|
|
3161
6268
|
if (channel.scale?.nice !== false) {
|
|
3162
6269
|
scale.nice();
|
|
3163
6270
|
}
|
|
@@ -3172,14 +6279,14 @@ function buildLinearScale(channel, data, rangeStart, rangeEnd) {
|
|
|
3172
6279
|
domainMin = d0;
|
|
3173
6280
|
domainMax = d1;
|
|
3174
6281
|
} else {
|
|
3175
|
-
domainMin =
|
|
3176
|
-
domainMax =
|
|
6282
|
+
domainMin = min2(values) ?? 0;
|
|
6283
|
+
domainMax = max2(values) ?? 1;
|
|
3177
6284
|
if (channel.scale?.zero !== false) {
|
|
3178
6285
|
domainMin = Math.min(0, domainMin);
|
|
3179
6286
|
domainMax = Math.max(0, domainMax);
|
|
3180
6287
|
}
|
|
3181
6288
|
}
|
|
3182
|
-
const scale =
|
|
6289
|
+
const scale = linear2().domain([domainMin, domainMax]).range([rangeStart, rangeEnd]);
|
|
3183
6290
|
if (channel.scale?.nice !== false) {
|
|
3184
6291
|
scale.nice();
|
|
3185
6292
|
}
|
|
@@ -3187,31 +6294,31 @@ function buildLinearScale(channel, data, rangeStart, rangeEnd) {
|
|
|
3187
6294
|
}
|
|
3188
6295
|
function buildLogScale(channel, data, rangeStart, rangeEnd) {
|
|
3189
6296
|
const values = parseNumbers(fieldValues(data, channel.field)).filter((v) => v > 0);
|
|
3190
|
-
const domainMin =
|
|
3191
|
-
const domainMax =
|
|
3192
|
-
const scale =
|
|
6297
|
+
const domainMin = min2(values) ?? 1;
|
|
6298
|
+
const domainMax = max2(values) ?? 10;
|
|
6299
|
+
const scale = log().domain([domainMin, domainMax]).range([rangeStart, rangeEnd]).nice();
|
|
3193
6300
|
return { scale, type: "log", channel };
|
|
3194
6301
|
}
|
|
3195
6302
|
function buildBandScale(channel, data, rangeStart, rangeEnd) {
|
|
3196
6303
|
const values = channel.scale?.domain ? channel.scale.domain : uniqueStrings(fieldValues(data, channel.field));
|
|
3197
|
-
const scale =
|
|
6304
|
+
const scale = band().domain(values).range([rangeStart, rangeEnd]).padding(0.35);
|
|
3198
6305
|
return { scale, type: "band", channel };
|
|
3199
6306
|
}
|
|
3200
6307
|
function buildPointScale(channel, data, rangeStart, rangeEnd) {
|
|
3201
6308
|
const values = channel.scale?.domain ? channel.scale.domain : uniqueStrings(fieldValues(data, channel.field));
|
|
3202
|
-
const scale =
|
|
6309
|
+
const scale = point2().domain(values).range([rangeStart, rangeEnd]).padding(0.5);
|
|
3203
6310
|
return { scale, type: "point", channel };
|
|
3204
6311
|
}
|
|
3205
6312
|
function buildOrdinalColorScale(channel, data, palette) {
|
|
3206
6313
|
const values = uniqueStrings(fieldValues(data, channel.field));
|
|
3207
|
-
const scale =
|
|
6314
|
+
const scale = ordinal().domain(values).range(palette);
|
|
3208
6315
|
return { scale, type: "ordinal", channel };
|
|
3209
6316
|
}
|
|
3210
6317
|
function buildSequentialColorScale(channel, data, palette) {
|
|
3211
6318
|
const values = parseNumbers(fieldValues(data, channel.field));
|
|
3212
|
-
const domainMin =
|
|
3213
|
-
const domainMax =
|
|
3214
|
-
const scale =
|
|
6319
|
+
const domainMin = min2(values) ?? 0;
|
|
6320
|
+
const domainMax = max2(values) ?? 1;
|
|
6321
|
+
const scale = linear2().domain([domainMin, domainMax]).range([palette[0], palette[palette.length - 1]]).clamp(true);
|
|
3215
6322
|
return { scale, type: "sequential", channel };
|
|
3216
6323
|
}
|
|
3217
6324
|
function buildPositionalScale(channel, data, rangeStart, rangeEnd, chartType, axis) {
|
|
@@ -3374,6 +6481,23 @@ function extractColorEntries(spec, theme) {
|
|
|
3374
6481
|
}));
|
|
3375
6482
|
}
|
|
3376
6483
|
function computeLegend(spec, strategy, theme, chartArea) {
|
|
6484
|
+
if (spec.legend?.show === false) {
|
|
6485
|
+
return {
|
|
6486
|
+
position: "top",
|
|
6487
|
+
entries: [],
|
|
6488
|
+
bounds: { x: 0, y: 0, width: 0, height: 0 },
|
|
6489
|
+
labelStyle: {
|
|
6490
|
+
fontFamily: theme.fonts.family,
|
|
6491
|
+
fontSize: theme.fonts.sizes.small,
|
|
6492
|
+
fontWeight: theme.fonts.weights.normal,
|
|
6493
|
+
fill: theme.colors.text,
|
|
6494
|
+
lineHeight: 1.3
|
|
6495
|
+
},
|
|
6496
|
+
swatchSize: SWATCH_SIZE2,
|
|
6497
|
+
swatchGap: SWATCH_GAP2,
|
|
6498
|
+
entryGap: ENTRY_GAP2
|
|
6499
|
+
};
|
|
6500
|
+
}
|
|
3377
6501
|
const entries = extractColorEntries(spec, theme);
|
|
3378
6502
|
const labelStyle = {
|
|
3379
6503
|
fontFamily: theme.fonts.family,
|
|
@@ -3485,24 +6609,24 @@ function computeBarCell(value, config, columnMax, columnMin, theme, _darkMode) {
|
|
|
3485
6609
|
};
|
|
3486
6610
|
}
|
|
3487
6611
|
function computeColumnMax(data, key) {
|
|
3488
|
-
let
|
|
6612
|
+
let max3 = 0;
|
|
3489
6613
|
for (const row of data) {
|
|
3490
6614
|
const val = row[key];
|
|
3491
|
-
if (typeof val === "number" && Number.isFinite(val) && val >
|
|
3492
|
-
|
|
6615
|
+
if (typeof val === "number" && Number.isFinite(val) && val > max3) {
|
|
6616
|
+
max3 = val;
|
|
3493
6617
|
}
|
|
3494
6618
|
}
|
|
3495
|
-
return
|
|
6619
|
+
return max3;
|
|
3496
6620
|
}
|
|
3497
6621
|
function computeColumnMin(data, key) {
|
|
3498
|
-
let
|
|
6622
|
+
let min3 = 0;
|
|
3499
6623
|
for (const row of data) {
|
|
3500
6624
|
const val = row[key];
|
|
3501
|
-
if (typeof val === "number" && Number.isFinite(val) && val <
|
|
3502
|
-
|
|
6625
|
+
if (typeof val === "number" && Number.isFinite(val) && val < min3) {
|
|
6626
|
+
min3 = val;
|
|
3503
6627
|
}
|
|
3504
6628
|
}
|
|
3505
|
-
return
|
|
6629
|
+
return min3;
|
|
3506
6630
|
}
|
|
3507
6631
|
|
|
3508
6632
|
// src/tables/category-colors.ts
|
|
@@ -3556,7 +6680,6 @@ function computeCategoryColors(data, column, theme, darkMode) {
|
|
|
3556
6680
|
|
|
3557
6681
|
// src/tables/format-cells.ts
|
|
3558
6682
|
import { formatDate as formatDate2, formatNumber as formatNumber4 } from "@opendata-ai/openchart-core";
|
|
3559
|
-
import { format as d3Format } from "d3-format";
|
|
3560
6683
|
function isNumericValue(value) {
|
|
3561
6684
|
if (typeof value === "number") return Number.isFinite(value);
|
|
3562
6685
|
return false;
|
|
@@ -3576,7 +6699,7 @@ function formatCell(value, column) {
|
|
|
3576
6699
|
}
|
|
3577
6700
|
if (column.format && isNumericValue(value)) {
|
|
3578
6701
|
try {
|
|
3579
|
-
const formatter =
|
|
6702
|
+
const formatter = format(column.format);
|
|
3580
6703
|
return {
|
|
3581
6704
|
value,
|
|
3582
6705
|
formattedValue: formatter(value),
|
|
@@ -3609,7 +6732,7 @@ function formatValueForSearch(value, column) {
|
|
|
3609
6732
|
if (value == null) return "";
|
|
3610
6733
|
if (column.format && isNumericValue(value)) {
|
|
3611
6734
|
try {
|
|
3612
|
-
return
|
|
6735
|
+
return format(column.format)(value);
|
|
3613
6736
|
} catch {
|
|
3614
6737
|
}
|
|
3615
6738
|
}
|
|
@@ -3621,8 +6744,6 @@ function formatValueForSearch(value, column) {
|
|
|
3621
6744
|
|
|
3622
6745
|
// src/tables/heatmap.ts
|
|
3623
6746
|
import { adaptColorForDarkMode as adaptColorForDarkMode2 } from "@opendata-ai/openchart-core";
|
|
3624
|
-
import { interpolateRgb } from "d3-interpolate";
|
|
3625
|
-
import { scaleSequential } from "d3-scale";
|
|
3626
6747
|
function interpolatorFromStops(stops) {
|
|
3627
6748
|
if (stops.length === 0) return () => "#ffffff";
|
|
3628
6749
|
if (stops.length === 1) return () => stops[0];
|
|
@@ -3632,7 +6753,7 @@ function interpolatorFromStops(stops) {
|
|
|
3632
6753
|
const lo = Math.floor(segment);
|
|
3633
6754
|
const hi = Math.min(lo + 1, stops.length - 1);
|
|
3634
6755
|
const frac = segment - lo;
|
|
3635
|
-
return
|
|
6756
|
+
return rgb_default(stops[lo], stops[hi])(frac);
|
|
3636
6757
|
};
|
|
3637
6758
|
}
|
|
3638
6759
|
function resolvePalette(palette, theme) {
|
|
@@ -3663,13 +6784,13 @@ function computeHeatmapColors(data, column, theme, darkMode) {
|
|
|
3663
6784
|
if (config.domain) {
|
|
3664
6785
|
domain = config.domain;
|
|
3665
6786
|
} else {
|
|
3666
|
-
let
|
|
3667
|
-
let
|
|
6787
|
+
let min3 = Infinity;
|
|
6788
|
+
let max3 = -Infinity;
|
|
3668
6789
|
for (const { value } of numericValues) {
|
|
3669
|
-
if (value <
|
|
3670
|
-
if (value >
|
|
6790
|
+
if (value < min3) min3 = value;
|
|
6791
|
+
if (value > max3) max3 = value;
|
|
3671
6792
|
}
|
|
3672
|
-
domain = [
|
|
6793
|
+
domain = [min3, max3];
|
|
3673
6794
|
}
|
|
3674
6795
|
let stops = resolvePalette(config.palette, theme);
|
|
3675
6796
|
if (darkMode) {
|
|
@@ -3678,7 +6799,7 @@ function computeHeatmapColors(data, column, theme, darkMode) {
|
|
|
3678
6799
|
stops = stops.map((c) => adaptColorForDarkMode2(c, lightBg, darkBg));
|
|
3679
6800
|
}
|
|
3680
6801
|
const interpolator = interpolatorFromStops(stops);
|
|
3681
|
-
const scale =
|
|
6802
|
+
const scale = sequential(interpolator).domain(domain).clamp(true);
|
|
3682
6803
|
for (const { index, value } of numericValues) {
|
|
3683
6804
|
const bg = scale(value);
|
|
3684
6805
|
const textColor = accessibleTextColor(bg);
|
|
@@ -3784,42 +6905,42 @@ function extractValues(row, columnKey, config) {
|
|
|
3784
6905
|
function computeSparkline(values, config, theme, _darkMode) {
|
|
3785
6906
|
if (values.length === 0) return null;
|
|
3786
6907
|
const type = config.type ?? "line";
|
|
3787
|
-
const
|
|
3788
|
-
let
|
|
3789
|
-
let
|
|
6908
|
+
const color2 = config.color ?? theme.colors.categorical[0];
|
|
6909
|
+
let min3 = Infinity;
|
|
6910
|
+
let max3 = -Infinity;
|
|
3790
6911
|
for (const v of values) {
|
|
3791
|
-
if (v <
|
|
3792
|
-
if (v >
|
|
6912
|
+
if (v < min3) min3 = v;
|
|
6913
|
+
if (v > max3) max3 = v;
|
|
3793
6914
|
}
|
|
3794
|
-
const
|
|
3795
|
-
const
|
|
6915
|
+
const range2 = max3 - min3;
|
|
6916
|
+
const normalize2 = (v) => range2 === 0 ? 0.5 : (v - min3) / range2;
|
|
3796
6917
|
const startValue = values[0];
|
|
3797
6918
|
const endValue = values[values.length - 1];
|
|
3798
6919
|
if (type === "line") {
|
|
3799
6920
|
const points2 = values.map((v, i) => ({
|
|
3800
6921
|
x: values.length === 1 ? 0.5 : i / (values.length - 1),
|
|
3801
|
-
y:
|
|
6922
|
+
y: normalize2(v)
|
|
3802
6923
|
}));
|
|
3803
6924
|
return {
|
|
3804
6925
|
type,
|
|
3805
6926
|
points: points2,
|
|
3806
6927
|
bars: [],
|
|
3807
|
-
color,
|
|
6928
|
+
color: color2,
|
|
3808
6929
|
count: values.length,
|
|
3809
6930
|
startValue,
|
|
3810
6931
|
endValue
|
|
3811
6932
|
};
|
|
3812
6933
|
}
|
|
3813
|
-
const bars = values.map(
|
|
6934
|
+
const bars = values.map(normalize2);
|
|
3814
6935
|
const points = values.map((v, i) => ({
|
|
3815
6936
|
x: values.length === 1 ? 0.5 : i / (values.length - 1),
|
|
3816
|
-
y:
|
|
6937
|
+
y: normalize2(v)
|
|
3817
6938
|
}));
|
|
3818
6939
|
return {
|
|
3819
6940
|
type,
|
|
3820
6941
|
points,
|
|
3821
6942
|
bars,
|
|
3822
|
-
color,
|
|
6943
|
+
color: color2,
|
|
3823
6944
|
count: values.length,
|
|
3824
6945
|
startValue,
|
|
3825
6946
|
endValue
|
|
@@ -4083,16 +7204,15 @@ function compileTableLayout(spec, options, theme) {
|
|
|
4083
7204
|
|
|
4084
7205
|
// src/tooltips/compute.ts
|
|
4085
7206
|
import { formatDate as formatDate3, formatNumber as formatNumber5 } from "@opendata-ai/openchart-core";
|
|
4086
|
-
|
|
4087
|
-
function formatValue(value, fieldType, format) {
|
|
7207
|
+
function formatValue(value, fieldType, format2) {
|
|
4088
7208
|
if (value == null) return "";
|
|
4089
7209
|
if (fieldType === "temporal" || value instanceof Date) {
|
|
4090
7210
|
return formatDate3(value);
|
|
4091
7211
|
}
|
|
4092
7212
|
if (typeof value === "number") {
|
|
4093
|
-
if (
|
|
7213
|
+
if (format2) {
|
|
4094
7214
|
try {
|
|
4095
|
-
return
|
|
7215
|
+
return format(format2)(value);
|
|
4096
7216
|
} catch {
|
|
4097
7217
|
return formatNumber5(value);
|
|
4098
7218
|
}
|
|
@@ -4101,13 +7221,13 @@ function formatValue(value, fieldType, format) {
|
|
|
4101
7221
|
}
|
|
4102
7222
|
return String(value);
|
|
4103
7223
|
}
|
|
4104
|
-
function buildFields(row, encoding,
|
|
7224
|
+
function buildFields(row, encoding, color2) {
|
|
4105
7225
|
const fields = [];
|
|
4106
7226
|
if (encoding.y) {
|
|
4107
7227
|
fields.push({
|
|
4108
7228
|
label: encoding.y.axis?.label ?? encoding.y.field,
|
|
4109
7229
|
value: formatValue(row[encoding.y.field], encoding.y.type, encoding.y.axis?.format),
|
|
4110
|
-
color
|
|
7230
|
+
color: color2
|
|
4111
7231
|
});
|
|
4112
7232
|
}
|
|
4113
7233
|
if (encoding.x) {
|
|
@@ -4272,14 +7392,52 @@ function compileChart(spec, options) {
|
|
|
4272
7392
|
if (normalized.type === "graph") {
|
|
4273
7393
|
throw new Error("compileChart received a graph spec. Use compileGraph instead.");
|
|
4274
7394
|
}
|
|
4275
|
-
|
|
7395
|
+
let chartSpec = normalized;
|
|
7396
|
+
const breakpoint = getBreakpoint(options.width);
|
|
7397
|
+
const strategy = getLayoutStrategy(breakpoint);
|
|
7398
|
+
const rawSpec = spec;
|
|
7399
|
+
const overrides = rawSpec.overrides;
|
|
7400
|
+
if (overrides?.[breakpoint]) {
|
|
7401
|
+
const bp = overrides[breakpoint];
|
|
7402
|
+
if (bp.chrome) {
|
|
7403
|
+
chartSpec = {
|
|
7404
|
+
...chartSpec,
|
|
7405
|
+
chrome: {
|
|
7406
|
+
...chartSpec.chrome,
|
|
7407
|
+
...bp.chrome
|
|
7408
|
+
}
|
|
7409
|
+
};
|
|
7410
|
+
}
|
|
7411
|
+
if (bp.labels) {
|
|
7412
|
+
chartSpec = {
|
|
7413
|
+
...chartSpec,
|
|
7414
|
+
labels: {
|
|
7415
|
+
...chartSpec.labels,
|
|
7416
|
+
...bp.labels
|
|
7417
|
+
}
|
|
7418
|
+
};
|
|
7419
|
+
}
|
|
7420
|
+
if (bp.legend) {
|
|
7421
|
+
chartSpec = {
|
|
7422
|
+
...chartSpec,
|
|
7423
|
+
legend: {
|
|
7424
|
+
...chartSpec.legend,
|
|
7425
|
+
...bp.legend
|
|
7426
|
+
}
|
|
7427
|
+
};
|
|
7428
|
+
}
|
|
7429
|
+
if (bp.annotations) {
|
|
7430
|
+
chartSpec = {
|
|
7431
|
+
...chartSpec,
|
|
7432
|
+
annotations: bp.annotations
|
|
7433
|
+
};
|
|
7434
|
+
}
|
|
7435
|
+
}
|
|
4276
7436
|
const mergedThemeConfig = options.theme ? { ...chartSpec.theme, ...options.theme } : chartSpec.theme;
|
|
4277
7437
|
let theme = resolveTheme2(mergedThemeConfig);
|
|
4278
7438
|
if (options.darkMode) {
|
|
4279
7439
|
theme = adaptTheme2(theme);
|
|
4280
7440
|
}
|
|
4281
|
-
const breakpoint = getBreakpoint(options.width);
|
|
4282
|
-
const strategy = getLayoutStrategy(breakpoint);
|
|
4283
7441
|
const preliminaryArea = {
|
|
4284
7442
|
x: 0,
|
|
4285
7443
|
y: 0,
|