@ammarkhalidfarooq/dashboard-package 0.6.79 → 0.6.81

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.cjs.js CHANGED
@@ -6488,6 +6488,38 @@ var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref8) {
6488
6488
  });
6489
6489
  };
6490
6490
 
6491
+ var formatCategoryLabel$1 = function formatCategoryLabel(val) {
6492
+ if (!val || typeof val !== "string") return val;
6493
+ var ddMmYyyy = val.match(/^(\d{2})-(\d{2})-(\d{4})$/);
6494
+ if (ddMmYyyy) {
6495
+ var _ddMmYyyy = _slicedToArray(ddMmYyyy, 4),
6496
+ day = _ddMmYyyy[1],
6497
+ month = _ddMmYyyy[2],
6498
+ year = _ddMmYyyy[3];
6499
+ var _date = new Date(Number(year), Number(month) - 1, Number(day));
6500
+ if (!Number.isNaN(_date.getTime())) {
6501
+ return _date.toLocaleDateString("en-US", {
6502
+ month: "short",
6503
+ day: "numeric"
6504
+ });
6505
+ }
6506
+ }
6507
+ var date = new Date(val);
6508
+ if (!Number.isNaN(date.getTime())) {
6509
+ return date.toLocaleDateString("en-US", {
6510
+ month: "short",
6511
+ day: "numeric"
6512
+ });
6513
+ }
6514
+ return val;
6515
+ };
6516
+ var buildAxisLabels = function buildAxisLabels(categories) {
6517
+ if (categories.length <= 1) return categories.map(formatCategoryLabel$1);
6518
+ if (categories.length === 2) {
6519
+ return [formatCategoryLabel$1(categories[0]), formatCategoryLabel$1(categories[categories.length - 1])];
6520
+ }
6521
+ return [formatCategoryLabel$1(categories[0]), formatCategoryLabel$1(categories[Math.floor(categories.length / 2)]), formatCategoryLabel$1(categories[categories.length - 1])];
6522
+ };
6491
6523
  var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
6492
6524
  var sx = _ref.sx,
6493
6525
  _ref$refundsChargebac = _ref.refundsChargebacksData,
@@ -6522,6 +6554,8 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
6522
6554
  var dataMax = Math.max.apply(Math, [0].concat(_toConsumableArray(chargebackSeries), _toConsumableArray(refundSeries)));
6523
6555
  var hasChartData = dataMax > 0;
6524
6556
  var yAxisMax = hasChartData ? Math.ceil(Math.max(dataMax, 1) * 1.2) : 0.5;
6557
+ var showAxisLabels = categories.length <= 15;
6558
+ var axisLabels = showAxisLabels ? buildAxisLabels(categories) : [];
6525
6559
  var chartOptions = {
6526
6560
  chart: {
6527
6561
  type: "area",
@@ -6563,18 +6597,17 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
6563
6597
  show: false
6564
6598
  },
6565
6599
  labels: {
6566
- show: categories.length <= 15,
6567
- rotate: -45,
6568
- style: {
6569
- colors: "rgba(0, 0, 0, 0.4)",
6570
- fontSize: "10px"
6571
- }
6600
+ show: false
6572
6601
  }
6573
6602
  },
6574
- yaxis: {
6603
+ yaxis: _objectSpread2(_objectSpread2({
6575
6604
  min: 0,
6576
- max: yAxisMax,
6577
- tickAmount: 4,
6605
+ max: yAxisMax
6606
+ }, hasChartData ? {
6607
+ tickAmount: 4
6608
+ } : {
6609
+ stepSize: 0.25
6610
+ }), {}, {
6578
6611
  labels: {
6579
6612
  formatter: function formatter(val) {
6580
6613
  return "".concat(parseFloat(val.toFixed(1)), "%");
@@ -6588,7 +6621,7 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
6588
6621
  fontSize: "11px"
6589
6622
  }
6590
6623
  }
6591
- },
6624
+ }),
6592
6625
  grid: {
6593
6626
  borderColor: "#f1f1f1",
6594
6627
  strokeDashArray: 4,
@@ -6628,6 +6661,12 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
6628
6661
  } : {},
6629
6662
  tooltip: {
6630
6663
  shared: true,
6664
+ x: {
6665
+ formatter: function formatter(_, _ref2) {
6666
+ var dataPointIndex = _ref2.dataPointIndex;
6667
+ return formatCategoryLabel$1(categories[dataPointIndex]);
6668
+ }
6669
+ },
6631
6670
  y: {
6632
6671
  formatter: function formatter(val) {
6633
6672
  return "".concat(parseFloat(val.toFixed(2)), "%");
@@ -6798,18 +6837,39 @@ var RefundsChargebacksCard = function RefundsChargebacksCard(_ref) {
6798
6837
  },
6799
6838
  children: ["$", fmt(totalRefundedAmount), " refunded \xB7 ", totalChargebacks, " chargebacks \xB7 ", totalRefunds, " refunds"]
6800
6839
  })
6801
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
6840
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
6802
6841
  sx: {
6803
- height: 140,
6804
6842
  width: "100%",
6805
6843
  flexShrink: 0
6806
6844
  },
6807
- children: /*#__PURE__*/jsxRuntime.jsx(ReactApexChart, {
6808
- options: chartOptions,
6809
- series: series,
6810
- type: "area",
6811
- height: "100%"
6812
- })
6845
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
6846
+ sx: {
6847
+ height: 140
6848
+ },
6849
+ children: /*#__PURE__*/jsxRuntime.jsx(ReactApexChart, {
6850
+ options: chartOptions,
6851
+ series: series,
6852
+ type: "area",
6853
+ height: "100%"
6854
+ })
6855
+ }), axisLabels.length > 0 && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
6856
+ sx: {
6857
+ display: "flex",
6858
+ justifyContent: "space-between",
6859
+ mt: 0.5,
6860
+ pl: 3,
6861
+ pr: 0.75
6862
+ },
6863
+ children: axisLabels.map(function (label, idx) {
6864
+ return /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
6865
+ sx: {
6866
+ fontSize: "10px",
6867
+ color: "rgba(0, 0, 0, 0.4)"
6868
+ },
6869
+ children: label
6870
+ }, "".concat(label, "-").concat(idx));
6871
+ })
6872
+ })]
6813
6873
  })]
6814
6874
  });
6815
6875
  };