td-plots 1.6.2 → 1.7.0

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.
@@ -0,0 +1,11 @@
1
+ export type StatsDonutProps = {
2
+ values: number[];
3
+ labels: string[];
4
+ hole: number;
5
+ withCenterLabel?: boolean;
6
+ centerLabel?: string;
7
+ centerValue?: string;
8
+ colors?: string[];
9
+ showLegend?: boolean;
10
+ };
11
+ export declare const StatsDonut: (props: StatsDonutProps) => import("react/jsx-runtime").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -3,6 +3,8 @@ export { HistogramPlot } from "./components/Histogram";
3
3
  export type { HistogramPlotProps } from "./components/Histogram";
4
4
  export { RadialHistogramPlot } from "./components/RadialHistogram";
5
5
  export type { RadialHistogramPlotProps } from "./components/RadialHistogram";
6
+ export { StatsDonut } from "./components/StatsDonut";
7
+ export type { StatsDonutProps } from "./components/StatsDonut";
6
8
  export { default as TestPlot } from "./components/TestPlot";
7
9
  export { isDateArray, isNumberArray } from "./components/Utils";
8
10
  export type { PlotParams } from "react-plotly.js";
package/dist/index.esm.js CHANGED
@@ -496,7 +496,7 @@ var SettingsIcon = createSvgIcon(/*#__PURE__*/jsx("path", {
496
496
  d: "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"
497
497
  }), 'Settings');
498
498
 
499
- const Plot$2 = lazy(() => import('react-plotly.js'));
499
+ const Plot$3 = lazy(() => import('react-plotly.js'));
500
500
  const HistogramPlot = (props) => {
501
501
  var _a, _b, _c, _d;
502
502
  const { data, title, xAxisTitle, barColor = "rgb(72, 72, 74)", unselectedBarColor = "rgba(203, 195, 195, 0.88)", selectorsColor = "black", containerStyleOverrides, unselectedData = [], handleClickOrSelection = () => { }, onDeselect = () => { }, plotId, selectByBin = false, dateTickFormat, binSizeOverride, statsAnnotations = ["mean"], emptySelectedRange = false, d3FormatValueString = ".1f", showBinSizeControls = "always", onBinSizeCalculated, onBinSizeChange, showBinSizeControlValue = true, isMobile = false, settingsTitleStylingOverrides = {}, } = props;
@@ -1246,7 +1246,7 @@ const HistogramPlot = (props) => {
1246
1246
  const newBinSize = newValue;
1247
1247
  setBinSize(newBinSize);
1248
1248
  onBinSizeChange === null || onBinSizeChange === void 0 ? void 0 : onBinSizeChange(newBinSize);
1249
- }, colorOverride: barColor, valueLabelFormat: valueLabelFormat, titleStylingOverrides: settingsTitleStylingOverrides, disabledTooltipText: "Requires 10 or more data points" }) }) })] })), jsx(Plot$2, { data: plotlyData, layout: layout, config: config, onSelected: handleSelection, onClick: handleClick, onDeselect: () => {
1249
+ }, colorOverride: barColor, valueLabelFormat: valueLabelFormat, titleStylingOverrides: settingsTitleStylingOverrides, disabledTooltipText: "Requires 10 or more data points" }) }) })] })), jsx(Plot$3, { data: plotlyData, layout: layout, config: config, onSelected: handleSelection, onClick: handleClick, onDeselect: () => {
1250
1250
  onDeselect();
1251
1251
  setSelectedRange(null); // Remove selected box
1252
1252
  }, onUpdate: handlePlotUpdate, useResizeHandler: true, style: {
@@ -1257,7 +1257,7 @@ const HistogramPlot = (props) => {
1257
1257
  } }, `histogram-${plotId || "default"}`)] }) }) }));
1258
1258
  };
1259
1259
 
1260
- const Plot$1 = lazy(() => import('react-plotly.js'));
1260
+ const Plot$2 = lazy(() => import('react-plotly.js'));
1261
1261
  const RadialHistogramPlot = (props) => {
1262
1262
  const { data, barColor = 'rgb(72, 72, 74)', unselectedBarColor = 'rgba(203, 195, 195, 0.88)', selectorsColor = 'black', onSelected, onClick, containerStyleOverrides, barWidth = 20, // Default bar width in degrees
1263
1263
  } = props;
@@ -1357,13 +1357,89 @@ const RadialHistogramPlot = (props) => {
1357
1357
  staticPlot: false,
1358
1358
  };
1359
1359
  const containerStyles = Object.assign({ width: "100%", height: "100%", position: "relative" }, containerStyleOverrides);
1360
- return (jsx("div", { ref: containerRef, className: "plot-container radial-histogram-container", style: Object.assign({ '--selection-color': selectorsColor }, containerStyles), children: jsx(Suspense, { fallback: jsx(Loading, {}), children: jsx(Plot$1, { data: plotlyData, layout: layout, config: config, onSelected: onSelected, onClick: onClick, useResizeHandler: true, style: {
1360
+ return (jsx("div", { ref: containerRef, className: "plot-container radial-histogram-container", style: Object.assign({ '--selection-color': selectorsColor }, containerStyles), children: jsx(Suspense, { fallback: jsx(Loading, {}), children: jsx(Plot$2, { data: plotlyData, layout: layout, config: config, onSelected: onSelected, onClick: onClick, useResizeHandler: true, style: {
1361
1361
  width: "100%",
1362
1362
  height: "100%",
1363
1363
  display: "block"
1364
1364
  } }) }) }));
1365
1365
  };
1366
1366
 
1367
+ const Plot$1 = lazy(() => import('react-plotly.js'));
1368
+ const StatsDonut = (props) => {
1369
+ const { withCenterLabel = false, centerLabel, centerValue, showLegend = true, } = props;
1370
+ const annotations = withCenterLabel
1371
+ ? [
1372
+ {
1373
+ text: centerLabel || "",
1374
+ x: 0.5,
1375
+ y: 0.55,
1376
+ xref: "paper",
1377
+ yref: "paper",
1378
+ showarrow: false,
1379
+ font: {
1380
+ size: 16,
1381
+ color: "#666",
1382
+ },
1383
+ },
1384
+ {
1385
+ text: centerValue || "",
1386
+ x: 0.5,
1387
+ y: 0.45,
1388
+ xref: "paper",
1389
+ yref: "paper",
1390
+ showarrow: false,
1391
+ font: {
1392
+ size: 24,
1393
+ weight: "bold",
1394
+ color: "#000",
1395
+ },
1396
+ },
1397
+ ]
1398
+ : [];
1399
+ return (jsx("div", { style: {
1400
+ height: "400px",
1401
+ width: "600px",
1402
+ display: "flex",
1403
+ justifyContent: "center",
1404
+ alignItems: "center",
1405
+ }, children: jsx(Suspense, { fallback: jsx(Loading, {}), children: jsx(Plot$1, { data: [
1406
+ {
1407
+ type: "pie",
1408
+ values: props.values,
1409
+ labels: props.labels,
1410
+ hole: props.hole,
1411
+ marker: props.colors
1412
+ ? {
1413
+ colors: props.colors,
1414
+ }
1415
+ : undefined,
1416
+ },
1417
+ ], layout: {
1418
+ showlegend: true,
1419
+ annotations,
1420
+ height: 400,
1421
+ width: 600,
1422
+ legend: {
1423
+ x: 1.3,
1424
+ y: 0.5,
1425
+ font: {
1426
+ size: 16,
1427
+ },
1428
+ },
1429
+ margin: {
1430
+ l: 25,
1431
+ r: 15,
1432
+ t: 0,
1433
+ b: 0,
1434
+ },
1435
+ }, style: {
1436
+ width: "100%",
1437
+ height: "100%",
1438
+ }, config: {
1439
+ displayModeBar: false,
1440
+ } }) }) }));
1441
+ };
1442
+
1367
1443
  const Plot = lazy(() => import('react-plotly.js'));
1368
1444
  const TestPlot = (props) => {
1369
1445
  var _a, _b;
@@ -1383,5 +1459,5 @@ const TestPlot = (props) => {
1383
1459
  return jsx(Plot, { data: data, layout: layout });
1384
1460
  };
1385
1461
 
1386
- export { HistogramPlot, RadialHistogramPlot, TestPlot, isDateArray, isNumberArray };
1462
+ export { HistogramPlot, RadialHistogramPlot, StatsDonut, TestPlot, isDateArray, isNumberArray };
1387
1463
  //# sourceMappingURL=index.esm.js.map