@apia/charts 0.3.2 → 0.3.3

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/LICENSE.md CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) [year] [fullname]
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/dist/index.d.ts CHANGED
@@ -237,6 +237,6 @@ type TWidgetData = {
237
237
 
238
238
  declare const WidgetContainer: ({ data }: {
239
239
  data: TWidgetData;
240
- }) => React__default.JSX.Element;
240
+ }) => React$1.JSX.Element;
241
241
 
242
242
  export { ChartRenderer, EmptyGrid, TApiaChartColumn, TApiaChartDefinition, TWidgetData, WidgetContainer };
package/dist/index.js CHANGED
@@ -765,7 +765,7 @@ const Slice = ({
765
765
  children: /* @__PURE__ */ jsx("strong", { children: arc.data.key })
766
766
  }
767
767
  ),
768
- chart.showValues && /* @__PURE__ */ jsx("div", { children: `${arc.value} ${arc.data.percentage ? "- " + arc.data.percentage : ""}${arc.data.percentage ? "%" : ""}` })
768
+ chart.showValues && /* @__PURE__ */ jsx("div", { children: `${arc.value} ${arc.data.percentage !== "" && arc.data.percentage !== void 0 ? "- " + arc.data.percentage : ""}${arc.data.percentage !== "" && arc.data.percentage !== void 0 ? "%" : ""}` })
769
769
  ] })
770
770
  });
771
771
  useImperativeComponentEvents({
@@ -894,7 +894,8 @@ const usePieAnimation = ({
894
894
  key: coord2.key,
895
895
  color: coord2.color,
896
896
  // Assuming color is the same for both coordinates
897
- value: newValue
897
+ value: newValue,
898
+ percentage: coord2.percentage !== "" && coord2.percentage !== void 0 ? coord2.percentage : void 0
898
899
  };
899
900
  difference.push(newCoordinate);
900
901
  } else if (!coord1 && coord2 && previousCoordinates.length > 0) {
@@ -903,7 +904,8 @@ const usePieAnimation = ({
903
904
  key: coord2.key,
904
905
  color: coord2.color,
905
906
  // Assuming color is the same for both coordinates
906
- value: newValue
907
+ value: newValue,
908
+ percentage: coord2.percentage !== "" && coord2.percentage !== void 0 ? coord2.percentage : void 0
907
909
  };
908
910
  difference.push(newCoordinate);
909
911
  }
@@ -1143,7 +1145,7 @@ const PieChart = ({
1143
1145
  },
1144
1146
  piezas.name
1145
1147
  ),
1146
- colorReference.length > 1 && /* @__PURE__ */ jsx(LegendContainer, { id: chartId, references: colorReference })
1148
+ chart.showLegend && colorReference.length > 1 && /* @__PURE__ */ jsx(LegendContainer, { id: chartId, references: colorReference })
1147
1149
  ] });
1148
1150
  };
1149
1151
 
@@ -3542,9 +3544,7 @@ const Counter = ({
3542
3544
  addBorder = false,
3543
3545
  colorRanges,
3544
3546
  currentValue,
3545
- height,
3546
3547
  valueRanges,
3547
- width,
3548
3548
  maxValue,
3549
3549
  minValue,
3550
3550
  currentValueFontSize,
@@ -3552,8 +3552,8 @@ const Counter = ({
3552
3552
  }) => {
3553
3553
  var _a, _b;
3554
3554
  const [value, setValue] = useState(currentValue != null ? currentValue : 0);
3555
- const diameter = Math.min(height, width);
3556
- const offset = 20;
3555
+ const actualWidth = (currentValueFontSize != null ? currentValueFontSize : 80) * 3 * 0.8;
3556
+ const diameter = actualWidth;
3557
3557
  const domainMax = (_a = noNaN(maxValue)) != null ? _a : valueRanges[valueRanges.length - 1];
3558
3558
  const domainMin = (_b = noNaN(minValue)) != null ? _b : valueRanges[0];
3559
3559
  const gauge = useGauge({
@@ -3589,51 +3589,43 @@ const Counter = ({
3589
3589
  }
3590
3590
  );
3591
3591
  }, [currentValue]);
3592
- const widgetContainer = document.querySelector(".widgetContainer__Counter");
3593
- let actualWidth = width;
3594
- if (widgetContainer) {
3595
- const box = widgetContainer.getBoundingClientRect();
3596
- if (box.width < actualWidth) {
3597
- actualWidth = box.width;
3598
- }
3599
- }
3600
3592
  return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, className: "widgetContainer__Counter", children: [
3601
3593
  /* @__PURE__ */ jsx(
3602
3594
  "svg",
3603
3595
  __spreadProps$1(__spreadValues$3({}, gauge.getSVGProps()), {
3604
- height,
3596
+ height: actualWidth,
3605
3597
  width: actualWidth,
3606
- viewBox: `-${diameter / 2 + offset} -${diameter / 2 + offset} ${diameter + offset * 2} ${diameter + offset * 2}`,
3607
- children: /* @__PURE__ */ jsx("g", { id: "arcs", children: addBorder && /* @__PURE__ */ jsx(
3608
- "path",
3609
- __spreadProps$1(__spreadValues$3({}, gauge.getArcProps({
3610
- offset: offset - 5,
3611
- startAngle: START_ANGLE$1,
3612
- endAngle: END_ANGLE$1
3613
- })), {
3598
+ viewBox: void 0,
3599
+ children: /* @__PURE__ */ jsx("g", { id: "arcs", children: addBorder && `${value}`.length < 4 && /* @__PURE__ */ jsx(
3600
+ "ellipse",
3601
+ {
3602
+ cx: actualWidth / 2,
3603
+ cy: actualWidth / 2,
3604
+ rx: actualWidth / 2 - 5,
3605
+ ry: actualWidth / 2 - 5,
3614
3606
  stroke: "gray",
3615
3607
  opacity: "0.2",
3616
3608
  fill: "none",
3617
3609
  strokeLinecap: "round",
3618
3610
  strokeWidth: 2
3619
- })
3611
+ }
3620
3612
  ) })
3621
3613
  })
3622
3614
  ),
3623
3615
  /* @__PURE__ */ jsx(
3624
3616
  "svg",
3625
3617
  {
3626
- height,
3618
+ height: actualWidth,
3627
3619
  width: actualWidth,
3628
3620
  style: { position: "absolute", left: 0, top: 0 },
3629
3621
  children: /* @__PURE__ */ jsx(
3630
3622
  "text",
3631
3623
  {
3632
3624
  x: actualWidth / 2,
3633
- y: height / 2,
3625
+ y: actualWidth / 2 - 5,
3634
3626
  textAnchor: "middle",
3635
3627
  style: {
3636
- fontSize: `${currentValueFontSize != null ? currentValueFontSize : 30}px`,
3628
+ fontSize: `${currentValueFontSize != null ? currentValueFontSize : 80}px`,
3637
3629
  transition: "fill 0.5s"
3638
3630
  },
3639
3631
  alignmentBaseline: "central",
@@ -4069,7 +4061,7 @@ const WidgetContainer = ({ data }) => {
4069
4061
  0
4070
4062
  );
4071
4063
  const panelData = usePanelIdentity();
4072
- return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
4064
+ return /* @__PURE__ */ jsx(
4073
4065
  CurrentWidget,
4074
4066
  {
4075
4067
  addBorder: realData.border,
@@ -4091,7 +4083,7 @@ const WidgetContainer = ({ data }) => {
4091
4083
  valueRanges,
4092
4084
  width: realData.width
4093
4085
  }
4094
- ) });
4086
+ );
4095
4087
  };
4096
4088
 
4097
4089
  export { ChartRenderer, EmptyGrid, WidgetContainer };