@economic/taco 2.57.0-charts.2 → 2.57.0-charts.4

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/taco.cjs CHANGED
@@ -82761,15 +82761,18 @@ var AreaChart$1 = generateCategoricalChart({
82761
82761
  }],
82762
82762
  formatAxisMap: formatAxisMap2
82763
82763
  });
82764
- function getAxisProps(scale2, tickFormatter, dataKey) {
82764
+ function getAxisProps(scale2, tickFormatter, dataKey, width) {
82765
+ const isYAxis = dataKey === void 0;
82765
82766
  return {
82766
82767
  axisLine: false,
82767
82768
  dataKey,
82768
82769
  fontSize: 11,
82770
+ interval: "preserveStartEnd",
82769
82771
  scale: scale2,
82770
82772
  tickLine: false,
82771
- tickMargin: 8,
82772
- tickFormatter
82773
+ tickMargin: isYAxis ? 2 : 6,
82774
+ tickFormatter,
82775
+ width: width ?? 55
82773
82776
  };
82774
82777
  }
82775
82778
  function ChartContainer(props) {
@@ -82812,7 +82815,7 @@ function Legend$1(props) {
82812
82815
  handleToggle(item.dataKey);
82813
82816
  };
82814
82817
  const moreButton = (moreButtonText) => /* @__PURE__ */ React.createElement(Button$4, { appearance: "transparent", className: "text-grey-700 !h-5 !min-h-[1.25rem] !px-1.5 text-xs" }, moreButtonText);
82815
- return /* @__PURE__ */ React.createElement(OverflowGroup, { className: "w-full gap-x-1", moreButton }, items.map((item, index2) => {
82818
+ return /* @__PURE__ */ React.createElement(OverflowGroup, { className: "mt-2.5 w-full gap-x-1", moreButton }, items.map((item, index2) => {
82816
82819
  const className = clsx("mr-1 flex h-3 w-3 rounded-sm", {
82817
82820
  [`bg-${item.color}`]: !item.isHidden,
82818
82821
  border: item.isHidden
@@ -83002,7 +83005,7 @@ function useChart(children, options) {
83002
83005
  };
83003
83006
  });
83004
83007
  const shapes2 = items2.filter((item) => !hiddenItems[item.dataKey]).map((item) => {
83005
- const color2 = getThemeColor(item.color, "blue-500");
83008
+ const color2 = getThemeColor(item.color, "blue-300");
83006
83009
  return {
83007
83010
  activeDot: {
83008
83011
  strokeWidth: 1
@@ -83010,7 +83013,7 @@ function useChart(children, options) {
83010
83013
  color: color2,
83011
83014
  dataKey: item.dataKey,
83012
83015
  dot: {
83013
- fillOpacity: 0.6
83016
+ fillOpacity: 0.8
83014
83017
  },
83015
83018
  isAnimationActive: false,
83016
83019
  fill: color2,
@@ -83044,6 +83047,7 @@ function useChartDataHiddenState() {
83044
83047
  function AreaChart(props) {
83045
83048
  const {
83046
83049
  children,
83050
+ className: customClassName,
83047
83051
  data,
83048
83052
  dataKey,
83049
83053
  showDots = false,
@@ -83059,13 +83063,19 @@ function AreaChart(props) {
83059
83063
  yAxisTickFormatter,
83060
83064
  ...attributes
83061
83065
  } = props;
83062
- const className = clsx("aspect-video", attributes.className);
83066
+ const className = clsx("relative aspect-video", { "mb-6": showLegend }, customClassName);
83063
83067
  const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
83064
- return /* @__PURE__ */ React.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-area" }, /* @__PURE__ */ React.createElement(
83068
+ return /* @__PURE__ */ React.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className: "h-full w-full", "data-taco": "chart-area" }, /* @__PURE__ */ React.createElement(
83065
83069
  AreaChart$1,
83066
83070
  {
83067
83071
  data,
83068
- margin: { bottom: 10, left: 10, right: 10, top: 10 },
83072
+ margin: {
83073
+ bottom: 0,
83074
+ // ensures dots on the edges of the chart don't get cropped
83075
+ left: 4,
83076
+ right: 4,
83077
+ top: 4
83078
+ },
83069
83079
  stackOffset: stacked === "expand" ? "expand" : void 0
83070
83080
  },
83071
83081
  /* @__PURE__ */ React.createElement(CartesianGrid, { vertical: false }),
@@ -83084,6 +83094,7 @@ function AreaChart(props) {
83084
83094
  key: shape.dataKey,
83085
83095
  ...shape,
83086
83096
  dot: showDots ? shape.dot : false,
83097
+ fillOpacity: 0.4,
83087
83098
  stackId: stacked ? "stack" : void 0,
83088
83099
  type
83089
83100
  }
@@ -83094,11 +83105,12 @@ function Area(_) {
83094
83105
  return null;
83095
83106
  }
83096
83107
  AreaChart.Area = Area;
83097
- const BAR_WIDTH = 20;
83108
+ const BAR_WIDTH = 18;
83098
83109
  function BarChart(props) {
83099
83110
  const isHorizontal = props.layout === "horizontal";
83100
83111
  const {
83101
83112
  children,
83113
+ className: customClassName,
83102
83114
  data,
83103
83115
  dataKey,
83104
83116
  showLabels = false,
@@ -83110,17 +83122,24 @@ function BarChart(props) {
83110
83122
  xAxisTickFormatter,
83111
83123
  yAxisScale,
83112
83124
  yAxisTickFormatter,
83125
+ yAxisWidth,
83113
83126
  ...attributes
83114
83127
  } = props;
83115
- const className = clsx("aspect-video", attributes.className);
83128
+ const className = clsx("relative aspect-video", { "mb-6": showLegend }, customClassName);
83116
83129
  const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
83117
- return /* @__PURE__ */ React.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-bar" }, /* @__PURE__ */ React.createElement(
83130
+ return /* @__PURE__ */ React.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className: "h-full w-full", "data-taco": "chart-bar" }, /* @__PURE__ */ React.createElement(
83118
83131
  BarChart$1,
83119
83132
  {
83120
83133
  data,
83121
83134
  barCategoryGap: "15%",
83122
83135
  barGap: "7.5%",
83123
- margin: { bottom: 10, left: isHorizontal ? -15 : 10, right: 10, top: 10 },
83136
+ margin: {
83137
+ bottom: 0,
83138
+ left: 0,
83139
+ right: 0,
83140
+ // ensures labels on top of bars don't get cropped
83141
+ top: isHorizontal ? 0 : 10
83142
+ },
83124
83143
  layout: isHorizontal ? "vertical" : void 0,
83125
83144
  stackOffset: stacked === "expand" ? "expand" : void 0
83126
83145
  },
@@ -83137,7 +83156,12 @@ function BarChart(props) {
83137
83156
  /* @__PURE__ */ React.createElement(
83138
83157
  YAxis,
83139
83158
  {
83140
- ...getAxisProps(yAxisScale, yAxisTickFormatter, isHorizontal ? dataKey : void 0),
83159
+ ...getAxisProps(
83160
+ yAxisScale,
83161
+ yAxisTickFormatter,
83162
+ isHorizontal ? dataKey : void 0,
83163
+ yAxisWidth
83164
+ ),
83141
83165
  hide: !showYAxis,
83142
83166
  type: isHorizontal ? "category" : void 0
83143
83167
  }
@@ -83148,17 +83172,17 @@ function BarChart(props) {
83148
83172
  key: shape.dataKey,
83149
83173
  ...shape,
83150
83174
  activeBar: { fillOpacity: 1, strokeWidth: 0 },
83151
- strokeWidth: 0,
83152
83175
  maxBarSize: BAR_WIDTH,
83153
83176
  radius: getRadius(index2, shapes.length, !!stacked, isHorizontal),
83154
- stackId: stacked ? "stack" : void 0
83177
+ stackId: stacked ? "stack" : void 0,
83178
+ strokeWidth: 0
83155
83179
  },
83156
83180
  showLabels ? /* @__PURE__ */ React.createElement(
83157
83181
  LabelList,
83158
83182
  {
83159
83183
  position: isHorizontal ? "insideRight" : "top",
83160
83184
  formatter: shape.formatter,
83161
- offset: isHorizontal ? 6 : 8,
83185
+ offset: 6,
83162
83186
  fill: isHorizontal ? getInverseThemeColor(shape.color ?? "") : "black",
83163
83187
  fontSize: 11
83164
83188
  }
@@ -83251,7 +83275,15 @@ function Total(props) {
83251
83275
  const total2 = items.filter((item) => !item.isHidden).reduce((acc, curr) => acc + curr.value, 0);
83252
83276
  return (formatter == null ? void 0 : formatter(total2)) ?? new Intl.NumberFormat(localization.locale).format(total2);
83253
83277
  }, [items]);
83254
- return /* @__PURE__ */ React.createElement("div", { ...attributes, className: "absolute-center-x flex aspect-square flex-col items-center justify-center rounded-full" }, /* @__PURE__ */ React.createElement("span", { className: "truncate text-2xl font-bold tabular-nums" }, total), unit2 ? /* @__PURE__ */ React.createElement("span", { className: "text-grey-700 -mb-1 -mt-0.5 truncate text-xs" }, unit2) : null);
83278
+ return /* @__PURE__ */ React.createElement(
83279
+ "div",
83280
+ {
83281
+ ...attributes,
83282
+ className: "absolute-center-x flex aspect-square flex-col items-center justify-center rounded-full pt-[2px]"
83283
+ },
83284
+ /* @__PURE__ */ React.createElement("span", { className: "truncate text-2xl font-bold tabular-nums" }, total),
83285
+ unit2 ? /* @__PURE__ */ React.createElement("span", { className: "text-grey-700 -mb-1 -mt-0.5 truncate text-xs" }, unit2) : null
83286
+ );
83255
83287
  }
83256
83288
  const Legend = ({ hoveredItem, selectedItem, data, onClick, setHoveredItem, formatter, total, label }) => {
83257
83289
  const isTotalLegendSelected = selectedItem.length === data.length;
@@ -83417,6 +83449,7 @@ const LegacyDonutChart = function LegacyDonutChart2({ children, formatter, onCli
83417
83449
  onMouseEnter: (segment) => data.length > 0 && setHoveredItem([segment.id]),
83418
83450
  onMouseLeave: () => setHoveredItem([]),
83419
83451
  outerRadius: radius - HOVER_DONUT_WIDTH,
83452
+ paddingAngle: 2.5,
83420
83453
  stroke: "0",
83421
83454
  rootTabIndex: -1
83422
83455
  },
@@ -83439,6 +83472,7 @@ LegacyDonutChart.Segment = Segment$1;
83439
83472
  function LineChart(props) {
83440
83473
  const {
83441
83474
  children,
83475
+ className: customClassName,
83442
83476
  data,
83443
83477
  dataKey,
83444
83478
  showDots = false,
@@ -83453,13 +83487,19 @@ function LineChart(props) {
83453
83487
  yAxisTickFormatter,
83454
83488
  ...attributes
83455
83489
  } = props;
83456
- const className = clsx("aspect-video", attributes.className);
83490
+ const className = clsx("relative aspect-video", { "mb-6": showLegend }, customClassName);
83457
83491
  const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
83458
- return /* @__PURE__ */ React.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-area" }, /* @__PURE__ */ React.createElement(
83492
+ return /* @__PURE__ */ React.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className: "h-full w-full", "data-taco": "chart-line" }, /* @__PURE__ */ React.createElement(
83459
83493
  LineChart$1,
83460
83494
  {
83461
83495
  data,
83462
- margin: { bottom: 10, left: 10, right: 10, top: 10 }
83496
+ margin: {
83497
+ bottom: 0,
83498
+ // ensures dots on the edges of the chart don't get cropped
83499
+ left: 4,
83500
+ right: 4,
83501
+ top: 4
83502
+ }
83463
83503
  },
83464
83504
  /* @__PURE__ */ React.createElement(CartesianGrid, { vertical: false }),
83465
83505
  /* @__PURE__ */ React.createElement(Tooltip$1, { content: /* @__PURE__ */ React.createElement(Tooltip, { title: tooltipTitle }) }),