@datawheel/data-explorer 1.1.7 → 1.1.8
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/main.mjs +77 -21
- package/package.json +3 -2
package/dist/main.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import { saveElement } from 'd3plus-export';
|
|
|
21
21
|
import { d3plusConfigBuilder } from '@datawheel/vizbuilder/react';
|
|
22
22
|
import { assign } from 'd3plus-common';
|
|
23
23
|
import { BarChart, Geomap, Donut, LinePlot, StackedArea, Treemap } from 'd3plus-react';
|
|
24
|
+
import { useInView } from 'react-intersection-observer';
|
|
24
25
|
|
|
25
26
|
// src/components/DebugView.tsx
|
|
26
27
|
var explorerTranslation = {
|
|
@@ -6342,9 +6343,20 @@ var iconByFormat = {
|
|
|
6342
6343
|
svg: IconVectorTriangle
|
|
6343
6344
|
};
|
|
6344
6345
|
function ChartCard(props) {
|
|
6345
|
-
const { chart, downloadFormats, isFullMode, onFocus, showConfidenceInt } = props;
|
|
6346
|
+
const { chart, downloadFormats, isFullMode, onFocus, showConfidenceInt, height } = props;
|
|
6346
6347
|
const { translate } = useTranslation();
|
|
6347
6348
|
const nodeRef = useRef(null);
|
|
6349
|
+
const { ref: inViewRef, inView } = useInView({ triggerOnce: false, threshold: 0 });
|
|
6350
|
+
const [hasBeenInView, setHasBeenInView] = useState(false);
|
|
6351
|
+
React13__default.useEffect(() => {
|
|
6352
|
+
if (inView && !hasBeenInView) {
|
|
6353
|
+
setHasBeenInView(true);
|
|
6354
|
+
}
|
|
6355
|
+
}, [inView, hasBeenInView]);
|
|
6356
|
+
const setRefs = (el) => {
|
|
6357
|
+
nodeRef.current = el;
|
|
6358
|
+
inViewRef(el);
|
|
6359
|
+
};
|
|
6348
6360
|
const [ChartComponent, config] = useD3plusConfig(chart, {
|
|
6349
6361
|
fullMode: !!isFullMode,
|
|
6350
6362
|
showConfidenceInt: !!showConfidenceInt,
|
|
@@ -6413,9 +6425,9 @@ function ChartCard(props) {
|
|
|
6413
6425
|
isShared ? translate("vizbuilder.share_copied") : translate("vizbuilder.action_share")
|
|
6414
6426
|
);
|
|
6415
6427
|
}, [clipboard, translate, isShared]);
|
|
6416
|
-
const
|
|
6428
|
+
const resolvedHeight = height ? height : isFullMode ? "calc(100vh - 3rem)" : 400;
|
|
6417
6429
|
if (!ChartComponent) return null;
|
|
6418
|
-
return /* @__PURE__ */ React13__default.createElement(Paper, { h:
|
|
6430
|
+
return /* @__PURE__ */ React13__default.createElement(Paper, { h: resolvedHeight, w: "100%", style: { overflow: "hidden" } }, /* @__PURE__ */ React13__default.createElement(ErrorBoundary, null, /* @__PURE__ */ React13__default.createElement(Stack, { spacing: 0, h: resolvedHeight, style: { position: "relative" }, w: "100%" }, /* @__PURE__ */ React13__default.createElement(Group, { position: "center", p: "xs", spacing: "xs", align: "center" }, isFullMode && shareButton, downloadButtons, onFocus && focusButton), /* @__PURE__ */ React13__default.createElement(Box, { style: { flex: "1 1 auto" }, ref: setRefs, pb: "xs", px: "xs" }, ChartComponent && (inView || hasBeenInView) ? /* @__PURE__ */ React13__default.createElement(ChartComponent, { config }) : /* @__PURE__ */ React13__default.createElement("div", { style: { height: "100%", width: "100%" } })))));
|
|
6419
6431
|
}
|
|
6420
6432
|
var getBackground = (node) => {
|
|
6421
6433
|
if (node.nodeType !== Node.ELEMENT_NODE) return "white";
|
|
@@ -6453,6 +6465,42 @@ function Vizbuilder(props) {
|
|
|
6453
6465
|
const queryItem = useSelector$1(selectCurrentQueryItem);
|
|
6454
6466
|
const currentChart = (queryItem == null ? void 0 : queryItem.chart) || "";
|
|
6455
6467
|
const { actions: actions2 } = useSettings();
|
|
6468
|
+
const useStyles6 = createStyles((theme) => ({
|
|
6469
|
+
grid: {
|
|
6470
|
+
padding: theme.spacing.xl,
|
|
6471
|
+
display: "grid",
|
|
6472
|
+
gridAutoRows: "minmax(200px, auto)",
|
|
6473
|
+
gap: theme.spacing.xl,
|
|
6474
|
+
gridTemplateColumns: "1fr 1fr",
|
|
6475
|
+
[theme.fn.smallerThan("md")]: {
|
|
6476
|
+
gridTemplateColumns: "1fr"
|
|
6477
|
+
}
|
|
6478
|
+
},
|
|
6479
|
+
itemLarge: {
|
|
6480
|
+
gridRow: "auto",
|
|
6481
|
+
gridColumn: "auto"
|
|
6482
|
+
},
|
|
6483
|
+
itemSmallTop: {
|
|
6484
|
+
gridRow: "auto",
|
|
6485
|
+
gridColumn: "auto"
|
|
6486
|
+
},
|
|
6487
|
+
itemSmallBottom: {
|
|
6488
|
+
gridRow: "auto",
|
|
6489
|
+
gridColumn: "auto"
|
|
6490
|
+
},
|
|
6491
|
+
// for single chart
|
|
6492
|
+
fill: {
|
|
6493
|
+
gridColumn: "1",
|
|
6494
|
+
gridRow: "1",
|
|
6495
|
+
height: "100%",
|
|
6496
|
+
width: "100%",
|
|
6497
|
+
[theme.fn.largerThan("md")]: {
|
|
6498
|
+
gridColumn: "1 / span 2",
|
|
6499
|
+
gridRow: "1 / span 2"
|
|
6500
|
+
}
|
|
6501
|
+
}
|
|
6502
|
+
}));
|
|
6503
|
+
const { classes, cx } = useStyles6();
|
|
6456
6504
|
const setCurrentChart = useCallback(
|
|
6457
6505
|
(chart) => {
|
|
6458
6506
|
actions2.updateChart(chart);
|
|
@@ -6489,34 +6537,40 @@ function Vizbuilder(props) {
|
|
|
6489
6537
|
if (chartList.length === 0 && !Array.isArray(datasets) && datasets.data.length === 1)
|
|
6490
6538
|
return /* @__PURE__ */ React13__default.createElement(Notice, { status: "one-row" });
|
|
6491
6539
|
if (chartList.length === 0) return /* @__PURE__ */ React13__default.createElement(Notice, { status: "empty" });
|
|
6492
|
-
const isSingleChart = chartList.length === 1;
|
|
6493
6540
|
if (chartList.length > 10) {
|
|
6494
6541
|
chartList = chartList.slice(0, 10);
|
|
6495
6542
|
}
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6543
|
+
const isSingleChart = chartList.length === 1;
|
|
6544
|
+
return /* @__PURE__ */ React13__default.createElement(ErrorBoundary, null, /* @__PURE__ */ React13__default.createElement("div", { className: cx(classes.grid, { [classes.fill]: isSingleChart }) }, chartList.map((chart, idx) => {
|
|
6545
|
+
const pos = idx % 3;
|
|
6546
|
+
let style = {};
|
|
6547
|
+
let className = "";
|
|
6548
|
+
let height;
|
|
6549
|
+
if (isSingleChart) {
|
|
6550
|
+
className = classes.fill;
|
|
6551
|
+
height = 600;
|
|
6552
|
+
} else {
|
|
6553
|
+
if (pos === 0) {
|
|
6554
|
+
className = classes.itemLarge;
|
|
6555
|
+
} else if (pos === 1) {
|
|
6556
|
+
className = classes.itemSmallTop;
|
|
6557
|
+
} else if (pos === 2) {
|
|
6558
|
+
className = classes.itemSmallBottom;
|
|
6559
|
+
}
|
|
6560
|
+
}
|
|
6561
|
+
return /* @__PURE__ */ React13__default.createElement("div", { key: chart.key, className, style }, /* @__PURE__ */ React13__default.createElement(
|
|
6508
6562
|
ChartCard,
|
|
6509
6563
|
{
|
|
6510
|
-
key: chart.key,
|
|
6511
6564
|
chart,
|
|
6512
6565
|
downloadFormats,
|
|
6513
6566
|
measureConfig: getMeasureConfig,
|
|
6514
6567
|
onFocus: () => setCurrentChart(chart.key),
|
|
6515
6568
|
showConfidenceInt,
|
|
6516
|
-
userConfig
|
|
6569
|
+
userConfig,
|
|
6570
|
+
...height ? { height } : {}
|
|
6517
6571
|
}
|
|
6518
|
-
))
|
|
6519
|
-
));
|
|
6572
|
+
));
|
|
6573
|
+
})));
|
|
6520
6574
|
}, [
|
|
6521
6575
|
charts,
|
|
6522
6576
|
datasets,
|
|
@@ -6524,7 +6578,9 @@ function Vizbuilder(props) {
|
|
|
6524
6578
|
getMeasureConfig,
|
|
6525
6579
|
nonIdealState,
|
|
6526
6580
|
showConfidenceInt,
|
|
6527
|
-
userConfig
|
|
6581
|
+
userConfig,
|
|
6582
|
+
classes,
|
|
6583
|
+
cx
|
|
6528
6584
|
]);
|
|
6529
6585
|
const focusContent = useMemo(() => {
|
|
6530
6586
|
const chart = charts[currentChart];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datawheel/data-explorer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"main": "./dist/main.mjs",
|
|
5
5
|
"types": "./dist/main.d.mts",
|
|
6
6
|
"files": [
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"mantine-react-table": "^1.3.0",
|
|
40
40
|
"match-sorter": "^6.3.4",
|
|
41
41
|
"postcss-modules": "^6.0.0",
|
|
42
|
+
"react-intersection-observer": "^9.16.0",
|
|
42
43
|
"react-redux": "^7.0.0",
|
|
43
44
|
"react-router-dom": "^6.30.0",
|
|
44
45
|
"react-viewport-list": "^3.0.0",
|
|
@@ -47,8 +48,8 @@
|
|
|
47
48
|
"yn": "^5.0.0"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
|
-
"@emotion/react": "^11.0.0",
|
|
51
51
|
"@datawheel/vizbuilder": "^0.6.0",
|
|
52
|
+
"@emotion/react": "^11.0.0",
|
|
52
53
|
"@mantine/core": "^6.0.0",
|
|
53
54
|
"@mantine/dates": "^6.0.0",
|
|
54
55
|
"@mantine/hooks": "^6.0.0",
|