@quillsql/react 2.13.42 → 2.13.43
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/cjs/components/Chart/GaugeChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/GaugeChart.js +70 -12
- package/dist/cjs/components/Chart/InternalChart.js +1 -1
- package/dist/cjs/components/Chart/MapChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/MapChart.js +65 -7
- package/dist/esm/components/Chart/GaugeChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/GaugeChart.js +33 -8
- package/dist/esm/components/Chart/InternalChart.js +1 -1
- package/dist/esm/components/Chart/MapChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/MapChart.js +30 -5
- package/package.json +5 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/GaugeChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/GaugeChart.tsx"],"names":[],"mappings":"AAOA,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,UAAU,EACV,WAAW,EACX,cAAc,EACd,MAAM,EACN,iBAAwB,GACzB,EAAE;IACD,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,2CAeA"}
|
|
@@ -1,11 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.default = GaugeChart;
|
|
4
37
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
38
|
const react_1 = require("react");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
39
|
+
// import { arc } from 'd3-shape';
|
|
40
|
+
// import { interpolate } from 'd3-interpolate';
|
|
41
|
+
// import { select } from 'd3-selection';
|
|
42
|
+
// These two are just for type checking
|
|
9
43
|
require("d3-transition");
|
|
10
44
|
const axisFormatter_1 = require("../../utils/axisFormatter");
|
|
11
45
|
function GaugeChart({ data, xAxisField, xAxisFormat, containerStyle, colors, isAnimationActive = true, }) {
|
|
@@ -27,13 +61,34 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
27
61
|
// Gauge arc from -135° to +135°
|
|
28
62
|
const startAngle = -(3 * Math.PI) / 4;
|
|
29
63
|
const totalAngle = (3 * Math.PI) / 2;
|
|
64
|
+
// We need to dynamically import d3 to avoid cjs/esm issues.
|
|
65
|
+
const [arc, setArc] = (0, react_1.useState)(null);
|
|
66
|
+
const [interpolate, setInterpolate] = (0, react_1.useState)(null);
|
|
67
|
+
const [select, setSelect] = (0, react_1.useState)(null);
|
|
68
|
+
(0, react_1.useEffect)(() => {
|
|
69
|
+
console.log('Loading D3 modules');
|
|
70
|
+
Promise.resolve().then(() => __importStar(require('d3-shape'))).then(({ arc }) => {
|
|
71
|
+
console.log('d3-shape loaded');
|
|
72
|
+
setArc(() => arc);
|
|
73
|
+
}).catch(err => console.error('Failed to load d3-shape:', err));
|
|
74
|
+
Promise.resolve().then(() => __importStar(require('d3-interpolate'))).then(({ interpolate }) => {
|
|
75
|
+
console.log('d3-interpolate loaded');
|
|
76
|
+
setInterpolate(() => interpolate);
|
|
77
|
+
}).catch(err => console.error('Failed to load d3-interpolate:', err));
|
|
78
|
+
Promise.resolve().then(() => __importStar(require('d3-selection'))).then(({ select }) => {
|
|
79
|
+
console.log('d3-selection loaded');
|
|
80
|
+
setSelect(() => select);
|
|
81
|
+
}).catch(err => console.error('Failed to load d3-selection:', err));
|
|
82
|
+
}, []);
|
|
30
83
|
// --- Initialization ---
|
|
31
84
|
(0, react_1.useEffect)(() => {
|
|
32
|
-
|
|
85
|
+
console.log('effect run');
|
|
86
|
+
if (!containerRef.current || !select)
|
|
33
87
|
return;
|
|
88
|
+
console.log('made it');
|
|
34
89
|
const container = containerRef.current;
|
|
35
|
-
|
|
36
|
-
svgRef.current =
|
|
90
|
+
select(container).select('svg').remove();
|
|
91
|
+
svgRef.current = select(container)
|
|
37
92
|
// Let CSS control the size.
|
|
38
93
|
.append('svg')
|
|
39
94
|
.attr('width', '100%')
|
|
@@ -67,7 +122,7 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
67
122
|
svgRef.current?.remove();
|
|
68
123
|
svgRef.current = null;
|
|
69
124
|
};
|
|
70
|
-
}, [colors]);
|
|
125
|
+
}, [colors, select]);
|
|
71
126
|
// --- Update & Resize ---
|
|
72
127
|
(0, react_1.useEffect)(() => {
|
|
73
128
|
if (!containerRef.current ||
|
|
@@ -75,7 +130,10 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
75
130
|
!gaugeGroupRef.current ||
|
|
76
131
|
!needleRef.current ||
|
|
77
132
|
!needleOutlineRef.current ||
|
|
78
|
-
!textRef.current
|
|
133
|
+
!textRef.current ||
|
|
134
|
+
!arc ||
|
|
135
|
+
!interpolate ||
|
|
136
|
+
!select)
|
|
79
137
|
return;
|
|
80
138
|
// Use getBoundingClientRect() so we get accurate dimensions.
|
|
81
139
|
const rect = containerRef.current.getBoundingClientRect();
|
|
@@ -101,7 +159,7 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
101
159
|
{ start: startAngle + totalAngle / 3, end: startAngle + (2 * totalAngle) / 3, color: colors[3] || 'yellow' },
|
|
102
160
|
{ start: startAngle + (2 * totalAngle) / 3, end: startAngle + totalAngle, color: colors[2] || 'green' },
|
|
103
161
|
];
|
|
104
|
-
const arcGenerator =
|
|
162
|
+
const arcGenerator = arc()
|
|
105
163
|
.innerRadius(innerRadius)
|
|
106
164
|
.outerRadius(radius);
|
|
107
165
|
segments.forEach((seg, i) => {
|
|
@@ -133,8 +191,8 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
133
191
|
.attr('y', radius * 0.1);
|
|
134
192
|
if (isAnimationActive) {
|
|
135
193
|
const prevAngle = startAngle + totalAngle * previousPercentageRef.current - Math.PI / 2;
|
|
136
|
-
const angleInterpolator =
|
|
137
|
-
const textInterpolator =
|
|
194
|
+
const angleInterpolator = interpolate(prevAngle, newAngle);
|
|
195
|
+
const textInterpolator = interpolate(previousPercentageRef.current, percentage);
|
|
138
196
|
needleRef.current.interrupt()
|
|
139
197
|
.transition()
|
|
140
198
|
.duration(1000)
|
|
@@ -182,7 +240,7 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
182
240
|
}
|
|
183
241
|
previousPercentageRef.current = percentage;
|
|
184
242
|
firstMountRef.current = false;
|
|
185
|
-
}, [percentage, colors, isAnimationActive, xAxisFormat]);
|
|
243
|
+
}, [percentage, colors, isAnimationActive, xAxisFormat, select, arc, interpolate]);
|
|
186
244
|
// Use ResizeObserver to trigger updates on container size changes.
|
|
187
245
|
(0, react_1.useEffect)(() => {
|
|
188
246
|
if (!containerRef.current)
|
|
@@ -466,7 +466,7 @@ function InternalChart({ report, colors, className, containerStyle, isAnimationA
|
|
|
466
466
|
marginBottom: 'auto',
|
|
467
467
|
display: 'flex',
|
|
468
468
|
}, children: (0, jsx_runtime_1.jsx)(MetricComponent, { error: error, isLoading: loading, report: report, children: report?.rows?.[0]?.[report.xAxisField] }) })), report.chartType !== 'table' && report.chartType !== 'metric' && ((0, jsx_runtime_1.jsx)(Chart_1.ChartDisplay, { config: report, containerStyle: {
|
|
469
|
-
minHeight:
|
|
469
|
+
minHeight: 300,
|
|
470
470
|
width: ['US map', 'World map'].includes(report.chartType) ? '70%' : ['gauge'].includes(report.chartType) ? undefined : '100%',
|
|
471
471
|
height: ['US map', 'World map'].includes(report.chartType) ? 'fit-content' : ['gauge'].includes(report.chartType) ? 500 : undefined,
|
|
472
472
|
marginLeft: ['gauge'].includes(report.chartType) ? 'undefined' : 'auto',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/MapChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/MapChart.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAuT3C,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,cAAc,GACf,EAAE;IACD,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAC;KAAE,EAAE,CAAC;IACrE,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACtC,2CAgKA;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,cAAc,GACf,EAAE;IACD,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAC;KAAE,EAAE,CAAC;IACrE,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACtC,2CAiKA"}
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -7,8 +40,6 @@ exports.USMap = USMap;
|
|
|
7
40
|
exports.WorldMap = WorldMap;
|
|
8
41
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
42
|
const react_simple_maps_1 = require("react-simple-maps");
|
|
10
|
-
const d3_geo_1 = require("d3-geo");
|
|
11
|
-
const d3_scale_1 = require("d3-scale");
|
|
12
43
|
const react_1 = require("react");
|
|
13
44
|
const ChartTooltipFrame_1 = __importDefault(require("./ChartTooltipFrame"));
|
|
14
45
|
const ChartTooltipRow_1 = __importDefault(require("./ChartTooltipRow"));
|
|
@@ -328,7 +359,16 @@ function USMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, onClickChart
|
|
|
328
359
|
return acc;
|
|
329
360
|
}, {});
|
|
330
361
|
const measureField = yAxisFields[0].field;
|
|
362
|
+
// These must be dynamically loaded as they are not available as CommonJS modules.
|
|
363
|
+
const [scaleLog, setScaleLog] = (0, react_1.useState)(null);
|
|
364
|
+
(0, react_1.useEffect)(() => {
|
|
365
|
+
Promise.resolve().then(() => __importStar(require("d3-scale"))).then((scale) => {
|
|
366
|
+
setScaleLog(() => scale.scaleLog);
|
|
367
|
+
});
|
|
368
|
+
}, []);
|
|
331
369
|
const colorScale = (0, react_1.useMemo)(() => {
|
|
370
|
+
if (!scaleLog)
|
|
371
|
+
return () => '#FFFFFF';
|
|
332
372
|
const values = Object.values(mappedData)
|
|
333
373
|
.map((d) => parseFloat(d[measureField]))
|
|
334
374
|
.filter((v) => !isNaN(v));
|
|
@@ -353,10 +393,10 @@ function USMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, onClickChart
|
|
|
353
393
|
const gradientStop = getCustomColor(yAxisFields[0]?.field ?? xAxisField, 'stop') ??
|
|
354
394
|
getCustomColor(yAxisFields[0]?.field ?? xAxisField) ??
|
|
355
395
|
colors[0];
|
|
356
|
-
return
|
|
396
|
+
return scaleLog()
|
|
357
397
|
.domain([minValue, maxValue])
|
|
358
398
|
.range([gradientStart ?? "#f7fbff", gradientStop ?? "#08306b"]);
|
|
359
|
-
}, [mappedData, measureField, colorMap, yAxisFields, xAxisField, colors]);
|
|
399
|
+
}, [mappedData, measureField, colorMap, yAxisFields, xAxisField, colors, scaleLog]);
|
|
360
400
|
const hoveredValue = (0, react_1.useMemo)(() => {
|
|
361
401
|
return !hoveredState ? undefined : mappedData[fipsToNames[hoveredState]?.abbreviation ?? '']?.[measureField] ??
|
|
362
402
|
mappedData[fipsToNames[hoveredState]?.name ?? '']?.[measureField] ??
|
|
@@ -422,7 +462,16 @@ function WorldMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, onClickCh
|
|
|
422
462
|
return acc;
|
|
423
463
|
}, {});
|
|
424
464
|
const measureField = yAxisFields[0].field;
|
|
465
|
+
// These must be dynamically loaded as they are not available as CommonJS modules.
|
|
466
|
+
const [scaleLog, setScaleLog] = (0, react_1.useState)(null);
|
|
467
|
+
(0, react_1.useEffect)(() => {
|
|
468
|
+
Promise.resolve().then(() => __importStar(require("d3-scale"))).then((scale) => {
|
|
469
|
+
setScaleLog(() => scale.scaleLog);
|
|
470
|
+
});
|
|
471
|
+
}, []);
|
|
425
472
|
const colorScale = (0, react_1.useMemo)(() => {
|
|
473
|
+
if (!scaleLog)
|
|
474
|
+
return () => '#FFFFFF';
|
|
426
475
|
const values = Object.values(mappedData)
|
|
427
476
|
.map((d) => parseFloat(d[measureField]))
|
|
428
477
|
.filter((v) => !isNaN(v));
|
|
@@ -447,10 +496,10 @@ function WorldMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, onClickCh
|
|
|
447
496
|
const gradientStop = getCustomColor(yAxisFields[0]?.field ?? xAxisField, 'stop') ??
|
|
448
497
|
getCustomColor(yAxisFields[0]?.field ?? xAxisField) ??
|
|
449
498
|
colors[0];
|
|
450
|
-
return
|
|
499
|
+
return scaleLog()
|
|
451
500
|
.domain([minValue, maxValue])
|
|
452
501
|
.range([gradientStart ?? "#f7fbff", gradientStop ?? "#08306b"]);
|
|
453
|
-
}, [mappedData, measureField, colorMap, yAxisFields, xAxisField, colors]);
|
|
502
|
+
}, [mappedData, measureField, colorMap, yAxisFields, xAxisField, colors, scaleLog]);
|
|
454
503
|
const hoveredValue = (0, react_1.useMemo)(() => {
|
|
455
504
|
return !hoveredCountry ? undefined : mappedData[isoToNames[hoveredCountry]?.abbreviation ?? '']?.[measureField] ??
|
|
456
505
|
mappedData[isoToNames[hoveredCountry]?.name ?? '']?.[measureField] ??
|
|
@@ -510,6 +559,13 @@ function WorldMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, onClickCh
|
|
|
510
559
|
}
|
|
511
560
|
function MapLayout({ geographyUrl, hoveredRegion, setHoveredRegion, setHoveredCoords, containerRef, mappedData, measureField, colorScale, onClickChartElement, regionNames, }) {
|
|
512
561
|
const { projection } = (0, react_simple_maps_1.useMapContext)();
|
|
562
|
+
// These must be dynamically loaded as they are not available as CommonJS modules.
|
|
563
|
+
const [geoCentroid, setGeoCentroid] = (0, react_1.useState)(null);
|
|
564
|
+
(0, react_1.useEffect)(() => {
|
|
565
|
+
Promise.resolve().then(() => __importStar(require("d3-geo"))).then((geo) => {
|
|
566
|
+
setGeoCentroid(() => geo.geoCentroid);
|
|
567
|
+
});
|
|
568
|
+
}, []);
|
|
513
569
|
return ((0, jsx_runtime_1.jsx)(react_simple_maps_1.Geographies, { geography: geographyUrl, children: ({ geographies }) => geographies.map((geo, index) => {
|
|
514
570
|
const regionData = mappedData[geo.id] ??
|
|
515
571
|
mappedData[regionNames[geo.id]?.abbreviation ?? ''] ??
|
|
@@ -519,7 +575,9 @@ function MapLayout({ geographyUrl, hoveredRegion, setHoveredRegion, setHoveredCo
|
|
|
519
575
|
const value = regionData ? parseFloat(regionData[measureField]) : null;
|
|
520
576
|
const fill = value != null ? colorScale(value) : "#D6D6DA";
|
|
521
577
|
return (0, jsx_runtime_1.jsx)(react_simple_maps_1.Geography, { geography: geo, fill: fill, stroke: "#FFFFFF", strokeWidth: 0.5, onMouseEnter: () => {
|
|
522
|
-
|
|
578
|
+
if (!geoCentroid)
|
|
579
|
+
return;
|
|
580
|
+
const centroid = geoCentroid(geo);
|
|
523
581
|
const projected = projection(centroid);
|
|
524
582
|
if (projected && containerRef.current) {
|
|
525
583
|
const [x, y] = projected;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/GaugeChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/GaugeChart.tsx"],"names":[],"mappings":"AAOA,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,UAAU,EACV,WAAW,EACX,cAAc,EACd,MAAM,EACN,iBAAwB,GACzB,EAAE;IACD,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,2CAeA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
// import { arc } from 'd3-shape';
|
|
4
|
+
// import { interpolate } from 'd3-interpolate';
|
|
5
|
+
// import { select } from 'd3-selection';
|
|
6
|
+
// These two are just for type checking
|
|
6
7
|
import 'd3-transition';
|
|
7
8
|
import { axisFormatter } from "../../utils/axisFormatter";
|
|
8
9
|
export default function GaugeChart({ data, xAxisField, xAxisFormat, containerStyle, colors, isAnimationActive = true, }) {
|
|
@@ -24,10 +25,31 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
24
25
|
// Gauge arc from -135° to +135°
|
|
25
26
|
const startAngle = -(3 * Math.PI) / 4;
|
|
26
27
|
const totalAngle = (3 * Math.PI) / 2;
|
|
28
|
+
// We need to dynamically import d3 to avoid cjs/esm issues.
|
|
29
|
+
const [arc, setArc] = useState(null);
|
|
30
|
+
const [interpolate, setInterpolate] = useState(null);
|
|
31
|
+
const [select, setSelect] = useState(null);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
console.log('Loading D3 modules');
|
|
34
|
+
import('d3-shape').then(({ arc }) => {
|
|
35
|
+
console.log('d3-shape loaded');
|
|
36
|
+
setArc(() => arc);
|
|
37
|
+
}).catch(err => console.error('Failed to load d3-shape:', err));
|
|
38
|
+
import('d3-interpolate').then(({ interpolate }) => {
|
|
39
|
+
console.log('d3-interpolate loaded');
|
|
40
|
+
setInterpolate(() => interpolate);
|
|
41
|
+
}).catch(err => console.error('Failed to load d3-interpolate:', err));
|
|
42
|
+
import('d3-selection').then(({ select }) => {
|
|
43
|
+
console.log('d3-selection loaded');
|
|
44
|
+
setSelect(() => select);
|
|
45
|
+
}).catch(err => console.error('Failed to load d3-selection:', err));
|
|
46
|
+
}, []);
|
|
27
47
|
// --- Initialization ---
|
|
28
48
|
useEffect(() => {
|
|
29
|
-
|
|
49
|
+
console.log('effect run');
|
|
50
|
+
if (!containerRef.current || !select)
|
|
30
51
|
return;
|
|
52
|
+
console.log('made it');
|
|
31
53
|
const container = containerRef.current;
|
|
32
54
|
select(container).select('svg').remove();
|
|
33
55
|
svgRef.current = select(container)
|
|
@@ -64,7 +86,7 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
64
86
|
svgRef.current?.remove();
|
|
65
87
|
svgRef.current = null;
|
|
66
88
|
};
|
|
67
|
-
}, [colors]);
|
|
89
|
+
}, [colors, select]);
|
|
68
90
|
// --- Update & Resize ---
|
|
69
91
|
useEffect(() => {
|
|
70
92
|
if (!containerRef.current ||
|
|
@@ -72,7 +94,10 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
72
94
|
!gaugeGroupRef.current ||
|
|
73
95
|
!needleRef.current ||
|
|
74
96
|
!needleOutlineRef.current ||
|
|
75
|
-
!textRef.current
|
|
97
|
+
!textRef.current ||
|
|
98
|
+
!arc ||
|
|
99
|
+
!interpolate ||
|
|
100
|
+
!select)
|
|
76
101
|
return;
|
|
77
102
|
// Use getBoundingClientRect() so we get accurate dimensions.
|
|
78
103
|
const rect = containerRef.current.getBoundingClientRect();
|
|
@@ -179,7 +204,7 @@ function D3Gauge({ percentage, containerStyle, xAxisFormat, colors, isAnimationA
|
|
|
179
204
|
}
|
|
180
205
|
previousPercentageRef.current = percentage;
|
|
181
206
|
firstMountRef.current = false;
|
|
182
|
-
}, [percentage, colors, isAnimationActive, xAxisFormat]);
|
|
207
|
+
}, [percentage, colors, isAnimationActive, xAxisFormat, select, arc, interpolate]);
|
|
183
208
|
// Use ResizeObserver to trigger updates on container size changes.
|
|
184
209
|
useEffect(() => {
|
|
185
210
|
if (!containerRef.current)
|
|
@@ -461,7 +461,7 @@ export default function InternalChart({ report, colors, className, containerStyl
|
|
|
461
461
|
marginBottom: 'auto',
|
|
462
462
|
display: 'flex',
|
|
463
463
|
}, children: _jsx(MetricComponent, { error: error, isLoading: loading, report: report, children: report?.rows?.[0]?.[report.xAxisField] }) })), report.chartType !== 'table' && report.chartType !== 'metric' && (_jsx(ChartDisplay, { config: report, containerStyle: {
|
|
464
|
-
minHeight:
|
|
464
|
+
minHeight: 300,
|
|
465
465
|
width: ['US map', 'World map'].includes(report.chartType) ? '70%' : ['gauge'].includes(report.chartType) ? undefined : '100%',
|
|
466
466
|
height: ['US map', 'World map'].includes(report.chartType) ? 'fit-content' : ['gauge'].includes(report.chartType) ? 500 : undefined,
|
|
467
467
|
marginLeft: ['gauge'].includes(report.chartType) ? 'undefined' : 'auto',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/MapChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/MapChart.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAuT3C,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,cAAc,GACf,EAAE;IACD,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAC;KAAE,EAAE,CAAC;IACrE,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACtC,2CAgKA;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,cAAc,GACf,EAAE;IACD,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAC;KAAE,EAAE,CAAC;IACrE,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACtC,2CAiKA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ComposableMap, Geographies, Geography, useMapContext } from "react-simple-maps";
|
|
3
|
-
import {
|
|
4
|
-
import { scaleLog } from "d3-scale";
|
|
5
|
-
import { useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
6
4
|
import ChartTooltipFrame from "./ChartTooltipFrame";
|
|
7
5
|
import ChartTooltipRow from "./ChartTooltipRow";
|
|
8
6
|
import { valueFormatter } from "../../utils/valueFormatter";
|
|
@@ -321,7 +319,16 @@ export function USMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, onCli
|
|
|
321
319
|
return acc;
|
|
322
320
|
}, {});
|
|
323
321
|
const measureField = yAxisFields[0].field;
|
|
322
|
+
// These must be dynamically loaded as they are not available as CommonJS modules.
|
|
323
|
+
const [scaleLog, setScaleLog] = useState(null);
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
import("d3-scale").then((scale) => {
|
|
326
|
+
setScaleLog(() => scale.scaleLog);
|
|
327
|
+
});
|
|
328
|
+
}, []);
|
|
324
329
|
const colorScale = useMemo(() => {
|
|
330
|
+
if (!scaleLog)
|
|
331
|
+
return () => '#FFFFFF';
|
|
325
332
|
const values = Object.values(mappedData)
|
|
326
333
|
.map((d) => parseFloat(d[measureField]))
|
|
327
334
|
.filter((v) => !isNaN(v));
|
|
@@ -349,7 +356,7 @@ export function USMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, onCli
|
|
|
349
356
|
return scaleLog()
|
|
350
357
|
.domain([minValue, maxValue])
|
|
351
358
|
.range([gradientStart ?? "#f7fbff", gradientStop ?? "#08306b"]);
|
|
352
|
-
}, [mappedData, measureField, colorMap, yAxisFields, xAxisField, colors]);
|
|
359
|
+
}, [mappedData, measureField, colorMap, yAxisFields, xAxisField, colors, scaleLog]);
|
|
353
360
|
const hoveredValue = useMemo(() => {
|
|
354
361
|
return !hoveredState ? undefined : mappedData[fipsToNames[hoveredState]?.abbreviation ?? '']?.[measureField] ??
|
|
355
362
|
mappedData[fipsToNames[hoveredState]?.name ?? '']?.[measureField] ??
|
|
@@ -415,7 +422,16 @@ export function WorldMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, on
|
|
|
415
422
|
return acc;
|
|
416
423
|
}, {});
|
|
417
424
|
const measureField = yAxisFields[0].field;
|
|
425
|
+
// These must be dynamically loaded as they are not available as CommonJS modules.
|
|
426
|
+
const [scaleLog, setScaleLog] = useState(null);
|
|
427
|
+
useEffect(() => {
|
|
428
|
+
import("d3-scale").then((scale) => {
|
|
429
|
+
setScaleLog(() => scale.scaleLog);
|
|
430
|
+
});
|
|
431
|
+
}, []);
|
|
418
432
|
const colorScale = useMemo(() => {
|
|
433
|
+
if (!scaleLog)
|
|
434
|
+
return () => '#FFFFFF';
|
|
419
435
|
const values = Object.values(mappedData)
|
|
420
436
|
.map((d) => parseFloat(d[measureField]))
|
|
421
437
|
.filter((v) => !isNaN(v));
|
|
@@ -443,7 +459,7 @@ export function WorldMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, on
|
|
|
443
459
|
return scaleLog()
|
|
444
460
|
.domain([minValue, maxValue])
|
|
445
461
|
.range([gradientStart ?? "#f7fbff", gradientStop ?? "#08306b"]);
|
|
446
|
-
}, [mappedData, measureField, colorMap, yAxisFields, xAxisField, colors]);
|
|
462
|
+
}, [mappedData, measureField, colorMap, yAxisFields, xAxisField, colors, scaleLog]);
|
|
447
463
|
const hoveredValue = useMemo(() => {
|
|
448
464
|
return !hoveredCountry ? undefined : mappedData[isoToNames[hoveredCountry]?.abbreviation ?? '']?.[measureField] ??
|
|
449
465
|
mappedData[isoToNames[hoveredCountry]?.name ?? '']?.[measureField] ??
|
|
@@ -503,6 +519,13 @@ export function WorldMap({ theme, data, xAxisField, xAxisFormat, yAxisFields, on
|
|
|
503
519
|
}
|
|
504
520
|
function MapLayout({ geographyUrl, hoveredRegion, setHoveredRegion, setHoveredCoords, containerRef, mappedData, measureField, colorScale, onClickChartElement, regionNames, }) {
|
|
505
521
|
const { projection } = useMapContext();
|
|
522
|
+
// These must be dynamically loaded as they are not available as CommonJS modules.
|
|
523
|
+
const [geoCentroid, setGeoCentroid] = useState(null);
|
|
524
|
+
useEffect(() => {
|
|
525
|
+
import("d3-geo").then((geo) => {
|
|
526
|
+
setGeoCentroid(() => geo.geoCentroid);
|
|
527
|
+
});
|
|
528
|
+
}, []);
|
|
506
529
|
return (_jsx(Geographies, { geography: geographyUrl, children: ({ geographies }) => geographies.map((geo, index) => {
|
|
507
530
|
const regionData = mappedData[geo.id] ??
|
|
508
531
|
mappedData[regionNames[geo.id]?.abbreviation ?? ''] ??
|
|
@@ -512,6 +535,8 @@ function MapLayout({ geographyUrl, hoveredRegion, setHoveredRegion, setHoveredCo
|
|
|
512
535
|
const value = regionData ? parseFloat(regionData[measureField]) : null;
|
|
513
536
|
const fill = value != null ? colorScale(value) : "#D6D6DA";
|
|
514
537
|
return _jsx(Geography, { geography: geo, fill: fill, stroke: "#FFFFFF", strokeWidth: 0.5, onMouseEnter: () => {
|
|
538
|
+
if (!geoCentroid)
|
|
539
|
+
return;
|
|
515
540
|
const centroid = geoCentroid(geo);
|
|
516
541
|
const projected = projection(centroid);
|
|
517
542
|
if (projected && containerRef.current) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillsql/react",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.43",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./dist/esm/index.js",
|
|
@@ -29,7 +29,10 @@
|
|
|
29
29
|
"@monaco-editor/react": "^4.5.1",
|
|
30
30
|
"big.js": "^6.2.1",
|
|
31
31
|
"d3-geo": "2.0.2",
|
|
32
|
-
"d3-
|
|
32
|
+
"d3-interpolate": "3.0.1",
|
|
33
|
+
"d3-scale": "4.0.2",
|
|
34
|
+
"d3-selection": "2.0.0",
|
|
35
|
+
"d3-shape": "3.2.0",
|
|
33
36
|
"date-fns": "^2.29.3",
|
|
34
37
|
"date-fns-tz": "^2.0.0",
|
|
35
38
|
"fast-deep-equal": "^3.1.3",
|