@apia/charts 0.2.4 → 0.3.2

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 CHANGED
@@ -31,7 +31,7 @@ function parseMargin(margin = {
31
31
 
32
32
  const ChartContext = createContext({});
33
33
 
34
- const LegendItem = ({
34
+ const ColoredLegendItem = ({
35
35
  groupId,
36
36
  title,
37
37
  color,
@@ -56,10 +56,44 @@ const LegendItem = ({
56
56
  return /* @__PURE__ */ jsx(
57
57
  SimpleButton,
58
58
  {
59
- variant: "icon-outline",
60
- className: `${className != null ? className : ""} ${isHighlighted ? "highlight" : ""} legendItem`,
59
+ variant: "link",
60
+ className: `${className != null ? className : ""} ${isHighlighted ? "highlight" : ""} ${isAnyHighlighted && !isHighlighted ? "isBlurred" : ""} legendItem`,
61
61
  iconColor: color || "black",
62
62
  icon: color === "transparent" ? void 0 : icons.SquareFilled,
63
+ title,
64
+ onMouseEnter: handleMouseEnter,
65
+ onMouseLeave: handleMouseLeave,
66
+ children: title
67
+ }
68
+ );
69
+ };
70
+
71
+ const NumberedLegendItem = ({
72
+ groupId,
73
+ title,
74
+ className,
75
+ isHighlighted,
76
+ isAnyHighlighted,
77
+ avoidEvent
78
+ }) => {
79
+ const { chartId } = useContext(ChartContext);
80
+ const handleMouseEnter = useCallback(() => {
81
+ if (avoidEvent) {
82
+ return;
83
+ }
84
+ chartMethods(chartId, "highlight", groupId);
85
+ }, [avoidEvent, chartId, groupId]);
86
+ const handleMouseLeave = useCallback(() => {
87
+ if (avoidEvent) {
88
+ return;
89
+ }
90
+ chartMethods(chartId, "highlight", "");
91
+ }, [avoidEvent, chartId]);
92
+ return /* @__PURE__ */ jsx(
93
+ SimpleButton,
94
+ {
95
+ variant: "link",
96
+ className: `${className != null ? className : ""} ${isHighlighted ? "highlight" : ""} legendItem`,
63
97
  sx: {
64
98
  opacity: isAnyHighlighted && !isHighlighted ? "0.15" : "1"
65
99
  },
@@ -80,10 +114,15 @@ const [legendContainerMethods, , LegendContainer] = makeImperativeComponent()({
80
114
  setState({ highlightedBarGroup });
81
115
  }
82
116
  },
83
- Component: ({ references, highlightedBarGroup, avoidEvent }) => {
84
- return /* @__PURE__ */ jsx(Box, { className: `legendContainer`, children: references.map((data) => {
117
+ Component: ({
118
+ references,
119
+ highlightedBarGroup,
120
+ avoidEvent,
121
+ useNumbered
122
+ }) => {
123
+ return /* @__PURE__ */ jsx(Box, { className: `legendContainer`, children: !useNumbered ? references.map((data) => {
85
124
  return /* @__PURE__ */ jsx(
86
- LegendItem,
125
+ ColoredLegendItem,
87
126
  {
88
127
  isHighlighted: data.title === highlightedBarGroup,
89
128
  isAnyHighlighted: highlightedBarGroup !== "",
@@ -94,6 +133,19 @@ const [legendContainerMethods, , LegendContainer] = makeImperativeComponent()({
94
133
  },
95
134
  data.title
96
135
  );
136
+ }) : references.map((data, i) => {
137
+ return /* @__PURE__ */ jsx(
138
+ NumberedLegendItem,
139
+ {
140
+ isHighlighted: data.title === highlightedBarGroup,
141
+ isAnyHighlighted: highlightedBarGroup !== "",
142
+ groupId: data.title,
143
+ position: `${i + 1}`,
144
+ title: data.title,
145
+ avoidEvent: avoidEvent != null ? avoidEvent : false
146
+ },
147
+ data.title
148
+ );
97
149
  }) });
98
150
  }
99
151
  });
@@ -133,8 +185,15 @@ const Bar$1 = ({
133
185
  useImperativeComponentEvents({
134
186
  highlight(barName) {
135
187
  if (barName.split(" - ").length === 1) {
136
- setIsHighlighted(barName === bar.key);
137
- setIsAnyHighlighted(barName !== bar.key && barName !== "");
188
+ if (arrayOrArray(chart.dataSets.data).length === 1) {
189
+ setIsHighlighted(barName === parsedData[barGroup.index].columnName);
190
+ setIsAnyHighlighted(
191
+ barName !== parsedData[barGroup.index].columnName && barName !== ""
192
+ );
193
+ } else {
194
+ setIsHighlighted(barName === bar.key);
195
+ setIsAnyHighlighted(barName !== bar.key && barName !== "");
196
+ }
138
197
  } else if (barName.split(" - ").length === 2) {
139
198
  setIsHighlighted(
140
199
  barName.split(" - ")[0] === bar.key && barName.split(" - ")[1] === set.key
@@ -446,7 +505,7 @@ const HorizontalBars = ({
446
505
  }
447
506
  return xScaleLog;
448
507
  }, [isLogScale, xScaleLine, xScaleLog]);
449
- const id = useMemo(() => `VerticalBars${uniqueId()}`, []);
508
+ const id = useMemo(() => `HorizontalBars${uniqueId()}`, []);
450
509
  useLayoutEffect(() => {
451
510
  document.querySelectorAll(
452
511
  `#${id} .__${chartId != null ? chartId : outerClassName}`
@@ -499,13 +558,49 @@ const HorizontalBars = ({
499
558
  });
500
559
  return returnColumnsArray;
501
560
  });
502
- const colorReference = setsWithColor.map((column) => {
503
- var _a2;
504
- return {
505
- color: (_a2 = column[0].color) != null ? _a2 : "",
506
- title: column[0].columnName
507
- };
508
- });
561
+ const colorReference = arrayOrArray(chart.dataSets.data).map(
562
+ (data, index) => {
563
+ const isSingle = arrayOrArray(chart.dataSets.data).length === 1;
564
+ const dataColor = data.color !== "" && data.color !== void 0 ? data.color : arrayOrArray(
565
+ styles ? styles.schema : [
566
+ "#7ad6f4",
567
+ "#45bdee",
568
+ "#28a7ea",
569
+ "#006cbb",
570
+ "#034698",
571
+ "#032f64"
572
+ ]
573
+ ).length > 0 ? getBarColor(
574
+ arrayOrArray(
575
+ styles ? styles.schema : [
576
+ "#7ad6f4",
577
+ "#45bdee",
578
+ "#28a7ea",
579
+ "#006cbb",
580
+ "#034698",
581
+ "#032f64"
582
+ ]
583
+ ),
584
+ index,
585
+ isSingle
586
+ ) : "";
587
+ return {
588
+ color: dataColor,
589
+ title: data.name
590
+ };
591
+ }
592
+ );
593
+ let numberReference = [];
594
+ if (colorReference.length === 1) {
595
+ numberReference = arrayOrArray(
596
+ arrayOrArray(chart.dataSets.data)[0].sets
597
+ ).map((data, index) => {
598
+ return {
599
+ color: `${index + 1}`,
600
+ title: data.key
601
+ };
602
+ });
603
+ }
509
604
  arrayOrArray(chart.dataSets.data).map((data) => {
510
605
  const returnArray = [];
511
606
  arrayOrArray(data.sets).forEach((set) => {
@@ -524,7 +619,7 @@ const HorizontalBars = ({
524
619
  {
525
620
  ref: boxRef,
526
621
  id,
527
- className: `${outerClassName != null ? outerClassName : ""} ${chartId} ${chart.title}`,
622
+ className: `${outerClassName != null ? outerClassName : ""} ${chartId} ${chart.title} chartBox`,
528
623
  sx: React.useMemo(() => {
529
624
  return {
530
625
  [`.__${chartId != null ? chartId : outerClassName}`]: {
@@ -634,7 +729,20 @@ const HorizontalBars = ({
634
729
  )
635
730
  }
636
731
  ),
637
- colorReference.length > 1 && /* @__PURE__ */ jsx(LegendContainer, { id: chartId, references: colorReference })
732
+ colorReference.length !== 0 && /* @__PURE__ */ jsx(
733
+ LegendContainer,
734
+ {
735
+ id: chartId,
736
+ references: (
737
+ // hideLegendsColors
738
+ // ? colorReference.map((ref) => {
739
+ // return { ...ref, color: 'transparent' };
740
+ // })
741
+ colorReference.length === 1 && numberReference.length > 0 ? numberReference : colorReference
742
+ ),
743
+ useNumbered: colorReference.length === 1
744
+ }
745
+ )
638
746
  ] });
639
747
  };
640
748
 
@@ -959,7 +1067,7 @@ const PieChart = ({
959
1067
  Box,
960
1068
  {
961
1069
  ref: boxRef,
962
- className: `${className ? className : ""} ${chartId}`,
1070
+ className: `${className ? className : ""} ${chartId} chartBox`,
963
1071
  sx: { textAlign: "center", pb: spacing(5) },
964
1072
  children: /* @__PURE__ */ jsx(
965
1073
  "svg",
@@ -1073,8 +1181,15 @@ const Bar = ({
1073
1181
  useImperativeComponentEvents({
1074
1182
  highlight(barName) {
1075
1183
  if (barName.split(" - ").length === 1) {
1076
- setIsHighlighted(barName === bar.key);
1077
- setIsAnyHighlighted(barName !== bar.key && barName !== "");
1184
+ if (arrayOrArray(chart.dataSets.data).length === 1) {
1185
+ setIsHighlighted(barName === parsedData[barGroup.index].columnName);
1186
+ setIsAnyHighlighted(
1187
+ barName !== parsedData[barGroup.index].columnName && barName !== ""
1188
+ );
1189
+ } else {
1190
+ setIsHighlighted(barName === bar.key);
1191
+ setIsAnyHighlighted(barName !== bar.key && barName !== "");
1192
+ }
1078
1193
  } else if (barName.split(" - ").length === 2) {
1079
1194
  setIsHighlighted(
1080
1195
  barName.split(" - ")[0] === bar.key && barName.split(" - ")[1] === set.key
@@ -1220,7 +1335,7 @@ function adjustDimensions$2({
1220
1335
  }
1221
1336
  const getXValue = (d) => d.columnName;
1222
1337
  const VerticalBars = ({
1223
- margin = { top: 20, left: 100, bottom: 150, right: 20 },
1338
+ margin = { top: 20, left: 100, bottom: 24, right: 0 },
1224
1339
  chart,
1225
1340
  className,
1226
1341
  chartId,
@@ -1270,11 +1385,19 @@ const VerticalBars = ({
1270
1385
  const xScale = scaleBand({
1271
1386
  range: [
1272
1387
  typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.left,
1273
- innerWidth
1388
+ chart.ratio.width
1274
1389
  ],
1275
1390
  domain: parsedData.map(getXValue),
1276
1391
  padding: 0.2
1277
1392
  });
1393
+ const numericXScale = scaleBand({
1394
+ range: [
1395
+ typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.left,
1396
+ chart.ratio.width
1397
+ ],
1398
+ domain: parsedData.map((_, i) => `${i + 1}`),
1399
+ padding: 0.2
1400
+ });
1278
1401
  const columnGroupScale = scaleBand({
1279
1402
  domain: columnNames,
1280
1403
  range: [0, xScale.bandwidth()]
@@ -1327,7 +1450,6 @@ const VerticalBars = ({
1327
1450
  useLayoutEffect(() => {
1328
1451
  document.querySelectorAll(`#${id} .tickLabel`).forEach((current) => {
1329
1452
  const box = current.getBoundingClientRect();
1330
- console.log(box);
1331
1453
  if (box.width > 125) {
1332
1454
  current.style.width = "125px";
1333
1455
  current.style.overflow = "hidden";
@@ -1412,6 +1534,17 @@ const VerticalBars = ({
1412
1534
  };
1413
1535
  }
1414
1536
  );
1537
+ let numberReference = [];
1538
+ if (colorReference.length === 1) {
1539
+ numberReference = arrayOrArray(
1540
+ arrayOrArray(chart.dataSets.data)[0].sets
1541
+ ).map((data, index) => {
1542
+ return {
1543
+ color: `${index + 1}`,
1544
+ title: data.key
1545
+ };
1546
+ });
1547
+ }
1415
1548
  arrayOrArray(chart.dataSets.data).map((data) => {
1416
1549
  const returnArray = [];
1417
1550
  arrayOrArray(data.sets).forEach((set) => {
@@ -1430,7 +1563,7 @@ const VerticalBars = ({
1430
1563
  {
1431
1564
  ref: boxRef,
1432
1565
  id,
1433
- className: `${className != null ? className : ""} ${chart.title}`,
1566
+ className: `${className != null ? className : ""} ${chart.title} chartBox`,
1434
1567
  sx: {
1435
1568
  overflow: "hidden"
1436
1569
  },
@@ -1448,7 +1581,7 @@ const VerticalBars = ({
1448
1581
  xScale,
1449
1582
  yScale,
1450
1583
  left: 0,
1451
- width: innerWidth,
1584
+ width: chart.ratio.width,
1452
1585
  height: innerHeight,
1453
1586
  numTicksRows: 10,
1454
1587
  numTicksColumns: 10,
@@ -1503,19 +1636,56 @@ const VerticalBars = ({
1503
1636
  {
1504
1637
  scale: yScale,
1505
1638
  left: effectiveMargin.left,
1506
- label: chart.chartType !== "pie2D" && chart.showAxisYTitle ? chart.axisYTitle : ""
1639
+ label: chart.chartType !== "pie2D" && chart.showAxisYTitle ? chart.axisYTitle : "",
1640
+ tickComponent: (props) => {
1641
+ var _a2;
1642
+ let value = Number((_a2 = props.formattedValue) == null ? void 0 : _a2.replace(",", ""));
1643
+ let counter = -1;
1644
+ const units = ["k", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"];
1645
+ while (value >= 1e3) {
1646
+ value = value / 1e3;
1647
+ counter++;
1648
+ }
1649
+ let stringValue = `${value}`;
1650
+ if (stringValue.length > 3) {
1651
+ stringValue = stringValue.slice(0, 3);
1652
+ }
1653
+ if (stringValue.endsWith(".")) {
1654
+ stringValue = stringValue.replace(".", "");
1655
+ }
1656
+ const newValue = `${stringValue}${counter >= 0 ? units[counter] : ""}`;
1657
+ return /* @__PURE__ */ jsx(
1658
+ "text",
1659
+ {
1660
+ dx: props.dx,
1661
+ dy: props.dy,
1662
+ fill: props.fill,
1663
+ fontSize: props.fontSize,
1664
+ textAnchor: props.textAnchor,
1665
+ x: props.x,
1666
+ y: props.y,
1667
+ children: newValue
1668
+ }
1669
+ );
1670
+ }
1507
1671
  }
1508
1672
  ),
1509
1673
  /* @__PURE__ */ jsx(
1510
1674
  AxisBottom,
1511
1675
  {
1512
1676
  top: innerHeight,
1513
- scale: xScale,
1677
+ scale: colorReference.length === 1 && numberReference.length > 0 ? numericXScale : xScale,
1514
1678
  label: chart.chartType !== "pie2D" && chart.showAxisXTitle ? chart.axisXTitle : "",
1515
- tickLabelProps: {
1516
- className: "tickLabel",
1517
- textAnchor: "start"
1518
- },
1679
+ tickLabelProps: (
1680
+ // colorReference.length === 1 && numberReference.length > 0
1681
+ // ? {}
1682
+ // : {
1683
+ // className: 'tickLabel',
1684
+ // textAnchor: 'start',
1685
+ // }
1686
+ { display: "none" }
1687
+ ),
1688
+ tickLineProps: { display: "none" },
1519
1689
  labelOffset: 50
1520
1690
  }
1521
1691
  )
@@ -1524,7 +1694,7 @@ const VerticalBars = ({
1524
1694
  )
1525
1695
  }
1526
1696
  ),
1527
- colorReference.length > 1 && /* @__PURE__ */ jsx(
1697
+ colorReference.length !== 0 && /* @__PURE__ */ jsx(
1528
1698
  LegendContainer,
1529
1699
  {
1530
1700
  id: chartId,
@@ -1533,8 +1703,9 @@ const VerticalBars = ({
1533
1703
  // ? colorReference.map((ref) => {
1534
1704
  // return { ...ref, color: 'transparent' };
1535
1705
  // })
1536
- colorReference
1537
- )
1706
+ colorReference.length === 1 && numberReference.length > 0 ? numberReference : colorReference
1707
+ ),
1708
+ useNumbered: colorReference.length === 1
1538
1709
  }
1539
1710
  )
1540
1711
  ] });
@@ -1832,7 +2003,7 @@ const LineChart = ({
1832
2003
  !allowZoom
1833
2004
  );
1834
2005
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1835
- /* @__PURE__ */ jsx(Box, { id, ref: boxRef, children: /* @__PURE__ */ jsxs(
2006
+ /* @__PURE__ */ jsx(Box, { id, ref: boxRef, className: "chartBox", children: /* @__PURE__ */ jsxs(
1836
2007
  "svg",
1837
2008
  {
1838
2009
  ref: elementRef,
@@ -2277,91 +2448,99 @@ const WaterfallBars = (_a) => {
2277
2448
  setCurrent: setCurrentPie
2278
2449
  }
2279
2450
  ) }),
2280
- /* @__PURE__ */ jsx(Box, { id, className, ref: boxRef, children: /* @__PURE__ */ jsx(
2281
- "svg",
2451
+ /* @__PURE__ */ jsx(
2452
+ Box,
2282
2453
  {
2283
- height: chart.ratio.height,
2284
- width: chart.ratio.width,
2285
- ref: elementRef,
2286
- children: /* @__PURE__ */ jsxs(Group, { left: effectiveMargin.left, top: effectiveMargin.top, children: [
2287
- /* @__PURE__ */ jsx(GridRows, { scale: yScale, width: innerWidth, strokeDasharray: "5" }),
2288
- steps.map((step, index) => {
2289
- var _a3;
2290
- const x = xScale(step.x);
2291
- const y = yScale(Math.max(step.start, step.end));
2292
- if (x == null || y == null) {
2293
- return null;
2294
- }
2295
- const barHeight = Math.abs(yScale(step.start) - yScale(step.end));
2296
- const isLast = index === steps.length - 1;
2297
- const linePadding = 2;
2298
- const x1 = x + xScale.bandwidth() + linePadding;
2299
- const x2 = x + xScale.bandwidth() / (1 - padding) - linePadding;
2300
- const lineY = step.end < step.start ? y + barHeight : y;
2301
- const labelOffset = 10;
2302
- const labelY = yScale(step.end) + (step.y < 0 ? labelOffset : -labelOffset);
2303
- let currentYValue = 0;
2304
- steps.filter((_, i) => {
2305
- var _a4;
2306
- if (((_a4 = chart.showTotal) != null ? _a4 : true) && !steps[i + 1]) {
2307
- return false;
2308
- }
2309
- return i <= index;
2310
- }).forEach((step2) => {
2311
- currentYValue += Number(step2.y);
2312
- });
2313
- return /* @__PURE__ */ jsx(
2314
- WaterfallBar,
2315
- {
2316
- chart,
2317
- columnName: chartNames[currentPie],
2318
- fill: step.color,
2319
- height: barHeight,
2320
- isLast,
2321
- lineY,
2322
- step,
2323
- stroke: waterfallColors.stepConnector,
2324
- strokeDashArray: 2,
2325
- textContent: ((_a3 = chart.showTotal) != null ? _a3 : true) ? step.y : currentYValue,
2326
- textX: x + xScale.bandwidth() / 2,
2327
- textY: labelY + 5,
2328
- width: xScale.bandwidth(),
2329
- x,
2330
- y,
2331
- x1,
2332
- x2
2333
- },
2334
- index
2335
- );
2336
- }),
2337
- /* @__PURE__ */ jsx(
2338
- AxisLeft,
2339
- {
2340
- label: "",
2341
- scale: yScale,
2342
- hideAxisLine: true,
2343
- hideTicks: true,
2344
- tickLabelProps: () => ({
2345
- textAnchor: "end",
2346
- verticalAnchor: "middle"
2347
- })
2348
- }
2349
- ),
2350
- /* @__PURE__ */ jsx(
2351
- AxisBottom,
2352
- {
2353
- scale: xScale,
2354
- top: innerHeight,
2355
- tickLabelProps: () => ({
2356
- textAnchor: "middle",
2357
- verticalAnchor: "middle",
2358
- className: "tickLabel"
2359
- })
2360
- }
2361
- )
2362
- ] })
2454
+ id,
2455
+ className: `${className ? className : ""} chartBox`,
2456
+ ref: boxRef,
2457
+ children: /* @__PURE__ */ jsx(
2458
+ "svg",
2459
+ {
2460
+ height: chart.ratio.height,
2461
+ width: chart.ratio.width,
2462
+ ref: elementRef,
2463
+ children: /* @__PURE__ */ jsxs(Group, { left: effectiveMargin.left, top: effectiveMargin.top, children: [
2464
+ /* @__PURE__ */ jsx(GridRows, { scale: yScale, width: innerWidth, strokeDasharray: "5" }),
2465
+ steps.map((step, index) => {
2466
+ var _a3;
2467
+ const x = xScale(step.x);
2468
+ const y = yScale(Math.max(step.start, step.end));
2469
+ if (x == null || y == null) {
2470
+ return null;
2471
+ }
2472
+ const barHeight = Math.abs(yScale(step.start) - yScale(step.end));
2473
+ const isLast = index === steps.length - 1;
2474
+ const linePadding = 2;
2475
+ const x1 = x + xScale.bandwidth() + linePadding;
2476
+ const x2 = x + xScale.bandwidth() / (1 - padding) - linePadding;
2477
+ const lineY = step.end < step.start ? y + barHeight : y;
2478
+ const labelOffset = 10;
2479
+ const labelY = yScale(step.end) + (step.y < 0 ? labelOffset : -labelOffset);
2480
+ let currentYValue = 0;
2481
+ steps.filter((_, i) => {
2482
+ var _a4;
2483
+ if (((_a4 = chart.showTotal) != null ? _a4 : true) && !steps[i + 1]) {
2484
+ return false;
2485
+ }
2486
+ return i <= index;
2487
+ }).forEach((step2) => {
2488
+ currentYValue += Number(step2.y);
2489
+ });
2490
+ return /* @__PURE__ */ jsx(
2491
+ WaterfallBar,
2492
+ {
2493
+ chart,
2494
+ columnName: chartNames[currentPie],
2495
+ fill: step.color,
2496
+ height: barHeight,
2497
+ isLast,
2498
+ lineY,
2499
+ step,
2500
+ stroke: waterfallColors.stepConnector,
2501
+ strokeDashArray: 2,
2502
+ textContent: ((_a3 = chart.showTotal) != null ? _a3 : true) ? step.y : currentYValue,
2503
+ textX: x + xScale.bandwidth() / 2,
2504
+ textY: labelY + 5,
2505
+ width: xScale.bandwidth(),
2506
+ x,
2507
+ y,
2508
+ x1,
2509
+ x2
2510
+ },
2511
+ index
2512
+ );
2513
+ }),
2514
+ /* @__PURE__ */ jsx(
2515
+ AxisLeft,
2516
+ {
2517
+ label: "",
2518
+ scale: yScale,
2519
+ hideAxisLine: true,
2520
+ hideTicks: true,
2521
+ tickLabelProps: () => ({
2522
+ textAnchor: "end",
2523
+ verticalAnchor: "middle"
2524
+ })
2525
+ }
2526
+ ),
2527
+ /* @__PURE__ */ jsx(
2528
+ AxisBottom,
2529
+ {
2530
+ scale: xScale,
2531
+ top: innerHeight,
2532
+ tickLabelProps: () => ({
2533
+ textAnchor: "middle",
2534
+ verticalAnchor: "middle",
2535
+ className: "tickLabel"
2536
+ })
2537
+ }
2538
+ )
2539
+ ] })
2540
+ }
2541
+ )
2363
2542
  }
2364
- ) }),
2543
+ ),
2365
2544
  /* @__PURE__ */ jsx(
2366
2545
  LegendContainer,
2367
2546
  {
@@ -2466,19 +2645,44 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
2466
2645
  lineHeight: "1em"
2467
2646
  }
2468
2647
  },
2648
+ ".chartBox": {
2649
+ position: "sticky",
2650
+ top: "0",
2651
+ background: "white",
2652
+ zIndex: "1"
2653
+ },
2469
2654
  ".legendContainer": {
2470
2655
  display: "flex",
2471
- flexDirection: "row",
2472
- gap: spacing(3),
2473
- flexWrap: "wrap"
2656
+ flexDirection: "column",
2657
+ gap: spacing(2),
2658
+ overflow: "hidden",
2659
+ alignItems: "start",
2660
+ button: () => ({
2661
+ justifyContent: "start",
2662
+ textAlign: "start",
2663
+ width: "100%",
2664
+ textDecoration: "none",
2665
+ svg: {
2666
+ paddingLeft: spacing(1)
2667
+ }
2668
+ })
2474
2669
  },
2475
2670
  ".chart__combo__wrapper": {
2476
2671
  position: "absolute"
2477
2672
  },
2478
- ".legendItem .button__content": {
2479
- overflow: "hidden",
2480
- textOverflow: "ellipsis",
2481
- wordWrap: "normal"
2673
+ ".legendItem": {
2674
+ transition: "opacity 200ms",
2675
+ "&.isBlurred": {
2676
+ opacity: "0.15"
2677
+ },
2678
+ ".button__content": {
2679
+ overflow: "hidden",
2680
+ textOverflow: "ellipsis",
2681
+ wordWrap: "normal",
2682
+ display: "block",
2683
+ whiteSpace: "nowrap",
2684
+ p: spacing(1)
2685
+ }
2482
2686
  }
2483
2687
  },
2484
2688
  // eslint-disable-next-line react/display-name
@@ -2528,6 +2732,50 @@ const [, chartMethods, ChartRenderer] = makeImperativeComponent()({
2528
2732
  )
2529
2733
  });
2530
2734
 
2735
+ const EmptyGrid = ({ width }) => {
2736
+ const xScale = scaleBand({
2737
+ range: [0, width != null ? width : 400],
2738
+ domain: ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"],
2739
+ padding: 0.2
2740
+ });
2741
+ const yScale = scaleBand({
2742
+ range: [0, 400],
2743
+ domain: ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"],
2744
+ padding: 0.2
2745
+ });
2746
+ return /* @__PURE__ */ jsxs("svg", { height: 400, width: width != null ? width : 400, children: [
2747
+ /* @__PURE__ */ jsx(
2748
+ Grid.Grid,
2749
+ {
2750
+ height: 400,
2751
+ width: width != null ? width : 400,
2752
+ numTicksRows: 10,
2753
+ numTicksColumns: 10,
2754
+ xScale,
2755
+ yScale
2756
+ }
2757
+ ),
2758
+ /* @__PURE__ */ jsx(
2759
+ AxisLeft,
2760
+ {
2761
+ scale: yScale,
2762
+ left: 20,
2763
+ hideTicks: true,
2764
+ tickLabelProps: { display: "none" }
2765
+ }
2766
+ ),
2767
+ /* @__PURE__ */ jsx(
2768
+ AxisBottom,
2769
+ {
2770
+ scale: xScale,
2771
+ top: 380,
2772
+ hideTicks: true,
2773
+ tickLabelProps: { display: "none" }
2774
+ }
2775
+ )
2776
+ ] });
2777
+ };
2778
+
2531
2779
  var __defProp$7 = Object.defineProperty;
2532
2780
  var __defProps$5 = Object.defineProperties;
2533
2781
  var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
@@ -3303,7 +3551,7 @@ const Counter = ({
3303
3551
  panelId
3304
3552
  }) => {
3305
3553
  var _a, _b;
3306
- const [value, setValue] = useState(currentValue);
3554
+ const [value, setValue] = useState(currentValue != null ? currentValue : 0);
3307
3555
  const diameter = Math.min(height, width);
3308
3556
  const offset = 20;
3309
3557
  const domainMax = (_a = noNaN(maxValue)) != null ? _a : valueRanges[valueRanges.length - 1];
@@ -3353,7 +3601,7 @@ const Counter = ({
3353
3601
  /* @__PURE__ */ jsx(
3354
3602
  "svg",
3355
3603
  __spreadProps$1(__spreadValues$3({}, gauge.getSVGProps()), {
3356
- height: Math.max(width, height),
3604
+ height,
3357
3605
  width: actualWidth,
3358
3606
  viewBox: `-${diameter / 2 + offset} -${diameter / 2 + offset} ${diameter + offset * 2} ${diameter + offset * 2}`,
3359
3607
  children: /* @__PURE__ */ jsx("g", { id: "arcs", children: addBorder && /* @__PURE__ */ jsx(
@@ -3375,14 +3623,14 @@ const Counter = ({
3375
3623
  /* @__PURE__ */ jsx(
3376
3624
  "svg",
3377
3625
  {
3378
- height: Math.max(width, height),
3626
+ height,
3379
3627
  width: actualWidth,
3380
3628
  style: { position: "absolute", left: 0, top: 0 },
3381
3629
  children: /* @__PURE__ */ jsx(
3382
3630
  "text",
3383
3631
  {
3384
3632
  x: actualWidth / 2,
3385
- y: Math.max(width, height) / 2,
3633
+ y: height / 2,
3386
3634
  textAnchor: "middle",
3387
3635
  style: {
3388
3636
  fontSize: `${currentValueFontSize != null ? currentValueFontSize : 30}px`,
@@ -3846,4 +4094,4 @@ const WidgetContainer = ({ data }) => {
3846
4094
  ) });
3847
4095
  };
3848
4096
 
3849
- export { ChartRenderer, WidgetContainer };
4097
+ export { ChartRenderer, EmptyGrid, WidgetContainer };