cr-ui-lib 1.1.15 → 1.1.16
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 +59 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -887,23 +887,23 @@ var Label = ({ title, classNames }) => {
|
|
|
887
887
|
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: tailwindMerge.twMerge("text-[14px] font-semibold ", classNames), children: title });
|
|
888
888
|
};
|
|
889
889
|
var Label_default = Label;
|
|
890
|
+
chart_js.Chart.register(
|
|
891
|
+
chart_js.CategoryScale,
|
|
892
|
+
chart_js.LinearScale,
|
|
893
|
+
chart_js.PointElement,
|
|
894
|
+
chart_js.LineElement,
|
|
895
|
+
chart_js.Title,
|
|
896
|
+
chart_js.Tooltip,
|
|
897
|
+
chart_js.Filler,
|
|
898
|
+
chart_js.Legend
|
|
899
|
+
);
|
|
890
900
|
var MultiLineGraph = ({
|
|
891
901
|
datasets,
|
|
892
902
|
xAxisLabels,
|
|
893
903
|
className = ""
|
|
894
904
|
}) => {
|
|
895
|
-
chart_js.Chart.register(
|
|
896
|
-
chart_js.CategoryScale,
|
|
897
|
-
chart_js.LinearScale,
|
|
898
|
-
chart_js.PointElement,
|
|
899
|
-
chart_js.LineElement,
|
|
900
|
-
chart_js.Title,
|
|
901
|
-
chart_js.Tooltip,
|
|
902
|
-
chart_js.Filler,
|
|
903
|
-
chart_js.Legend
|
|
904
|
-
);
|
|
905
905
|
const chartRef = React.useRef(null);
|
|
906
|
-
const [chartKey, setChartKey] = React.useState(
|
|
906
|
+
const [chartKey, setChartKey] = React.useState(`chart-${Date.now()}`);
|
|
907
907
|
const defaultColors = [
|
|
908
908
|
{ line: "#17CA43", point: "#17CA43" },
|
|
909
909
|
{ line: "#FF6B6B", point: "#FF4757" },
|
|
@@ -914,7 +914,7 @@ var MultiLineGraph = ({
|
|
|
914
914
|
];
|
|
915
915
|
React.useEffect(() => {
|
|
916
916
|
const handleResize = () => {
|
|
917
|
-
setChartKey((
|
|
917
|
+
setChartKey(`chart-${Date.now()}`);
|
|
918
918
|
};
|
|
919
919
|
window.addEventListener("resize", handleResize);
|
|
920
920
|
return () => {
|
|
@@ -943,12 +943,12 @@ var MultiLineGraph = ({
|
|
|
943
943
|
},
|
|
944
944
|
y: {
|
|
945
945
|
display: true,
|
|
946
|
+
// Set to `false` if you want to hide the y-axis labels
|
|
946
947
|
border: {
|
|
947
948
|
display: false
|
|
948
949
|
},
|
|
949
950
|
grid: {
|
|
950
|
-
|
|
951
|
-
drawTicks: false,
|
|
951
|
+
// This is ignored because our custom plugin below handles drawing
|
|
952
952
|
drawOnChartArea: false
|
|
953
953
|
},
|
|
954
954
|
ticks: {
|
|
@@ -997,27 +997,11 @@ var MultiLineGraph = ({
|
|
|
997
997
|
const innerHtml = `
|
|
998
998
|
<div style="position: relative; background: white; border: 1px solid rgba(16, 30, 115, 0.1); padding: 10px; border-radius: 4px; font-size: 12px; color: #333; min-width: 120px;">
|
|
999
999
|
<div id="tooltip-arrow-border" style="
|
|
1000
|
-
position: absolute;
|
|
1001
|
-
|
|
1002
|
-
left: 50%;
|
|
1003
|
-
transform: translateX(-50%);
|
|
1004
|
-
width: 0;
|
|
1005
|
-
height: 0;
|
|
1006
|
-
border-left: ${outerArrowSize}px solid transparent;
|
|
1007
|
-
border-right: ${outerArrowSize}px solid transparent;
|
|
1008
|
-
border-top: ${outerArrowSize}px solid rgba(16, 30, 115, 0.1);
|
|
1009
|
-
"></div>
|
|
1000
|
+
position: absolute; top: 100%; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: ${outerArrowSize}px solid transparent; border-right: ${outerArrowSize}px solid transparent; border-top: ${outerArrowSize}px solid rgba(16, 30, 115, 0.1);">
|
|
1001
|
+
</div>
|
|
1010
1002
|
<div id="tooltip-arrow" style="
|
|
1011
|
-
position: absolute;
|
|
1012
|
-
|
|
1013
|
-
left: 50%;
|
|
1014
|
-
transform: translateX(-50%) translateY(-1px);
|
|
1015
|
-
width: 0;
|
|
1016
|
-
height: 0;
|
|
1017
|
-
border-left: ${innerArrowSize}px solid transparent;
|
|
1018
|
-
border-right: ${innerArrowSize}px solid transparent;
|
|
1019
|
-
border-top: ${innerArrowSize}px solid white;
|
|
1020
|
-
"></div>
|
|
1003
|
+
position: absolute; top: 100%; left: 50%; transform: translateX(-50%) translateY(-1px); width: 0; height: 0; border-left: ${innerArrowSize}px solid transparent; border-right: ${innerArrowSize}px solid transparent; border-top: ${innerArrowSize}px solid white;">
|
|
1004
|
+
</div>
|
|
1021
1005
|
<div>
|
|
1022
1006
|
<p style="color:#757575; margin: 0 0 8px 0;"><strong>${label}</strong></p>
|
|
1023
1007
|
${dataPointsHtml}
|
|
@@ -1076,10 +1060,9 @@ var MultiLineGraph = ({
|
|
|
1076
1060
|
() => ({
|
|
1077
1061
|
id: "verticalLine",
|
|
1078
1062
|
beforeDatasetsDraw: (chart) => {
|
|
1079
|
-
var _a;
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
const activePoint = chart.tooltip._active[0];
|
|
1063
|
+
var _a, _b;
|
|
1064
|
+
if ((_b = (_a = chart.tooltip) == null ? void 0 : _a.getActiveElements()) == null ? void 0 : _b.length) {
|
|
1065
|
+
const activePoint = chart.tooltip.getActiveElements()[0];
|
|
1083
1066
|
const ctx = chart.ctx;
|
|
1084
1067
|
const x = activePoint.element.x;
|
|
1085
1068
|
const topY = chart.scales.y.top;
|
|
@@ -1098,6 +1081,32 @@ var MultiLineGraph = ({
|
|
|
1098
1081
|
}),
|
|
1099
1082
|
[]
|
|
1100
1083
|
);
|
|
1084
|
+
const dashedGridPlugin = React.useMemo(
|
|
1085
|
+
() => ({
|
|
1086
|
+
id: "customGridAndLabels",
|
|
1087
|
+
afterDraw(chart) {
|
|
1088
|
+
const ctx = chart.ctx;
|
|
1089
|
+
const yAxis = chart.scales.y;
|
|
1090
|
+
if (!yAxis) return;
|
|
1091
|
+
const { left, right } = chart.chartArea;
|
|
1092
|
+
ctx.save();
|
|
1093
|
+
ctx.setLineDash([4, 4]);
|
|
1094
|
+
ctx.strokeStyle = "rgba(0, 0, 0, 0.1)";
|
|
1095
|
+
ctx.lineWidth = 1;
|
|
1096
|
+
const ticks = yAxis.ticks || [];
|
|
1097
|
+
ticks.forEach((tick, index) => {
|
|
1098
|
+
if (index === 0) return;
|
|
1099
|
+
const yPos = yAxis.getPixelForValue(tick.value);
|
|
1100
|
+
ctx.beginPath();
|
|
1101
|
+
ctx.moveTo(left, yPos);
|
|
1102
|
+
ctx.lineTo(right, yPos);
|
|
1103
|
+
ctx.stroke();
|
|
1104
|
+
});
|
|
1105
|
+
ctx.restore();
|
|
1106
|
+
}
|
|
1107
|
+
}),
|
|
1108
|
+
[]
|
|
1109
|
+
);
|
|
1101
1110
|
const lineData = React.useMemo(
|
|
1102
1111
|
() => ({
|
|
1103
1112
|
labels: xAxisLabels,
|
|
@@ -1119,29 +1128,6 @@ var MultiLineGraph = ({
|
|
|
1119
1128
|
}),
|
|
1120
1129
|
[datasets, xAxisLabels]
|
|
1121
1130
|
);
|
|
1122
|
-
const dashedGridPlugin = {
|
|
1123
|
-
id: "customGridAndLabels",
|
|
1124
|
-
afterDraw(chart) {
|
|
1125
|
-
const ctx = chart.ctx;
|
|
1126
|
-
const yAxis = chart.scales.y;
|
|
1127
|
-
if (!yAxis) return;
|
|
1128
|
-
const { left, right } = chart.chartArea;
|
|
1129
|
-
ctx.save();
|
|
1130
|
-
ctx.setLineDash([4, 4]);
|
|
1131
|
-
ctx.strokeStyle = "rgba(0, 0, 0, 0.1)";
|
|
1132
|
-
ctx.lineWidth = 1;
|
|
1133
|
-
const ticks = yAxis.ticks || [];
|
|
1134
|
-
ticks.forEach((tick, index) => {
|
|
1135
|
-
if (index === 0) return;
|
|
1136
|
-
const yPos = yAxis.getPixelForValue(tick.value);
|
|
1137
|
-
ctx.beginPath();
|
|
1138
|
-
ctx.moveTo(left, yPos);
|
|
1139
|
-
ctx.lineTo(right, yPos);
|
|
1140
|
-
ctx.stroke();
|
|
1141
|
-
});
|
|
1142
|
-
ctx.restore();
|
|
1143
|
-
}
|
|
1144
|
-
};
|
|
1145
1131
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: tailwindMerge.twMerge(" w-full h-full", className), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1146
1132
|
reactChartjs2.Line,
|
|
1147
1133
|
{
|
|
@@ -1154,6 +1140,16 @@ var MultiLineGraph = ({
|
|
|
1154
1140
|
) });
|
|
1155
1141
|
};
|
|
1156
1142
|
var MultiLineGraph_default = MultiLineGraph;
|
|
1143
|
+
chart_js.Chart.register(
|
|
1144
|
+
chart_js.CategoryScale,
|
|
1145
|
+
chart_js.LinearScale,
|
|
1146
|
+
chart_js.PointElement,
|
|
1147
|
+
chart_js.LineElement,
|
|
1148
|
+
chart_js.Title,
|
|
1149
|
+
chart_js.Tooltip,
|
|
1150
|
+
chart_js.Filler,
|
|
1151
|
+
chart_js.Legend
|
|
1152
|
+
);
|
|
1157
1153
|
var SingleLineGraph = ({
|
|
1158
1154
|
data,
|
|
1159
1155
|
label,
|
|
@@ -1164,21 +1160,11 @@ var SingleLineGraph = ({
|
|
|
1164
1160
|
labelPopupTitle = "Requests Completed",
|
|
1165
1161
|
className = ""
|
|
1166
1162
|
}) => {
|
|
1167
|
-
chart_js.Chart.register(
|
|
1168
|
-
chart_js.CategoryScale,
|
|
1169
|
-
chart_js.LinearScale,
|
|
1170
|
-
chart_js.PointElement,
|
|
1171
|
-
chart_js.LineElement,
|
|
1172
|
-
chart_js.Title,
|
|
1173
|
-
chart_js.Tooltip,
|
|
1174
|
-
chart_js.Filler,
|
|
1175
|
-
chart_js.Legend
|
|
1176
|
-
);
|
|
1177
1163
|
const chartRef = React.useRef(null);
|
|
1178
|
-
const [chartKey, setChartKey] = React.useState(
|
|
1164
|
+
const [chartKey, setChartKey] = React.useState(`chart-${Date.now()}`);
|
|
1179
1165
|
React.useEffect(() => {
|
|
1180
1166
|
const handleResize = () => {
|
|
1181
|
-
setChartKey((
|
|
1167
|
+
setChartKey(`chart-${Date.now()}`);
|
|
1182
1168
|
};
|
|
1183
1169
|
window.addEventListener("resize", handleResize);
|
|
1184
1170
|
return () => {
|