dp-widgets-framework 1.3.5 → 1.3.7
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.esm.js +2277 -76
- package/dist/index.js +2277 -76
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,8 +17,6 @@ var reactGridLayout = require('react-grid-layout');
|
|
|
17
17
|
var uuid = require('uuid');
|
|
18
18
|
var reactCore = require('@copilotkit/react-core');
|
|
19
19
|
var reactUi = require('@copilotkit/react-ui');
|
|
20
|
-
var ChartDataLabels = require('chartjs-plugin-datalabels');
|
|
21
|
-
var ChartPieChartOutlabels = require('@energiency/chartjs-plugin-piechart-outlabels');
|
|
22
20
|
var CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
23
21
|
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
24
22
|
|
|
@@ -1514,11 +1512,11 @@ const Input = React__namespace.forwardRef((_a, ref) => {
|
|
|
1514
1512
|
Input.displayName = "Input";
|
|
1515
1513
|
|
|
1516
1514
|
const labelVariants = classVarianceAuthority.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
1517
|
-
const Label = React__namespace.forwardRef((_a, ref) => {
|
|
1515
|
+
const Label$1 = React__namespace.forwardRef((_a, ref) => {
|
|
1518
1516
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1519
1517
|
return (jsxRuntimeExports.jsx(LabelPrimitive__namespace.Root, Object.assign({ ref: ref, className: cn(labelVariants(), className) }, props)));
|
|
1520
1518
|
});
|
|
1521
|
-
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
1519
|
+
Label$1.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
1522
1520
|
|
|
1523
1521
|
const Switch = React__namespace.forwardRef((_a, ref) => {
|
|
1524
1522
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
@@ -1827,17 +1825,17 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1827
1825
|
};
|
|
1828
1826
|
const renderCommonSettings = () => {
|
|
1829
1827
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
1830
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsx(Input, { value: localWidget.title, onChange: (e) => updateWidget({ title: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Show Header" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showHeader) !== false, onCheckedChange: (checked) => updateConfig({ showHeader: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Resizable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_resizable, onCheckedChange: (checked) => updateWidget({ is_resizable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Draggable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_draggable, onCheckedChange: (checked) => updateWidget({ is_draggable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Background Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_c = (_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_e = (_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.styles) === null || _e === void 0 ? void 0 : _e.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Border Radius" }), jsxRuntimeExports.jsxs(Select, { value: ((_g = (_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.styles) === null || _g === void 0 ? void 0 : _g.borderRadius) || "rounded", onValueChange: (value) => updateStyle({ borderRadius: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select border radius" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "none", children: "None" }), jsxRuntimeExports.jsx(SelectItem, { value: "rounded", children: "Rounded" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Padding" }), jsxRuntimeExports.jsxs(Select, { value: ((_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.styles) === null || _j === void 0 ? void 0 : _j.padding) || "medium", onValueChange: (value) => updateStyle({ padding: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select padding" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "small", children: "Small" }), jsxRuntimeExports.jsx(SelectItem, { value: "medium", children: "Medium" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Text Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_l = (_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.styles) === null || _l === void 0 ? void 0 : _l.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_o = (_m = localWidget.config) === null || _m === void 0 ? void 0 : _m.styles) === null || _o === void 0 ? void 0 : _o.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Font Size" }), jsxRuntimeExports.jsx(Input, { value: ((_q = (_p = localWidget.config) === null || _p === void 0 ? void 0 : _p.styles) === null || _q === void 0 ? void 0 : _q.fontSize) || "14px", onChange: (e) => updateStyle({ fontSize: e.target.value }), className: "h-8", placeholder: "e.g., 14px, 1rem" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Alignment" }), jsxRuntimeExports.jsxs(Select, { value: ((_s = (_r = localWidget.config) === null || _r === void 0 ? void 0 : _r.styles) === null || _s === void 0 ? void 0 : _s.alignment) || "left", onValueChange: (value) => updateStyle({ alignment: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select alignment" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" })] })] })] })] }));
|
|
1828
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsx(Input, { value: localWidget.title, onChange: (e) => updateWidget({ title: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Show Header" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showHeader) !== false, onCheckedChange: (checked) => updateConfig({ showHeader: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Resizable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_resizable, onCheckedChange: (checked) => updateWidget({ is_resizable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Draggable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_draggable, onCheckedChange: (checked) => updateWidget({ is_draggable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Background Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_c = (_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_e = (_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.styles) === null || _e === void 0 ? void 0 : _e.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Border Radius" }), jsxRuntimeExports.jsxs(Select, { value: ((_g = (_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.styles) === null || _g === void 0 ? void 0 : _g.borderRadius) || "rounded", onValueChange: (value) => updateStyle({ borderRadius: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select border radius" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "none", children: "None" }), jsxRuntimeExports.jsx(SelectItem, { value: "rounded", children: "Rounded" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Padding" }), jsxRuntimeExports.jsxs(Select, { value: ((_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.styles) === null || _j === void 0 ? void 0 : _j.padding) || "medium", onValueChange: (value) => updateStyle({ padding: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select padding" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "small", children: "Small" }), jsxRuntimeExports.jsx(SelectItem, { value: "medium", children: "Medium" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Text Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_l = (_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.styles) === null || _l === void 0 ? void 0 : _l.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_o = (_m = localWidget.config) === null || _m === void 0 ? void 0 : _m.styles) === null || _o === void 0 ? void 0 : _o.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Font Size" }), jsxRuntimeExports.jsx(Input, { value: ((_q = (_p = localWidget.config) === null || _p === void 0 ? void 0 : _p.styles) === null || _q === void 0 ? void 0 : _q.fontSize) || "14px", onChange: (e) => updateStyle({ fontSize: e.target.value }), className: "h-8", placeholder: "e.g., 14px, 1rem" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Alignment" }), jsxRuntimeExports.jsxs(Select, { value: ((_s = (_r = localWidget.config) === null || _r === void 0 ? void 0 : _r.styles) === null || _s === void 0 ? void 0 : _s.alignment) || "left", onValueChange: (value) => updateStyle({ alignment: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select alignment" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" })] })] })] })] }));
|
|
1831
1829
|
};
|
|
1832
1830
|
const renderSearchSettings = () => {
|
|
1833
1831
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1834
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Placeholder Text" }), jsxRuntimeExports.jsx(Input, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.placeholder) || "", onChange: (e) => updateConfig({ placeholder: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Minimum Characters" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, max: 10, value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.minCharacters) || 3, onChange: (e) => updateConfig({
|
|
1832
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Placeholder Text" }), jsxRuntimeExports.jsx(Input, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.placeholder) || "", onChange: (e) => updateConfig({ placeholder: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Minimum Characters" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, max: 10, value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.minCharacters) || 3, onChange: (e) => updateConfig({
|
|
1835
1833
|
minCharacters: parseInt(e.target.value) || 3,
|
|
1836
|
-
}), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Search Delay (ms)" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 0, max: 1000, step: 50, value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.searchDelay) || 300, onChange: (e) => updateConfig({
|
|
1834
|
+
}), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Search Delay (ms)" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 0, max: 1000, step: 50, value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.searchDelay) || 300, onChange: (e) => updateConfig({
|
|
1837
1835
|
searchDelay: parseInt(e.target.value) || 300,
|
|
1838
|
-
}), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Auto Focus" }), jsxRuntimeExports.jsx(Switch, { checked: ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.autoFocus) || false, onCheckedChange: (checked) => updateConfig({ autoFocus: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Voice Search" }), jsxRuntimeExports.jsx(Switch, { checked: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.voiceSearch) || false, onCheckedChange: (checked) => updateConfig({ voiceSearch: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Recent Searches" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.recentSearches) || false, onCheckedChange: (checked) => updateConfig({ recentSearches: checked }) })] }), ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.recentSearches) && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Maximum Recent Searches" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, value: ((_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.maxRecentSearches) || 5, onChange: (e) => updateConfig({
|
|
1836
|
+
}), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Auto Focus" }), jsxRuntimeExports.jsx(Switch, { checked: ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.autoFocus) || false, onCheckedChange: (checked) => updateConfig({ autoFocus: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Voice Search" }), jsxRuntimeExports.jsx(Switch, { checked: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.voiceSearch) || false, onCheckedChange: (checked) => updateConfig({ voiceSearch: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Recent Searches" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.recentSearches) || false, onCheckedChange: (checked) => updateConfig({ recentSearches: checked }) })] }), ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.recentSearches) && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Maximum Recent Searches" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, value: ((_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.maxRecentSearches) || 5, onChange: (e) => updateConfig({
|
|
1839
1837
|
maxRecentSearches: parseInt(e.target.value) || 5,
|
|
1840
|
-
}), className: "h-8" })] })), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_l = (_k = (_j = widget.config) === null || _j === void 0 ? void 0 : _j.facets) === null || _k === void 0 ? void 0 : _k.enabled) !== null && _l !== void 0 ? _l : false, onCheckedChange: (checked) => {
|
|
1838
|
+
}), className: "h-8" })] })), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label$1, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_l = (_k = (_j = widget.config) === null || _j === void 0 ? void 0 : _j.facets) === null || _k === void 0 ? void 0 : _k.enabled) !== null && _l !== void 0 ? _l : false, onCheckedChange: (checked) => {
|
|
1841
1839
|
var _a, _b, _c;
|
|
1842
1840
|
const newConfig = Object.assign(Object.assign({}, widget.config), { facets: Object.assign(Object.assign({}, (((_a = widget.config) === null || _a === void 0 ? void 0 : _a.facets) || {})), { enabled: checked, fields: ((_c = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.facets) === null || _c === void 0 ? void 0 : _c.fields) || [] }) });
|
|
1843
1841
|
updateWidgetAPI(widget.id, { config: newConfig }).catch(console.error);
|
|
@@ -1848,29 +1846,29 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1848
1846
|
};
|
|
1849
1847
|
const renderResultsSettings = () => {
|
|
1850
1848
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1851
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Layout Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_b = (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.type) || "list", onValueChange: (value) => {
|
|
1849
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Layout Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_b = (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.type) || "list", onValueChange: (value) => {
|
|
1852
1850
|
var _a;
|
|
1853
1851
|
return updateConfig({
|
|
1854
1852
|
layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { type: value }),
|
|
1855
1853
|
});
|
|
1856
|
-
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select layout type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "grid", children: "Grid" }), jsxRuntimeExports.jsx(SelectItem, { value: "list", children: "List" }), jsxRuntimeExports.jsx(SelectItem, { value: "table", children: "Table" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Items Per Page" }), jsxRuntimeExports.jsxs(Select, { value: String(((_d = (_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.itemsPerPage) || 10), onValueChange: (value) => {
|
|
1854
|
+
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select layout type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "grid", children: "Grid" }), jsxRuntimeExports.jsx(SelectItem, { value: "list", children: "List" }), jsxRuntimeExports.jsx(SelectItem, { value: "table", children: "Table" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Items Per Page" }), jsxRuntimeExports.jsxs(Select, { value: String(((_d = (_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.itemsPerPage) || 10), onValueChange: (value) => {
|
|
1857
1855
|
var _a;
|
|
1858
1856
|
return updateConfig({
|
|
1859
1857
|
layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { itemsPerPage: parseInt(value) }),
|
|
1860
1858
|
});
|
|
1861
|
-
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select items per page" }) }), jsxRuntimeExports.jsx(SelectContent, { children: [5, 10, 20, 50, 100].map((value) => (jsxRuntimeExports.jsxs(SelectItem, { value: String(value), children: [value, " items"] }, value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Infinite Scroll" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = (_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.layout) === null || _f === void 0 ? void 0 : _f.infiniteScroll) || false, onCheckedChange: (checked) => {
|
|
1859
|
+
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select items per page" }) }), jsxRuntimeExports.jsx(SelectContent, { children: [5, 10, 20, 50, 100].map((value) => (jsxRuntimeExports.jsxs(SelectItem, { value: String(value), children: [value, " items"] }, value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Infinite Scroll" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = (_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.layout) === null || _f === void 0 ? void 0 : _f.infiniteScroll) || false, onCheckedChange: (checked) => {
|
|
1862
1860
|
var _a;
|
|
1863
1861
|
return updateConfig({
|
|
1864
1862
|
layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { infiniteScroll: checked }),
|
|
1865
1863
|
});
|
|
1866
|
-
} })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Show Pagination" }), jsxRuntimeExports.jsx(Switch, { checked: ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.showPagination) !== false, onCheckedChange: (checked) => updateConfig({ showPagination: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Hide Relevance" }), jsxRuntimeExports.jsx(Switch, { checked: (_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.hideRelevance) !== null && _j !== void 0 ? _j : false, onCheckedChange: (checked) => updateConfig({ hideRelevance: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsxs(Select, { value: ((_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.titleTemplate) || "filename", onValueChange: (value) => updateConfig({ titleTemplate: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select title template" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => facet.type === "string" && (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Metadata" }), jsxRuntimeExports.jsx(SearchWidgetFacetSettings, { placeHolder: "Select metadata field", value: ((_m = (_l = widget.config) === null || _l === void 0 ? void 0 : _l.metadata) === null || _m === void 0 ? void 0 : _m.fields) || [], onChange: (fields) => {
|
|
1864
|
+
} })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Show Pagination" }), jsxRuntimeExports.jsx(Switch, { checked: ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.showPagination) !== false, onCheckedChange: (checked) => updateConfig({ showPagination: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Hide Relevance" }), jsxRuntimeExports.jsx(Switch, { checked: (_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.hideRelevance) !== null && _j !== void 0 ? _j : false, onCheckedChange: (checked) => updateConfig({ hideRelevance: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsxs(Select, { value: ((_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.titleTemplate) || "filename", onValueChange: (value) => updateConfig({ titleTemplate: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select title template" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => facet.type === "string" && (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Metadata" }), jsxRuntimeExports.jsx(SearchWidgetFacetSettings, { placeHolder: "Select metadata field", value: ((_m = (_l = widget.config) === null || _l === void 0 ? void 0 : _l.metadata) === null || _m === void 0 ? void 0 : _m.fields) || [], onChange: (fields) => {
|
|
1867
1865
|
const newConfig = Object.assign(Object.assign({}, widget.config), { metadata: Object.assign(Object.assign({}, widget.config.metadata), { fields }) });
|
|
1868
1866
|
updateWidgetAPI(widget.id, { config: newConfig }).catch(console.error);
|
|
1869
1867
|
}, maxFields: ((_p = (_o = widget.config) === null || _o === void 0 ? void 0 : _o.facets) === null || _p === void 0 ? void 0 : _p.maxFields) || 10 })] })] }));
|
|
1870
1868
|
};
|
|
1871
1869
|
const renderCodeSettings = () => {
|
|
1872
1870
|
var _a;
|
|
1873
|
-
return (jsxRuntimeExports.jsx("div", { className: "space-y-4", children: jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Custom Widget Code" }), jsxRuntimeExports.jsx(CodeEditor, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.customCode) ||
|
|
1871
|
+
return (jsxRuntimeExports.jsx("div", { className: "space-y-4", children: jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Custom Widget Code" }), jsxRuntimeExports.jsx(CodeEditor, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.customCode) ||
|
|
1874
1872
|
`// Custom search widget code
|
|
1875
1873
|
// You can modify the widget behavior here
|
|
1876
1874
|
function customSearch(query) {
|
|
@@ -1885,7 +1883,7 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1885
1883
|
};
|
|
1886
1884
|
const renderFilterSettings = () => {
|
|
1887
1885
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1888
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Show Clear Button" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showClearButton) !== false, onCheckedChange: (checked) => updateConfig({ showClearButton: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Collapsible Sections" }), jsxRuntimeExports.jsx(Switch, { checked: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.collapsible) !== false, onCheckedChange: (checked) => updateConfig({ collapsible: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Default Expanded" }), jsxRuntimeExports.jsx(Switch, { checked: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.defaultExpanded) !== false, onCheckedChange: (checked) => updateConfig({ defaultExpanded: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_f = (_e = (_d = widget.config) === null || _d === void 0 ? void 0 : _d.facets) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : false, onCheckedChange: (checked) => {
|
|
1886
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Show Clear Button" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showClearButton) !== false, onCheckedChange: (checked) => updateConfig({ showClearButton: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Collapsible Sections" }), jsxRuntimeExports.jsx(Switch, { checked: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.collapsible) !== false, onCheckedChange: (checked) => updateConfig({ collapsible: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Default Expanded" }), jsxRuntimeExports.jsx(Switch, { checked: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.defaultExpanded) !== false, onCheckedChange: (checked) => updateConfig({ defaultExpanded: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label$1, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_f = (_e = (_d = widget.config) === null || _d === void 0 ? void 0 : _d.facets) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : false, onCheckedChange: (checked) => {
|
|
1889
1887
|
var _a, _b, _c;
|
|
1890
1888
|
const newConfig = Object.assign(Object.assign({}, widget.config), { facets: Object.assign(Object.assign({}, (((_a = widget.config) === null || _a === void 0 ? void 0 : _a.facets) || {})), { enabled: checked, fields: ((_c = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.facets) === null || _c === void 0 ? void 0 : _c.fields) || [] }) });
|
|
1891
1889
|
console.log("newConfig", newConfig);
|
|
@@ -1897,14 +1895,14 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1897
1895
|
};
|
|
1898
1896
|
const renderAgentSettings = () => {
|
|
1899
1897
|
var _a, _b, _c, _d, _e;
|
|
1900
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Agent Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.agentType) || "Chatbot Agent", onValueChange: (value) => {
|
|
1898
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Agent Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.agentType) || "Chatbot Agent", onValueChange: (value) => {
|
|
1901
1899
|
const updates = { agentType: value };
|
|
1902
1900
|
// Remove query property when Chatbot Agent is selected
|
|
1903
1901
|
if (value === "Chatbot Agent") {
|
|
1904
1902
|
updates.query = undefined;
|
|
1905
1903
|
}
|
|
1906
1904
|
updateConfig(updates);
|
|
1907
|
-
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select agent type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "Chatbot Agent", children: "Chatbot Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Bar Chart Agent", children: "Bar Chart Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Pie Chart Agent", children: "Pie Chart Agent" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Agent ID" }), agentIds && agentIds.length > 0 ? (jsxRuntimeExports.jsxs(Select, { value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.agentName) || "", onValueChange: (value) => updateConfig({ agentName: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select an agent ID" }) }), jsxRuntimeExports.jsx(SelectContent, { children: agentIds.map((agentId) => (jsxRuntimeExports.jsx(SelectItem, { value: agentId, children: agentId }, agentId))) })] })) : (jsxRuntimeExports.jsx(Input, { value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.agentName) || "", onChange: (e) => updateConfig({ agentName: e.target.value }), className: "h-8", placeholder: "e.g., adk-construction-project-agent" }))] }), ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.agentType) !== "Chatbot Agent" && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Query" }), jsxRuntimeExports.jsx(Input, { value: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.query) || "", onChange: (e) => updateConfig({ query: e.target.value }), className: "h-8", placeholder: "Enter query for the agent..." })] }))] }));
|
|
1905
|
+
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select agent type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "Chatbot Agent", children: "Chatbot Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Bar Chart Agent", children: "Bar Chart Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Pie Chart Agent", children: "Pie Chart Agent" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Agent ID" }), agentIds && agentIds.length > 0 ? (jsxRuntimeExports.jsxs(Select, { value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.agentName) || "", onValueChange: (value) => updateConfig({ agentName: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select an agent ID" }) }), jsxRuntimeExports.jsx(SelectContent, { children: agentIds.map((agentId) => (jsxRuntimeExports.jsx(SelectItem, { value: agentId, children: agentId }, agentId))) })] })) : (jsxRuntimeExports.jsx(Input, { value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.agentName) || "", onChange: (e) => updateConfig({ agentName: e.target.value }), className: "h-8", placeholder: "e.g., adk-construction-project-agent" }))] }), ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.agentType) !== "Chatbot Agent" && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Query" }), jsxRuntimeExports.jsx(Input, { value: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.query) || "", onChange: (e) => updateConfig({ query: e.target.value }), className: "h-8", placeholder: "Enter query for the agent..." })] }))] }));
|
|
1908
1906
|
};
|
|
1909
1907
|
return (jsxRuntimeExports.jsxs("div", { className: "h-full flex flex-col", children: [jsxRuntimeExports.jsx("div", { className: "p-3 border-b flex justify-between items-center", children: jsxRuntimeExports.jsx("h3", { className: "font-medium text-sm", children: "Widget Settings" }) }), error && (jsxRuntimeExports.jsxs(Alert, { variant: "destructive", className: "m-3", children: [jsxRuntimeExports.jsx(lucideReact.AlertCircle, { className: "h-4 w-4" }), jsxRuntimeExports.jsx(AlertDescription, { children: error })] })), jsxRuntimeExports.jsx(ScrollArea, { className: "flex-1", children: jsxRuntimeExports.jsx("div", { className: "p-3", children: jsxRuntimeExports.jsxs(Tabs, { defaultValue: "common", children: [jsxRuntimeExports.jsxs(TabsList, { className: "w-full", children: [jsxRuntimeExports.jsx(TabsTrigger, { value: "common", className: "flex-1", children: "Common" }), localWidget.type === "search" && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TabsTrigger, { value: "search", className: "flex-1", children: "Search" }), jsxRuntimeExports.jsx(TabsTrigger, { value: "code", className: "flex-1", children: "Code" })] })), localWidget.type === "results" && (jsxRuntimeExports.jsx(TabsTrigger, { value: "results", className: "flex-1", children: "Results" })), localWidget.type === "filter" && (jsxRuntimeExports.jsx(TabsTrigger, { value: "filter", className: "flex-1", children: "Filter" })), localWidget.type === "agent" && (jsxRuntimeExports.jsx(TabsTrigger, { value: "agent", className: "flex-1", children: "Agent" }))] }), jsxRuntimeExports.jsxs("div", { className: "mt-4", children: [jsxRuntimeExports.jsx(TabsContent, { value: "common", children: renderCommonSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "search", children: renderSearchSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "results", children: renderResultsSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "filter", children: renderFilterSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "agent", children: renderAgentSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "code", children: renderCodeSettings() })] })] }) }) }), jsxRuntimeExports.jsxs("div", { className: "p-3 border-t flex justify-between gap-2", children: [jsxRuntimeExports.jsx("div", { className: "text-sm text-muted-foreground", children: isAutosaving && "Autosaving..." }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: handleCancel, disabled: isSaving || isAutosaving, children: "Cancel" }), jsxRuntimeExports.jsx(Button, { onClick: handleSave, disabled: isSaving || isAutosaving, children: isSaving ? "Saving..." : "Save Changes" })] })] })] }));
|
|
1910
1908
|
}
|
|
@@ -2216,7 +2214,7 @@ function FacetWidget({ widget, showHeader = true, onConfigUpdate, }) {
|
|
|
2216
2214
|
onConfigUpdate(Object.assign(Object.assign({}, widget.config), { fields: newFields }));
|
|
2217
2215
|
}
|
|
2218
2216
|
};
|
|
2219
|
-
return (jsxRuntimeExports.jsxs(Card, { className: "p-4 h-full", children: [showHeader && jsxRuntimeExports.jsx("h3", { className: "font-medium mb-4", children: "Facet Configuration" }), jsxRuntimeExports.jsx(ScrollArea, { className: "h-[calc(100%-2rem)]", children: jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [fields.map((field, index) => (jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 bg-accent/10 p-2 rounded-md", children: [jsxRuntimeExports.jsxs("div", { className: "flex-1 space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsxs(Label, { children: ["Field ", index + 1] }), jsxRuntimeExports.jsxs(Select, { value: field.field, onValueChange: (value) => updateField(index, value, field.displayName), children: [jsxRuntimeExports.jsx(SelectTrigger, { children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select field" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsx(Label, { children: "Display Name" }), jsxRuntimeExports.jsx(Input, { value: field.displayName, onChange: (e) => updateField(index, field.field, e.target.value), placeholder: "Enter display name" })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "up"), disabled: index === 0, children: jsxRuntimeExports.jsx(lucideReact.ArrowUp, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "down"), disabled: index === fields.length - 1, children: jsxRuntimeExports.jsx(lucideReact.ArrowDown, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => removeField(index), children: jsxRuntimeExports.jsx(lucideReact.Trash2, { className: "h-4 w-4" }) })] })] }, index))), fields.length < (((_b = widget.config) === null || _b === void 0 ? void 0 : _b.maxFields) || 10) && (jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "w-full", onClick: addField, children: [jsxRuntimeExports.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }), "Add Facet"] })), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-destructive mt-2", children: error })] }) })] }));
|
|
2217
|
+
return (jsxRuntimeExports.jsxs(Card, { className: "p-4 h-full", children: [showHeader && jsxRuntimeExports.jsx("h3", { className: "font-medium mb-4", children: "Facet Configuration" }), jsxRuntimeExports.jsx(ScrollArea, { className: "h-[calc(100%-2rem)]", children: jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [fields.map((field, index) => (jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 bg-accent/10 p-2 rounded-md", children: [jsxRuntimeExports.jsxs("div", { className: "flex-1 space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsxs(Label$1, { children: ["Field ", index + 1] }), jsxRuntimeExports.jsxs(Select, { value: field.field, onValueChange: (value) => updateField(index, value, field.displayName), children: [jsxRuntimeExports.jsx(SelectTrigger, { children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select field" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsx(Label$1, { children: "Display Name" }), jsxRuntimeExports.jsx(Input, { value: field.displayName, onChange: (e) => updateField(index, field.field, e.target.value), placeholder: "Enter display name" })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "up"), disabled: index === 0, children: jsxRuntimeExports.jsx(lucideReact.ArrowUp, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "down"), disabled: index === fields.length - 1, children: jsxRuntimeExports.jsx(lucideReact.ArrowDown, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => removeField(index), children: jsxRuntimeExports.jsx(lucideReact.Trash2, { className: "h-4 w-4" }) })] })] }, index))), fields.length < (((_b = widget.config) === null || _b === void 0 ? void 0 : _b.maxFields) || 10) && (jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "w-full", onClick: addField, children: [jsxRuntimeExports.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }), "Add Facet"] })), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-destructive mt-2", children: error })] }) })] }));
|
|
2220
2218
|
}
|
|
2221
2219
|
|
|
2222
2220
|
// src/graphql/@generated/graphql.ts
|
|
@@ -3919,7 +3917,7 @@ function set(root, scope, values) {
|
|
|
3919
3917
|
appliers.forEach((apply)=>apply(this));
|
|
3920
3918
|
}
|
|
3921
3919
|
}
|
|
3922
|
-
var defaults = /* #__PURE__ */ new Defaults({
|
|
3920
|
+
var defaults$1 = /* #__PURE__ */ new Defaults({
|
|
3923
3921
|
_scriptable: (name)=>!name.startsWith('on'),
|
|
3924
3922
|
_indexable: (name)=>name !== 'events',
|
|
3925
3923
|
hover: {
|
|
@@ -3940,7 +3938,7 @@ var defaults = /* #__PURE__ */ new Defaults({
|
|
|
3940
3938
|
* @param font - A font object.
|
|
3941
3939
|
* @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
|
|
3942
3940
|
* @private
|
|
3943
|
-
*/ function toFontString(font) {
|
|
3941
|
+
*/ function toFontString$1(font) {
|
|
3944
3942
|
if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
|
|
3945
3943
|
return null;
|
|
3946
3944
|
}
|
|
@@ -4351,7 +4349,7 @@ function _readValueToProps(value, props) {
|
|
|
4351
4349
|
* @private
|
|
4352
4350
|
*/ function toFont(options, fallback) {
|
|
4353
4351
|
options = options || {};
|
|
4354
|
-
fallback = fallback || defaults.font;
|
|
4352
|
+
fallback = fallback || defaults$1.font;
|
|
4355
4353
|
let size = valueOrDefault(options.size, fallback.size);
|
|
4356
4354
|
if (typeof size === 'string') {
|
|
4357
4355
|
size = parseInt(size, 10);
|
|
@@ -4369,7 +4367,7 @@ function _readValueToProps(value, props) {
|
|
|
4369
4367
|
weight: valueOrDefault(options.weight, fallback.weight),
|
|
4370
4368
|
string: ''
|
|
4371
4369
|
};
|
|
4372
|
-
font.string = toFontString(font);
|
|
4370
|
+
font.string = toFontString$1(font);
|
|
4373
4371
|
return font;
|
|
4374
4372
|
}
|
|
4375
4373
|
/**
|
|
@@ -4389,6 +4387,12 @@ function _readValueToProps(value, props) {
|
|
|
4389
4387
|
if (value === undefined) {
|
|
4390
4388
|
continue;
|
|
4391
4389
|
}
|
|
4390
|
+
if (context !== undefined && typeof value === 'function') {
|
|
4391
|
+
value = value(context);
|
|
4392
|
+
}
|
|
4393
|
+
if (index !== undefined && isArray(value)) {
|
|
4394
|
+
value = value[index % value.length];
|
|
4395
|
+
}
|
|
4392
4396
|
if (value !== undefined) {
|
|
4393
4397
|
return value;
|
|
4394
4398
|
}
|
|
@@ -5796,7 +5800,7 @@ class Animations {
|
|
|
5796
5800
|
if (!isObject(config)) {
|
|
5797
5801
|
return;
|
|
5798
5802
|
}
|
|
5799
|
-
const animationOptions = Object.keys(defaults.animation);
|
|
5803
|
+
const animationOptions = Object.keys(defaults$1.animation);
|
|
5800
5804
|
const animatedProps = this._properties;
|
|
5801
5805
|
Object.getOwnPropertyNames(config).forEach((key)=>{
|
|
5802
5806
|
const cfg = config[key];
|
|
@@ -6494,7 +6498,7 @@ class DatasetController {
|
|
|
6494
6498
|
''
|
|
6495
6499
|
];
|
|
6496
6500
|
const scopes = config.getOptionScopes(this.getDataset(), scopeKeys);
|
|
6497
|
-
const names = Object.keys(defaults.elements[elementType]);
|
|
6501
|
+
const names = Object.keys(defaults$1.elements[elementType]);
|
|
6498
6502
|
const context = ()=>this.getContext(index, active, mode);
|
|
6499
6503
|
const values = config.resolveNamedOptions(scopes, names, context, prefixes);
|
|
6500
6504
|
if (values.$shared) {
|
|
@@ -8252,7 +8256,7 @@ class BasicPlatform extends BasePlatform {
|
|
|
8252
8256
|
}
|
|
8253
8257
|
}
|
|
8254
8258
|
|
|
8255
|
-
const EXPANDO_KEY = '$chartjs';
|
|
8259
|
+
const EXPANDO_KEY$1 = '$chartjs';
|
|
8256
8260
|
const EVENT_TYPES = {
|
|
8257
8261
|
touchstart: 'mousedown',
|
|
8258
8262
|
touchmove: 'mousemove',
|
|
@@ -8269,7 +8273,7 @@ const isNullOrEmpty = (value)=>value === null || value === '';
|
|
|
8269
8273
|
const style = canvas.style;
|
|
8270
8274
|
const renderHeight = canvas.getAttribute('height');
|
|
8271
8275
|
const renderWidth = canvas.getAttribute('width');
|
|
8272
|
-
canvas[EXPANDO_KEY] = {
|
|
8276
|
+
canvas[EXPANDO_KEY$1] = {
|
|
8273
8277
|
initial: {
|
|
8274
8278
|
height: renderHeight,
|
|
8275
8279
|
width: renderWidth,
|
|
@@ -8448,10 +8452,10 @@ function createProxyAndListen(chart, type, listener) {
|
|
|
8448
8452
|
}
|
|
8449
8453
|
releaseContext(context) {
|
|
8450
8454
|
const canvas = context.canvas;
|
|
8451
|
-
if (!canvas[EXPANDO_KEY]) {
|
|
8455
|
+
if (!canvas[EXPANDO_KEY$1]) {
|
|
8452
8456
|
return false;
|
|
8453
8457
|
}
|
|
8454
|
-
const initial = canvas[EXPANDO_KEY].initial;
|
|
8458
|
+
const initial = canvas[EXPANDO_KEY$1].initial;
|
|
8455
8459
|
[
|
|
8456
8460
|
'height',
|
|
8457
8461
|
'width'
|
|
@@ -8468,7 +8472,7 @@ function createProxyAndListen(chart, type, listener) {
|
|
|
8468
8472
|
canvas.style[key] = style[key];
|
|
8469
8473
|
});
|
|
8470
8474
|
canvas.width = canvas.width;
|
|
8471
|
-
delete canvas[EXPANDO_KEY];
|
|
8475
|
+
delete canvas[EXPANDO_KEY$1];
|
|
8472
8476
|
return true;
|
|
8473
8477
|
}
|
|
8474
8478
|
addEventListener(chart, type, listener) {
|
|
@@ -9960,7 +9964,7 @@ class TypedRegistry {
|
|
|
9960
9964
|
items[id] = item;
|
|
9961
9965
|
registerDefaults(item, scope, parentScope);
|
|
9962
9966
|
if (this.override) {
|
|
9963
|
-
defaults.override(item.id, item.overrides);
|
|
9967
|
+
defaults$1.override(item.id, item.overrides);
|
|
9964
9968
|
}
|
|
9965
9969
|
return scope;
|
|
9966
9970
|
}
|
|
@@ -9974,8 +9978,8 @@ class TypedRegistry {
|
|
|
9974
9978
|
if (id in items) {
|
|
9975
9979
|
delete items[id];
|
|
9976
9980
|
}
|
|
9977
|
-
if (scope && id in defaults[scope]) {
|
|
9978
|
-
delete defaults[scope][id];
|
|
9981
|
+
if (scope && id in defaults$1[scope]) {
|
|
9982
|
+
delete defaults$1[scope][id];
|
|
9979
9983
|
if (this.override) {
|
|
9980
9984
|
delete overrides[id];
|
|
9981
9985
|
}
|
|
@@ -9984,16 +9988,16 @@ class TypedRegistry {
|
|
|
9984
9988
|
}
|
|
9985
9989
|
function registerDefaults(item, scope, parentScope) {
|
|
9986
9990
|
const itemDefaults = merge$1(Object.create(null), [
|
|
9987
|
-
parentScope ? defaults.get(parentScope) : {},
|
|
9988
|
-
defaults.get(scope),
|
|
9991
|
+
parentScope ? defaults$1.get(parentScope) : {},
|
|
9992
|
+
defaults$1.get(scope),
|
|
9989
9993
|
item.defaults
|
|
9990
9994
|
]);
|
|
9991
|
-
defaults.set(scope, itemDefaults);
|
|
9995
|
+
defaults$1.set(scope, itemDefaults);
|
|
9992
9996
|
if (item.defaultRoutes) {
|
|
9993
9997
|
routeDefaults(scope, item.defaultRoutes);
|
|
9994
9998
|
}
|
|
9995
9999
|
if (item.descriptors) {
|
|
9996
|
-
defaults.describe(scope, item.descriptors);
|
|
10000
|
+
defaults$1.describe(scope, item.descriptors);
|
|
9997
10001
|
}
|
|
9998
10002
|
}
|
|
9999
10003
|
function routeDefaults(scope, routes) {
|
|
@@ -10006,7 +10010,7 @@ function routeDefaults(scope, routes) {
|
|
|
10006
10010
|
const parts = routes[property].split('.');
|
|
10007
10011
|
const targetName = parts.pop();
|
|
10008
10012
|
const targetScope = parts.join('.');
|
|
10009
|
-
defaults.route(sourceScope, sourceName, targetScope, targetName);
|
|
10013
|
+
defaults$1.route(sourceScope, sourceName, targetScope, targetName);
|
|
10010
10014
|
});
|
|
10011
10015
|
}
|
|
10012
10016
|
function isIChartComponent(proto) {
|
|
@@ -10232,7 +10236,7 @@ function pluginOpts(config, { plugin , local }, opts, context) {
|
|
|
10232
10236
|
}
|
|
10233
10237
|
|
|
10234
10238
|
function getIndexAxis(type, options) {
|
|
10235
|
-
const datasetDefaults = defaults.datasets[type] || {};
|
|
10239
|
+
const datasetDefaults = defaults$1.datasets[type] || {};
|
|
10236
10240
|
const datasetOptions = (options.datasets || {})[type] || {};
|
|
10237
10241
|
return datasetOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || 'x';
|
|
10238
10242
|
}
|
|
@@ -10304,7 +10308,7 @@ function mergeScaleConfig(config, options) {
|
|
|
10304
10308
|
if (scaleConf._proxy) {
|
|
10305
10309
|
return console.warn(`Ignoring resolver passed as options for scale: ${id}`);
|
|
10306
10310
|
}
|
|
10307
|
-
const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults.scales[scaleConf.type]);
|
|
10311
|
+
const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults$1.scales[scaleConf.type]);
|
|
10308
10312
|
const defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);
|
|
10309
10313
|
const defaultScaleOptions = chartDefaults.scales || {};
|
|
10310
10314
|
scales[id] = mergeIf(Object.create(null), [
|
|
@@ -10337,8 +10341,8 @@ function mergeScaleConfig(config, options) {
|
|
|
10337
10341
|
Object.keys(scales).forEach((key)=>{
|
|
10338
10342
|
const scale = scales[key];
|
|
10339
10343
|
mergeIf(scale, [
|
|
10340
|
-
defaults.scales[scale.type],
|
|
10341
|
-
defaults.scale
|
|
10344
|
+
defaults$1.scales[scale.type],
|
|
10345
|
+
defaults$1.scale
|
|
10342
10346
|
]);
|
|
10343
10347
|
});
|
|
10344
10348
|
return scales;
|
|
@@ -10480,7 +10484,7 @@ class Config {
|
|
|
10480
10484
|
}
|
|
10481
10485
|
keys.forEach((key)=>addIfFound(scopes, options, key));
|
|
10482
10486
|
keys.forEach((key)=>addIfFound(scopes, overrides[type] || {}, key));
|
|
10483
|
-
keys.forEach((key)=>addIfFound(scopes, defaults, key));
|
|
10487
|
+
keys.forEach((key)=>addIfFound(scopes, defaults$1, key));
|
|
10484
10488
|
keys.forEach((key)=>addIfFound(scopes, descriptors, key));
|
|
10485
10489
|
});
|
|
10486
10490
|
const array = Array.from(scopes);
|
|
@@ -10497,11 +10501,11 @@ class Config {
|
|
|
10497
10501
|
return [
|
|
10498
10502
|
options,
|
|
10499
10503
|
overrides[type] || {},
|
|
10500
|
-
defaults.datasets[type] || {},
|
|
10504
|
+
defaults$1.datasets[type] || {},
|
|
10501
10505
|
{
|
|
10502
10506
|
type
|
|
10503
10507
|
},
|
|
10504
|
-
defaults,
|
|
10508
|
+
defaults$1,
|
|
10505
10509
|
descriptors
|
|
10506
10510
|
];
|
|
10507
10511
|
}
|
|
@@ -10634,7 +10638,7 @@ function moveNumericKeys(obj, start, move) {
|
|
|
10634
10638
|
return e;
|
|
10635
10639
|
}
|
|
10636
10640
|
let Chart$1 = class Chart {
|
|
10637
|
-
static defaults = defaults;
|
|
10641
|
+
static defaults = defaults$1;
|
|
10638
10642
|
static instances = instances;
|
|
10639
10643
|
static overrides = overrides;
|
|
10640
10644
|
static registry = registry;
|
|
@@ -10892,7 +10896,7 @@ let Chart$1 = class Chart {
|
|
|
10892
10896
|
meta.controller.linkScales();
|
|
10893
10897
|
} else {
|
|
10894
10898
|
const ControllerClass = registry.getController(type);
|
|
10895
|
-
const { datasetElementType , dataElementType } = defaults.datasets[type];
|
|
10899
|
+
const { datasetElementType , dataElementType } = defaults$1.datasets[type];
|
|
10896
10900
|
Object.assign(ControllerClass, {
|
|
10897
10901
|
dataElementType: registry.getElement(dataElementType),
|
|
10898
10902
|
datasetElementType: datasetElementType && registry.getElement(datasetElementType)
|
|
@@ -12225,7 +12229,7 @@ function parseBorderRadius(bar, maxW, maxH) {
|
|
|
12225
12229
|
bottomRight: skipOrLimit(!enableBorder || skip.bottom || skip.right, o.bottomRight, 0, maxR)
|
|
12226
12230
|
};
|
|
12227
12231
|
}
|
|
12228
|
-
function boundingRects(bar) {
|
|
12232
|
+
function boundingRects$1(bar) {
|
|
12229
12233
|
const bounds = getBarBounds(bar);
|
|
12230
12234
|
const width = bounds.right - bounds.left;
|
|
12231
12235
|
const height = bounds.bottom - bounds.top;
|
|
@@ -12306,7 +12310,7 @@ class BarElement extends Element {
|
|
|
12306
12310
|
}
|
|
12307
12311
|
draw(ctx) {
|
|
12308
12312
|
const { inflateAmount , options: { borderColor , backgroundColor } } = this;
|
|
12309
|
-
const { inner , outer } = boundingRects(this);
|
|
12313
|
+
const { inner , outer } = boundingRects$1(this);
|
|
12310
12314
|
const addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath;
|
|
12311
12315
|
ctx.save();
|
|
12312
12316
|
if (outer.w !== inner.w || outer.h !== inner.h) {
|
|
@@ -12564,7 +12568,7 @@ class Legend extends Element {
|
|
|
12564
12568
|
_draw() {
|
|
12565
12569
|
const { options: opts , columnSizes , lineWidths , ctx } = this;
|
|
12566
12570
|
const { align , labels: labelOpts } = opts;
|
|
12567
|
-
const defaultColor = defaults.color;
|
|
12571
|
+
const defaultColor = defaults$1.color;
|
|
12568
12572
|
const rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);
|
|
12569
12573
|
const labelFont = toFont(labelOpts.font);
|
|
12570
12574
|
const { padding } = labelOpts;
|
|
@@ -13038,7 +13042,7 @@ var plugin_title = {
|
|
|
13038
13042
|
}
|
|
13039
13043
|
};
|
|
13040
13044
|
|
|
13041
|
-
const positioners = {
|
|
13045
|
+
const positioners$2 = {
|
|
13042
13046
|
average (items) {
|
|
13043
13047
|
if (!items.length) {
|
|
13044
13048
|
return false;
|
|
@@ -13353,7 +13357,7 @@ const defaultCallbacks = {
|
|
|
13353
13357
|
return result;
|
|
13354
13358
|
}
|
|
13355
13359
|
class Tooltip extends Element {
|
|
13356
|
-
static positioners = positioners;
|
|
13360
|
+
static positioners = positioners$2;
|
|
13357
13361
|
constructor(config){
|
|
13358
13362
|
super();
|
|
13359
13363
|
this.opacity = 0;
|
|
@@ -13492,7 +13496,7 @@ class Tooltip extends Element {
|
|
|
13492
13496
|
};
|
|
13493
13497
|
}
|
|
13494
13498
|
} else {
|
|
13495
|
-
const position = positioners[options.position].call(this, active, this._eventPosition);
|
|
13499
|
+
const position = positioners$2[options.position].call(this, active, this._eventPosition);
|
|
13496
13500
|
tooltipItems = this._createItems(options);
|
|
13497
13501
|
this.title = this.getTitle(tooltipItems, options);
|
|
13498
13502
|
this.beforeBody = this.getBeforeBody(tooltipItems, options);
|
|
@@ -13773,7 +13777,7 @@ class Tooltip extends Element {
|
|
|
13773
13777
|
const animX = anims && anims.x;
|
|
13774
13778
|
const animY = anims && anims.y;
|
|
13775
13779
|
if (animX || animY) {
|
|
13776
|
-
const position = positioners[options.position].call(this, this._active, this._eventPosition);
|
|
13780
|
+
const position = positioners$2[options.position].call(this, this._active, this._eventPosition);
|
|
13777
13781
|
if (!position) {
|
|
13778
13782
|
return;
|
|
13779
13783
|
}
|
|
@@ -13889,14 +13893,14 @@ class Tooltip extends Element {
|
|
|
13889
13893
|
}
|
|
13890
13894
|
_positionChanged(active, e) {
|
|
13891
13895
|
const { caretX , caretY , options } = this;
|
|
13892
|
-
const position = positioners[options.position].call(this, active, e);
|
|
13896
|
+
const position = positioners$2[options.position].call(this, active, e);
|
|
13893
13897
|
return position !== false && (caretX !== position.x || caretY !== position.y);
|
|
13894
13898
|
}
|
|
13895
13899
|
}
|
|
13896
13900
|
var plugin_tooltip = {
|
|
13897
13901
|
id: 'tooltip',
|
|
13898
13902
|
_element: Tooltip,
|
|
13899
|
-
positioners,
|
|
13903
|
+
positioners: positioners$2,
|
|
13900
13904
|
afterInit (chart, _args, options) {
|
|
13901
13905
|
if (options) {
|
|
13902
13906
|
chart.tooltip = new Tooltip({
|
|
@@ -15163,9 +15167,10 @@ function BarChart({ orientation, title, data, options, className, units, content
|
|
|
15163
15167
|
|
|
15164
15168
|
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15165
15169
|
function SeriesChart({ orientation, title, data, options, className, units, content }) {
|
|
15170
|
+
var _a, _b;
|
|
15166
15171
|
const formatValue = (value) => {
|
|
15167
15172
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15168
|
-
if (
|
|
15173
|
+
if (!isNaN(numValue)) {
|
|
15169
15174
|
return numValue.toLocaleString();
|
|
15170
15175
|
}
|
|
15171
15176
|
return value;
|
|
@@ -15190,6 +15195,14 @@ function SeriesChart({ orientation, title, data, options, className, units, cont
|
|
|
15190
15195
|
});
|
|
15191
15196
|
},
|
|
15192
15197
|
};
|
|
15198
|
+
const getAxisLabel = (symbol) => {
|
|
15199
|
+
const labelMap = {
|
|
15200
|
+
"%": "Percentage",
|
|
15201
|
+
"$": "Cost",
|
|
15202
|
+
"#": "Count",
|
|
15203
|
+
};
|
|
15204
|
+
return labelMap[symbol] || symbol; // fallback if not found
|
|
15205
|
+
};
|
|
15193
15206
|
const defaultOptions = {
|
|
15194
15207
|
responsive: true,
|
|
15195
15208
|
maintainAspectRatio: false,
|
|
@@ -15204,7 +15217,13 @@ function SeriesChart({ orientation, title, data, options, className, units, cont
|
|
|
15204
15217
|
},
|
|
15205
15218
|
plugins: {
|
|
15206
15219
|
legend: {
|
|
15207
|
-
display:
|
|
15220
|
+
display: (ctx) => {
|
|
15221
|
+
const chart = ctx.chart;
|
|
15222
|
+
const datasets = chart.data.datasets;
|
|
15223
|
+
if (datasets.length > 1)
|
|
15224
|
+
return true;
|
|
15225
|
+
return false;
|
|
15226
|
+
},
|
|
15208
15227
|
labels: {
|
|
15209
15228
|
boxWidth: 12,
|
|
15210
15229
|
boxHeight: 12,
|
|
@@ -15237,13 +15256,17 @@ function SeriesChart({ orientation, title, data, options, className, units, cont
|
|
|
15237
15256
|
ticks: { autoSkip: false, maxRotation: 45, minRotation: 0 },
|
|
15238
15257
|
},
|
|
15239
15258
|
y: {
|
|
15259
|
+
title: {
|
|
15260
|
+
display: true,
|
|
15261
|
+
text: (data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : ""),
|
|
15262
|
+
},
|
|
15240
15263
|
beginAtZero: true,
|
|
15241
15264
|
ticks: {
|
|
15242
15265
|
callback: function (value) {
|
|
15243
15266
|
if (units === '$') {
|
|
15244
15267
|
return `${units}${formatValue(value)}`;
|
|
15245
15268
|
}
|
|
15246
|
-
return units ? `${formatValue(value)} ${units}` : value;
|
|
15269
|
+
return units ? `${formatValue(value)} ${(units === null || units === void 0 ? void 0 : units.length) < 3 ? units : ""}` : value;
|
|
15247
15270
|
}
|
|
15248
15271
|
}
|
|
15249
15272
|
},
|
|
@@ -15252,15 +15275,1372 @@ function SeriesChart({ orientation, title, data, options, className, units, cont
|
|
|
15252
15275
|
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [barValuePlugin] }));
|
|
15253
15276
|
}
|
|
15254
15277
|
|
|
15278
|
+
/*!
|
|
15279
|
+
* chartjs-plugin-datalabels v2.2.0
|
|
15280
|
+
* https://chartjs-plugin-datalabels.netlify.app
|
|
15281
|
+
* (c) 2017-2022 chartjs-plugin-datalabels contributors
|
|
15282
|
+
* Released under the MIT license
|
|
15283
|
+
*/
|
|
15284
|
+
|
|
15285
|
+
var devicePixelRatio = (function() {
|
|
15286
|
+
if (typeof window !== 'undefined') {
|
|
15287
|
+
if (window.devicePixelRatio) {
|
|
15288
|
+
return window.devicePixelRatio;
|
|
15289
|
+
}
|
|
15290
|
+
|
|
15291
|
+
// devicePixelRatio is undefined on IE10
|
|
15292
|
+
// https://stackoverflow.com/a/20204180/8837887
|
|
15293
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/85
|
|
15294
|
+
var screen = window.screen;
|
|
15295
|
+
if (screen) {
|
|
15296
|
+
return (screen.deviceXDPI || 1) / (screen.logicalXDPI || 1);
|
|
15297
|
+
}
|
|
15298
|
+
}
|
|
15299
|
+
|
|
15300
|
+
return 1;
|
|
15301
|
+
}());
|
|
15302
|
+
|
|
15303
|
+
var utils = {
|
|
15304
|
+
// @todo move this in Chart.helpers.toTextLines
|
|
15305
|
+
toTextLines: function(inputs) {
|
|
15306
|
+
var lines = [];
|
|
15307
|
+
var input;
|
|
15308
|
+
|
|
15309
|
+
inputs = [].concat(inputs);
|
|
15310
|
+
while (inputs.length) {
|
|
15311
|
+
input = inputs.pop();
|
|
15312
|
+
if (typeof input === 'string') {
|
|
15313
|
+
lines.unshift.apply(lines, input.split('\n'));
|
|
15314
|
+
} else if (Array.isArray(input)) {
|
|
15315
|
+
inputs.push.apply(inputs, input);
|
|
15316
|
+
} else if (!isNullOrUndef(inputs)) {
|
|
15317
|
+
lines.unshift('' + input);
|
|
15318
|
+
}
|
|
15319
|
+
}
|
|
15320
|
+
|
|
15321
|
+
return lines;
|
|
15322
|
+
},
|
|
15323
|
+
|
|
15324
|
+
// @todo move this in Chart.helpers.canvas.textSize
|
|
15325
|
+
// @todo cache calls of measureText if font doesn't change?!
|
|
15326
|
+
textSize: function(ctx, lines, font) {
|
|
15327
|
+
var items = [].concat(lines);
|
|
15328
|
+
var ilen = items.length;
|
|
15329
|
+
var prev = ctx.font;
|
|
15330
|
+
var width = 0;
|
|
15331
|
+
var i;
|
|
15332
|
+
|
|
15333
|
+
ctx.font = font.string;
|
|
15334
|
+
|
|
15335
|
+
for (i = 0; i < ilen; ++i) {
|
|
15336
|
+
width = Math.max(ctx.measureText(items[i]).width, width);
|
|
15337
|
+
}
|
|
15338
|
+
|
|
15339
|
+
ctx.font = prev;
|
|
15340
|
+
|
|
15341
|
+
return {
|
|
15342
|
+
height: ilen * font.lineHeight,
|
|
15343
|
+
width: width
|
|
15344
|
+
};
|
|
15345
|
+
},
|
|
15346
|
+
|
|
15347
|
+
/**
|
|
15348
|
+
* Returns value bounded by min and max. This is equivalent to max(min, min(value, max)).
|
|
15349
|
+
* @todo move this method in Chart.helpers.bound
|
|
15350
|
+
* https://doc.qt.io/qt-5/qtglobal.html#qBound
|
|
15351
|
+
*/
|
|
15352
|
+
bound: function(min, value, max) {
|
|
15353
|
+
return Math.max(min, Math.min(value, max));
|
|
15354
|
+
},
|
|
15355
|
+
|
|
15356
|
+
/**
|
|
15357
|
+
* Returns an array of pair [value, state] where state is:
|
|
15358
|
+
* * -1: value is only in a0 (removed)
|
|
15359
|
+
* * 1: value is only in a1 (added)
|
|
15360
|
+
*/
|
|
15361
|
+
arrayDiff: function(a0, a1) {
|
|
15362
|
+
var prev = a0.slice();
|
|
15363
|
+
var updates = [];
|
|
15364
|
+
var i, j, ilen, v;
|
|
15365
|
+
|
|
15366
|
+
for (i = 0, ilen = a1.length; i < ilen; ++i) {
|
|
15367
|
+
v = a1[i];
|
|
15368
|
+
j = prev.indexOf(v);
|
|
15369
|
+
|
|
15370
|
+
if (j === -1) {
|
|
15371
|
+
updates.push([v, 1]);
|
|
15372
|
+
} else {
|
|
15373
|
+
prev.splice(j, 1);
|
|
15374
|
+
}
|
|
15375
|
+
}
|
|
15376
|
+
|
|
15377
|
+
for (i = 0, ilen = prev.length; i < ilen; ++i) {
|
|
15378
|
+
updates.push([prev[i], -1]);
|
|
15379
|
+
}
|
|
15380
|
+
|
|
15381
|
+
return updates;
|
|
15382
|
+
},
|
|
15383
|
+
|
|
15384
|
+
/**
|
|
15385
|
+
* https://github.com/chartjs/chartjs-plugin-datalabels/issues/70
|
|
15386
|
+
*/
|
|
15387
|
+
rasterize: function(v) {
|
|
15388
|
+
return Math.round(v * devicePixelRatio) / devicePixelRatio;
|
|
15389
|
+
}
|
|
15390
|
+
};
|
|
15391
|
+
|
|
15392
|
+
function orient(point, origin) {
|
|
15393
|
+
var x0 = origin.x;
|
|
15394
|
+
var y0 = origin.y;
|
|
15395
|
+
|
|
15396
|
+
if (x0 === null) {
|
|
15397
|
+
return {x: 0, y: -1};
|
|
15398
|
+
}
|
|
15399
|
+
if (y0 === null) {
|
|
15400
|
+
return {x: 1, y: 0};
|
|
15401
|
+
}
|
|
15402
|
+
|
|
15403
|
+
var dx = point.x - x0;
|
|
15404
|
+
var dy = point.y - y0;
|
|
15405
|
+
var ln = Math.sqrt(dx * dx + dy * dy);
|
|
15406
|
+
|
|
15407
|
+
return {
|
|
15408
|
+
x: ln ? dx / ln : 0,
|
|
15409
|
+
y: ln ? dy / ln : -1
|
|
15410
|
+
};
|
|
15411
|
+
}
|
|
15412
|
+
|
|
15413
|
+
function aligned(x, y, vx, vy, align) {
|
|
15414
|
+
switch (align) {
|
|
15415
|
+
case 'center':
|
|
15416
|
+
vx = vy = 0;
|
|
15417
|
+
break;
|
|
15418
|
+
case 'bottom':
|
|
15419
|
+
vx = 0;
|
|
15420
|
+
vy = 1;
|
|
15421
|
+
break;
|
|
15422
|
+
case 'right':
|
|
15423
|
+
vx = 1;
|
|
15424
|
+
vy = 0;
|
|
15425
|
+
break;
|
|
15426
|
+
case 'left':
|
|
15427
|
+
vx = -1;
|
|
15428
|
+
vy = 0;
|
|
15429
|
+
break;
|
|
15430
|
+
case 'top':
|
|
15431
|
+
vx = 0;
|
|
15432
|
+
vy = -1;
|
|
15433
|
+
break;
|
|
15434
|
+
case 'start':
|
|
15435
|
+
vx = -vx;
|
|
15436
|
+
vy = -vy;
|
|
15437
|
+
break;
|
|
15438
|
+
case 'end':
|
|
15439
|
+
// keep natural orientation
|
|
15440
|
+
break;
|
|
15441
|
+
default:
|
|
15442
|
+
// clockwise rotation (in degree)
|
|
15443
|
+
align *= (Math.PI / 180);
|
|
15444
|
+
vx = Math.cos(align);
|
|
15445
|
+
vy = Math.sin(align);
|
|
15446
|
+
break;
|
|
15447
|
+
}
|
|
15448
|
+
|
|
15449
|
+
return {
|
|
15450
|
+
x: x,
|
|
15451
|
+
y: y,
|
|
15452
|
+
vx: vx,
|
|
15453
|
+
vy: vy
|
|
15454
|
+
};
|
|
15455
|
+
}
|
|
15456
|
+
|
|
15457
|
+
// Line clipping (Cohen–Sutherland algorithm)
|
|
15458
|
+
// https://en.wikipedia.org/wiki/Cohen–Sutherland_algorithm
|
|
15459
|
+
|
|
15460
|
+
var R_INSIDE = 0;
|
|
15461
|
+
var R_LEFT = 1;
|
|
15462
|
+
var R_RIGHT = 2;
|
|
15463
|
+
var R_BOTTOM = 4;
|
|
15464
|
+
var R_TOP = 8;
|
|
15465
|
+
|
|
15466
|
+
function region(x, y, rect) {
|
|
15467
|
+
var res = R_INSIDE;
|
|
15468
|
+
|
|
15469
|
+
if (x < rect.left) {
|
|
15470
|
+
res |= R_LEFT;
|
|
15471
|
+
} else if (x > rect.right) {
|
|
15472
|
+
res |= R_RIGHT;
|
|
15473
|
+
}
|
|
15474
|
+
if (y < rect.top) {
|
|
15475
|
+
res |= R_TOP;
|
|
15476
|
+
} else if (y > rect.bottom) {
|
|
15477
|
+
res |= R_BOTTOM;
|
|
15478
|
+
}
|
|
15479
|
+
|
|
15480
|
+
return res;
|
|
15481
|
+
}
|
|
15482
|
+
|
|
15483
|
+
function clipped(segment, area) {
|
|
15484
|
+
var x0 = segment.x0;
|
|
15485
|
+
var y0 = segment.y0;
|
|
15486
|
+
var x1 = segment.x1;
|
|
15487
|
+
var y1 = segment.y1;
|
|
15488
|
+
var r0 = region(x0, y0, area);
|
|
15489
|
+
var r1 = region(x1, y1, area);
|
|
15490
|
+
var r, x, y;
|
|
15491
|
+
|
|
15492
|
+
// eslint-disable-next-line no-constant-condition
|
|
15493
|
+
while (true) {
|
|
15494
|
+
if (!(r0 | r1) || (r0 & r1)) {
|
|
15495
|
+
// both points inside or on the same side: no clipping
|
|
15496
|
+
break;
|
|
15497
|
+
}
|
|
15498
|
+
|
|
15499
|
+
// at least one point is outside
|
|
15500
|
+
r = r0 || r1;
|
|
15501
|
+
|
|
15502
|
+
if (r & R_TOP) {
|
|
15503
|
+
x = x0 + (x1 - x0) * (area.top - y0) / (y1 - y0);
|
|
15504
|
+
y = area.top;
|
|
15505
|
+
} else if (r & R_BOTTOM) {
|
|
15506
|
+
x = x0 + (x1 - x0) * (area.bottom - y0) / (y1 - y0);
|
|
15507
|
+
y = area.bottom;
|
|
15508
|
+
} else if (r & R_RIGHT) {
|
|
15509
|
+
y = y0 + (y1 - y0) * (area.right - x0) / (x1 - x0);
|
|
15510
|
+
x = area.right;
|
|
15511
|
+
} else if (r & R_LEFT) {
|
|
15512
|
+
y = y0 + (y1 - y0) * (area.left - x0) / (x1 - x0);
|
|
15513
|
+
x = area.left;
|
|
15514
|
+
}
|
|
15515
|
+
|
|
15516
|
+
if (r === r0) {
|
|
15517
|
+
x0 = x;
|
|
15518
|
+
y0 = y;
|
|
15519
|
+
r0 = region(x0, y0, area);
|
|
15520
|
+
} else {
|
|
15521
|
+
x1 = x;
|
|
15522
|
+
y1 = y;
|
|
15523
|
+
r1 = region(x1, y1, area);
|
|
15524
|
+
}
|
|
15525
|
+
}
|
|
15526
|
+
|
|
15527
|
+
return {
|
|
15528
|
+
x0: x0,
|
|
15529
|
+
x1: x1,
|
|
15530
|
+
y0: y0,
|
|
15531
|
+
y1: y1
|
|
15532
|
+
};
|
|
15533
|
+
}
|
|
15534
|
+
|
|
15535
|
+
function compute$1(range, config) {
|
|
15536
|
+
var anchor = config.anchor;
|
|
15537
|
+
var segment = range;
|
|
15538
|
+
var x, y;
|
|
15539
|
+
|
|
15540
|
+
if (config.clamp) {
|
|
15541
|
+
segment = clipped(segment, config.area);
|
|
15542
|
+
}
|
|
15543
|
+
|
|
15544
|
+
if (anchor === 'start') {
|
|
15545
|
+
x = segment.x0;
|
|
15546
|
+
y = segment.y0;
|
|
15547
|
+
} else if (anchor === 'end') {
|
|
15548
|
+
x = segment.x1;
|
|
15549
|
+
y = segment.y1;
|
|
15550
|
+
} else {
|
|
15551
|
+
x = (segment.x0 + segment.x1) / 2;
|
|
15552
|
+
y = (segment.y0 + segment.y1) / 2;
|
|
15553
|
+
}
|
|
15554
|
+
|
|
15555
|
+
return aligned(x, y, range.vx, range.vy, config.align);
|
|
15556
|
+
}
|
|
15557
|
+
|
|
15558
|
+
var positioners$1 = {
|
|
15559
|
+
arc: function(el, config) {
|
|
15560
|
+
var angle = (el.startAngle + el.endAngle) / 2;
|
|
15561
|
+
var vx = Math.cos(angle);
|
|
15562
|
+
var vy = Math.sin(angle);
|
|
15563
|
+
var r0 = el.innerRadius;
|
|
15564
|
+
var r1 = el.outerRadius;
|
|
15565
|
+
|
|
15566
|
+
return compute$1({
|
|
15567
|
+
x0: el.x + vx * r0,
|
|
15568
|
+
y0: el.y + vy * r0,
|
|
15569
|
+
x1: el.x + vx * r1,
|
|
15570
|
+
y1: el.y + vy * r1,
|
|
15571
|
+
vx: vx,
|
|
15572
|
+
vy: vy
|
|
15573
|
+
}, config);
|
|
15574
|
+
},
|
|
15575
|
+
|
|
15576
|
+
point: function(el, config) {
|
|
15577
|
+
var v = orient(el, config.origin);
|
|
15578
|
+
var rx = v.x * el.options.radius;
|
|
15579
|
+
var ry = v.y * el.options.radius;
|
|
15580
|
+
|
|
15581
|
+
return compute$1({
|
|
15582
|
+
x0: el.x - rx,
|
|
15583
|
+
y0: el.y - ry,
|
|
15584
|
+
x1: el.x + rx,
|
|
15585
|
+
y1: el.y + ry,
|
|
15586
|
+
vx: v.x,
|
|
15587
|
+
vy: v.y
|
|
15588
|
+
}, config);
|
|
15589
|
+
},
|
|
15590
|
+
|
|
15591
|
+
bar: function(el, config) {
|
|
15592
|
+
var v = orient(el, config.origin);
|
|
15593
|
+
var x = el.x;
|
|
15594
|
+
var y = el.y;
|
|
15595
|
+
var sx = 0;
|
|
15596
|
+
var sy = 0;
|
|
15597
|
+
|
|
15598
|
+
if (el.horizontal) {
|
|
15599
|
+
x = Math.min(el.x, el.base);
|
|
15600
|
+
sx = Math.abs(el.base - el.x);
|
|
15601
|
+
} else {
|
|
15602
|
+
y = Math.min(el.y, el.base);
|
|
15603
|
+
sy = Math.abs(el.base - el.y);
|
|
15604
|
+
}
|
|
15605
|
+
|
|
15606
|
+
return compute$1({
|
|
15607
|
+
x0: x,
|
|
15608
|
+
y0: y + sy,
|
|
15609
|
+
x1: x + sx,
|
|
15610
|
+
y1: y,
|
|
15611
|
+
vx: v.x,
|
|
15612
|
+
vy: v.y
|
|
15613
|
+
}, config);
|
|
15614
|
+
},
|
|
15615
|
+
|
|
15616
|
+
fallback: function(el, config) {
|
|
15617
|
+
var v = orient(el, config.origin);
|
|
15618
|
+
|
|
15619
|
+
return compute$1({
|
|
15620
|
+
x0: el.x,
|
|
15621
|
+
y0: el.y,
|
|
15622
|
+
x1: el.x + (el.width || 0),
|
|
15623
|
+
y1: el.y + (el.height || 0),
|
|
15624
|
+
vx: v.x,
|
|
15625
|
+
vy: v.y
|
|
15626
|
+
}, config);
|
|
15627
|
+
}
|
|
15628
|
+
};
|
|
15629
|
+
|
|
15630
|
+
var rasterize = utils.rasterize;
|
|
15631
|
+
|
|
15632
|
+
function boundingRects(model) {
|
|
15633
|
+
var borderWidth = model.borderWidth || 0;
|
|
15634
|
+
var padding = model.padding;
|
|
15635
|
+
var th = model.size.height;
|
|
15636
|
+
var tw = model.size.width;
|
|
15637
|
+
var tx = -tw / 2;
|
|
15638
|
+
var ty = -th / 2;
|
|
15639
|
+
|
|
15640
|
+
return {
|
|
15641
|
+
frame: {
|
|
15642
|
+
x: tx - padding.left - borderWidth,
|
|
15643
|
+
y: ty - padding.top - borderWidth,
|
|
15644
|
+
w: tw + padding.width + borderWidth * 2,
|
|
15645
|
+
h: th + padding.height + borderWidth * 2
|
|
15646
|
+
},
|
|
15647
|
+
text: {
|
|
15648
|
+
x: tx,
|
|
15649
|
+
y: ty,
|
|
15650
|
+
w: tw,
|
|
15651
|
+
h: th
|
|
15652
|
+
}
|
|
15653
|
+
};
|
|
15654
|
+
}
|
|
15655
|
+
|
|
15656
|
+
function getScaleOrigin(el, context) {
|
|
15657
|
+
var scale = context.chart.getDatasetMeta(context.datasetIndex).vScale;
|
|
15658
|
+
|
|
15659
|
+
if (!scale) {
|
|
15660
|
+
return null;
|
|
15661
|
+
}
|
|
15662
|
+
|
|
15663
|
+
if (scale.xCenter !== undefined && scale.yCenter !== undefined) {
|
|
15664
|
+
return {x: scale.xCenter, y: scale.yCenter};
|
|
15665
|
+
}
|
|
15666
|
+
|
|
15667
|
+
var pixel = scale.getBasePixel();
|
|
15668
|
+
return el.horizontal ?
|
|
15669
|
+
{x: pixel, y: null} :
|
|
15670
|
+
{x: null, y: pixel};
|
|
15671
|
+
}
|
|
15672
|
+
|
|
15673
|
+
function getPositioner(el) {
|
|
15674
|
+
if (el instanceof ArcElement) {
|
|
15675
|
+
return positioners$1.arc;
|
|
15676
|
+
}
|
|
15677
|
+
if (el instanceof PointElement) {
|
|
15678
|
+
return positioners$1.point;
|
|
15679
|
+
}
|
|
15680
|
+
if (el instanceof BarElement) {
|
|
15681
|
+
return positioners$1.bar;
|
|
15682
|
+
}
|
|
15683
|
+
return positioners$1.fallback;
|
|
15684
|
+
}
|
|
15685
|
+
|
|
15686
|
+
function drawRoundedRect(ctx, x, y, w, h, radius) {
|
|
15687
|
+
var HALF_PI = Math.PI / 2;
|
|
15688
|
+
|
|
15689
|
+
if (radius) {
|
|
15690
|
+
var r = Math.min(radius, h / 2, w / 2);
|
|
15691
|
+
var left = x + r;
|
|
15692
|
+
var top = y + r;
|
|
15693
|
+
var right = x + w - r;
|
|
15694
|
+
var bottom = y + h - r;
|
|
15695
|
+
|
|
15696
|
+
ctx.moveTo(x, top);
|
|
15697
|
+
if (left < right && top < bottom) {
|
|
15698
|
+
ctx.arc(left, top, r, -Math.PI, -HALF_PI);
|
|
15699
|
+
ctx.arc(right, top, r, -HALF_PI, 0);
|
|
15700
|
+
ctx.arc(right, bottom, r, 0, HALF_PI);
|
|
15701
|
+
ctx.arc(left, bottom, r, HALF_PI, Math.PI);
|
|
15702
|
+
} else if (left < right) {
|
|
15703
|
+
ctx.moveTo(left, y);
|
|
15704
|
+
ctx.arc(right, top, r, -HALF_PI, HALF_PI);
|
|
15705
|
+
ctx.arc(left, top, r, HALF_PI, Math.PI + HALF_PI);
|
|
15706
|
+
} else if (top < bottom) {
|
|
15707
|
+
ctx.arc(left, top, r, -Math.PI, 0);
|
|
15708
|
+
ctx.arc(left, bottom, r, 0, Math.PI);
|
|
15709
|
+
} else {
|
|
15710
|
+
ctx.arc(left, top, r, -Math.PI, Math.PI);
|
|
15711
|
+
}
|
|
15712
|
+
ctx.closePath();
|
|
15713
|
+
ctx.moveTo(x, y);
|
|
15714
|
+
} else {
|
|
15715
|
+
ctx.rect(x, y, w, h);
|
|
15716
|
+
}
|
|
15717
|
+
}
|
|
15718
|
+
|
|
15719
|
+
function drawFrame(ctx, rect, model) {
|
|
15720
|
+
var bgColor = model.backgroundColor;
|
|
15721
|
+
var borderColor = model.borderColor;
|
|
15722
|
+
var borderWidth = model.borderWidth;
|
|
15723
|
+
|
|
15724
|
+
if (!bgColor && (!borderColor || !borderWidth)) {
|
|
15725
|
+
return;
|
|
15726
|
+
}
|
|
15727
|
+
|
|
15728
|
+
ctx.beginPath();
|
|
15729
|
+
|
|
15730
|
+
drawRoundedRect(
|
|
15731
|
+
ctx,
|
|
15732
|
+
rasterize(rect.x) + borderWidth / 2,
|
|
15733
|
+
rasterize(rect.y) + borderWidth / 2,
|
|
15734
|
+
rasterize(rect.w) - borderWidth,
|
|
15735
|
+
rasterize(rect.h) - borderWidth,
|
|
15736
|
+
model.borderRadius);
|
|
15737
|
+
|
|
15738
|
+
ctx.closePath();
|
|
15739
|
+
|
|
15740
|
+
if (bgColor) {
|
|
15741
|
+
ctx.fillStyle = bgColor;
|
|
15742
|
+
ctx.fill();
|
|
15743
|
+
}
|
|
15744
|
+
|
|
15745
|
+
if (borderColor && borderWidth) {
|
|
15746
|
+
ctx.strokeStyle = borderColor;
|
|
15747
|
+
ctx.lineWidth = borderWidth;
|
|
15748
|
+
ctx.lineJoin = 'miter';
|
|
15749
|
+
ctx.stroke();
|
|
15750
|
+
}
|
|
15751
|
+
}
|
|
15752
|
+
|
|
15753
|
+
function textGeometry(rect, align, font) {
|
|
15754
|
+
var h = font.lineHeight;
|
|
15755
|
+
var w = rect.w;
|
|
15756
|
+
var x = rect.x;
|
|
15757
|
+
var y = rect.y + h / 2;
|
|
15758
|
+
|
|
15759
|
+
if (align === 'center') {
|
|
15760
|
+
x += w / 2;
|
|
15761
|
+
} else if (align === 'end' || align === 'right') {
|
|
15762
|
+
x += w;
|
|
15763
|
+
}
|
|
15764
|
+
|
|
15765
|
+
return {
|
|
15766
|
+
h: h,
|
|
15767
|
+
w: w,
|
|
15768
|
+
x: x,
|
|
15769
|
+
y: y
|
|
15770
|
+
};
|
|
15771
|
+
}
|
|
15772
|
+
|
|
15773
|
+
function drawTextLine(ctx, text, cfg) {
|
|
15774
|
+
var shadow = ctx.shadowBlur;
|
|
15775
|
+
var stroked = cfg.stroked;
|
|
15776
|
+
var x = rasterize(cfg.x);
|
|
15777
|
+
var y = rasterize(cfg.y);
|
|
15778
|
+
var w = rasterize(cfg.w);
|
|
15779
|
+
|
|
15780
|
+
if (stroked) {
|
|
15781
|
+
ctx.strokeText(text, x, y, w);
|
|
15782
|
+
}
|
|
15783
|
+
|
|
15784
|
+
if (cfg.filled) {
|
|
15785
|
+
if (shadow && stroked) {
|
|
15786
|
+
// Prevent drawing shadow on both the text stroke and fill, so
|
|
15787
|
+
// if the text is stroked, remove the shadow for the text fill.
|
|
15788
|
+
ctx.shadowBlur = 0;
|
|
15789
|
+
}
|
|
15790
|
+
|
|
15791
|
+
ctx.fillText(text, x, y, w);
|
|
15792
|
+
|
|
15793
|
+
if (shadow && stroked) {
|
|
15794
|
+
ctx.shadowBlur = shadow;
|
|
15795
|
+
}
|
|
15796
|
+
}
|
|
15797
|
+
}
|
|
15798
|
+
|
|
15799
|
+
function drawText(ctx, lines, rect, model) {
|
|
15800
|
+
var align = model.textAlign;
|
|
15801
|
+
var color = model.color;
|
|
15802
|
+
var filled = !!color;
|
|
15803
|
+
var font = model.font;
|
|
15804
|
+
var ilen = lines.length;
|
|
15805
|
+
var strokeColor = model.textStrokeColor;
|
|
15806
|
+
var strokeWidth = model.textStrokeWidth;
|
|
15807
|
+
var stroked = strokeColor && strokeWidth;
|
|
15808
|
+
var i;
|
|
15809
|
+
|
|
15810
|
+
if (!ilen || (!filled && !stroked)) {
|
|
15811
|
+
return;
|
|
15812
|
+
}
|
|
15813
|
+
|
|
15814
|
+
// Adjust coordinates based on text alignment and line height
|
|
15815
|
+
rect = textGeometry(rect, align, font);
|
|
15816
|
+
|
|
15817
|
+
ctx.font = font.string;
|
|
15818
|
+
ctx.textAlign = align;
|
|
15819
|
+
ctx.textBaseline = 'middle';
|
|
15820
|
+
ctx.shadowBlur = model.textShadowBlur;
|
|
15821
|
+
ctx.shadowColor = model.textShadowColor;
|
|
15822
|
+
|
|
15823
|
+
if (filled) {
|
|
15824
|
+
ctx.fillStyle = color;
|
|
15825
|
+
}
|
|
15826
|
+
if (stroked) {
|
|
15827
|
+
ctx.lineJoin = 'round';
|
|
15828
|
+
ctx.lineWidth = strokeWidth;
|
|
15829
|
+
ctx.strokeStyle = strokeColor;
|
|
15830
|
+
}
|
|
15831
|
+
|
|
15832
|
+
for (i = 0, ilen = lines.length; i < ilen; ++i) {
|
|
15833
|
+
drawTextLine(ctx, lines[i], {
|
|
15834
|
+
stroked: stroked,
|
|
15835
|
+
filled: filled,
|
|
15836
|
+
w: rect.w,
|
|
15837
|
+
x: rect.x,
|
|
15838
|
+
y: rect.y + rect.h * i
|
|
15839
|
+
});
|
|
15840
|
+
}
|
|
15841
|
+
}
|
|
15842
|
+
|
|
15843
|
+
var Label = function(config, ctx, el, index) {
|
|
15844
|
+
var me = this;
|
|
15845
|
+
|
|
15846
|
+
me._config = config;
|
|
15847
|
+
me._index = index;
|
|
15848
|
+
me._model = null;
|
|
15849
|
+
me._rects = null;
|
|
15850
|
+
me._ctx = ctx;
|
|
15851
|
+
me._el = el;
|
|
15852
|
+
};
|
|
15853
|
+
|
|
15854
|
+
merge$1(Label.prototype, {
|
|
15855
|
+
/**
|
|
15856
|
+
* @private
|
|
15857
|
+
*/
|
|
15858
|
+
_modelize: function(display, lines, config, context) {
|
|
15859
|
+
var me = this;
|
|
15860
|
+
var index = me._index;
|
|
15861
|
+
var font = toFont(resolve([config.font, {}], context, index));
|
|
15862
|
+
var color = resolve([config.color, defaults$1.color], context, index);
|
|
15863
|
+
|
|
15864
|
+
return {
|
|
15865
|
+
align: resolve([config.align, 'center'], context, index),
|
|
15866
|
+
anchor: resolve([config.anchor, 'center'], context, index),
|
|
15867
|
+
area: context.chart.chartArea,
|
|
15868
|
+
backgroundColor: resolve([config.backgroundColor, null], context, index),
|
|
15869
|
+
borderColor: resolve([config.borderColor, null], context, index),
|
|
15870
|
+
borderRadius: resolve([config.borderRadius, 0], context, index),
|
|
15871
|
+
borderWidth: resolve([config.borderWidth, 0], context, index),
|
|
15872
|
+
clamp: resolve([config.clamp, false], context, index),
|
|
15873
|
+
clip: resolve([config.clip, false], context, index),
|
|
15874
|
+
color: color,
|
|
15875
|
+
display: display,
|
|
15876
|
+
font: font,
|
|
15877
|
+
lines: lines,
|
|
15878
|
+
offset: resolve([config.offset, 4], context, index),
|
|
15879
|
+
opacity: resolve([config.opacity, 1], context, index),
|
|
15880
|
+
origin: getScaleOrigin(me._el, context),
|
|
15881
|
+
padding: toPadding(resolve([config.padding, 4], context, index)),
|
|
15882
|
+
positioner: getPositioner(me._el),
|
|
15883
|
+
rotation: resolve([config.rotation, 0], context, index) * (Math.PI / 180),
|
|
15884
|
+
size: utils.textSize(me._ctx, lines, font),
|
|
15885
|
+
textAlign: resolve([config.textAlign, 'start'], context, index),
|
|
15886
|
+
textShadowBlur: resolve([config.textShadowBlur, 0], context, index),
|
|
15887
|
+
textShadowColor: resolve([config.textShadowColor, color], context, index),
|
|
15888
|
+
textStrokeColor: resolve([config.textStrokeColor, color], context, index),
|
|
15889
|
+
textStrokeWidth: resolve([config.textStrokeWidth, 0], context, index)
|
|
15890
|
+
};
|
|
15891
|
+
},
|
|
15892
|
+
|
|
15893
|
+
update: function(context) {
|
|
15894
|
+
var me = this;
|
|
15895
|
+
var model = null;
|
|
15896
|
+
var rects = null;
|
|
15897
|
+
var index = me._index;
|
|
15898
|
+
var config = me._config;
|
|
15899
|
+
var value, label, lines;
|
|
15900
|
+
|
|
15901
|
+
// We first resolve the display option (separately) to avoid computing
|
|
15902
|
+
// other options in case the label is hidden (i.e. display: false).
|
|
15903
|
+
var display = resolve([config.display, true], context, index);
|
|
15904
|
+
|
|
15905
|
+
if (display) {
|
|
15906
|
+
value = context.dataset.data[index];
|
|
15907
|
+
label = valueOrDefault(callback(config.formatter, [value, context]), value);
|
|
15908
|
+
lines = isNullOrUndef(label) ? [] : utils.toTextLines(label);
|
|
15909
|
+
|
|
15910
|
+
if (lines.length) {
|
|
15911
|
+
model = me._modelize(display, lines, config, context);
|
|
15912
|
+
rects = boundingRects(model);
|
|
15913
|
+
}
|
|
15914
|
+
}
|
|
15915
|
+
|
|
15916
|
+
me._model = model;
|
|
15917
|
+
me._rects = rects;
|
|
15918
|
+
},
|
|
15919
|
+
|
|
15920
|
+
geometry: function() {
|
|
15921
|
+
return this._rects ? this._rects.frame : {};
|
|
15922
|
+
},
|
|
15923
|
+
|
|
15924
|
+
rotation: function() {
|
|
15925
|
+
return this._model ? this._model.rotation : 0;
|
|
15926
|
+
},
|
|
15927
|
+
|
|
15928
|
+
visible: function() {
|
|
15929
|
+
return this._model && this._model.opacity;
|
|
15930
|
+
},
|
|
15931
|
+
|
|
15932
|
+
model: function() {
|
|
15933
|
+
return this._model;
|
|
15934
|
+
},
|
|
15935
|
+
|
|
15936
|
+
draw: function(chart, center) {
|
|
15937
|
+
var me = this;
|
|
15938
|
+
var ctx = chart.ctx;
|
|
15939
|
+
var model = me._model;
|
|
15940
|
+
var rects = me._rects;
|
|
15941
|
+
var area;
|
|
15942
|
+
|
|
15943
|
+
if (!this.visible()) {
|
|
15944
|
+
return;
|
|
15945
|
+
}
|
|
15946
|
+
|
|
15947
|
+
ctx.save();
|
|
15948
|
+
|
|
15949
|
+
if (model.clip) {
|
|
15950
|
+
area = model.area;
|
|
15951
|
+
ctx.beginPath();
|
|
15952
|
+
ctx.rect(
|
|
15953
|
+
area.left,
|
|
15954
|
+
area.top,
|
|
15955
|
+
area.right - area.left,
|
|
15956
|
+
area.bottom - area.top);
|
|
15957
|
+
ctx.clip();
|
|
15958
|
+
}
|
|
15959
|
+
|
|
15960
|
+
ctx.globalAlpha = utils.bound(0, model.opacity, 1);
|
|
15961
|
+
ctx.translate(rasterize(center.x), rasterize(center.y));
|
|
15962
|
+
ctx.rotate(model.rotation);
|
|
15963
|
+
|
|
15964
|
+
drawFrame(ctx, rects.frame, model);
|
|
15965
|
+
drawText(ctx, model.lines, rects.text, model);
|
|
15966
|
+
|
|
15967
|
+
ctx.restore();
|
|
15968
|
+
}
|
|
15969
|
+
});
|
|
15970
|
+
|
|
15971
|
+
var MIN_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991; // eslint-disable-line es/no-number-minsafeinteger
|
|
15972
|
+
var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line es/no-number-maxsafeinteger
|
|
15973
|
+
|
|
15974
|
+
function rotated(point, center, angle) {
|
|
15975
|
+
var cos = Math.cos(angle);
|
|
15976
|
+
var sin = Math.sin(angle);
|
|
15977
|
+
var cx = center.x;
|
|
15978
|
+
var cy = center.y;
|
|
15979
|
+
|
|
15980
|
+
return {
|
|
15981
|
+
x: cx + cos * (point.x - cx) - sin * (point.y - cy),
|
|
15982
|
+
y: cy + sin * (point.x - cx) + cos * (point.y - cy)
|
|
15983
|
+
};
|
|
15984
|
+
}
|
|
15985
|
+
|
|
15986
|
+
function projected(points, axis) {
|
|
15987
|
+
var min = MAX_INTEGER;
|
|
15988
|
+
var max = MIN_INTEGER;
|
|
15989
|
+
var origin = axis.origin;
|
|
15990
|
+
var i, pt, vx, vy, dp;
|
|
15991
|
+
|
|
15992
|
+
for (i = 0; i < points.length; ++i) {
|
|
15993
|
+
pt = points[i];
|
|
15994
|
+
vx = pt.x - origin.x;
|
|
15995
|
+
vy = pt.y - origin.y;
|
|
15996
|
+
dp = axis.vx * vx + axis.vy * vy;
|
|
15997
|
+
min = Math.min(min, dp);
|
|
15998
|
+
max = Math.max(max, dp);
|
|
15999
|
+
}
|
|
16000
|
+
|
|
16001
|
+
return {
|
|
16002
|
+
min: min,
|
|
16003
|
+
max: max
|
|
16004
|
+
};
|
|
16005
|
+
}
|
|
16006
|
+
|
|
16007
|
+
function toAxis(p0, p1) {
|
|
16008
|
+
var vx = p1.x - p0.x;
|
|
16009
|
+
var vy = p1.y - p0.y;
|
|
16010
|
+
var ln = Math.sqrt(vx * vx + vy * vy);
|
|
16011
|
+
|
|
16012
|
+
return {
|
|
16013
|
+
vx: (p1.x - p0.x) / ln,
|
|
16014
|
+
vy: (p1.y - p0.y) / ln,
|
|
16015
|
+
origin: p0,
|
|
16016
|
+
ln: ln
|
|
16017
|
+
};
|
|
16018
|
+
}
|
|
16019
|
+
|
|
16020
|
+
var HitBox = function() {
|
|
16021
|
+
this._rotation = 0;
|
|
16022
|
+
this._rect = {
|
|
16023
|
+
x: 0,
|
|
16024
|
+
y: 0,
|
|
16025
|
+
w: 0,
|
|
16026
|
+
h: 0
|
|
16027
|
+
};
|
|
16028
|
+
};
|
|
16029
|
+
|
|
16030
|
+
merge$1(HitBox.prototype, {
|
|
16031
|
+
center: function() {
|
|
16032
|
+
var r = this._rect;
|
|
16033
|
+
return {
|
|
16034
|
+
x: r.x + r.w / 2,
|
|
16035
|
+
y: r.y + r.h / 2
|
|
16036
|
+
};
|
|
16037
|
+
},
|
|
16038
|
+
|
|
16039
|
+
update: function(center, rect, rotation) {
|
|
16040
|
+
this._rotation = rotation;
|
|
16041
|
+
this._rect = {
|
|
16042
|
+
x: rect.x + center.x,
|
|
16043
|
+
y: rect.y + center.y,
|
|
16044
|
+
w: rect.w,
|
|
16045
|
+
h: rect.h
|
|
16046
|
+
};
|
|
16047
|
+
},
|
|
16048
|
+
|
|
16049
|
+
contains: function(point) {
|
|
16050
|
+
var me = this;
|
|
16051
|
+
var margin = 1;
|
|
16052
|
+
var rect = me._rect;
|
|
16053
|
+
|
|
16054
|
+
point = rotated(point, me.center(), -me._rotation);
|
|
16055
|
+
|
|
16056
|
+
return !(point.x < rect.x - margin
|
|
16057
|
+
|| point.y < rect.y - margin
|
|
16058
|
+
|| point.x > rect.x + rect.w + margin * 2
|
|
16059
|
+
|| point.y > rect.y + rect.h + margin * 2);
|
|
16060
|
+
},
|
|
16061
|
+
|
|
16062
|
+
// Separating Axis Theorem
|
|
16063
|
+
// https://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169
|
|
16064
|
+
intersects: function(other) {
|
|
16065
|
+
var r0 = this._points();
|
|
16066
|
+
var r1 = other._points();
|
|
16067
|
+
var axes = [
|
|
16068
|
+
toAxis(r0[0], r0[1]),
|
|
16069
|
+
toAxis(r0[0], r0[3])
|
|
16070
|
+
];
|
|
16071
|
+
var i, pr0, pr1;
|
|
16072
|
+
|
|
16073
|
+
if (this._rotation !== other._rotation) {
|
|
16074
|
+
// Only separate with r1 axis if the rotation is different,
|
|
16075
|
+
// else it's enough to separate r0 and r1 with r0 axis only!
|
|
16076
|
+
axes.push(
|
|
16077
|
+
toAxis(r1[0], r1[1]),
|
|
16078
|
+
toAxis(r1[0], r1[3])
|
|
16079
|
+
);
|
|
16080
|
+
}
|
|
16081
|
+
|
|
16082
|
+
for (i = 0; i < axes.length; ++i) {
|
|
16083
|
+
pr0 = projected(r0, axes[i]);
|
|
16084
|
+
pr1 = projected(r1, axes[i]);
|
|
16085
|
+
|
|
16086
|
+
if (pr0.max < pr1.min || pr1.max < pr0.min) {
|
|
16087
|
+
return false;
|
|
16088
|
+
}
|
|
16089
|
+
}
|
|
16090
|
+
|
|
16091
|
+
return true;
|
|
16092
|
+
},
|
|
16093
|
+
|
|
16094
|
+
/**
|
|
16095
|
+
* @private
|
|
16096
|
+
*/
|
|
16097
|
+
_points: function() {
|
|
16098
|
+
var me = this;
|
|
16099
|
+
var rect = me._rect;
|
|
16100
|
+
var angle = me._rotation;
|
|
16101
|
+
var center = me.center();
|
|
16102
|
+
|
|
16103
|
+
return [
|
|
16104
|
+
rotated({x: rect.x, y: rect.y}, center, angle),
|
|
16105
|
+
rotated({x: rect.x + rect.w, y: rect.y}, center, angle),
|
|
16106
|
+
rotated({x: rect.x + rect.w, y: rect.y + rect.h}, center, angle),
|
|
16107
|
+
rotated({x: rect.x, y: rect.y + rect.h}, center, angle)
|
|
16108
|
+
];
|
|
16109
|
+
}
|
|
16110
|
+
});
|
|
16111
|
+
|
|
16112
|
+
function coordinates(el, model, geometry) {
|
|
16113
|
+
var point = model.positioner(el, model);
|
|
16114
|
+
var vx = point.vx;
|
|
16115
|
+
var vy = point.vy;
|
|
16116
|
+
|
|
16117
|
+
if (!vx && !vy) {
|
|
16118
|
+
// if aligned center, we don't want to offset the center point
|
|
16119
|
+
return {x: point.x, y: point.y};
|
|
16120
|
+
}
|
|
16121
|
+
|
|
16122
|
+
var w = geometry.w;
|
|
16123
|
+
var h = geometry.h;
|
|
16124
|
+
|
|
16125
|
+
// take in account the label rotation
|
|
16126
|
+
var rotation = model.rotation;
|
|
16127
|
+
var dx = Math.abs(w / 2 * Math.cos(rotation)) + Math.abs(h / 2 * Math.sin(rotation));
|
|
16128
|
+
var dy = Math.abs(w / 2 * Math.sin(rotation)) + Math.abs(h / 2 * Math.cos(rotation));
|
|
16129
|
+
|
|
16130
|
+
// scale the unit vector (vx, vy) to get at least dx or dy equal to
|
|
16131
|
+
// w or h respectively (else we would calculate the distance to the
|
|
16132
|
+
// ellipse inscribed in the bounding rect)
|
|
16133
|
+
var vs = 1 / Math.max(Math.abs(vx), Math.abs(vy));
|
|
16134
|
+
dx *= vx * vs;
|
|
16135
|
+
dy *= vy * vs;
|
|
16136
|
+
|
|
16137
|
+
// finally, include the explicit offset
|
|
16138
|
+
dx += model.offset * vx;
|
|
16139
|
+
dy += model.offset * vy;
|
|
16140
|
+
|
|
16141
|
+
return {
|
|
16142
|
+
x: point.x + dx,
|
|
16143
|
+
y: point.y + dy
|
|
16144
|
+
};
|
|
16145
|
+
}
|
|
16146
|
+
|
|
16147
|
+
function collide(labels, collider) {
|
|
16148
|
+
var i, j, s0, s1;
|
|
16149
|
+
|
|
16150
|
+
// IMPORTANT Iterate in the reverse order since items at the end of the
|
|
16151
|
+
// list have an higher weight/priority and thus should be less impacted
|
|
16152
|
+
// by the overlapping strategy.
|
|
16153
|
+
|
|
16154
|
+
for (i = labels.length - 1; i >= 0; --i) {
|
|
16155
|
+
s0 = labels[i].$layout;
|
|
16156
|
+
|
|
16157
|
+
for (j = i - 1; j >= 0 && s0._visible; --j) {
|
|
16158
|
+
s1 = labels[j].$layout;
|
|
16159
|
+
|
|
16160
|
+
if (s1._visible && s0._box.intersects(s1._box)) {
|
|
16161
|
+
collider(s0, s1);
|
|
16162
|
+
}
|
|
16163
|
+
}
|
|
16164
|
+
}
|
|
16165
|
+
|
|
16166
|
+
return labels;
|
|
16167
|
+
}
|
|
16168
|
+
|
|
16169
|
+
function compute(labels) {
|
|
16170
|
+
var i, ilen, label, state, geometry, center, proxy;
|
|
16171
|
+
|
|
16172
|
+
// Initialize labels for overlap detection
|
|
16173
|
+
for (i = 0, ilen = labels.length; i < ilen; ++i) {
|
|
16174
|
+
label = labels[i];
|
|
16175
|
+
state = label.$layout;
|
|
16176
|
+
|
|
16177
|
+
if (state._visible) {
|
|
16178
|
+
// Chart.js 3 removed el._model in favor of getProps(), making harder to
|
|
16179
|
+
// abstract reading values in positioners. Also, using string arrays to
|
|
16180
|
+
// read values (i.e. var {a,b,c} = el.getProps(["a","b","c"])) would make
|
|
16181
|
+
// positioners inefficient in the normal case (i.e. not the final values)
|
|
16182
|
+
// and the code a bit ugly, so let's use a Proxy instead.
|
|
16183
|
+
proxy = new Proxy(label._el, {get: (el, p) => el.getProps([p], true)[p]});
|
|
16184
|
+
|
|
16185
|
+
geometry = label.geometry();
|
|
16186
|
+
center = coordinates(proxy, label.model(), geometry);
|
|
16187
|
+
state._box.update(center, geometry, label.rotation());
|
|
16188
|
+
}
|
|
16189
|
+
}
|
|
16190
|
+
|
|
16191
|
+
// Auto hide overlapping labels
|
|
16192
|
+
return collide(labels, function(s0, s1) {
|
|
16193
|
+
var h0 = s0._hidable;
|
|
16194
|
+
var h1 = s1._hidable;
|
|
16195
|
+
|
|
16196
|
+
if ((h0 && h1) || h1) {
|
|
16197
|
+
s1._visible = false;
|
|
16198
|
+
} else if (h0) {
|
|
16199
|
+
s0._visible = false;
|
|
16200
|
+
}
|
|
16201
|
+
});
|
|
16202
|
+
}
|
|
16203
|
+
|
|
16204
|
+
var layout = {
|
|
16205
|
+
prepare: function(datasets) {
|
|
16206
|
+
var labels = [];
|
|
16207
|
+
var i, j, ilen, jlen, label;
|
|
16208
|
+
|
|
16209
|
+
for (i = 0, ilen = datasets.length; i < ilen; ++i) {
|
|
16210
|
+
for (j = 0, jlen = datasets[i].length; j < jlen; ++j) {
|
|
16211
|
+
label = datasets[i][j];
|
|
16212
|
+
labels.push(label);
|
|
16213
|
+
label.$layout = {
|
|
16214
|
+
_box: new HitBox(),
|
|
16215
|
+
_hidable: false,
|
|
16216
|
+
_visible: true,
|
|
16217
|
+
_set: i,
|
|
16218
|
+
_idx: label._index
|
|
16219
|
+
};
|
|
16220
|
+
}
|
|
16221
|
+
}
|
|
16222
|
+
|
|
16223
|
+
// TODO New `z` option: labels with a higher z-index are drawn
|
|
16224
|
+
// of top of the ones with a lower index. Lowest z-index labels
|
|
16225
|
+
// are also discarded first when hiding overlapping labels.
|
|
16226
|
+
labels.sort(function(a, b) {
|
|
16227
|
+
var sa = a.$layout;
|
|
16228
|
+
var sb = b.$layout;
|
|
16229
|
+
|
|
16230
|
+
return sa._idx === sb._idx
|
|
16231
|
+
? sb._set - sa._set
|
|
16232
|
+
: sb._idx - sa._idx;
|
|
16233
|
+
});
|
|
16234
|
+
|
|
16235
|
+
this.update(labels);
|
|
16236
|
+
|
|
16237
|
+
return labels;
|
|
16238
|
+
},
|
|
16239
|
+
|
|
16240
|
+
update: function(labels) {
|
|
16241
|
+
var dirty = false;
|
|
16242
|
+
var i, ilen, label, model, state;
|
|
16243
|
+
|
|
16244
|
+
for (i = 0, ilen = labels.length; i < ilen; ++i) {
|
|
16245
|
+
label = labels[i];
|
|
16246
|
+
model = label.model();
|
|
16247
|
+
state = label.$layout;
|
|
16248
|
+
state._hidable = model && model.display === 'auto';
|
|
16249
|
+
state._visible = label.visible();
|
|
16250
|
+
dirty |= state._hidable;
|
|
16251
|
+
}
|
|
16252
|
+
|
|
16253
|
+
if (dirty) {
|
|
16254
|
+
compute(labels);
|
|
16255
|
+
}
|
|
16256
|
+
},
|
|
16257
|
+
|
|
16258
|
+
lookup: function(labels, point) {
|
|
16259
|
+
var i, state;
|
|
16260
|
+
|
|
16261
|
+
// IMPORTANT Iterate in the reverse order since items at the end of
|
|
16262
|
+
// the list have an higher z-index, thus should be picked first.
|
|
16263
|
+
|
|
16264
|
+
for (i = labels.length - 1; i >= 0; --i) {
|
|
16265
|
+
state = labels[i].$layout;
|
|
16266
|
+
|
|
16267
|
+
if (state && state._visible && state._box.contains(point)) {
|
|
16268
|
+
return labels[i];
|
|
16269
|
+
}
|
|
16270
|
+
}
|
|
16271
|
+
|
|
16272
|
+
return null;
|
|
16273
|
+
},
|
|
16274
|
+
|
|
16275
|
+
draw: function(chart, labels) {
|
|
16276
|
+
var i, ilen, label, state, geometry, center;
|
|
16277
|
+
|
|
16278
|
+
for (i = 0, ilen = labels.length; i < ilen; ++i) {
|
|
16279
|
+
label = labels[i];
|
|
16280
|
+
state = label.$layout;
|
|
16281
|
+
|
|
16282
|
+
if (state._visible) {
|
|
16283
|
+
geometry = label.geometry();
|
|
16284
|
+
center = coordinates(label._el, label.model(), geometry);
|
|
16285
|
+
state._box.update(center, geometry, label.rotation());
|
|
16286
|
+
label.draw(chart, center);
|
|
16287
|
+
}
|
|
16288
|
+
}
|
|
16289
|
+
}
|
|
16290
|
+
};
|
|
16291
|
+
|
|
16292
|
+
var formatter = function(value) {
|
|
16293
|
+
if (isNullOrUndef(value)) {
|
|
16294
|
+
return null;
|
|
16295
|
+
}
|
|
16296
|
+
|
|
16297
|
+
var label = value;
|
|
16298
|
+
var keys, klen, k;
|
|
16299
|
+
if (isObject(value)) {
|
|
16300
|
+
if (!isNullOrUndef(value.label)) {
|
|
16301
|
+
label = value.label;
|
|
16302
|
+
} else if (!isNullOrUndef(value.r)) {
|
|
16303
|
+
label = value.r;
|
|
16304
|
+
} else {
|
|
16305
|
+
label = '';
|
|
16306
|
+
keys = Object.keys(value);
|
|
16307
|
+
for (k = 0, klen = keys.length; k < klen; ++k) {
|
|
16308
|
+
label += (k !== 0 ? ', ' : '') + keys[k] + ': ' + value[keys[k]];
|
|
16309
|
+
}
|
|
16310
|
+
}
|
|
16311
|
+
}
|
|
16312
|
+
|
|
16313
|
+
return '' + label;
|
|
16314
|
+
};
|
|
16315
|
+
|
|
16316
|
+
/**
|
|
16317
|
+
* IMPORTANT: make sure to also update tests and TypeScript definition
|
|
16318
|
+
* files (`/test/specs/defaults.spec.js` and `/types/options.d.ts`)
|
|
16319
|
+
*/
|
|
16320
|
+
|
|
16321
|
+
var defaults = {
|
|
16322
|
+
align: 'center',
|
|
16323
|
+
anchor: 'center',
|
|
16324
|
+
backgroundColor: null,
|
|
16325
|
+
borderColor: null,
|
|
16326
|
+
borderRadius: 0,
|
|
16327
|
+
borderWidth: 0,
|
|
16328
|
+
clamp: false,
|
|
16329
|
+
clip: false,
|
|
16330
|
+
color: undefined,
|
|
16331
|
+
display: true,
|
|
16332
|
+
font: {
|
|
16333
|
+
family: undefined,
|
|
16334
|
+
lineHeight: 1.2,
|
|
16335
|
+
size: undefined,
|
|
16336
|
+
style: undefined,
|
|
16337
|
+
weight: null
|
|
16338
|
+
},
|
|
16339
|
+
formatter: formatter,
|
|
16340
|
+
labels: undefined,
|
|
16341
|
+
listeners: {},
|
|
16342
|
+
offset: 4,
|
|
16343
|
+
opacity: 1,
|
|
16344
|
+
padding: {
|
|
16345
|
+
top: 4,
|
|
16346
|
+
right: 4,
|
|
16347
|
+
bottom: 4,
|
|
16348
|
+
left: 4
|
|
16349
|
+
},
|
|
16350
|
+
rotation: 0,
|
|
16351
|
+
textAlign: 'start',
|
|
16352
|
+
textStrokeColor: undefined,
|
|
16353
|
+
textStrokeWidth: 0,
|
|
16354
|
+
textShadowBlur: 0,
|
|
16355
|
+
textShadowColor: undefined
|
|
16356
|
+
};
|
|
16357
|
+
|
|
16358
|
+
/**
|
|
16359
|
+
* @see https://github.com/chartjs/Chart.js/issues/4176
|
|
16360
|
+
*/
|
|
16361
|
+
|
|
16362
|
+
var EXPANDO_KEY = '$datalabels';
|
|
16363
|
+
var DEFAULT_KEY = '$default';
|
|
16364
|
+
|
|
16365
|
+
function configure$2(dataset, options) {
|
|
16366
|
+
var override = dataset.datalabels;
|
|
16367
|
+
var listeners = {};
|
|
16368
|
+
var configs = [];
|
|
16369
|
+
var labels, keys;
|
|
16370
|
+
|
|
16371
|
+
if (override === false) {
|
|
16372
|
+
return null;
|
|
16373
|
+
}
|
|
16374
|
+
if (override === true) {
|
|
16375
|
+
override = {};
|
|
16376
|
+
}
|
|
16377
|
+
|
|
16378
|
+
options = merge$1({}, [options, override]);
|
|
16379
|
+
labels = options.labels || {};
|
|
16380
|
+
keys = Object.keys(labels);
|
|
16381
|
+
delete options.labels;
|
|
16382
|
+
|
|
16383
|
+
if (keys.length) {
|
|
16384
|
+
keys.forEach(function(key) {
|
|
16385
|
+
if (labels[key]) {
|
|
16386
|
+
configs.push(merge$1({}, [
|
|
16387
|
+
options,
|
|
16388
|
+
labels[key],
|
|
16389
|
+
{_key: key}
|
|
16390
|
+
]));
|
|
16391
|
+
}
|
|
16392
|
+
});
|
|
16393
|
+
} else {
|
|
16394
|
+
// Default label if no "named" label defined.
|
|
16395
|
+
configs.push(options);
|
|
16396
|
+
}
|
|
16397
|
+
|
|
16398
|
+
// listeners: {<event-type>: {<label-key>: <fn>}}
|
|
16399
|
+
listeners = configs.reduce(function(target, config) {
|
|
16400
|
+
each(config.listeners || {}, function(fn, event) {
|
|
16401
|
+
target[event] = target[event] || {};
|
|
16402
|
+
target[event][config._key || DEFAULT_KEY] = fn;
|
|
16403
|
+
});
|
|
16404
|
+
|
|
16405
|
+
delete config.listeners;
|
|
16406
|
+
return target;
|
|
16407
|
+
}, {});
|
|
16408
|
+
|
|
16409
|
+
return {
|
|
16410
|
+
labels: configs,
|
|
16411
|
+
listeners: listeners
|
|
16412
|
+
};
|
|
16413
|
+
}
|
|
16414
|
+
|
|
16415
|
+
function dispatchEvent(chart, listeners, label, event) {
|
|
16416
|
+
if (!listeners) {
|
|
16417
|
+
return;
|
|
16418
|
+
}
|
|
16419
|
+
|
|
16420
|
+
var context = label.$context;
|
|
16421
|
+
var groups = label.$groups;
|
|
16422
|
+
var callback$1;
|
|
16423
|
+
|
|
16424
|
+
if (!listeners[groups._set]) {
|
|
16425
|
+
return;
|
|
16426
|
+
}
|
|
16427
|
+
|
|
16428
|
+
callback$1 = listeners[groups._set][groups._key];
|
|
16429
|
+
if (!callback$1) {
|
|
16430
|
+
return;
|
|
16431
|
+
}
|
|
16432
|
+
|
|
16433
|
+
if (callback(callback$1, [context, event]) === true) {
|
|
16434
|
+
// Users are allowed to tweak the given context by injecting values that can be
|
|
16435
|
+
// used in scriptable options to display labels differently based on the current
|
|
16436
|
+
// event (e.g. highlight an hovered label). That's why we update the label with
|
|
16437
|
+
// the output context and schedule a new chart render by setting it dirty.
|
|
16438
|
+
chart[EXPANDO_KEY]._dirty = true;
|
|
16439
|
+
label.update(context);
|
|
16440
|
+
}
|
|
16441
|
+
}
|
|
16442
|
+
|
|
16443
|
+
function dispatchMoveEvents(chart, listeners, previous, label, event) {
|
|
16444
|
+
var enter, leave;
|
|
16445
|
+
|
|
16446
|
+
if (!previous && !label) {
|
|
16447
|
+
return;
|
|
16448
|
+
}
|
|
16449
|
+
|
|
16450
|
+
if (!previous) {
|
|
16451
|
+
enter = true;
|
|
16452
|
+
} else if (!label) {
|
|
16453
|
+
leave = true;
|
|
16454
|
+
} else if (previous !== label) {
|
|
16455
|
+
leave = enter = true;
|
|
16456
|
+
}
|
|
16457
|
+
|
|
16458
|
+
if (leave) {
|
|
16459
|
+
dispatchEvent(chart, listeners.leave, previous, event);
|
|
16460
|
+
}
|
|
16461
|
+
if (enter) {
|
|
16462
|
+
dispatchEvent(chart, listeners.enter, label, event);
|
|
16463
|
+
}
|
|
16464
|
+
}
|
|
16465
|
+
|
|
16466
|
+
function handleMoveEvents(chart, event) {
|
|
16467
|
+
var expando = chart[EXPANDO_KEY];
|
|
16468
|
+
var listeners = expando._listeners;
|
|
16469
|
+
var previous, label;
|
|
16470
|
+
|
|
16471
|
+
if (!listeners.enter && !listeners.leave) {
|
|
16472
|
+
return;
|
|
16473
|
+
}
|
|
16474
|
+
|
|
16475
|
+
if (event.type === 'mousemove') {
|
|
16476
|
+
label = layout.lookup(expando._labels, event);
|
|
16477
|
+
} else if (event.type !== 'mouseout') {
|
|
16478
|
+
return;
|
|
16479
|
+
}
|
|
16480
|
+
|
|
16481
|
+
previous = expando._hovered;
|
|
16482
|
+
expando._hovered = label;
|
|
16483
|
+
dispatchMoveEvents(chart, listeners, previous, label, event);
|
|
16484
|
+
}
|
|
16485
|
+
|
|
16486
|
+
function handleClickEvents(chart, event) {
|
|
16487
|
+
var expando = chart[EXPANDO_KEY];
|
|
16488
|
+
var handlers = expando._listeners.click;
|
|
16489
|
+
var label = handlers && layout.lookup(expando._labels, event);
|
|
16490
|
+
if (label) {
|
|
16491
|
+
dispatchEvent(chart, handlers, label, event);
|
|
16492
|
+
}
|
|
16493
|
+
}
|
|
16494
|
+
|
|
16495
|
+
var plugin$1 = {
|
|
16496
|
+
id: 'datalabels',
|
|
16497
|
+
|
|
16498
|
+
defaults: defaults,
|
|
16499
|
+
|
|
16500
|
+
beforeInit: function(chart) {
|
|
16501
|
+
chart[EXPANDO_KEY] = {
|
|
16502
|
+
_actives: []
|
|
16503
|
+
};
|
|
16504
|
+
},
|
|
16505
|
+
|
|
16506
|
+
beforeUpdate: function(chart) {
|
|
16507
|
+
var expando = chart[EXPANDO_KEY];
|
|
16508
|
+
expando._listened = false;
|
|
16509
|
+
expando._listeners = {}; // {<event-type>: {<dataset-index>: {<label-key>: <fn>}}}
|
|
16510
|
+
expando._datasets = []; // per dataset labels: [Label[]]
|
|
16511
|
+
expando._labels = []; // layouted labels: Label[]
|
|
16512
|
+
},
|
|
16513
|
+
|
|
16514
|
+
afterDatasetUpdate: function(chart, args, options) {
|
|
16515
|
+
var datasetIndex = args.index;
|
|
16516
|
+
var expando = chart[EXPANDO_KEY];
|
|
16517
|
+
var labels = expando._datasets[datasetIndex] = [];
|
|
16518
|
+
var visible = chart.isDatasetVisible(datasetIndex);
|
|
16519
|
+
var dataset = chart.data.datasets[datasetIndex];
|
|
16520
|
+
var config = configure$2(dataset, options);
|
|
16521
|
+
var elements = args.meta.data || [];
|
|
16522
|
+
var ctx = chart.ctx;
|
|
16523
|
+
var i, j, ilen, jlen, cfg, key, el, label;
|
|
16524
|
+
|
|
16525
|
+
ctx.save();
|
|
16526
|
+
|
|
16527
|
+
for (i = 0, ilen = elements.length; i < ilen; ++i) {
|
|
16528
|
+
el = elements[i];
|
|
16529
|
+
el[EXPANDO_KEY] = [];
|
|
16530
|
+
|
|
16531
|
+
if (visible && el && chart.getDataVisibility(i) && !el.skip) {
|
|
16532
|
+
for (j = 0, jlen = config.labels.length; j < jlen; ++j) {
|
|
16533
|
+
cfg = config.labels[j];
|
|
16534
|
+
key = cfg._key;
|
|
16535
|
+
|
|
16536
|
+
label = new Label(cfg, ctx, el, i);
|
|
16537
|
+
label.$groups = {
|
|
16538
|
+
_set: datasetIndex,
|
|
16539
|
+
_key: key || DEFAULT_KEY
|
|
16540
|
+
};
|
|
16541
|
+
label.$context = {
|
|
16542
|
+
active: false,
|
|
16543
|
+
chart: chart,
|
|
16544
|
+
dataIndex: i,
|
|
16545
|
+
dataset: dataset,
|
|
16546
|
+
datasetIndex: datasetIndex
|
|
16547
|
+
};
|
|
16548
|
+
|
|
16549
|
+
label.update(label.$context);
|
|
16550
|
+
el[EXPANDO_KEY].push(label);
|
|
16551
|
+
labels.push(label);
|
|
16552
|
+
}
|
|
16553
|
+
}
|
|
16554
|
+
}
|
|
16555
|
+
|
|
16556
|
+
ctx.restore();
|
|
16557
|
+
|
|
16558
|
+
// Store listeners at the chart level and per event type to optimize
|
|
16559
|
+
// cases where no listeners are registered for a specific event.
|
|
16560
|
+
merge$1(expando._listeners, config.listeners, {
|
|
16561
|
+
merger: function(event, target, source) {
|
|
16562
|
+
target[event] = target[event] || {};
|
|
16563
|
+
target[event][args.index] = source[event];
|
|
16564
|
+
expando._listened = true;
|
|
16565
|
+
}
|
|
16566
|
+
});
|
|
16567
|
+
},
|
|
16568
|
+
|
|
16569
|
+
afterUpdate: function(chart) {
|
|
16570
|
+
chart[EXPANDO_KEY]._labels = layout.prepare(chart[EXPANDO_KEY]._datasets);
|
|
16571
|
+
},
|
|
16572
|
+
|
|
16573
|
+
// Draw labels on top of all dataset elements
|
|
16574
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/29
|
|
16575
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/32
|
|
16576
|
+
afterDatasetsDraw: function(chart) {
|
|
16577
|
+
layout.draw(chart, chart[EXPANDO_KEY]._labels);
|
|
16578
|
+
},
|
|
16579
|
+
|
|
16580
|
+
beforeEvent: function(chart, args) {
|
|
16581
|
+
// If there is no listener registered for this chart, `listened` will be false,
|
|
16582
|
+
// meaning we can immediately ignore the incoming event and avoid useless extra
|
|
16583
|
+
// computation for users who don't implement label interactions.
|
|
16584
|
+
if (chart[EXPANDO_KEY]._listened) {
|
|
16585
|
+
var event = args.event;
|
|
16586
|
+
switch (event.type) {
|
|
16587
|
+
case 'mousemove':
|
|
16588
|
+
case 'mouseout':
|
|
16589
|
+
handleMoveEvents(chart, event);
|
|
16590
|
+
break;
|
|
16591
|
+
case 'click':
|
|
16592
|
+
handleClickEvents(chart, event);
|
|
16593
|
+
break;
|
|
16594
|
+
}
|
|
16595
|
+
}
|
|
16596
|
+
},
|
|
16597
|
+
|
|
16598
|
+
afterEvent: function(chart) {
|
|
16599
|
+
var expando = chart[EXPANDO_KEY];
|
|
16600
|
+
var previous = expando._actives;
|
|
16601
|
+
var actives = expando._actives = chart.getActiveElements();
|
|
16602
|
+
var updates = utils.arrayDiff(previous, actives);
|
|
16603
|
+
var i, ilen, j, jlen, update, label, labels;
|
|
16604
|
+
|
|
16605
|
+
for (i = 0, ilen = updates.length; i < ilen; ++i) {
|
|
16606
|
+
update = updates[i];
|
|
16607
|
+
if (update[1]) {
|
|
16608
|
+
labels = update[0].element[EXPANDO_KEY] || [];
|
|
16609
|
+
for (j = 0, jlen = labels.length; j < jlen; ++j) {
|
|
16610
|
+
label = labels[j];
|
|
16611
|
+
label.$context.active = (update[1] === 1);
|
|
16612
|
+
label.update(label.$context);
|
|
16613
|
+
}
|
|
16614
|
+
}
|
|
16615
|
+
}
|
|
16616
|
+
|
|
16617
|
+
if (expando._dirty || updates.length) {
|
|
16618
|
+
layout.update(expando._labels);
|
|
16619
|
+
chart.render();
|
|
16620
|
+
}
|
|
16621
|
+
|
|
16622
|
+
delete expando._dirty;
|
|
16623
|
+
}
|
|
16624
|
+
};
|
|
16625
|
+
|
|
15255
16626
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15256
16627
|
function SeriesLineChart({ orientation, title, data, options, className, units, content }) {
|
|
16628
|
+
var _a, _b;
|
|
15257
16629
|
const formatValue = (value) => {
|
|
15258
16630
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15259
|
-
if (
|
|
16631
|
+
if (!isNaN(numValue)) {
|
|
15260
16632
|
return numValue.toLocaleString();
|
|
15261
16633
|
}
|
|
15262
16634
|
return value;
|
|
15263
16635
|
};
|
|
16636
|
+
const getAxisLabel = (symbol) => {
|
|
16637
|
+
const labelMap = {
|
|
16638
|
+
"%": "Percentage",
|
|
16639
|
+
"$": "Cost",
|
|
16640
|
+
"#": "Count",
|
|
16641
|
+
};
|
|
16642
|
+
return labelMap[symbol] || symbol; // fallback if not found
|
|
16643
|
+
};
|
|
15264
16644
|
const defaultOptions = {
|
|
15265
16645
|
responsive: true,
|
|
15266
16646
|
maintainAspectRatio: false,
|
|
@@ -15274,7 +16654,13 @@ function SeriesLineChart({ orientation, title, data, options, className, units,
|
|
|
15274
16654
|
},
|
|
15275
16655
|
plugins: {
|
|
15276
16656
|
legend: {
|
|
15277
|
-
display:
|
|
16657
|
+
display: (ctx) => {
|
|
16658
|
+
const chart = ctx.chart;
|
|
16659
|
+
const datasets = chart.data.datasets;
|
|
16660
|
+
if (datasets.length > 1)
|
|
16661
|
+
return true;
|
|
16662
|
+
return false;
|
|
16663
|
+
},
|
|
15278
16664
|
labels: {
|
|
15279
16665
|
boxWidth: 12,
|
|
15280
16666
|
boxHeight: 12,
|
|
@@ -15317,6 +16703,10 @@ function SeriesLineChart({ orientation, title, data, options, className, units,
|
|
|
15317
16703
|
ticks: { autoSkip: true, maxTicksLimit: 8, maxRotation: 45, minRotation: 0 },
|
|
15318
16704
|
},
|
|
15319
16705
|
y: {
|
|
16706
|
+
title: {
|
|
16707
|
+
display: true,
|
|
16708
|
+
text: (data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : ""),
|
|
16709
|
+
},
|
|
15320
16710
|
beginAtZero: true,
|
|
15321
16711
|
ticks: {
|
|
15322
16712
|
callback: function (value) {
|
|
@@ -15334,9 +16724,791 @@ function SeriesLineChart({ orientation, title, data, options, className, units,
|
|
|
15334
16724
|
},
|
|
15335
16725
|
},
|
|
15336
16726
|
};
|
|
15337
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [
|
|
16727
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin$1] }));
|
|
15338
16728
|
}
|
|
15339
16729
|
|
|
16730
|
+
/*!
|
|
16731
|
+
* @energiency/chartjs-plugin-piechart-outlabels v1.3.4
|
|
16732
|
+
* http://www.chartjs.org
|
|
16733
|
+
* (c) 2017-2025 @energiency/chartjs-plugin-piechart-outlabels contributors
|
|
16734
|
+
* Released under the MIT license
|
|
16735
|
+
*/
|
|
16736
|
+
|
|
16737
|
+
/**
|
|
16738
|
+
* @module Options
|
|
16739
|
+
*/
|
|
16740
|
+
|
|
16741
|
+
var customDefaults = {
|
|
16742
|
+
PLUGIN_KEY: '$outlabels',
|
|
16743
|
+
|
|
16744
|
+
/**
|
|
16745
|
+
* The color used to draw the background of the label rect.
|
|
16746
|
+
* @member {String|Array|Function|null}
|
|
16747
|
+
* @default null (adaptive background)
|
|
16748
|
+
*/
|
|
16749
|
+
backgroundColor: function (context) {
|
|
16750
|
+
return context.dataset.backgroundColor;
|
|
16751
|
+
},
|
|
16752
|
+
|
|
16753
|
+
/**
|
|
16754
|
+
* The color used to draw the border of the label rect.
|
|
16755
|
+
* @member {String|Array|Function|null}
|
|
16756
|
+
* @default null (adaptive border color)
|
|
16757
|
+
*/
|
|
16758
|
+
borderColor: function (context) {
|
|
16759
|
+
return context.dataset.backgroundColor;
|
|
16760
|
+
},
|
|
16761
|
+
|
|
16762
|
+
/**
|
|
16763
|
+
* The color used to draw the line between label and arc of the chart.
|
|
16764
|
+
* @member {String|Array|Function|null}
|
|
16765
|
+
* @default null (adaptive line color)
|
|
16766
|
+
*/
|
|
16767
|
+
lineColor: function (context) {
|
|
16768
|
+
return context.dataset.backgroundColor;
|
|
16769
|
+
},
|
|
16770
|
+
|
|
16771
|
+
/**
|
|
16772
|
+
* The border radius used to add rounded corners to the label rect.
|
|
16773
|
+
* @member {Number|Array|Function}
|
|
16774
|
+
* @default 0 (not rounded)
|
|
16775
|
+
*/
|
|
16776
|
+
borderRadius: 0,
|
|
16777
|
+
|
|
16778
|
+
/**
|
|
16779
|
+
* The border width of the surrounding frame.
|
|
16780
|
+
* @member {Number|Array|Function}
|
|
16781
|
+
* @default 0 (no border)
|
|
16782
|
+
*/
|
|
16783
|
+
borderWidth: 0,
|
|
16784
|
+
|
|
16785
|
+
/**
|
|
16786
|
+
* The width (thickness) of the line between label and chart arc.
|
|
16787
|
+
* @member {Number|Array|Function}
|
|
16788
|
+
* @default 2
|
|
16789
|
+
*/
|
|
16790
|
+
lineWidth: 2,
|
|
16791
|
+
|
|
16792
|
+
/**
|
|
16793
|
+
* The color used to draw the label text.
|
|
16794
|
+
* @member {String|Array|Function}
|
|
16795
|
+
* @default white
|
|
16796
|
+
*/
|
|
16797
|
+
color: 'white',
|
|
16798
|
+
|
|
16799
|
+
/**
|
|
16800
|
+
* Whether to display labels global (boolean) or per data (function)
|
|
16801
|
+
* @member {Boolean|Array|Function}
|
|
16802
|
+
* @default true
|
|
16803
|
+
*/
|
|
16804
|
+
display: true,
|
|
16805
|
+
|
|
16806
|
+
/**
|
|
16807
|
+
* The font options used to draw the label text.
|
|
16808
|
+
* @member {Object|Array|Function}
|
|
16809
|
+
* @prop {Boolean} font.family - defaults to Chart.defaults.global.defaultFontFamily
|
|
16810
|
+
* @prop {Boolean} font.size - defaults to Chart.defaults.global.defaultFontSize
|
|
16811
|
+
* @prop {Boolean} font.style - defaults to Chart.defaults.global.defaultFontStyle
|
|
16812
|
+
* @prop {Boolean} font.weight - defaults to 'normal'
|
|
16813
|
+
* @prop {Boolean} font.maxSize - defaults to undefined (unlimited)
|
|
16814
|
+
* @prop {Boolean} font.minSize - defaults to undefined (unlimited)
|
|
16815
|
+
* @prop {Boolean} font.resizable - defaults to true
|
|
16816
|
+
* @default Chart.defaults.global.defaultFont.*
|
|
16817
|
+
*/
|
|
16818
|
+
font: {
|
|
16819
|
+
family: undefined,
|
|
16820
|
+
size: undefined,
|
|
16821
|
+
style: undefined,
|
|
16822
|
+
weight: null,
|
|
16823
|
+
maxSize: null,
|
|
16824
|
+
minSize: null,
|
|
16825
|
+
resizable: true,
|
|
16826
|
+
},
|
|
16827
|
+
|
|
16828
|
+
/**
|
|
16829
|
+
* The line height (in pixel) to use for multi-lines labels.
|
|
16830
|
+
* @member {Number|Array|Function|undefined}
|
|
16831
|
+
* @default 1.2
|
|
16832
|
+
*/
|
|
16833
|
+
lineHeight: 1.2,
|
|
16834
|
+
|
|
16835
|
+
/**
|
|
16836
|
+
* The padding (in pixels) to apply between the text and the surrounding frame.
|
|
16837
|
+
* @member {Number|Object|Array|Function}
|
|
16838
|
+
* @prop {Number} padding.top - Space above the text.
|
|
16839
|
+
* @prop {Number} padding.right - Space on the right of the text.
|
|
16840
|
+
* @prop {Number} padding.bottom - Space below the text.
|
|
16841
|
+
* @prop {Number} padding.left - Space on the left of the text.
|
|
16842
|
+
* @default 4 (all values)
|
|
16843
|
+
*/
|
|
16844
|
+
padding: {
|
|
16845
|
+
top: 2,
|
|
16846
|
+
right: 2,
|
|
16847
|
+
bottom: 2,
|
|
16848
|
+
left: 2,
|
|
16849
|
+
},
|
|
16850
|
+
|
|
16851
|
+
/**
|
|
16852
|
+
* Text alignment for multi-lines labels ('left'|'right'|'start'|'center'|'end').
|
|
16853
|
+
* @member {String|Array|Function}
|
|
16854
|
+
* @default 'center'
|
|
16855
|
+
*/
|
|
16856
|
+
textAlign: 'center',
|
|
16857
|
+
|
|
16858
|
+
/**
|
|
16859
|
+
* The radius of distance where the label will be drawn
|
|
16860
|
+
* @member {Number|Array|Function|undefined}
|
|
16861
|
+
* @default 30
|
|
16862
|
+
*/
|
|
16863
|
+
stretch: 12,
|
|
16864
|
+
|
|
16865
|
+
/**
|
|
16866
|
+
* The length of the horizontal part of line between label and chart arc.
|
|
16867
|
+
* @member {Number}
|
|
16868
|
+
* @default 30
|
|
16869
|
+
*/
|
|
16870
|
+
horizontalStrechPad: 12,
|
|
16871
|
+
|
|
16872
|
+
/**
|
|
16873
|
+
* The text of the label.
|
|
16874
|
+
* @member {String}
|
|
16875
|
+
* @default '%l %p' (label name and value percentage)
|
|
16876
|
+
*/
|
|
16877
|
+
text: '%l %p',
|
|
16878
|
+
|
|
16879
|
+
/**
|
|
16880
|
+
* The max level of zoom (out) for pie/doughnut chart in percent.
|
|
16881
|
+
* @member {Number}
|
|
16882
|
+
* @default 50 (%)
|
|
16883
|
+
*/
|
|
16884
|
+
maxZoomOutPercentage: 50,
|
|
16885
|
+
|
|
16886
|
+
/**
|
|
16887
|
+
* The count of numbers after the point separator for float values of percent property
|
|
16888
|
+
* @member {Number}
|
|
16889
|
+
* @default 1
|
|
16890
|
+
*/
|
|
16891
|
+
percentPrecision: 1,
|
|
16892
|
+
|
|
16893
|
+
/**
|
|
16894
|
+
* The count of numbers after the point separator for float values of value property
|
|
16895
|
+
* @member {Number}
|
|
16896
|
+
* @default 3
|
|
16897
|
+
*/
|
|
16898
|
+
valuePrecision: 3,
|
|
16899
|
+
};
|
|
16900
|
+
|
|
16901
|
+
const chartStates = new WeakMap();
|
|
16902
|
+
|
|
16903
|
+
function getState(chart) {
|
|
16904
|
+
let state = chartStates.get(chart);
|
|
16905
|
+
if (!state) {
|
|
16906
|
+
state = { sizeChanged: false, fitting: false };
|
|
16907
|
+
chartStates.set(chart, state);
|
|
16908
|
+
}
|
|
16909
|
+
return state;
|
|
16910
|
+
}
|
|
16911
|
+
|
|
16912
|
+
function removeState(chart) {
|
|
16913
|
+
chartStates.delete(chart);
|
|
16914
|
+
}
|
|
16915
|
+
|
|
16916
|
+
var positioners = {
|
|
16917
|
+
center: function (arc, stretch) {
|
|
16918
|
+
var angle = (arc.startAngle + arc.endAngle) / 2;
|
|
16919
|
+
var cosA = Math.cos(angle);
|
|
16920
|
+
var sinA = Math.sin(angle);
|
|
16921
|
+
var d = arc.outerRadius;
|
|
16922
|
+
|
|
16923
|
+
var stretchedD = d + stretch;
|
|
16924
|
+
return {
|
|
16925
|
+
x: arc.x + cosA * stretchedD,
|
|
16926
|
+
y: arc.y + sinA * stretchedD,
|
|
16927
|
+
d: stretchedD,
|
|
16928
|
+
arc: arc,
|
|
16929
|
+
anchor: { x: arc.x + cosA * d, y: arc.y + sinA * d },
|
|
16930
|
+
copy: { x: arc.x + cosA * stretchedD, y: arc.y + sinA * stretchedD },
|
|
16931
|
+
};
|
|
16932
|
+
},
|
|
16933
|
+
|
|
16934
|
+
moveFromAnchor: function (center, dist) {
|
|
16935
|
+
var arc = center.arc;
|
|
16936
|
+
var d = center.d;
|
|
16937
|
+
var angle = (arc.startAngle + arc.endAngle) / 2;
|
|
16938
|
+
var cosA = Math.cos(angle);
|
|
16939
|
+
var sinA = Math.sin(angle);
|
|
16940
|
+
|
|
16941
|
+
d += dist;
|
|
16942
|
+
|
|
16943
|
+
return {
|
|
16944
|
+
x: arc.x + cosA * d,
|
|
16945
|
+
y: arc.y + sinA * d,
|
|
16946
|
+
d: d,
|
|
16947
|
+
arc: arc,
|
|
16948
|
+
anchor: center.anchor,
|
|
16949
|
+
copy: {
|
|
16950
|
+
x: arc.x + cosA * d,
|
|
16951
|
+
y: arc.y + sinA * d,
|
|
16952
|
+
},
|
|
16953
|
+
};
|
|
16954
|
+
},
|
|
16955
|
+
};
|
|
16956
|
+
|
|
16957
|
+
function toFontString(font) {
|
|
16958
|
+
if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
|
|
16959
|
+
return null;
|
|
16960
|
+
}
|
|
16961
|
+
|
|
16962
|
+
return (
|
|
16963
|
+
(font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family
|
|
16964
|
+
);
|
|
16965
|
+
}
|
|
16966
|
+
|
|
16967
|
+
function textSize(ctx, lines, font) {
|
|
16968
|
+
var items = [].concat(lines);
|
|
16969
|
+
var ilen = items.length;
|
|
16970
|
+
var prev = ctx.font;
|
|
16971
|
+
var width = 0;
|
|
16972
|
+
var i;
|
|
16973
|
+
|
|
16974
|
+
ctx.font = font.string;
|
|
16975
|
+
|
|
16976
|
+
for (i = 0; i < ilen; ++i) {
|
|
16977
|
+
width = Math.max(ctx.measureText(items[i]).width, width);
|
|
16978
|
+
}
|
|
16979
|
+
|
|
16980
|
+
ctx.font = prev;
|
|
16981
|
+
|
|
16982
|
+
return {
|
|
16983
|
+
height: ilen * font.lineHeight,
|
|
16984
|
+
width,
|
|
16985
|
+
};
|
|
16986
|
+
}
|
|
16987
|
+
|
|
16988
|
+
function adaptTextSizeToDimensions(width, height, minimum, maximum) {
|
|
16989
|
+
const diag = Math.sqrt(Math.pow(width || 100, 2) + Math.pow(height || 100, 2));
|
|
16990
|
+
const size = Math.round(diag * 0.02);
|
|
16991
|
+
|
|
16992
|
+
if (minimum && size < minimum) {
|
|
16993
|
+
return minimum;
|
|
16994
|
+
}
|
|
16995
|
+
if (maximum && size > maximum) {
|
|
16996
|
+
return maximum;
|
|
16997
|
+
}
|
|
16998
|
+
return size;
|
|
16999
|
+
}
|
|
17000
|
+
|
|
17001
|
+
function parseFont(value, width, height) {
|
|
17002
|
+
var size = valueOrDefault(value.size, Chart$1.defaults.defaultFontSize);
|
|
17003
|
+
|
|
17004
|
+
if (value.resizable) {
|
|
17005
|
+
size = adaptTextSizeToDimensions(width, height, value.minSize, value.maxSize);
|
|
17006
|
+
}
|
|
17007
|
+
|
|
17008
|
+
var font = {
|
|
17009
|
+
family: valueOrDefault(value.family, Chart$1.defaults.defaultFontFamily),
|
|
17010
|
+
lineHeight: toLineHeight(value.lineHeight, size),
|
|
17011
|
+
lineWidth: toLineHeight(value.lineWidth, size),
|
|
17012
|
+
size,
|
|
17013
|
+
style: valueOrDefault(value.style, Chart$1.defaults.defaultFontStyle),
|
|
17014
|
+
weight: valueOrDefault(value.weight, null),
|
|
17015
|
+
string: '',
|
|
17016
|
+
};
|
|
17017
|
+
|
|
17018
|
+
font.string = toFontString(font);
|
|
17019
|
+
return font;
|
|
17020
|
+
}
|
|
17021
|
+
|
|
17022
|
+
var PLUGIN_KEY$1 = customDefaults.PLUGIN_KEY;
|
|
17023
|
+
|
|
17024
|
+
function collides(rect, otherRect) {
|
|
17025
|
+
return (
|
|
17026
|
+
rect.x < otherRect.x + otherRect.width &&
|
|
17027
|
+
rect.x + rect.width > otherRect.x &&
|
|
17028
|
+
rect.y < otherRect.y + otherRect.height &&
|
|
17029
|
+
rect.y + rect.height > otherRect.y
|
|
17030
|
+
);
|
|
17031
|
+
}
|
|
17032
|
+
|
|
17033
|
+
var classes = {
|
|
17034
|
+
OutLabel: function (chart, index, ctx, config, context) {
|
|
17035
|
+
// Check whether the label should be displayed
|
|
17036
|
+
if (!resolve([config.display, true], context, index)) {
|
|
17037
|
+
throw new Error('Label display property is set to false.');
|
|
17038
|
+
}
|
|
17039
|
+
|
|
17040
|
+
// Init text
|
|
17041
|
+
var value = context.dataset.data[index];
|
|
17042
|
+
var label = context.labels[index];
|
|
17043
|
+
var text = resolve([config.text, customDefaults.text], context, index);
|
|
17044
|
+
/* Replace label marker */
|
|
17045
|
+
text = text.replace(/%l/gi, label);
|
|
17046
|
+
|
|
17047
|
+
/* Replace value marker with possible precision value */
|
|
17048
|
+
(text.match(/%v\.?(\d*)/gi) || [])
|
|
17049
|
+
.map(function (val) {
|
|
17050
|
+
var prec = val.replace(/%v\./gi, '');
|
|
17051
|
+
if (prec.length) {
|
|
17052
|
+
return +prec;
|
|
17053
|
+
}
|
|
17054
|
+
return config.valuePrecision || customDefaults.valuePrecision;
|
|
17055
|
+
})
|
|
17056
|
+
.forEach(function (val) {
|
|
17057
|
+
text = text.replace(/%v\.?(\d*)/i, value.toFixed(val));
|
|
17058
|
+
});
|
|
17059
|
+
|
|
17060
|
+
/* Replace percent marker with possible precision value */
|
|
17061
|
+
(text.match(/%p\.?(\d*)/gi) || [])
|
|
17062
|
+
.map(function (val) {
|
|
17063
|
+
var prec = val.replace(/%p\./gi, '');
|
|
17064
|
+
if (prec.length) {
|
|
17065
|
+
return +prec;
|
|
17066
|
+
}
|
|
17067
|
+
return config.percentPrecision || customDefaults.percentPrecision;
|
|
17068
|
+
})
|
|
17069
|
+
.forEach(function (val) {
|
|
17070
|
+
text = text.replace(/%p\.?(\d*)/i, (context.percent * 100).toFixed(val) + '%');
|
|
17071
|
+
});
|
|
17072
|
+
|
|
17073
|
+
// Count lines
|
|
17074
|
+
var lines = text.match(/[^\r\n]+/g) || [];
|
|
17075
|
+
|
|
17076
|
+
// Remove unnecessary spaces
|
|
17077
|
+
for (var i = 0; i < lines.length; ++i) {
|
|
17078
|
+
lines[i] = lines[i].trim();
|
|
17079
|
+
}
|
|
17080
|
+
|
|
17081
|
+
/* ===================== CONSTRUCTOR ==================== */
|
|
17082
|
+
this.init = function (text, lines) {
|
|
17083
|
+
// If everything ok -> begin initializing
|
|
17084
|
+
this.encodedText = config.text;
|
|
17085
|
+
this.text = text;
|
|
17086
|
+
this.lines = lines;
|
|
17087
|
+
this.label = label;
|
|
17088
|
+
this.value = value;
|
|
17089
|
+
|
|
17090
|
+
// Init style
|
|
17091
|
+
this.style = {
|
|
17092
|
+
backgroundColor: resolve(
|
|
17093
|
+
[config.backgroundColor, customDefaults.backgroundColor, 'black'],
|
|
17094
|
+
context,
|
|
17095
|
+
index,
|
|
17096
|
+
),
|
|
17097
|
+
borderColor: resolve([config.borderColor, customDefaults.borderColor, 'black'], context, index),
|
|
17098
|
+
borderRadius: resolve([config.borderRadius, 0], context, index),
|
|
17099
|
+
borderWidth: resolve([config.borderWidth, 0], context, index),
|
|
17100
|
+
lineWidth: resolve([config.lineWidth, 2], context, index),
|
|
17101
|
+
lineColor: resolve([config.lineColor, customDefaults.lineColor, 'black'], context, index),
|
|
17102
|
+
color: resolve([config.color, 'white'], context, index),
|
|
17103
|
+
font: parseFont(
|
|
17104
|
+
resolve([config.font, { resizable: true }]),
|
|
17105
|
+
ctx.canvas.style.width.slice(0, -2),
|
|
17106
|
+
ctx.canvas.style.height.slice(0, -2),
|
|
17107
|
+
),
|
|
17108
|
+
padding: toPadding(resolve([config.padding, 0], context, index)),
|
|
17109
|
+
textAlign: resolve([config.textAlign, 'left'], context, index),
|
|
17110
|
+
};
|
|
17111
|
+
|
|
17112
|
+
this.stretch = resolve([config.stretch, customDefaults.stretch], context, index);
|
|
17113
|
+
this.horizontalStrechPad = resolve(
|
|
17114
|
+
[config.horizontalStrechPad, customDefaults.horizontalStrechPad],
|
|
17115
|
+
context,
|
|
17116
|
+
index,
|
|
17117
|
+
);
|
|
17118
|
+
this.size = textSize(ctx, this.lines, this.style.font);
|
|
17119
|
+
|
|
17120
|
+
this.offsetStep = this.size.width / 20;
|
|
17121
|
+
this.offset = {
|
|
17122
|
+
x: 0,
|
|
17123
|
+
y: 0,
|
|
17124
|
+
};
|
|
17125
|
+
};
|
|
17126
|
+
|
|
17127
|
+
this.init(text, lines);
|
|
17128
|
+
|
|
17129
|
+
/* COMPUTING RECTS PART */
|
|
17130
|
+
this.computeLabelRect = function () {
|
|
17131
|
+
var width =
|
|
17132
|
+
this.textRect.width + 2 * this.style.borderWidth + this.style.padding.left + this.style.padding.right;
|
|
17133
|
+
var height =
|
|
17134
|
+
this.textRect.height + 2 * this.style.borderWidth + this.style.padding.top + this.style.padding.bottom;
|
|
17135
|
+
|
|
17136
|
+
var x = this.textRect.x - this.style.borderWidth;
|
|
17137
|
+
var y = this.textRect.y - this.style.borderWidth;
|
|
17138
|
+
|
|
17139
|
+
return {
|
|
17140
|
+
x: x,
|
|
17141
|
+
y: y,
|
|
17142
|
+
width: width,
|
|
17143
|
+
height: height,
|
|
17144
|
+
isLeft: this.textRect.isLeft,
|
|
17145
|
+
isTop: this.textRect.isTop,
|
|
17146
|
+
};
|
|
17147
|
+
};
|
|
17148
|
+
|
|
17149
|
+
this.computeTextRect = function () {
|
|
17150
|
+
const isLeft = this.center.x - this.center.anchor.x < 0;
|
|
17151
|
+
const isTop = this.center.y - this.center.anchor.y < 0;
|
|
17152
|
+
const shift = isLeft ? -(this.horizontalStrechPad + this.size.width) : this.horizontalStrechPad;
|
|
17153
|
+
return {
|
|
17154
|
+
x: this.center.x - this.style.padding.left + shift,
|
|
17155
|
+
y: this.center.y - this.size.height / 2,
|
|
17156
|
+
width: this.size.width,
|
|
17157
|
+
height: this.size.height,
|
|
17158
|
+
isLeft,
|
|
17159
|
+
isTop,
|
|
17160
|
+
};
|
|
17161
|
+
};
|
|
17162
|
+
|
|
17163
|
+
/* ======================= DRAWING ======================= */
|
|
17164
|
+
// Draw label text
|
|
17165
|
+
this.drawText = function (ctx) {
|
|
17166
|
+
var align = this.style.textAlign;
|
|
17167
|
+
var font = this.style.font;
|
|
17168
|
+
var lh = font.lineHeight;
|
|
17169
|
+
var color = this.style.color;
|
|
17170
|
+
var ilen = this.lines.length;
|
|
17171
|
+
var x, y, idx;
|
|
17172
|
+
|
|
17173
|
+
if (!ilen || !color) {
|
|
17174
|
+
return;
|
|
17175
|
+
}
|
|
17176
|
+
|
|
17177
|
+
x = this.textRect.x;
|
|
17178
|
+
y = this.textRect.y + lh / 2;
|
|
17179
|
+
|
|
17180
|
+
if (align === 'center') {
|
|
17181
|
+
x += this.textRect.width / 2;
|
|
17182
|
+
} else if (align === 'end' || align === 'right') {
|
|
17183
|
+
x += this.textRect.width;
|
|
17184
|
+
}
|
|
17185
|
+
|
|
17186
|
+
ctx.font = this.style.font.string;
|
|
17187
|
+
ctx.fillStyle = color;
|
|
17188
|
+
ctx.textAlign = align;
|
|
17189
|
+
ctx.textBaseline = 'middle';
|
|
17190
|
+
|
|
17191
|
+
for (idx = 0; idx < ilen; ++idx) {
|
|
17192
|
+
ctx.fillText(
|
|
17193
|
+
this.lines[idx],
|
|
17194
|
+
Math.round(x) + this.style.padding.left,
|
|
17195
|
+
Math.round(y),
|
|
17196
|
+
Math.round(this.textRect.width),
|
|
17197
|
+
);
|
|
17198
|
+
y += lh;
|
|
17199
|
+
}
|
|
17200
|
+
};
|
|
17201
|
+
|
|
17202
|
+
// Draw label box
|
|
17203
|
+
this.drawLabel = function (ctx) {
|
|
17204
|
+
ctx.beginPath();
|
|
17205
|
+
|
|
17206
|
+
ctx.roundRect(
|
|
17207
|
+
Math.round(this.labelRect.x),
|
|
17208
|
+
Math.round(this.labelRect.y),
|
|
17209
|
+
Math.round(this.labelRect.width),
|
|
17210
|
+
Math.round(this.labelRect.height),
|
|
17211
|
+
this.style.borderRadius,
|
|
17212
|
+
);
|
|
17213
|
+
ctx.closePath();
|
|
17214
|
+
|
|
17215
|
+
if (this.style.backgroundColor) {
|
|
17216
|
+
ctx.fillStyle = this.style.backgroundColor || 'transparent';
|
|
17217
|
+
ctx.fill();
|
|
17218
|
+
}
|
|
17219
|
+
|
|
17220
|
+
if (this.style.borderColor && this.style.borderWidth) {
|
|
17221
|
+
ctx.strokeStyle = this.style.borderColor;
|
|
17222
|
+
ctx.lineWidth = this.style.borderWidth;
|
|
17223
|
+
ctx.lineJoin = 'miter';
|
|
17224
|
+
ctx.stroke();
|
|
17225
|
+
}
|
|
17226
|
+
};
|
|
17227
|
+
|
|
17228
|
+
this.ccw = function (A, B, C) {
|
|
17229
|
+
return (C.y - A.y) * (B.x - A.x) > (B.y - A.y) * (C.x - A.x);
|
|
17230
|
+
};
|
|
17231
|
+
|
|
17232
|
+
this.intersects = function (A, B, C, D) {
|
|
17233
|
+
return this.ccw(A, C, D) !== this.ccw(B, C, D) && this.ccw(A, B, C) !== this.ccw(A, B, D);
|
|
17234
|
+
};
|
|
17235
|
+
|
|
17236
|
+
this.drawLine = function (ctx) {
|
|
17237
|
+
if (!this.lines.length) {
|
|
17238
|
+
return;
|
|
17239
|
+
}
|
|
17240
|
+
ctx.save();
|
|
17241
|
+
|
|
17242
|
+
ctx.strokeStyle = this.style.lineColor;
|
|
17243
|
+
ctx.lineWidth = this.style.lineWidth;
|
|
17244
|
+
ctx.lineJoin = 'miter';
|
|
17245
|
+
ctx.beginPath();
|
|
17246
|
+
ctx.moveTo(this.center.anchor.x, this.center.anchor.y);
|
|
17247
|
+
ctx.lineTo(this.center.copy.x, this.center.copy.y);
|
|
17248
|
+
ctx.stroke();
|
|
17249
|
+
|
|
17250
|
+
ctx.beginPath();
|
|
17251
|
+
ctx.moveTo(this.center.copy.x, this.center.copy.y);
|
|
17252
|
+
const xOffset = this.textRect.width + this.style.padding.width;
|
|
17253
|
+
const intersect = this.intersects(
|
|
17254
|
+
this.textRect,
|
|
17255
|
+
{
|
|
17256
|
+
x: this.textRect.x + this.textRect.width,
|
|
17257
|
+
y: this.textRect.y + this.textRect.height,
|
|
17258
|
+
},
|
|
17259
|
+
this.center.copy,
|
|
17260
|
+
{
|
|
17261
|
+
x: this.textRect.x,
|
|
17262
|
+
y: this.textRect.y + this.textRect.height / 2,
|
|
17263
|
+
},
|
|
17264
|
+
);
|
|
17265
|
+
ctx.lineTo(this.textRect.x + (intersect ? xOffset : 0), this.textRect.y + this.textRect.height / 2);
|
|
17266
|
+
ctx.stroke();
|
|
17267
|
+
ctx.restore();
|
|
17268
|
+
};
|
|
17269
|
+
|
|
17270
|
+
this.draw = function (ctx) {
|
|
17271
|
+
if (chart.getDataVisibility(index)) {
|
|
17272
|
+
this.drawLabel(ctx);
|
|
17273
|
+
this.drawText(ctx);
|
|
17274
|
+
this.drawLine(ctx);
|
|
17275
|
+
}
|
|
17276
|
+
};
|
|
17277
|
+
|
|
17278
|
+
// eslint-disable-next-line max-statements
|
|
17279
|
+
this.update = function (view, elements, max) {
|
|
17280
|
+
this.center = positioners.center(view, this.stretch);
|
|
17281
|
+
|
|
17282
|
+
let valid = false;
|
|
17283
|
+
let steps = 30;
|
|
17284
|
+
|
|
17285
|
+
while (!valid && steps > 0) {
|
|
17286
|
+
this.textRect = this.computeTextRect();
|
|
17287
|
+
this.labelRect = this.computeLabelRect();
|
|
17288
|
+
|
|
17289
|
+
valid = true;
|
|
17290
|
+
|
|
17291
|
+
for (var e = 0; e < max; ++e) {
|
|
17292
|
+
var element = elements[e][PLUGIN_KEY$1];
|
|
17293
|
+
if (!element || !chart.getDataVisibility(index)) {
|
|
17294
|
+
continue;
|
|
17295
|
+
}
|
|
17296
|
+
|
|
17297
|
+
if (collides(this.labelRect, element.labelRect)) {
|
|
17298
|
+
valid = false;
|
|
17299
|
+
break;
|
|
17300
|
+
}
|
|
17301
|
+
}
|
|
17302
|
+
|
|
17303
|
+
if (!valid) {
|
|
17304
|
+
this.center = positioners.moveFromAnchor(this.center, 5);
|
|
17305
|
+
}
|
|
17306
|
+
|
|
17307
|
+
steps--;
|
|
17308
|
+
}
|
|
17309
|
+
};
|
|
17310
|
+
},
|
|
17311
|
+
};
|
|
17312
|
+
|
|
17313
|
+
defaults$1.plugins.outlabels = customDefaults;
|
|
17314
|
+
|
|
17315
|
+
var PLUGIN_KEY = customDefaults.PLUGIN_KEY;
|
|
17316
|
+
|
|
17317
|
+
function configure$1(dataset, options) {
|
|
17318
|
+
var override = dataset.outlabels;
|
|
17319
|
+
var config = {};
|
|
17320
|
+
|
|
17321
|
+
if (override === false) {
|
|
17322
|
+
return null;
|
|
17323
|
+
}
|
|
17324
|
+
if (override === true) {
|
|
17325
|
+
override = {};
|
|
17326
|
+
}
|
|
17327
|
+
|
|
17328
|
+
return Object.assign({}, config, options, override);
|
|
17329
|
+
}
|
|
17330
|
+
|
|
17331
|
+
/**
|
|
17332
|
+
* Returns the bounding box of the given label elements.
|
|
17333
|
+
*
|
|
17334
|
+
* @param {*} elements List of chart elements
|
|
17335
|
+
* @returns Bounding box
|
|
17336
|
+
*/
|
|
17337
|
+
function getBoundingBox(elements) {
|
|
17338
|
+
const rect = { left: Infinity, right: -Infinity, top: Infinity, bottom: -Infinity };
|
|
17339
|
+
|
|
17340
|
+
for (let i = 0, l = elements.length; i < l; i++) {
|
|
17341
|
+
const outlabel = elements[i][PLUGIN_KEY];
|
|
17342
|
+
if (!outlabel || !outlabel.labelRect) {
|
|
17343
|
+
continue;
|
|
17344
|
+
}
|
|
17345
|
+
|
|
17346
|
+
const { labelRect } = outlabel;
|
|
17347
|
+
const { x, y, width, height } = labelRect;
|
|
17348
|
+
|
|
17349
|
+
rect.left = Math.min(rect.left, x);
|
|
17350
|
+
rect.right = Math.max(rect.right, x + width);
|
|
17351
|
+
rect.top = Math.min(rect.top, y);
|
|
17352
|
+
rect.bottom = Math.max(rect.bottom, y + height);
|
|
17353
|
+
}
|
|
17354
|
+
|
|
17355
|
+
return {
|
|
17356
|
+
...rect,
|
|
17357
|
+
width: rect.right - rect.left,
|
|
17358
|
+
height: rect.bottom - rect.top,
|
|
17359
|
+
};
|
|
17360
|
+
}
|
|
17361
|
+
|
|
17362
|
+
/**
|
|
17363
|
+
* Returns the zoom percentage required to fit the given bounding box within the given bounding box.
|
|
17364
|
+
*
|
|
17365
|
+
* @param {*} boundingBoxToResize
|
|
17366
|
+
* @param {*} boundingBoxToFitWithin
|
|
17367
|
+
* @returns Zoom percentage
|
|
17368
|
+
*/
|
|
17369
|
+
function getResizeZoomPercentage(boundingBoxToResize, boundingBoxToFitWithin) {
|
|
17370
|
+
const { width, height } = boundingBoxToFitWithin;
|
|
17371
|
+
const deltas = [
|
|
17372
|
+
((boundingBoxToFitWithin.left - boundingBoxToResize.left) / width) * 2,
|
|
17373
|
+
((boundingBoxToFitWithin.top - boundingBoxToResize.top) / height) * 2,
|
|
17374
|
+
((boundingBoxToResize.right - boundingBoxToFitWithin.right) / width) * 2,
|
|
17375
|
+
((boundingBoxToResize.bottom - boundingBoxToFitWithin.bottom) / height) * 2,
|
|
17376
|
+
];
|
|
17377
|
+
|
|
17378
|
+
const maxDelta = Math.max(0, ...deltas);
|
|
17379
|
+
return 1 - maxDelta;
|
|
17380
|
+
}
|
|
17381
|
+
|
|
17382
|
+
/**
|
|
17383
|
+
* Updates the labels of the given elements.
|
|
17384
|
+
* @param {*} elements
|
|
17385
|
+
*/
|
|
17386
|
+
function updateLabels(elements) {
|
|
17387
|
+
for (let i = 0, l = elements.length; i < l; i++) {
|
|
17388
|
+
const element = elements[i];
|
|
17389
|
+
const outlabel = element[PLUGIN_KEY];
|
|
17390
|
+
if (!outlabel) {
|
|
17391
|
+
continue;
|
|
17392
|
+
}
|
|
17393
|
+
|
|
17394
|
+
outlabel.update(element, elements, i);
|
|
17395
|
+
}
|
|
17396
|
+
}
|
|
17397
|
+
|
|
17398
|
+
function fitChartArea(chart) {
|
|
17399
|
+
const ctrl = chart._metasets[0].controller;
|
|
17400
|
+
const meta = ctrl.getMeta();
|
|
17401
|
+
const elements = meta.data || [];
|
|
17402
|
+
|
|
17403
|
+
const boundingBox = getBoundingBox(elements);
|
|
17404
|
+
const zoom = getResizeZoomPercentage(boundingBox, chart.chartArea);
|
|
17405
|
+
|
|
17406
|
+
if (zoom && zoom !== 1) {
|
|
17407
|
+
ctrl.outerRadius = ctrl.outerRadius * zoom;
|
|
17408
|
+
ctrl.innerRadius *= zoom;
|
|
17409
|
+
|
|
17410
|
+
ctrl.updateElements(meta.data, 0, meta.data.length, 'none');
|
|
17411
|
+
return true;
|
|
17412
|
+
}
|
|
17413
|
+
|
|
17414
|
+
return false;
|
|
17415
|
+
}
|
|
17416
|
+
|
|
17417
|
+
var plugin = {
|
|
17418
|
+
id: 'outlabels',
|
|
17419
|
+
resize: function (chart) {
|
|
17420
|
+
getState(chart).sizeChanged = true;
|
|
17421
|
+
},
|
|
17422
|
+
afterUpdate: (chart) => {
|
|
17423
|
+
const ctrl = chart._metasets[0].controller;
|
|
17424
|
+
const meta = ctrl.getMeta();
|
|
17425
|
+
const elements = meta.data || [];
|
|
17426
|
+
|
|
17427
|
+
let fit = false;
|
|
17428
|
+
// Limit the number of steps to prevent infinite loops
|
|
17429
|
+
// It seems that using the number of elements will ensure that the chart
|
|
17430
|
+
// fits by positioning all labels in successive resizes
|
|
17431
|
+
let maxSteps = elements.length;
|
|
17432
|
+
|
|
17433
|
+
// Avoid to draw labels while fitting the chart area
|
|
17434
|
+
getState(chart).fitting = true;
|
|
17435
|
+
|
|
17436
|
+
while (!fit && maxSteps-- > 0) {
|
|
17437
|
+
updateLabels(elements);
|
|
17438
|
+
fit = !fitChartArea(chart);
|
|
17439
|
+
}
|
|
17440
|
+
|
|
17441
|
+
getState(chart).fitting = false;
|
|
17442
|
+
},
|
|
17443
|
+
afterDatasetUpdate: function (chart, args, options) {
|
|
17444
|
+
var labels = chart.config.data.labels;
|
|
17445
|
+
var dataset = chart.data.datasets[args.index];
|
|
17446
|
+
var config = configure$1(dataset, options);
|
|
17447
|
+
var display = config && config.display;
|
|
17448
|
+
var elements = args.meta.data || [];
|
|
17449
|
+
var ctx = chart.ctx;
|
|
17450
|
+
var el, label, percent, newLabel, context, i;
|
|
17451
|
+
ctx.save();
|
|
17452
|
+
|
|
17453
|
+
for (i = 0; i < elements.length; ++i) {
|
|
17454
|
+
el = elements[i];
|
|
17455
|
+
label = el[PLUGIN_KEY];
|
|
17456
|
+
percent = dataset.data[i] / args.meta.total;
|
|
17457
|
+
newLabel = null;
|
|
17458
|
+
|
|
17459
|
+
if (display && el && !el.hidden) {
|
|
17460
|
+
try {
|
|
17461
|
+
context = {
|
|
17462
|
+
chart: chart,
|
|
17463
|
+
dataIndex: i,
|
|
17464
|
+
dataset: dataset,
|
|
17465
|
+
labels: labels,
|
|
17466
|
+
datasetIndex: args.index,
|
|
17467
|
+
percent: percent,
|
|
17468
|
+
};
|
|
17469
|
+
newLabel = new classes.OutLabel(chart, i, ctx, config, context);
|
|
17470
|
+
} catch (e) {
|
|
17471
|
+
newLabel = null;
|
|
17472
|
+
}
|
|
17473
|
+
}
|
|
17474
|
+
|
|
17475
|
+
if (
|
|
17476
|
+
label &&
|
|
17477
|
+
newLabel &&
|
|
17478
|
+
!getState(chart).sizeChanged &&
|
|
17479
|
+
label.label === newLabel.label &&
|
|
17480
|
+
label.encodedText === newLabel.encodedText
|
|
17481
|
+
) {
|
|
17482
|
+
newLabel.offset = label.offset;
|
|
17483
|
+
}
|
|
17484
|
+
el[PLUGIN_KEY] = newLabel;
|
|
17485
|
+
}
|
|
17486
|
+
|
|
17487
|
+
ctx.restore();
|
|
17488
|
+
getState(chart).sizeChanged = false;
|
|
17489
|
+
},
|
|
17490
|
+
afterDatasetDraw: function (chart, args) {
|
|
17491
|
+
var elements = args.meta.data || [];
|
|
17492
|
+
var ctx = chart.ctx;
|
|
17493
|
+
|
|
17494
|
+
if (getState(chart).fitting) {
|
|
17495
|
+
return;
|
|
17496
|
+
}
|
|
17497
|
+
|
|
17498
|
+
elements.forEach((el, index) => {
|
|
17499
|
+
const outlabelPlugin = el[PLUGIN_KEY];
|
|
17500
|
+
if (!outlabelPlugin) {
|
|
17501
|
+
return;
|
|
17502
|
+
}
|
|
17503
|
+
outlabelPlugin.update(el, elements, index);
|
|
17504
|
+
outlabelPlugin.draw(ctx);
|
|
17505
|
+
});
|
|
17506
|
+
},
|
|
17507
|
+
afterDestroy: function (chart) {
|
|
17508
|
+
removeState(chart);
|
|
17509
|
+
},
|
|
17510
|
+
};
|
|
17511
|
+
|
|
15340
17512
|
Chart$1.register(ArcElement, plugin_tooltip, plugin_legend);
|
|
15341
17513
|
const PieChart = (props) => {
|
|
15342
17514
|
const { data, title, options, units, content } = props;
|
|
@@ -15414,7 +17586,7 @@ const PieChart = (props) => {
|
|
|
15414
17586
|
},
|
|
15415
17587
|
},
|
|
15416
17588
|
};
|
|
15417
|
-
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [
|
|
17589
|
+
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin] });
|
|
15418
17590
|
};
|
|
15419
17591
|
|
|
15420
17592
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
@@ -15491,13 +17663,14 @@ function LineChart({ title, data, options, className, units, content }) {
|
|
|
15491
17663
|
},
|
|
15492
17664
|
},
|
|
15493
17665
|
};
|
|
15494
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [
|
|
17666
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin$1] }));
|
|
15495
17667
|
}
|
|
15496
17668
|
|
|
15497
17669
|
function DataGrid({ title, data, className }) {
|
|
15498
17670
|
var _a;
|
|
15499
|
-
const { columns, rows, grouped = false, grouping } = data;
|
|
17671
|
+
const { columns, rows, units, grouped = false, grouping } = data;
|
|
15500
17672
|
const [expandedGroups, setExpandedGroups] = React.useState(new Set(((_a = grouping === null || grouping === void 0 ? void 0 : grouping.sections) === null || _a === void 0 ? void 0 : _a.filter(s => s.expanded).map(s => s.group_value)) || []));
|
|
17673
|
+
console.log('units==>', units);
|
|
15501
17674
|
const toggleGroup = (groupValue) => {
|
|
15502
17675
|
const newExpanded = new Set(expandedGroups);
|
|
15503
17676
|
if (newExpanded.has(groupValue)) {
|
|
@@ -15508,6 +17681,30 @@ function DataGrid({ title, data, className }) {
|
|
|
15508
17681
|
}
|
|
15509
17682
|
setExpandedGroups(newExpanded);
|
|
15510
17683
|
};
|
|
17684
|
+
const formatValueWithUnit = (value, columnIndex) => {
|
|
17685
|
+
if (value === null || value === undefined)
|
|
17686
|
+
return "—";
|
|
17687
|
+
const unit = units === null || units === void 0 ? void 0 : units[columnIndex];
|
|
17688
|
+
// Format the value with commas if it's a number or numeric string
|
|
17689
|
+
let valueStr;
|
|
17690
|
+
if (typeof value === 'number') {
|
|
17691
|
+
valueStr = value.toLocaleString();
|
|
17692
|
+
}
|
|
17693
|
+
else {
|
|
17694
|
+
const numValue = parseFloat(String(value));
|
|
17695
|
+
valueStr = !isNaN(numValue) ? numValue.toLocaleString() : String(value);
|
|
17696
|
+
}
|
|
17697
|
+
// If no unit or unit length > 3, return value only
|
|
17698
|
+
if (!unit || unit.length > 3) {
|
|
17699
|
+
return valueStr;
|
|
17700
|
+
}
|
|
17701
|
+
// If unit is $, display unit before value
|
|
17702
|
+
if (unit === '$') {
|
|
17703
|
+
return `${unit}${valueStr}`;
|
|
17704
|
+
}
|
|
17705
|
+
// Otherwise display value then unit
|
|
17706
|
+
return `${valueStr}${unit}`;
|
|
17707
|
+
};
|
|
15511
17708
|
// Backward compatibility: if no data or not grouped, show original table
|
|
15512
17709
|
if (!columns || columns.length === 0 || (!grouped && (!rows || rows.length === 0))) {
|
|
15513
17710
|
return (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500", children: "No data available" }) }));
|
|
@@ -15519,7 +17716,7 @@ function DataGrid({ title, data, className }) {
|
|
|
15519
17716
|
const renderGroupedTable = () => {
|
|
15520
17717
|
if (!(grouping === null || grouping === void 0 ? void 0 : grouping.sections))
|
|
15521
17718
|
return null;
|
|
15522
|
-
return (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-200", children: [jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50 w-8" }), columns.map((column, index) => (jsxRuntimeExports.
|
|
17719
|
+
return (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-200", children: [jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50 w-8" }), columns.map((column, index) => (jsxRuntimeExports.jsxs("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: [column, (units === null || units === void 0 ? void 0 : units[index]) ? ` (${units[index]})` : ''] }, index)))] }) }), jsxRuntimeExports.jsx("tbody", { children: grouping.sections.map((section, sectionIndex) => {
|
|
15523
17720
|
const isExpanded = expandedGroups.has(section.group_value);
|
|
15524
17721
|
return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsxs("tr", { className: "bg-blue-50 border-b border-gray-200", children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3", children: section.collapsible && (jsxRuntimeExports.jsx("button", { onClick: () => toggleGroup(section.group_value), className: "flex items-center justify-center w-6 h-6 hover:bg-blue-100 rounded transition-colors", "aria-label": isExpanded ? "Collapse group" : "Expand group", children: isExpanded ? (jsxRuntimeExports.jsx(lucideReact.ChevronDown, { className: "w-4 h-4 text-blue-600" })) : (jsxRuntimeExports.jsx(lucideReact.ChevronRight, { className: "w-4 h-4 text-blue-600" })) })) }), columns.map((column, columnIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm font-medium text-blue-700", children: columnIndex === 0 ? (jsxRuntimeExports.jsxs("span", { className: "font-semibold text-blue-900", children: [section.title, ": ", section.group_value] })) : (jsxRuntimeExports.jsx("div", { className: "text-left", children: (() => {
|
|
15525
17722
|
var _a;
|
|
@@ -15531,7 +17728,7 @@ function DataGrid({ title, data, className }) {
|
|
|
15531
17728
|
if (sectionStats[column] &&
|
|
15532
17729
|
typeof sectionStats[column].total === 'number' &&
|
|
15533
17730
|
!isNaN(sectionStats[column].total)) {
|
|
15534
|
-
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[column].total
|
|
17731
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: formatValueWithUnit(sectionStats[column].total, columnIndex) }));
|
|
15535
17732
|
}
|
|
15536
17733
|
// If exact match fails, try to find by partial match
|
|
15537
17734
|
const matchingKey = Object.keys(sectionStats).find(key => key.toLowerCase().includes(column.toLowerCase()) ||
|
|
@@ -15539,17 +17736,17 @@ function DataGrid({ title, data, className }) {
|
|
|
15539
17736
|
if (matchingKey && sectionStats[matchingKey] &&
|
|
15540
17737
|
typeof sectionStats[matchingKey].total === 'number' &&
|
|
15541
17738
|
!isNaN(sectionStats[matchingKey].total)) {
|
|
15542
|
-
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[matchingKey].total
|
|
17739
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: formatValueWithUnit(sectionStats[matchingKey].total, columnIndex) }));
|
|
15543
17740
|
}
|
|
15544
17741
|
return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
|
|
15545
17742
|
})() })) }, columnIndex)))] }), (!section.collapsible || isExpanded) && section.rows.map((row, rowIndex) => (jsxRuntimeExports.jsxs("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
15546
17743
|
? "bg-white"
|
|
15547
|
-
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell
|
|
17744
|
+
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
|
|
15548
17745
|
}) })] }));
|
|
15549
17746
|
};
|
|
15550
|
-
const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.
|
|
17747
|
+
const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.jsxs("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: [column, (units === null || units === void 0 ? void 0 : units[index]) ? ` (${units[index]})` : ''] }, index))) }) }), jsxRuntimeExports.jsx("tbody", { children: rows.map((row, rowIndex) => (jsxRuntimeExports.jsx("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
15551
17748
|
? "bg-white"
|
|
15552
|
-
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell
|
|
17749
|
+
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex))) }, rowIndex))) })] }));
|
|
15553
17750
|
return (jsxRuntimeExports.jsxs("div", { className: `h-full flex flex-col ${className || ""}`, children: [title && (jsxRuntimeExports.jsx("div", { className: "pb-4", children: jsxRuntimeExports.jsx("h3", { className: "text-lg font-bold", style: {
|
|
15554
17751
|
color: "#0F172A"
|
|
15555
17752
|
}, children: title }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntimeExports.jsx("div", { className: "min-w-full", children: grouped && grouping ? renderGroupedTable() : renderRegularTable() }) }), jsxRuntimeExports.jsx("div", { className: "pt-2 text-xs text-gray-500", children: grouped && grouping && grouping.section_statistics ? (jsxRuntimeExports.jsxs("div", { className: "flex gap-6", children: [jsxRuntimeExports.jsxs("span", { children: [grouping.total_groups, " group", grouping.total_groups !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] }), jsxRuntimeExports.jsx("div", { className: "flex gap-4", children: (() => {
|
|
@@ -15561,7 +17758,10 @@ function DataGrid({ title, data, className }) {
|
|
|
15561
17758
|
}
|
|
15562
17759
|
});
|
|
15563
17760
|
});
|
|
15564
|
-
return Object.entries(totals).map(([column, total], index) =>
|
|
17761
|
+
return Object.entries(totals).map(([column, total], index) => {
|
|
17762
|
+
const columnIndex = columns.findIndex(col => col === column);
|
|
17763
|
+
return (jsxRuntimeExports.jsxs("span", { className: "font-medium", children: ["Total ", column, ": ", formatValueWithUnit(total, columnIndex)] }, index));
|
|
17764
|
+
});
|
|
15565
17765
|
})() })] })) : (jsxRuntimeExports.jsxs("span", { children: ["Showing ", rows.length, " row", rows.length !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] })) })] }));
|
|
15566
17766
|
}
|
|
15567
17767
|
|
|
@@ -36674,11 +38874,12 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36674
38874
|
return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36675
38875
|
}
|
|
36676
38876
|
function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36677
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
38877
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
36678
38878
|
const hasCalledRef = React.useRef(false);
|
|
36679
38879
|
const columns = ((_b = (_a = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.headers) || ((_e = (_d = (_c = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _c === void 0 ? void 0 : _c.matrix_grid_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.headers) || [];
|
|
36680
38880
|
const rows = ((_g = (_f = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.rows) || ((_k = (_j = (_h = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _h === void 0 ? void 0 : _h.matrix_grid_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.rows) || [];
|
|
36681
38881
|
const gridTitle = ((_l = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _l === void 0 ? void 0 : _l.title) || ((_o = (_m = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _m === void 0 ? void 0 : _m.matrix_grid_data) === null || _o === void 0 ? void 0 : _o.title) || "";
|
|
38882
|
+
const units = ((_q = (_p = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.units) || ((_t = (_s = (_r = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _r === void 0 ? void 0 : _r.matrix_grid_data) === null || _s === void 0 ? void 0 : _s.data) === null || _t === void 0 ? void 0 : _t.units) || [];
|
|
36682
38883
|
const isEmpty = columns.length === 0 || rows.length === 0;
|
|
36683
38884
|
const handleRefresh = async () => {
|
|
36684
38885
|
if (query) {
|
|
@@ -36712,9 +38913,10 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36712
38913
|
}
|
|
36713
38914
|
const transformedData = {
|
|
36714
38915
|
columns: columns,
|
|
38916
|
+
units: units,
|
|
36715
38917
|
rows: rows,
|
|
36716
|
-
grouped: ((
|
|
36717
|
-
grouping: ((
|
|
38918
|
+
grouped: ((_u = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _u === void 0 ? void 0 : _u.grouped) || ((_w = (_v = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _v === void 0 ? void 0 : _v.matrix_grid_data) === null || _w === void 0 ? void 0 : _w.grouped) || false,
|
|
38919
|
+
grouping: ((_x = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _x === void 0 ? void 0 : _x.grouping) || ((_z = (_y = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _y === void 0 ? void 0 : _y.matrix_grid_data) === null || _z === void 0 ? void 0 : _z.grouping)
|
|
36718
38920
|
};
|
|
36719
38921
|
return (jsxRuntimeExports.jsx(DataGrid, { title: gridTitle, data: transformedData, className: "" }));
|
|
36720
38922
|
}
|
|
@@ -36864,7 +39066,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36864
39066
|
React.useEffect(() => {
|
|
36865
39067
|
const handleTriggerAgent = (event) => {
|
|
36866
39068
|
const { widgetId, query, agentType: eventAgentType, datasetId } = event.detail;
|
|
36867
|
-
console.log('event.detail==>', event.detail);
|
|
36868
39069
|
if (widgetId === widget.id) {
|
|
36869
39070
|
let messageContent = query;
|
|
36870
39071
|
// Customize message based on agent type
|
|
@@ -40744,7 +42945,7 @@ function SavedPages({ onEditPage, widgetBackendUrl }) {
|
|
|
40744
42945
|
if (isLoading) {
|
|
40745
42946
|
return (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-screen", children: jsxRuntimeExports.jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }) }));
|
|
40746
42947
|
}
|
|
40747
|
-
return (jsxRuntimeExports.jsxs("div", { className: "container mx-auto p-6 space-y-6", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsx("h1", { className: "text-2xl font-bold", children: "Saved Pages" }), jsxRuntimeExports.jsxs(Button, { onClick: handleCreatePage, children: [jsxRuntimeExports.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }), "Create New Page"] })] }), error && (jsxRuntimeExports.jsx(Alert, { variant: "destructive", children: jsxRuntimeExports.jsx(AlertDescription, { children: error }) })), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(lucideReact.Search, { className: "h-4 w-4 text-muted-foreground" }), jsxRuntimeExports.jsx(Input, { placeholder: "Search pages...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), className: "max-w-sm" })] }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6", children: filteredPages.map((page) => (jsxRuntimeExports.jsxs(Card, { className: "hover:shadow-lg transition-shadow", children: [jsxRuntimeExports.jsxs(CardHeader, { children: [jsxRuntimeExports.jsx(CardTitle, { children: page.title }), jsxRuntimeExports.jsxs(CardDescription, { children: ["Created: ", format(new Date(page.created_at), "PPP")] })] }), jsxRuntimeExports.jsx(CardContent, { children: jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2 text-sm text-muted-foreground", children: [jsxRuntimeExports.jsx(lucideReact.LayoutGrid, { className: "h-4 w-4" }), jsxRuntimeExports.jsxs("span", { children: ["Page #", page.id] })] }), jsxRuntimeExports.jsxs("div", { className: "flex space-x-2", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => onEditPage(page.id), children: jsxRuntimeExports.jsx(lucideReact.Edit2, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => handleDeletePage(page.id), children: jsxRuntimeExports.jsx(lucideReact.Trash2, { className: "h-4 w-4" }) })] })] }) })] }, page.id))) }), filteredPages.length === 0 && (jsxRuntimeExports.jsx("div", { className: "text-center text-muted-foreground py-12", children: "No pages found. Create a new one to get started." })), jsxRuntimeExports.jsx(Dialog, { open: isCreateModalOpen, onOpenChange: setIsCreateModalOpen, children: jsxRuntimeExports.jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [jsxRuntimeExports.jsxs(DialogHeader, { children: [jsxRuntimeExports.jsx(DialogTitle, { children: "Create New Page" }), jsxRuntimeExports.jsx(DialogDescription, { children: "Create a new page with widgets. You can customize it after creation." })] }), jsxRuntimeExports.jsxs("div", { className: "grid gap-4 py-4", children: [jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [jsxRuntimeExports.jsx(Label, { htmlFor: "title", className: "text-right", children: "Title" }), jsxRuntimeExports.jsx(Input, { id: "title", value: newPageTitle, onChange: (e) => setNewPageTitle(e.target.value), placeholder: "Enter page title...", className: "col-span-3" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Checkbox, { id: "public", checked: newPageIsPublic, onCheckedChange: (checked) => setNewPageIsPublic(checked === true) }), jsxRuntimeExports.jsx(Label, { htmlFor: "public", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: "Make this page public" })] })] }), jsxRuntimeExports.jsxs(DialogFooter, { children: [jsxRuntimeExports.jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
42948
|
+
return (jsxRuntimeExports.jsxs("div", { className: "container mx-auto p-6 space-y-6", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsx("h1", { className: "text-2xl font-bold", children: "Saved Pages" }), jsxRuntimeExports.jsxs(Button, { onClick: handleCreatePage, children: [jsxRuntimeExports.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }), "Create New Page"] })] }), error && (jsxRuntimeExports.jsx(Alert, { variant: "destructive", children: jsxRuntimeExports.jsx(AlertDescription, { children: error }) })), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(lucideReact.Search, { className: "h-4 w-4 text-muted-foreground" }), jsxRuntimeExports.jsx(Input, { placeholder: "Search pages...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), className: "max-w-sm" })] }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6", children: filteredPages.map((page) => (jsxRuntimeExports.jsxs(Card, { className: "hover:shadow-lg transition-shadow", children: [jsxRuntimeExports.jsxs(CardHeader, { children: [jsxRuntimeExports.jsx(CardTitle, { children: page.title }), jsxRuntimeExports.jsxs(CardDescription, { children: ["Created: ", format(new Date(page.created_at), "PPP")] })] }), jsxRuntimeExports.jsx(CardContent, { children: jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2 text-sm text-muted-foreground", children: [jsxRuntimeExports.jsx(lucideReact.LayoutGrid, { className: "h-4 w-4" }), jsxRuntimeExports.jsxs("span", { children: ["Page #", page.id] })] }), jsxRuntimeExports.jsxs("div", { className: "flex space-x-2", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => onEditPage(page.id), children: jsxRuntimeExports.jsx(lucideReact.Edit2, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => handleDeletePage(page.id), children: jsxRuntimeExports.jsx(lucideReact.Trash2, { className: "h-4 w-4" }) })] })] }) })] }, page.id))) }), filteredPages.length === 0 && (jsxRuntimeExports.jsx("div", { className: "text-center text-muted-foreground py-12", children: "No pages found. Create a new one to get started." })), jsxRuntimeExports.jsx(Dialog, { open: isCreateModalOpen, onOpenChange: setIsCreateModalOpen, children: jsxRuntimeExports.jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [jsxRuntimeExports.jsxs(DialogHeader, { children: [jsxRuntimeExports.jsx(DialogTitle, { children: "Create New Page" }), jsxRuntimeExports.jsx(DialogDescription, { children: "Create a new page with widgets. You can customize it after creation." })] }), jsxRuntimeExports.jsxs("div", { className: "grid gap-4 py-4", children: [jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [jsxRuntimeExports.jsx(Label$1, { htmlFor: "title", className: "text-right", children: "Title" }), jsxRuntimeExports.jsx(Input, { id: "title", value: newPageTitle, onChange: (e) => setNewPageTitle(e.target.value), placeholder: "Enter page title...", className: "col-span-3" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Checkbox, { id: "public", checked: newPageIsPublic, onCheckedChange: (checked) => setNewPageIsPublic(checked === true) }), jsxRuntimeExports.jsx(Label$1, { htmlFor: "public", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: "Make this page public" })] })] }), jsxRuntimeExports.jsxs(DialogFooter, { children: [jsxRuntimeExports.jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
40748
42949
|
setIsCreateModalOpen(false);
|
|
40749
42950
|
setNewPageTitle("");
|
|
40750
42951
|
setNewPageIsPublic(false);
|