mario-education 2.4.588-release → 2.4.589-release

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
@@ -29738,7 +29738,7 @@ var optionColumnChartAndPercents = function optionColumnChartAndPercents(min, mo
29738
29738
  yaxis: {
29739
29739
  tickAmount: 5,
29740
29740
  min: 0,
29741
- max: !isCountSeries || !maxSeries ? 100 : Math.ceil(maxSeries * 1.1),
29741
+ max: !isCountSeries || !maxSeries ? 100 : maxSeries,
29742
29742
  axisBorder: {
29743
29743
  show: true
29744
29744
  },
@@ -29754,14 +29754,17 @@ var optionColumnChartAndPercents = function optionColumnChartAndPercents(min, mo
29754
29754
  cssClass: "apexcharts-yaxis-label"
29755
29755
  },
29756
29756
  formatter: function formatter(value) {
29757
- var roundedValue = Math.round(value);
29758
- return !isCountSeries ? roundedValue + "%" : roundedValue.toString();
29757
+ if (!isCountSeries) {
29758
+ return Math.round(value) + "%";
29759
+ }
29760
+
29761
+ return value % 1 === 0 ? value.toString() : value.toFixed(1);
29759
29762
  },
29760
29763
  offsetX: 0,
29761
29764
  offsetY: 0,
29762
29765
  rotate: 0
29763
29766
  },
29764
- decimalsInFloat: 0
29767
+ decimalsInFloat: 1
29765
29768
  },
29766
29769
  tooltip: {
29767
29770
  y: {
@@ -35646,9 +35649,47 @@ var BarChart = function BarChart(_ref) {
35646
35649
  lowMetricStudents = _ref.lowMetricStudents,
35647
35650
  print = _ref.print,
35648
35651
  labelDate = _ref.labelDate;
35649
- var maxSeries = series.reduce(function (max, item) {
35650
- return Math.max.apply(Math, [max].concat(item.data));
35651
- }, -Infinity) || 0;
35652
+
35653
+ var roundUpToNiceNumber = function roundUpToNiceNumber(num) {
35654
+ if (num === 0) return 5;
35655
+ if (num <= 50) return Math.ceil(num / 5) * 5;
35656
+ if (num <= 100) return Math.ceil(num / 10) * 10;
35657
+ return Math.ceil(num / 20) * 20;
35658
+ };
35659
+
35660
+ var _useMemo = React.useMemo(function () {
35661
+ if (!lowMetricStudents || lowMetricStudents.length === 0) {
35662
+ var max = series.reduce(function (max, item) {
35663
+ return Math.max.apply(Math, [max].concat(item.data));
35664
+ }, -Infinity) || 0;
35665
+ return {
35666
+ correctedSeries: series,
35667
+ maxSeries: roundUpToNiceNumber(max)
35668
+ };
35669
+ }
35670
+
35671
+ var studentCountsPerPeriod = {};
35672
+ lowMetricStudents.forEach(function (student) {
35673
+ var periodIndex = labelDate !== "Monthly" ? student.orderWeek : student.orderMonth;
35674
+ studentCountsPerPeriod[periodIndex] = (studentCountsPerPeriod[periodIndex] || 0) + 1;
35675
+ });
35676
+ var correctedData = months.map(function (_, index) {
35677
+ return studentCountsPerPeriod[index] || 0;
35678
+ });
35679
+ var maxCount = Math.max.apply(Math, correctedData.concat([0]));
35680
+ var roundedMax = roundUpToNiceNumber(maxCount);
35681
+ var newSeries = series.map(function (s) {
35682
+ return _extends({}, s, {
35683
+ data: correctedData
35684
+ });
35685
+ });
35686
+ return {
35687
+ correctedSeries: newSeries,
35688
+ maxSeries: roundedMax
35689
+ };
35690
+ }, [series, lowMetricStudents, labelDate, months]),
35691
+ correctedSeries = _useMemo.correctedSeries,
35692
+ maxSeries = _useMemo.maxSeries;
35652
35693
 
35653
35694
  var _useState = React.useState(null),
35654
35695
  tooltipData = _useState[0],
@@ -35675,7 +35716,7 @@ var BarChart = function BarChart(_ref) {
35675
35716
  events: {
35676
35717
  dataPointSelection: function dataPointSelection(_event, _chartContext, config) {
35677
35718
  var dataPointIndex = config.dataPointIndex;
35678
- var chartEl = document.querySelector("#apexchartsmy-bar-chart");
35719
+ var chartEl = document.querySelector("#bar_chart_metric_admin");
35679
35720
  if (!chartEl) return;
35680
35721
  var barEls = chartEl.querySelectorAll(".apexcharts-bar-series path");
35681
35722
  if (!barEls.length) return;
@@ -35691,7 +35732,7 @@ var BarChart = function BarChart(_ref) {
35691
35732
  dataPointMouseEnter: function dataPointMouseEnter(_event, _chartContext, config) {
35692
35733
  var dataPointIndex = config === null || config === void 0 ? void 0 : config.dataPointIndex;
35693
35734
  var currentTooltip = tooltipDataRef.current;
35694
- var chartEl = document.querySelector("#apexchartsmy-bar-chart");
35735
+ var chartEl = document.querySelector("#bar_chart_metric_admin");
35695
35736
  if (!chartEl) return;
35696
35737
  var barEls = chartEl.querySelectorAll(".apexcharts-bar-series path");
35697
35738
  if (!barEls.length) return;
@@ -35807,7 +35848,7 @@ var BarChart = function BarChart(_ref) {
35807
35848
  React.useEffect(function () {
35808
35849
  var handleClickOutside = function handleClickOutside(e) {
35809
35850
  if (open) return;
35810
- var chartEl = document.querySelector("#apexchartsmy-bar-chart");
35851
+ var chartEl = document.querySelector("#bar_chart_metric_admin");
35811
35852
  if (!chartEl) return;
35812
35853
 
35813
35854
  if (!chartEl.contains(e.target)) {
@@ -35831,12 +35872,13 @@ var BarChart = function BarChart(_ref) {
35831
35872
  ref: chartWrapperRef,
35832
35873
  style: {
35833
35874
  position: "relative"
35834
- }
35875
+ },
35876
+ id: "bar_chart_metric_admin"
35835
35877
  }, React__default.createElement(Chart, {
35836
35878
  ref: chartRef,
35837
35879
  options: options,
35838
35880
  type: "bar",
35839
- series: series,
35881
+ series: correctedSeries,
35840
35882
  width: "100%",
35841
35883
  height: 300
35842
35884
  }), renderCustomTooltip()), React__default.createElement(MetricModelStudent, {