dp-widgets-framework 1.3.6 → 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 +2234 -71
- package/dist/index.js +2234 -71
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -16,8 +16,6 @@ import { WidthProvider, Responsive } from 'react-grid-layout';
|
|
|
16
16
|
import { v4 } from 'uuid';
|
|
17
17
|
import { CopilotKit, useCopilotContext, useCoAgent, useCopilotChat } from '@copilotkit/react-core';
|
|
18
18
|
import { CopilotChat } from '@copilotkit/react-ui';
|
|
19
|
-
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
|
20
|
-
import ChartPieChartOutlabels from '@energiency/chartjs-plugin-piechart-outlabels';
|
|
21
19
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
22
20
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
23
21
|
|
|
@@ -1487,11 +1485,11 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
1487
1485
|
Input.displayName = "Input";
|
|
1488
1486
|
|
|
1489
1487
|
const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
1490
|
-
const Label = React.forwardRef((_a, ref) => {
|
|
1488
|
+
const Label$1 = React.forwardRef((_a, ref) => {
|
|
1491
1489
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1492
1490
|
return (jsxRuntimeExports.jsx(LabelPrimitive.Root, Object.assign({ ref: ref, className: cn(labelVariants(), className) }, props)));
|
|
1493
1491
|
});
|
|
1494
|
-
Label.displayName = LabelPrimitive.Root.displayName;
|
|
1492
|
+
Label$1.displayName = LabelPrimitive.Root.displayName;
|
|
1495
1493
|
|
|
1496
1494
|
const Switch = React.forwardRef((_a, ref) => {
|
|
1497
1495
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
@@ -1800,17 +1798,17 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1800
1798
|
};
|
|
1801
1799
|
const renderCommonSettings = () => {
|
|
1802
1800
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
1803
|
-
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" })] })] })] })] }));
|
|
1801
|
+
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" })] })] })] })] }));
|
|
1804
1802
|
};
|
|
1805
1803
|
const renderSearchSettings = () => {
|
|
1806
1804
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1807
|
-
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({
|
|
1805
|
+
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({
|
|
1808
1806
|
minCharacters: parseInt(e.target.value) || 3,
|
|
1809
|
-
}), 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({
|
|
1807
|
+
}), 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({
|
|
1810
1808
|
searchDelay: parseInt(e.target.value) || 300,
|
|
1811
|
-
}), 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({
|
|
1809
|
+
}), 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({
|
|
1812
1810
|
maxRecentSearches: parseInt(e.target.value) || 5,
|
|
1813
|
-
}), 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) => {
|
|
1811
|
+
}), 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) => {
|
|
1814
1812
|
var _a, _b, _c;
|
|
1815
1813
|
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) || [] }) });
|
|
1816
1814
|
updateWidgetAPI(widget.id, { config: newConfig }).catch(console.error);
|
|
@@ -1821,29 +1819,29 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1821
1819
|
};
|
|
1822
1820
|
const renderResultsSettings = () => {
|
|
1823
1821
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1824
|
-
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) => {
|
|
1822
|
+
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) => {
|
|
1825
1823
|
var _a;
|
|
1826
1824
|
return updateConfig({
|
|
1827
1825
|
layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { type: value }),
|
|
1828
1826
|
});
|
|
1829
|
-
}, 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) => {
|
|
1827
|
+
}, 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) => {
|
|
1830
1828
|
var _a;
|
|
1831
1829
|
return updateConfig({
|
|
1832
1830
|
layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { itemsPerPage: parseInt(value) }),
|
|
1833
1831
|
});
|
|
1834
|
-
}, 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) => {
|
|
1832
|
+
}, 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) => {
|
|
1835
1833
|
var _a;
|
|
1836
1834
|
return updateConfig({
|
|
1837
1835
|
layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { infiniteScroll: checked }),
|
|
1838
1836
|
});
|
|
1839
|
-
} })] }), 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) => {
|
|
1837
|
+
} })] }), 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) => {
|
|
1840
1838
|
const newConfig = Object.assign(Object.assign({}, widget.config), { metadata: Object.assign(Object.assign({}, widget.config.metadata), { fields }) });
|
|
1841
1839
|
updateWidgetAPI(widget.id, { config: newConfig }).catch(console.error);
|
|
1842
1840
|
}, maxFields: ((_p = (_o = widget.config) === null || _o === void 0 ? void 0 : _o.facets) === null || _p === void 0 ? void 0 : _p.maxFields) || 10 })] })] }));
|
|
1843
1841
|
};
|
|
1844
1842
|
const renderCodeSettings = () => {
|
|
1845
1843
|
var _a;
|
|
1846
|
-
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) ||
|
|
1844
|
+
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) ||
|
|
1847
1845
|
`// Custom search widget code
|
|
1848
1846
|
// You can modify the widget behavior here
|
|
1849
1847
|
function customSearch(query) {
|
|
@@ -1858,7 +1856,7 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1858
1856
|
};
|
|
1859
1857
|
const renderFilterSettings = () => {
|
|
1860
1858
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1861
|
-
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) => {
|
|
1859
|
+
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) => {
|
|
1862
1860
|
var _a, _b, _c;
|
|
1863
1861
|
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) || [] }) });
|
|
1864
1862
|
console.log("newConfig", newConfig);
|
|
@@ -1870,14 +1868,14 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1870
1868
|
};
|
|
1871
1869
|
const renderAgentSettings = () => {
|
|
1872
1870
|
var _a, _b, _c, _d, _e;
|
|
1873
|
-
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) => {
|
|
1871
|
+
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) => {
|
|
1874
1872
|
const updates = { agentType: value };
|
|
1875
1873
|
// Remove query property when Chatbot Agent is selected
|
|
1876
1874
|
if (value === "Chatbot Agent") {
|
|
1877
1875
|
updates.query = undefined;
|
|
1878
1876
|
}
|
|
1879
1877
|
updateConfig(updates);
|
|
1880
|
-
}, 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..." })] }))] }));
|
|
1878
|
+
}, 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..." })] }))] }));
|
|
1881
1879
|
};
|
|
1882
1880
|
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(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" })] })] })] }));
|
|
1883
1881
|
}
|
|
@@ -2189,7 +2187,7 @@ function FacetWidget({ widget, showHeader = true, onConfigUpdate, }) {
|
|
|
2189
2187
|
onConfigUpdate(Object.assign(Object.assign({}, widget.config), { fields: newFields }));
|
|
2190
2188
|
}
|
|
2191
2189
|
};
|
|
2192
|
-
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(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(ArrowDown, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => removeField(index), children: jsxRuntimeExports.jsx(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(Plus, { className: "h-4 w-4 mr-2" }), "Add Facet"] })), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-destructive mt-2", children: error })] }) })] }));
|
|
2190
|
+
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(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(ArrowDown, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => removeField(index), children: jsxRuntimeExports.jsx(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(Plus, { className: "h-4 w-4 mr-2" }), "Add Facet"] })), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-destructive mt-2", children: error })] }) })] }));
|
|
2193
2191
|
}
|
|
2194
2192
|
|
|
2195
2193
|
// src/graphql/@generated/graphql.ts
|
|
@@ -3892,7 +3890,7 @@ function set(root, scope, values) {
|
|
|
3892
3890
|
appliers.forEach((apply)=>apply(this));
|
|
3893
3891
|
}
|
|
3894
3892
|
}
|
|
3895
|
-
var defaults = /* #__PURE__ */ new Defaults({
|
|
3893
|
+
var defaults$1 = /* #__PURE__ */ new Defaults({
|
|
3896
3894
|
_scriptable: (name)=>!name.startsWith('on'),
|
|
3897
3895
|
_indexable: (name)=>name !== 'events',
|
|
3898
3896
|
hover: {
|
|
@@ -3913,7 +3911,7 @@ var defaults = /* #__PURE__ */ new Defaults({
|
|
|
3913
3911
|
* @param font - A font object.
|
|
3914
3912
|
* @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
|
|
3915
3913
|
* @private
|
|
3916
|
-
*/ function toFontString(font) {
|
|
3914
|
+
*/ function toFontString$1(font) {
|
|
3917
3915
|
if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
|
|
3918
3916
|
return null;
|
|
3919
3917
|
}
|
|
@@ -4324,7 +4322,7 @@ function _readValueToProps(value, props) {
|
|
|
4324
4322
|
* @private
|
|
4325
4323
|
*/ function toFont(options, fallback) {
|
|
4326
4324
|
options = options || {};
|
|
4327
|
-
fallback = fallback || defaults.font;
|
|
4325
|
+
fallback = fallback || defaults$1.font;
|
|
4328
4326
|
let size = valueOrDefault(options.size, fallback.size);
|
|
4329
4327
|
if (typeof size === 'string') {
|
|
4330
4328
|
size = parseInt(size, 10);
|
|
@@ -4342,7 +4340,7 @@ function _readValueToProps(value, props) {
|
|
|
4342
4340
|
weight: valueOrDefault(options.weight, fallback.weight),
|
|
4343
4341
|
string: ''
|
|
4344
4342
|
};
|
|
4345
|
-
font.string = toFontString(font);
|
|
4343
|
+
font.string = toFontString$1(font);
|
|
4346
4344
|
return font;
|
|
4347
4345
|
}
|
|
4348
4346
|
/**
|
|
@@ -4362,6 +4360,12 @@ function _readValueToProps(value, props) {
|
|
|
4362
4360
|
if (value === undefined) {
|
|
4363
4361
|
continue;
|
|
4364
4362
|
}
|
|
4363
|
+
if (context !== undefined && typeof value === 'function') {
|
|
4364
|
+
value = value(context);
|
|
4365
|
+
}
|
|
4366
|
+
if (index !== undefined && isArray(value)) {
|
|
4367
|
+
value = value[index % value.length];
|
|
4368
|
+
}
|
|
4365
4369
|
if (value !== undefined) {
|
|
4366
4370
|
return value;
|
|
4367
4371
|
}
|
|
@@ -5769,7 +5773,7 @@ class Animations {
|
|
|
5769
5773
|
if (!isObject(config)) {
|
|
5770
5774
|
return;
|
|
5771
5775
|
}
|
|
5772
|
-
const animationOptions = Object.keys(defaults.animation);
|
|
5776
|
+
const animationOptions = Object.keys(defaults$1.animation);
|
|
5773
5777
|
const animatedProps = this._properties;
|
|
5774
5778
|
Object.getOwnPropertyNames(config).forEach((key)=>{
|
|
5775
5779
|
const cfg = config[key];
|
|
@@ -6467,7 +6471,7 @@ class DatasetController {
|
|
|
6467
6471
|
''
|
|
6468
6472
|
];
|
|
6469
6473
|
const scopes = config.getOptionScopes(this.getDataset(), scopeKeys);
|
|
6470
|
-
const names = Object.keys(defaults.elements[elementType]);
|
|
6474
|
+
const names = Object.keys(defaults$1.elements[elementType]);
|
|
6471
6475
|
const context = ()=>this.getContext(index, active, mode);
|
|
6472
6476
|
const values = config.resolveNamedOptions(scopes, names, context, prefixes);
|
|
6473
6477
|
if (values.$shared) {
|
|
@@ -8225,7 +8229,7 @@ class BasicPlatform extends BasePlatform {
|
|
|
8225
8229
|
}
|
|
8226
8230
|
}
|
|
8227
8231
|
|
|
8228
|
-
const EXPANDO_KEY = '$chartjs';
|
|
8232
|
+
const EXPANDO_KEY$1 = '$chartjs';
|
|
8229
8233
|
const EVENT_TYPES = {
|
|
8230
8234
|
touchstart: 'mousedown',
|
|
8231
8235
|
touchmove: 'mousemove',
|
|
@@ -8242,7 +8246,7 @@ const isNullOrEmpty = (value)=>value === null || value === '';
|
|
|
8242
8246
|
const style = canvas.style;
|
|
8243
8247
|
const renderHeight = canvas.getAttribute('height');
|
|
8244
8248
|
const renderWidth = canvas.getAttribute('width');
|
|
8245
|
-
canvas[EXPANDO_KEY] = {
|
|
8249
|
+
canvas[EXPANDO_KEY$1] = {
|
|
8246
8250
|
initial: {
|
|
8247
8251
|
height: renderHeight,
|
|
8248
8252
|
width: renderWidth,
|
|
@@ -8421,10 +8425,10 @@ function createProxyAndListen(chart, type, listener) {
|
|
|
8421
8425
|
}
|
|
8422
8426
|
releaseContext(context) {
|
|
8423
8427
|
const canvas = context.canvas;
|
|
8424
|
-
if (!canvas[EXPANDO_KEY]) {
|
|
8428
|
+
if (!canvas[EXPANDO_KEY$1]) {
|
|
8425
8429
|
return false;
|
|
8426
8430
|
}
|
|
8427
|
-
const initial = canvas[EXPANDO_KEY].initial;
|
|
8431
|
+
const initial = canvas[EXPANDO_KEY$1].initial;
|
|
8428
8432
|
[
|
|
8429
8433
|
'height',
|
|
8430
8434
|
'width'
|
|
@@ -8441,7 +8445,7 @@ function createProxyAndListen(chart, type, listener) {
|
|
|
8441
8445
|
canvas.style[key] = style[key];
|
|
8442
8446
|
});
|
|
8443
8447
|
canvas.width = canvas.width;
|
|
8444
|
-
delete canvas[EXPANDO_KEY];
|
|
8448
|
+
delete canvas[EXPANDO_KEY$1];
|
|
8445
8449
|
return true;
|
|
8446
8450
|
}
|
|
8447
8451
|
addEventListener(chart, type, listener) {
|
|
@@ -9933,7 +9937,7 @@ class TypedRegistry {
|
|
|
9933
9937
|
items[id] = item;
|
|
9934
9938
|
registerDefaults(item, scope, parentScope);
|
|
9935
9939
|
if (this.override) {
|
|
9936
|
-
defaults.override(item.id, item.overrides);
|
|
9940
|
+
defaults$1.override(item.id, item.overrides);
|
|
9937
9941
|
}
|
|
9938
9942
|
return scope;
|
|
9939
9943
|
}
|
|
@@ -9947,8 +9951,8 @@ class TypedRegistry {
|
|
|
9947
9951
|
if (id in items) {
|
|
9948
9952
|
delete items[id];
|
|
9949
9953
|
}
|
|
9950
|
-
if (scope && id in defaults[scope]) {
|
|
9951
|
-
delete defaults[scope][id];
|
|
9954
|
+
if (scope && id in defaults$1[scope]) {
|
|
9955
|
+
delete defaults$1[scope][id];
|
|
9952
9956
|
if (this.override) {
|
|
9953
9957
|
delete overrides[id];
|
|
9954
9958
|
}
|
|
@@ -9957,16 +9961,16 @@ class TypedRegistry {
|
|
|
9957
9961
|
}
|
|
9958
9962
|
function registerDefaults(item, scope, parentScope) {
|
|
9959
9963
|
const itemDefaults = merge$1(Object.create(null), [
|
|
9960
|
-
parentScope ? defaults.get(parentScope) : {},
|
|
9961
|
-
defaults.get(scope),
|
|
9964
|
+
parentScope ? defaults$1.get(parentScope) : {},
|
|
9965
|
+
defaults$1.get(scope),
|
|
9962
9966
|
item.defaults
|
|
9963
9967
|
]);
|
|
9964
|
-
defaults.set(scope, itemDefaults);
|
|
9968
|
+
defaults$1.set(scope, itemDefaults);
|
|
9965
9969
|
if (item.defaultRoutes) {
|
|
9966
9970
|
routeDefaults(scope, item.defaultRoutes);
|
|
9967
9971
|
}
|
|
9968
9972
|
if (item.descriptors) {
|
|
9969
|
-
defaults.describe(scope, item.descriptors);
|
|
9973
|
+
defaults$1.describe(scope, item.descriptors);
|
|
9970
9974
|
}
|
|
9971
9975
|
}
|
|
9972
9976
|
function routeDefaults(scope, routes) {
|
|
@@ -9979,7 +9983,7 @@ function routeDefaults(scope, routes) {
|
|
|
9979
9983
|
const parts = routes[property].split('.');
|
|
9980
9984
|
const targetName = parts.pop();
|
|
9981
9985
|
const targetScope = parts.join('.');
|
|
9982
|
-
defaults.route(sourceScope, sourceName, targetScope, targetName);
|
|
9986
|
+
defaults$1.route(sourceScope, sourceName, targetScope, targetName);
|
|
9983
9987
|
});
|
|
9984
9988
|
}
|
|
9985
9989
|
function isIChartComponent(proto) {
|
|
@@ -10205,7 +10209,7 @@ function pluginOpts(config, { plugin , local }, opts, context) {
|
|
|
10205
10209
|
}
|
|
10206
10210
|
|
|
10207
10211
|
function getIndexAxis(type, options) {
|
|
10208
|
-
const datasetDefaults = defaults.datasets[type] || {};
|
|
10212
|
+
const datasetDefaults = defaults$1.datasets[type] || {};
|
|
10209
10213
|
const datasetOptions = (options.datasets || {})[type] || {};
|
|
10210
10214
|
return datasetOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || 'x';
|
|
10211
10215
|
}
|
|
@@ -10277,7 +10281,7 @@ function mergeScaleConfig(config, options) {
|
|
|
10277
10281
|
if (scaleConf._proxy) {
|
|
10278
10282
|
return console.warn(`Ignoring resolver passed as options for scale: ${id}`);
|
|
10279
10283
|
}
|
|
10280
|
-
const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults.scales[scaleConf.type]);
|
|
10284
|
+
const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults$1.scales[scaleConf.type]);
|
|
10281
10285
|
const defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);
|
|
10282
10286
|
const defaultScaleOptions = chartDefaults.scales || {};
|
|
10283
10287
|
scales[id] = mergeIf(Object.create(null), [
|
|
@@ -10310,8 +10314,8 @@ function mergeScaleConfig(config, options) {
|
|
|
10310
10314
|
Object.keys(scales).forEach((key)=>{
|
|
10311
10315
|
const scale = scales[key];
|
|
10312
10316
|
mergeIf(scale, [
|
|
10313
|
-
defaults.scales[scale.type],
|
|
10314
|
-
defaults.scale
|
|
10317
|
+
defaults$1.scales[scale.type],
|
|
10318
|
+
defaults$1.scale
|
|
10315
10319
|
]);
|
|
10316
10320
|
});
|
|
10317
10321
|
return scales;
|
|
@@ -10453,7 +10457,7 @@ class Config {
|
|
|
10453
10457
|
}
|
|
10454
10458
|
keys.forEach((key)=>addIfFound(scopes, options, key));
|
|
10455
10459
|
keys.forEach((key)=>addIfFound(scopes, overrides[type] || {}, key));
|
|
10456
|
-
keys.forEach((key)=>addIfFound(scopes, defaults, key));
|
|
10460
|
+
keys.forEach((key)=>addIfFound(scopes, defaults$1, key));
|
|
10457
10461
|
keys.forEach((key)=>addIfFound(scopes, descriptors, key));
|
|
10458
10462
|
});
|
|
10459
10463
|
const array = Array.from(scopes);
|
|
@@ -10470,11 +10474,11 @@ class Config {
|
|
|
10470
10474
|
return [
|
|
10471
10475
|
options,
|
|
10472
10476
|
overrides[type] || {},
|
|
10473
|
-
defaults.datasets[type] || {},
|
|
10477
|
+
defaults$1.datasets[type] || {},
|
|
10474
10478
|
{
|
|
10475
10479
|
type
|
|
10476
10480
|
},
|
|
10477
|
-
defaults,
|
|
10481
|
+
defaults$1,
|
|
10478
10482
|
descriptors
|
|
10479
10483
|
];
|
|
10480
10484
|
}
|
|
@@ -10607,7 +10611,7 @@ function moveNumericKeys(obj, start, move) {
|
|
|
10607
10611
|
return e;
|
|
10608
10612
|
}
|
|
10609
10613
|
let Chart$1 = class Chart {
|
|
10610
|
-
static defaults = defaults;
|
|
10614
|
+
static defaults = defaults$1;
|
|
10611
10615
|
static instances = instances;
|
|
10612
10616
|
static overrides = overrides;
|
|
10613
10617
|
static registry = registry;
|
|
@@ -10865,7 +10869,7 @@ let Chart$1 = class Chart {
|
|
|
10865
10869
|
meta.controller.linkScales();
|
|
10866
10870
|
} else {
|
|
10867
10871
|
const ControllerClass = registry.getController(type);
|
|
10868
|
-
const { datasetElementType , dataElementType } = defaults.datasets[type];
|
|
10872
|
+
const { datasetElementType , dataElementType } = defaults$1.datasets[type];
|
|
10869
10873
|
Object.assign(ControllerClass, {
|
|
10870
10874
|
dataElementType: registry.getElement(dataElementType),
|
|
10871
10875
|
datasetElementType: datasetElementType && registry.getElement(datasetElementType)
|
|
@@ -12198,7 +12202,7 @@ function parseBorderRadius(bar, maxW, maxH) {
|
|
|
12198
12202
|
bottomRight: skipOrLimit(!enableBorder || skip.bottom || skip.right, o.bottomRight, 0, maxR)
|
|
12199
12203
|
};
|
|
12200
12204
|
}
|
|
12201
|
-
function boundingRects(bar) {
|
|
12205
|
+
function boundingRects$1(bar) {
|
|
12202
12206
|
const bounds = getBarBounds(bar);
|
|
12203
12207
|
const width = bounds.right - bounds.left;
|
|
12204
12208
|
const height = bounds.bottom - bounds.top;
|
|
@@ -12279,7 +12283,7 @@ class BarElement extends Element {
|
|
|
12279
12283
|
}
|
|
12280
12284
|
draw(ctx) {
|
|
12281
12285
|
const { inflateAmount , options: { borderColor , backgroundColor } } = this;
|
|
12282
|
-
const { inner , outer } = boundingRects(this);
|
|
12286
|
+
const { inner , outer } = boundingRects$1(this);
|
|
12283
12287
|
const addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath;
|
|
12284
12288
|
ctx.save();
|
|
12285
12289
|
if (outer.w !== inner.w || outer.h !== inner.h) {
|
|
@@ -12537,7 +12541,7 @@ class Legend extends Element {
|
|
|
12537
12541
|
_draw() {
|
|
12538
12542
|
const { options: opts , columnSizes , lineWidths , ctx } = this;
|
|
12539
12543
|
const { align , labels: labelOpts } = opts;
|
|
12540
|
-
const defaultColor = defaults.color;
|
|
12544
|
+
const defaultColor = defaults$1.color;
|
|
12541
12545
|
const rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);
|
|
12542
12546
|
const labelFont = toFont(labelOpts.font);
|
|
12543
12547
|
const { padding } = labelOpts;
|
|
@@ -13011,7 +13015,7 @@ var plugin_title = {
|
|
|
13011
13015
|
}
|
|
13012
13016
|
};
|
|
13013
13017
|
|
|
13014
|
-
const positioners = {
|
|
13018
|
+
const positioners$2 = {
|
|
13015
13019
|
average (items) {
|
|
13016
13020
|
if (!items.length) {
|
|
13017
13021
|
return false;
|
|
@@ -13326,7 +13330,7 @@ const defaultCallbacks = {
|
|
|
13326
13330
|
return result;
|
|
13327
13331
|
}
|
|
13328
13332
|
class Tooltip extends Element {
|
|
13329
|
-
static positioners = positioners;
|
|
13333
|
+
static positioners = positioners$2;
|
|
13330
13334
|
constructor(config){
|
|
13331
13335
|
super();
|
|
13332
13336
|
this.opacity = 0;
|
|
@@ -13465,7 +13469,7 @@ class Tooltip extends Element {
|
|
|
13465
13469
|
};
|
|
13466
13470
|
}
|
|
13467
13471
|
} else {
|
|
13468
|
-
const position = positioners[options.position].call(this, active, this._eventPosition);
|
|
13472
|
+
const position = positioners$2[options.position].call(this, active, this._eventPosition);
|
|
13469
13473
|
tooltipItems = this._createItems(options);
|
|
13470
13474
|
this.title = this.getTitle(tooltipItems, options);
|
|
13471
13475
|
this.beforeBody = this.getBeforeBody(tooltipItems, options);
|
|
@@ -13746,7 +13750,7 @@ class Tooltip extends Element {
|
|
|
13746
13750
|
const animX = anims && anims.x;
|
|
13747
13751
|
const animY = anims && anims.y;
|
|
13748
13752
|
if (animX || animY) {
|
|
13749
|
-
const position = positioners[options.position].call(this, this._active, this._eventPosition);
|
|
13753
|
+
const position = positioners$2[options.position].call(this, this._active, this._eventPosition);
|
|
13750
13754
|
if (!position) {
|
|
13751
13755
|
return;
|
|
13752
13756
|
}
|
|
@@ -13862,14 +13866,14 @@ class Tooltip extends Element {
|
|
|
13862
13866
|
}
|
|
13863
13867
|
_positionChanged(active, e) {
|
|
13864
13868
|
const { caretX , caretY , options } = this;
|
|
13865
|
-
const position = positioners[options.position].call(this, active, e);
|
|
13869
|
+
const position = positioners$2[options.position].call(this, active, e);
|
|
13866
13870
|
return position !== false && (caretX !== position.x || caretY !== position.y);
|
|
13867
13871
|
}
|
|
13868
13872
|
}
|
|
13869
13873
|
var plugin_tooltip = {
|
|
13870
13874
|
id: 'tooltip',
|
|
13871
13875
|
_element: Tooltip,
|
|
13872
|
-
positioners,
|
|
13876
|
+
positioners: positioners$2,
|
|
13873
13877
|
afterInit (chart, _args, options) {
|
|
13874
13878
|
if (options) {
|
|
13875
13879
|
chart.tooltip = new Tooltip({
|
|
@@ -15244,6 +15248,1354 @@ function SeriesChart({ orientation, title, data, options, className, units, cont
|
|
|
15244
15248
|
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [barValuePlugin] }));
|
|
15245
15249
|
}
|
|
15246
15250
|
|
|
15251
|
+
/*!
|
|
15252
|
+
* chartjs-plugin-datalabels v2.2.0
|
|
15253
|
+
* https://chartjs-plugin-datalabels.netlify.app
|
|
15254
|
+
* (c) 2017-2022 chartjs-plugin-datalabels contributors
|
|
15255
|
+
* Released under the MIT license
|
|
15256
|
+
*/
|
|
15257
|
+
|
|
15258
|
+
var devicePixelRatio = (function() {
|
|
15259
|
+
if (typeof window !== 'undefined') {
|
|
15260
|
+
if (window.devicePixelRatio) {
|
|
15261
|
+
return window.devicePixelRatio;
|
|
15262
|
+
}
|
|
15263
|
+
|
|
15264
|
+
// devicePixelRatio is undefined on IE10
|
|
15265
|
+
// https://stackoverflow.com/a/20204180/8837887
|
|
15266
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/85
|
|
15267
|
+
var screen = window.screen;
|
|
15268
|
+
if (screen) {
|
|
15269
|
+
return (screen.deviceXDPI || 1) / (screen.logicalXDPI || 1);
|
|
15270
|
+
}
|
|
15271
|
+
}
|
|
15272
|
+
|
|
15273
|
+
return 1;
|
|
15274
|
+
}());
|
|
15275
|
+
|
|
15276
|
+
var utils = {
|
|
15277
|
+
// @todo move this in Chart.helpers.toTextLines
|
|
15278
|
+
toTextLines: function(inputs) {
|
|
15279
|
+
var lines = [];
|
|
15280
|
+
var input;
|
|
15281
|
+
|
|
15282
|
+
inputs = [].concat(inputs);
|
|
15283
|
+
while (inputs.length) {
|
|
15284
|
+
input = inputs.pop();
|
|
15285
|
+
if (typeof input === 'string') {
|
|
15286
|
+
lines.unshift.apply(lines, input.split('\n'));
|
|
15287
|
+
} else if (Array.isArray(input)) {
|
|
15288
|
+
inputs.push.apply(inputs, input);
|
|
15289
|
+
} else if (!isNullOrUndef(inputs)) {
|
|
15290
|
+
lines.unshift('' + input);
|
|
15291
|
+
}
|
|
15292
|
+
}
|
|
15293
|
+
|
|
15294
|
+
return lines;
|
|
15295
|
+
},
|
|
15296
|
+
|
|
15297
|
+
// @todo move this in Chart.helpers.canvas.textSize
|
|
15298
|
+
// @todo cache calls of measureText if font doesn't change?!
|
|
15299
|
+
textSize: function(ctx, lines, font) {
|
|
15300
|
+
var items = [].concat(lines);
|
|
15301
|
+
var ilen = items.length;
|
|
15302
|
+
var prev = ctx.font;
|
|
15303
|
+
var width = 0;
|
|
15304
|
+
var i;
|
|
15305
|
+
|
|
15306
|
+
ctx.font = font.string;
|
|
15307
|
+
|
|
15308
|
+
for (i = 0; i < ilen; ++i) {
|
|
15309
|
+
width = Math.max(ctx.measureText(items[i]).width, width);
|
|
15310
|
+
}
|
|
15311
|
+
|
|
15312
|
+
ctx.font = prev;
|
|
15313
|
+
|
|
15314
|
+
return {
|
|
15315
|
+
height: ilen * font.lineHeight,
|
|
15316
|
+
width: width
|
|
15317
|
+
};
|
|
15318
|
+
},
|
|
15319
|
+
|
|
15320
|
+
/**
|
|
15321
|
+
* Returns value bounded by min and max. This is equivalent to max(min, min(value, max)).
|
|
15322
|
+
* @todo move this method in Chart.helpers.bound
|
|
15323
|
+
* https://doc.qt.io/qt-5/qtglobal.html#qBound
|
|
15324
|
+
*/
|
|
15325
|
+
bound: function(min, value, max) {
|
|
15326
|
+
return Math.max(min, Math.min(value, max));
|
|
15327
|
+
},
|
|
15328
|
+
|
|
15329
|
+
/**
|
|
15330
|
+
* Returns an array of pair [value, state] where state is:
|
|
15331
|
+
* * -1: value is only in a0 (removed)
|
|
15332
|
+
* * 1: value is only in a1 (added)
|
|
15333
|
+
*/
|
|
15334
|
+
arrayDiff: function(a0, a1) {
|
|
15335
|
+
var prev = a0.slice();
|
|
15336
|
+
var updates = [];
|
|
15337
|
+
var i, j, ilen, v;
|
|
15338
|
+
|
|
15339
|
+
for (i = 0, ilen = a1.length; i < ilen; ++i) {
|
|
15340
|
+
v = a1[i];
|
|
15341
|
+
j = prev.indexOf(v);
|
|
15342
|
+
|
|
15343
|
+
if (j === -1) {
|
|
15344
|
+
updates.push([v, 1]);
|
|
15345
|
+
} else {
|
|
15346
|
+
prev.splice(j, 1);
|
|
15347
|
+
}
|
|
15348
|
+
}
|
|
15349
|
+
|
|
15350
|
+
for (i = 0, ilen = prev.length; i < ilen; ++i) {
|
|
15351
|
+
updates.push([prev[i], -1]);
|
|
15352
|
+
}
|
|
15353
|
+
|
|
15354
|
+
return updates;
|
|
15355
|
+
},
|
|
15356
|
+
|
|
15357
|
+
/**
|
|
15358
|
+
* https://github.com/chartjs/chartjs-plugin-datalabels/issues/70
|
|
15359
|
+
*/
|
|
15360
|
+
rasterize: function(v) {
|
|
15361
|
+
return Math.round(v * devicePixelRatio) / devicePixelRatio;
|
|
15362
|
+
}
|
|
15363
|
+
};
|
|
15364
|
+
|
|
15365
|
+
function orient(point, origin) {
|
|
15366
|
+
var x0 = origin.x;
|
|
15367
|
+
var y0 = origin.y;
|
|
15368
|
+
|
|
15369
|
+
if (x0 === null) {
|
|
15370
|
+
return {x: 0, y: -1};
|
|
15371
|
+
}
|
|
15372
|
+
if (y0 === null) {
|
|
15373
|
+
return {x: 1, y: 0};
|
|
15374
|
+
}
|
|
15375
|
+
|
|
15376
|
+
var dx = point.x - x0;
|
|
15377
|
+
var dy = point.y - y0;
|
|
15378
|
+
var ln = Math.sqrt(dx * dx + dy * dy);
|
|
15379
|
+
|
|
15380
|
+
return {
|
|
15381
|
+
x: ln ? dx / ln : 0,
|
|
15382
|
+
y: ln ? dy / ln : -1
|
|
15383
|
+
};
|
|
15384
|
+
}
|
|
15385
|
+
|
|
15386
|
+
function aligned(x, y, vx, vy, align) {
|
|
15387
|
+
switch (align) {
|
|
15388
|
+
case 'center':
|
|
15389
|
+
vx = vy = 0;
|
|
15390
|
+
break;
|
|
15391
|
+
case 'bottom':
|
|
15392
|
+
vx = 0;
|
|
15393
|
+
vy = 1;
|
|
15394
|
+
break;
|
|
15395
|
+
case 'right':
|
|
15396
|
+
vx = 1;
|
|
15397
|
+
vy = 0;
|
|
15398
|
+
break;
|
|
15399
|
+
case 'left':
|
|
15400
|
+
vx = -1;
|
|
15401
|
+
vy = 0;
|
|
15402
|
+
break;
|
|
15403
|
+
case 'top':
|
|
15404
|
+
vx = 0;
|
|
15405
|
+
vy = -1;
|
|
15406
|
+
break;
|
|
15407
|
+
case 'start':
|
|
15408
|
+
vx = -vx;
|
|
15409
|
+
vy = -vy;
|
|
15410
|
+
break;
|
|
15411
|
+
case 'end':
|
|
15412
|
+
// keep natural orientation
|
|
15413
|
+
break;
|
|
15414
|
+
default:
|
|
15415
|
+
// clockwise rotation (in degree)
|
|
15416
|
+
align *= (Math.PI / 180);
|
|
15417
|
+
vx = Math.cos(align);
|
|
15418
|
+
vy = Math.sin(align);
|
|
15419
|
+
break;
|
|
15420
|
+
}
|
|
15421
|
+
|
|
15422
|
+
return {
|
|
15423
|
+
x: x,
|
|
15424
|
+
y: y,
|
|
15425
|
+
vx: vx,
|
|
15426
|
+
vy: vy
|
|
15427
|
+
};
|
|
15428
|
+
}
|
|
15429
|
+
|
|
15430
|
+
// Line clipping (Cohen–Sutherland algorithm)
|
|
15431
|
+
// https://en.wikipedia.org/wiki/Cohen–Sutherland_algorithm
|
|
15432
|
+
|
|
15433
|
+
var R_INSIDE = 0;
|
|
15434
|
+
var R_LEFT = 1;
|
|
15435
|
+
var R_RIGHT = 2;
|
|
15436
|
+
var R_BOTTOM = 4;
|
|
15437
|
+
var R_TOP = 8;
|
|
15438
|
+
|
|
15439
|
+
function region(x, y, rect) {
|
|
15440
|
+
var res = R_INSIDE;
|
|
15441
|
+
|
|
15442
|
+
if (x < rect.left) {
|
|
15443
|
+
res |= R_LEFT;
|
|
15444
|
+
} else if (x > rect.right) {
|
|
15445
|
+
res |= R_RIGHT;
|
|
15446
|
+
}
|
|
15447
|
+
if (y < rect.top) {
|
|
15448
|
+
res |= R_TOP;
|
|
15449
|
+
} else if (y > rect.bottom) {
|
|
15450
|
+
res |= R_BOTTOM;
|
|
15451
|
+
}
|
|
15452
|
+
|
|
15453
|
+
return res;
|
|
15454
|
+
}
|
|
15455
|
+
|
|
15456
|
+
function clipped(segment, area) {
|
|
15457
|
+
var x0 = segment.x0;
|
|
15458
|
+
var y0 = segment.y0;
|
|
15459
|
+
var x1 = segment.x1;
|
|
15460
|
+
var y1 = segment.y1;
|
|
15461
|
+
var r0 = region(x0, y0, area);
|
|
15462
|
+
var r1 = region(x1, y1, area);
|
|
15463
|
+
var r, x, y;
|
|
15464
|
+
|
|
15465
|
+
// eslint-disable-next-line no-constant-condition
|
|
15466
|
+
while (true) {
|
|
15467
|
+
if (!(r0 | r1) || (r0 & r1)) {
|
|
15468
|
+
// both points inside or on the same side: no clipping
|
|
15469
|
+
break;
|
|
15470
|
+
}
|
|
15471
|
+
|
|
15472
|
+
// at least one point is outside
|
|
15473
|
+
r = r0 || r1;
|
|
15474
|
+
|
|
15475
|
+
if (r & R_TOP) {
|
|
15476
|
+
x = x0 + (x1 - x0) * (area.top - y0) / (y1 - y0);
|
|
15477
|
+
y = area.top;
|
|
15478
|
+
} else if (r & R_BOTTOM) {
|
|
15479
|
+
x = x0 + (x1 - x0) * (area.bottom - y0) / (y1 - y0);
|
|
15480
|
+
y = area.bottom;
|
|
15481
|
+
} else if (r & R_RIGHT) {
|
|
15482
|
+
y = y0 + (y1 - y0) * (area.right - x0) / (x1 - x0);
|
|
15483
|
+
x = area.right;
|
|
15484
|
+
} else if (r & R_LEFT) {
|
|
15485
|
+
y = y0 + (y1 - y0) * (area.left - x0) / (x1 - x0);
|
|
15486
|
+
x = area.left;
|
|
15487
|
+
}
|
|
15488
|
+
|
|
15489
|
+
if (r === r0) {
|
|
15490
|
+
x0 = x;
|
|
15491
|
+
y0 = y;
|
|
15492
|
+
r0 = region(x0, y0, area);
|
|
15493
|
+
} else {
|
|
15494
|
+
x1 = x;
|
|
15495
|
+
y1 = y;
|
|
15496
|
+
r1 = region(x1, y1, area);
|
|
15497
|
+
}
|
|
15498
|
+
}
|
|
15499
|
+
|
|
15500
|
+
return {
|
|
15501
|
+
x0: x0,
|
|
15502
|
+
x1: x1,
|
|
15503
|
+
y0: y0,
|
|
15504
|
+
y1: y1
|
|
15505
|
+
};
|
|
15506
|
+
}
|
|
15507
|
+
|
|
15508
|
+
function compute$1(range, config) {
|
|
15509
|
+
var anchor = config.anchor;
|
|
15510
|
+
var segment = range;
|
|
15511
|
+
var x, y;
|
|
15512
|
+
|
|
15513
|
+
if (config.clamp) {
|
|
15514
|
+
segment = clipped(segment, config.area);
|
|
15515
|
+
}
|
|
15516
|
+
|
|
15517
|
+
if (anchor === 'start') {
|
|
15518
|
+
x = segment.x0;
|
|
15519
|
+
y = segment.y0;
|
|
15520
|
+
} else if (anchor === 'end') {
|
|
15521
|
+
x = segment.x1;
|
|
15522
|
+
y = segment.y1;
|
|
15523
|
+
} else {
|
|
15524
|
+
x = (segment.x0 + segment.x1) / 2;
|
|
15525
|
+
y = (segment.y0 + segment.y1) / 2;
|
|
15526
|
+
}
|
|
15527
|
+
|
|
15528
|
+
return aligned(x, y, range.vx, range.vy, config.align);
|
|
15529
|
+
}
|
|
15530
|
+
|
|
15531
|
+
var positioners$1 = {
|
|
15532
|
+
arc: function(el, config) {
|
|
15533
|
+
var angle = (el.startAngle + el.endAngle) / 2;
|
|
15534
|
+
var vx = Math.cos(angle);
|
|
15535
|
+
var vy = Math.sin(angle);
|
|
15536
|
+
var r0 = el.innerRadius;
|
|
15537
|
+
var r1 = el.outerRadius;
|
|
15538
|
+
|
|
15539
|
+
return compute$1({
|
|
15540
|
+
x0: el.x + vx * r0,
|
|
15541
|
+
y0: el.y + vy * r0,
|
|
15542
|
+
x1: el.x + vx * r1,
|
|
15543
|
+
y1: el.y + vy * r1,
|
|
15544
|
+
vx: vx,
|
|
15545
|
+
vy: vy
|
|
15546
|
+
}, config);
|
|
15547
|
+
},
|
|
15548
|
+
|
|
15549
|
+
point: function(el, config) {
|
|
15550
|
+
var v = orient(el, config.origin);
|
|
15551
|
+
var rx = v.x * el.options.radius;
|
|
15552
|
+
var ry = v.y * el.options.radius;
|
|
15553
|
+
|
|
15554
|
+
return compute$1({
|
|
15555
|
+
x0: el.x - rx,
|
|
15556
|
+
y0: el.y - ry,
|
|
15557
|
+
x1: el.x + rx,
|
|
15558
|
+
y1: el.y + ry,
|
|
15559
|
+
vx: v.x,
|
|
15560
|
+
vy: v.y
|
|
15561
|
+
}, config);
|
|
15562
|
+
},
|
|
15563
|
+
|
|
15564
|
+
bar: function(el, config) {
|
|
15565
|
+
var v = orient(el, config.origin);
|
|
15566
|
+
var x = el.x;
|
|
15567
|
+
var y = el.y;
|
|
15568
|
+
var sx = 0;
|
|
15569
|
+
var sy = 0;
|
|
15570
|
+
|
|
15571
|
+
if (el.horizontal) {
|
|
15572
|
+
x = Math.min(el.x, el.base);
|
|
15573
|
+
sx = Math.abs(el.base - el.x);
|
|
15574
|
+
} else {
|
|
15575
|
+
y = Math.min(el.y, el.base);
|
|
15576
|
+
sy = Math.abs(el.base - el.y);
|
|
15577
|
+
}
|
|
15578
|
+
|
|
15579
|
+
return compute$1({
|
|
15580
|
+
x0: x,
|
|
15581
|
+
y0: y + sy,
|
|
15582
|
+
x1: x + sx,
|
|
15583
|
+
y1: y,
|
|
15584
|
+
vx: v.x,
|
|
15585
|
+
vy: v.y
|
|
15586
|
+
}, config);
|
|
15587
|
+
},
|
|
15588
|
+
|
|
15589
|
+
fallback: function(el, config) {
|
|
15590
|
+
var v = orient(el, config.origin);
|
|
15591
|
+
|
|
15592
|
+
return compute$1({
|
|
15593
|
+
x0: el.x,
|
|
15594
|
+
y0: el.y,
|
|
15595
|
+
x1: el.x + (el.width || 0),
|
|
15596
|
+
y1: el.y + (el.height || 0),
|
|
15597
|
+
vx: v.x,
|
|
15598
|
+
vy: v.y
|
|
15599
|
+
}, config);
|
|
15600
|
+
}
|
|
15601
|
+
};
|
|
15602
|
+
|
|
15603
|
+
var rasterize = utils.rasterize;
|
|
15604
|
+
|
|
15605
|
+
function boundingRects(model) {
|
|
15606
|
+
var borderWidth = model.borderWidth || 0;
|
|
15607
|
+
var padding = model.padding;
|
|
15608
|
+
var th = model.size.height;
|
|
15609
|
+
var tw = model.size.width;
|
|
15610
|
+
var tx = -tw / 2;
|
|
15611
|
+
var ty = -th / 2;
|
|
15612
|
+
|
|
15613
|
+
return {
|
|
15614
|
+
frame: {
|
|
15615
|
+
x: tx - padding.left - borderWidth,
|
|
15616
|
+
y: ty - padding.top - borderWidth,
|
|
15617
|
+
w: tw + padding.width + borderWidth * 2,
|
|
15618
|
+
h: th + padding.height + borderWidth * 2
|
|
15619
|
+
},
|
|
15620
|
+
text: {
|
|
15621
|
+
x: tx,
|
|
15622
|
+
y: ty,
|
|
15623
|
+
w: tw,
|
|
15624
|
+
h: th
|
|
15625
|
+
}
|
|
15626
|
+
};
|
|
15627
|
+
}
|
|
15628
|
+
|
|
15629
|
+
function getScaleOrigin(el, context) {
|
|
15630
|
+
var scale = context.chart.getDatasetMeta(context.datasetIndex).vScale;
|
|
15631
|
+
|
|
15632
|
+
if (!scale) {
|
|
15633
|
+
return null;
|
|
15634
|
+
}
|
|
15635
|
+
|
|
15636
|
+
if (scale.xCenter !== undefined && scale.yCenter !== undefined) {
|
|
15637
|
+
return {x: scale.xCenter, y: scale.yCenter};
|
|
15638
|
+
}
|
|
15639
|
+
|
|
15640
|
+
var pixel = scale.getBasePixel();
|
|
15641
|
+
return el.horizontal ?
|
|
15642
|
+
{x: pixel, y: null} :
|
|
15643
|
+
{x: null, y: pixel};
|
|
15644
|
+
}
|
|
15645
|
+
|
|
15646
|
+
function getPositioner(el) {
|
|
15647
|
+
if (el instanceof ArcElement) {
|
|
15648
|
+
return positioners$1.arc;
|
|
15649
|
+
}
|
|
15650
|
+
if (el instanceof PointElement) {
|
|
15651
|
+
return positioners$1.point;
|
|
15652
|
+
}
|
|
15653
|
+
if (el instanceof BarElement) {
|
|
15654
|
+
return positioners$1.bar;
|
|
15655
|
+
}
|
|
15656
|
+
return positioners$1.fallback;
|
|
15657
|
+
}
|
|
15658
|
+
|
|
15659
|
+
function drawRoundedRect(ctx, x, y, w, h, radius) {
|
|
15660
|
+
var HALF_PI = Math.PI / 2;
|
|
15661
|
+
|
|
15662
|
+
if (radius) {
|
|
15663
|
+
var r = Math.min(radius, h / 2, w / 2);
|
|
15664
|
+
var left = x + r;
|
|
15665
|
+
var top = y + r;
|
|
15666
|
+
var right = x + w - r;
|
|
15667
|
+
var bottom = y + h - r;
|
|
15668
|
+
|
|
15669
|
+
ctx.moveTo(x, top);
|
|
15670
|
+
if (left < right && top < bottom) {
|
|
15671
|
+
ctx.arc(left, top, r, -Math.PI, -HALF_PI);
|
|
15672
|
+
ctx.arc(right, top, r, -HALF_PI, 0);
|
|
15673
|
+
ctx.arc(right, bottom, r, 0, HALF_PI);
|
|
15674
|
+
ctx.arc(left, bottom, r, HALF_PI, Math.PI);
|
|
15675
|
+
} else if (left < right) {
|
|
15676
|
+
ctx.moveTo(left, y);
|
|
15677
|
+
ctx.arc(right, top, r, -HALF_PI, HALF_PI);
|
|
15678
|
+
ctx.arc(left, top, r, HALF_PI, Math.PI + HALF_PI);
|
|
15679
|
+
} else if (top < bottom) {
|
|
15680
|
+
ctx.arc(left, top, r, -Math.PI, 0);
|
|
15681
|
+
ctx.arc(left, bottom, r, 0, Math.PI);
|
|
15682
|
+
} else {
|
|
15683
|
+
ctx.arc(left, top, r, -Math.PI, Math.PI);
|
|
15684
|
+
}
|
|
15685
|
+
ctx.closePath();
|
|
15686
|
+
ctx.moveTo(x, y);
|
|
15687
|
+
} else {
|
|
15688
|
+
ctx.rect(x, y, w, h);
|
|
15689
|
+
}
|
|
15690
|
+
}
|
|
15691
|
+
|
|
15692
|
+
function drawFrame(ctx, rect, model) {
|
|
15693
|
+
var bgColor = model.backgroundColor;
|
|
15694
|
+
var borderColor = model.borderColor;
|
|
15695
|
+
var borderWidth = model.borderWidth;
|
|
15696
|
+
|
|
15697
|
+
if (!bgColor && (!borderColor || !borderWidth)) {
|
|
15698
|
+
return;
|
|
15699
|
+
}
|
|
15700
|
+
|
|
15701
|
+
ctx.beginPath();
|
|
15702
|
+
|
|
15703
|
+
drawRoundedRect(
|
|
15704
|
+
ctx,
|
|
15705
|
+
rasterize(rect.x) + borderWidth / 2,
|
|
15706
|
+
rasterize(rect.y) + borderWidth / 2,
|
|
15707
|
+
rasterize(rect.w) - borderWidth,
|
|
15708
|
+
rasterize(rect.h) - borderWidth,
|
|
15709
|
+
model.borderRadius);
|
|
15710
|
+
|
|
15711
|
+
ctx.closePath();
|
|
15712
|
+
|
|
15713
|
+
if (bgColor) {
|
|
15714
|
+
ctx.fillStyle = bgColor;
|
|
15715
|
+
ctx.fill();
|
|
15716
|
+
}
|
|
15717
|
+
|
|
15718
|
+
if (borderColor && borderWidth) {
|
|
15719
|
+
ctx.strokeStyle = borderColor;
|
|
15720
|
+
ctx.lineWidth = borderWidth;
|
|
15721
|
+
ctx.lineJoin = 'miter';
|
|
15722
|
+
ctx.stroke();
|
|
15723
|
+
}
|
|
15724
|
+
}
|
|
15725
|
+
|
|
15726
|
+
function textGeometry(rect, align, font) {
|
|
15727
|
+
var h = font.lineHeight;
|
|
15728
|
+
var w = rect.w;
|
|
15729
|
+
var x = rect.x;
|
|
15730
|
+
var y = rect.y + h / 2;
|
|
15731
|
+
|
|
15732
|
+
if (align === 'center') {
|
|
15733
|
+
x += w / 2;
|
|
15734
|
+
} else if (align === 'end' || align === 'right') {
|
|
15735
|
+
x += w;
|
|
15736
|
+
}
|
|
15737
|
+
|
|
15738
|
+
return {
|
|
15739
|
+
h: h,
|
|
15740
|
+
w: w,
|
|
15741
|
+
x: x,
|
|
15742
|
+
y: y
|
|
15743
|
+
};
|
|
15744
|
+
}
|
|
15745
|
+
|
|
15746
|
+
function drawTextLine(ctx, text, cfg) {
|
|
15747
|
+
var shadow = ctx.shadowBlur;
|
|
15748
|
+
var stroked = cfg.stroked;
|
|
15749
|
+
var x = rasterize(cfg.x);
|
|
15750
|
+
var y = rasterize(cfg.y);
|
|
15751
|
+
var w = rasterize(cfg.w);
|
|
15752
|
+
|
|
15753
|
+
if (stroked) {
|
|
15754
|
+
ctx.strokeText(text, x, y, w);
|
|
15755
|
+
}
|
|
15756
|
+
|
|
15757
|
+
if (cfg.filled) {
|
|
15758
|
+
if (shadow && stroked) {
|
|
15759
|
+
// Prevent drawing shadow on both the text stroke and fill, so
|
|
15760
|
+
// if the text is stroked, remove the shadow for the text fill.
|
|
15761
|
+
ctx.shadowBlur = 0;
|
|
15762
|
+
}
|
|
15763
|
+
|
|
15764
|
+
ctx.fillText(text, x, y, w);
|
|
15765
|
+
|
|
15766
|
+
if (shadow && stroked) {
|
|
15767
|
+
ctx.shadowBlur = shadow;
|
|
15768
|
+
}
|
|
15769
|
+
}
|
|
15770
|
+
}
|
|
15771
|
+
|
|
15772
|
+
function drawText(ctx, lines, rect, model) {
|
|
15773
|
+
var align = model.textAlign;
|
|
15774
|
+
var color = model.color;
|
|
15775
|
+
var filled = !!color;
|
|
15776
|
+
var font = model.font;
|
|
15777
|
+
var ilen = lines.length;
|
|
15778
|
+
var strokeColor = model.textStrokeColor;
|
|
15779
|
+
var strokeWidth = model.textStrokeWidth;
|
|
15780
|
+
var stroked = strokeColor && strokeWidth;
|
|
15781
|
+
var i;
|
|
15782
|
+
|
|
15783
|
+
if (!ilen || (!filled && !stroked)) {
|
|
15784
|
+
return;
|
|
15785
|
+
}
|
|
15786
|
+
|
|
15787
|
+
// Adjust coordinates based on text alignment and line height
|
|
15788
|
+
rect = textGeometry(rect, align, font);
|
|
15789
|
+
|
|
15790
|
+
ctx.font = font.string;
|
|
15791
|
+
ctx.textAlign = align;
|
|
15792
|
+
ctx.textBaseline = 'middle';
|
|
15793
|
+
ctx.shadowBlur = model.textShadowBlur;
|
|
15794
|
+
ctx.shadowColor = model.textShadowColor;
|
|
15795
|
+
|
|
15796
|
+
if (filled) {
|
|
15797
|
+
ctx.fillStyle = color;
|
|
15798
|
+
}
|
|
15799
|
+
if (stroked) {
|
|
15800
|
+
ctx.lineJoin = 'round';
|
|
15801
|
+
ctx.lineWidth = strokeWidth;
|
|
15802
|
+
ctx.strokeStyle = strokeColor;
|
|
15803
|
+
}
|
|
15804
|
+
|
|
15805
|
+
for (i = 0, ilen = lines.length; i < ilen; ++i) {
|
|
15806
|
+
drawTextLine(ctx, lines[i], {
|
|
15807
|
+
stroked: stroked,
|
|
15808
|
+
filled: filled,
|
|
15809
|
+
w: rect.w,
|
|
15810
|
+
x: rect.x,
|
|
15811
|
+
y: rect.y + rect.h * i
|
|
15812
|
+
});
|
|
15813
|
+
}
|
|
15814
|
+
}
|
|
15815
|
+
|
|
15816
|
+
var Label = function(config, ctx, el, index) {
|
|
15817
|
+
var me = this;
|
|
15818
|
+
|
|
15819
|
+
me._config = config;
|
|
15820
|
+
me._index = index;
|
|
15821
|
+
me._model = null;
|
|
15822
|
+
me._rects = null;
|
|
15823
|
+
me._ctx = ctx;
|
|
15824
|
+
me._el = el;
|
|
15825
|
+
};
|
|
15826
|
+
|
|
15827
|
+
merge$1(Label.prototype, {
|
|
15828
|
+
/**
|
|
15829
|
+
* @private
|
|
15830
|
+
*/
|
|
15831
|
+
_modelize: function(display, lines, config, context) {
|
|
15832
|
+
var me = this;
|
|
15833
|
+
var index = me._index;
|
|
15834
|
+
var font = toFont(resolve([config.font, {}], context, index));
|
|
15835
|
+
var color = resolve([config.color, defaults$1.color], context, index);
|
|
15836
|
+
|
|
15837
|
+
return {
|
|
15838
|
+
align: resolve([config.align, 'center'], context, index),
|
|
15839
|
+
anchor: resolve([config.anchor, 'center'], context, index),
|
|
15840
|
+
area: context.chart.chartArea,
|
|
15841
|
+
backgroundColor: resolve([config.backgroundColor, null], context, index),
|
|
15842
|
+
borderColor: resolve([config.borderColor, null], context, index),
|
|
15843
|
+
borderRadius: resolve([config.borderRadius, 0], context, index),
|
|
15844
|
+
borderWidth: resolve([config.borderWidth, 0], context, index),
|
|
15845
|
+
clamp: resolve([config.clamp, false], context, index),
|
|
15846
|
+
clip: resolve([config.clip, false], context, index),
|
|
15847
|
+
color: color,
|
|
15848
|
+
display: display,
|
|
15849
|
+
font: font,
|
|
15850
|
+
lines: lines,
|
|
15851
|
+
offset: resolve([config.offset, 4], context, index),
|
|
15852
|
+
opacity: resolve([config.opacity, 1], context, index),
|
|
15853
|
+
origin: getScaleOrigin(me._el, context),
|
|
15854
|
+
padding: toPadding(resolve([config.padding, 4], context, index)),
|
|
15855
|
+
positioner: getPositioner(me._el),
|
|
15856
|
+
rotation: resolve([config.rotation, 0], context, index) * (Math.PI / 180),
|
|
15857
|
+
size: utils.textSize(me._ctx, lines, font),
|
|
15858
|
+
textAlign: resolve([config.textAlign, 'start'], context, index),
|
|
15859
|
+
textShadowBlur: resolve([config.textShadowBlur, 0], context, index),
|
|
15860
|
+
textShadowColor: resolve([config.textShadowColor, color], context, index),
|
|
15861
|
+
textStrokeColor: resolve([config.textStrokeColor, color], context, index),
|
|
15862
|
+
textStrokeWidth: resolve([config.textStrokeWidth, 0], context, index)
|
|
15863
|
+
};
|
|
15864
|
+
},
|
|
15865
|
+
|
|
15866
|
+
update: function(context) {
|
|
15867
|
+
var me = this;
|
|
15868
|
+
var model = null;
|
|
15869
|
+
var rects = null;
|
|
15870
|
+
var index = me._index;
|
|
15871
|
+
var config = me._config;
|
|
15872
|
+
var value, label, lines;
|
|
15873
|
+
|
|
15874
|
+
// We first resolve the display option (separately) to avoid computing
|
|
15875
|
+
// other options in case the label is hidden (i.e. display: false).
|
|
15876
|
+
var display = resolve([config.display, true], context, index);
|
|
15877
|
+
|
|
15878
|
+
if (display) {
|
|
15879
|
+
value = context.dataset.data[index];
|
|
15880
|
+
label = valueOrDefault(callback(config.formatter, [value, context]), value);
|
|
15881
|
+
lines = isNullOrUndef(label) ? [] : utils.toTextLines(label);
|
|
15882
|
+
|
|
15883
|
+
if (lines.length) {
|
|
15884
|
+
model = me._modelize(display, lines, config, context);
|
|
15885
|
+
rects = boundingRects(model);
|
|
15886
|
+
}
|
|
15887
|
+
}
|
|
15888
|
+
|
|
15889
|
+
me._model = model;
|
|
15890
|
+
me._rects = rects;
|
|
15891
|
+
},
|
|
15892
|
+
|
|
15893
|
+
geometry: function() {
|
|
15894
|
+
return this._rects ? this._rects.frame : {};
|
|
15895
|
+
},
|
|
15896
|
+
|
|
15897
|
+
rotation: function() {
|
|
15898
|
+
return this._model ? this._model.rotation : 0;
|
|
15899
|
+
},
|
|
15900
|
+
|
|
15901
|
+
visible: function() {
|
|
15902
|
+
return this._model && this._model.opacity;
|
|
15903
|
+
},
|
|
15904
|
+
|
|
15905
|
+
model: function() {
|
|
15906
|
+
return this._model;
|
|
15907
|
+
},
|
|
15908
|
+
|
|
15909
|
+
draw: function(chart, center) {
|
|
15910
|
+
var me = this;
|
|
15911
|
+
var ctx = chart.ctx;
|
|
15912
|
+
var model = me._model;
|
|
15913
|
+
var rects = me._rects;
|
|
15914
|
+
var area;
|
|
15915
|
+
|
|
15916
|
+
if (!this.visible()) {
|
|
15917
|
+
return;
|
|
15918
|
+
}
|
|
15919
|
+
|
|
15920
|
+
ctx.save();
|
|
15921
|
+
|
|
15922
|
+
if (model.clip) {
|
|
15923
|
+
area = model.area;
|
|
15924
|
+
ctx.beginPath();
|
|
15925
|
+
ctx.rect(
|
|
15926
|
+
area.left,
|
|
15927
|
+
area.top,
|
|
15928
|
+
area.right - area.left,
|
|
15929
|
+
area.bottom - area.top);
|
|
15930
|
+
ctx.clip();
|
|
15931
|
+
}
|
|
15932
|
+
|
|
15933
|
+
ctx.globalAlpha = utils.bound(0, model.opacity, 1);
|
|
15934
|
+
ctx.translate(rasterize(center.x), rasterize(center.y));
|
|
15935
|
+
ctx.rotate(model.rotation);
|
|
15936
|
+
|
|
15937
|
+
drawFrame(ctx, rects.frame, model);
|
|
15938
|
+
drawText(ctx, model.lines, rects.text, model);
|
|
15939
|
+
|
|
15940
|
+
ctx.restore();
|
|
15941
|
+
}
|
|
15942
|
+
});
|
|
15943
|
+
|
|
15944
|
+
var MIN_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991; // eslint-disable-line es/no-number-minsafeinteger
|
|
15945
|
+
var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line es/no-number-maxsafeinteger
|
|
15946
|
+
|
|
15947
|
+
function rotated(point, center, angle) {
|
|
15948
|
+
var cos = Math.cos(angle);
|
|
15949
|
+
var sin = Math.sin(angle);
|
|
15950
|
+
var cx = center.x;
|
|
15951
|
+
var cy = center.y;
|
|
15952
|
+
|
|
15953
|
+
return {
|
|
15954
|
+
x: cx + cos * (point.x - cx) - sin * (point.y - cy),
|
|
15955
|
+
y: cy + sin * (point.x - cx) + cos * (point.y - cy)
|
|
15956
|
+
};
|
|
15957
|
+
}
|
|
15958
|
+
|
|
15959
|
+
function projected(points, axis) {
|
|
15960
|
+
var min = MAX_INTEGER;
|
|
15961
|
+
var max = MIN_INTEGER;
|
|
15962
|
+
var origin = axis.origin;
|
|
15963
|
+
var i, pt, vx, vy, dp;
|
|
15964
|
+
|
|
15965
|
+
for (i = 0; i < points.length; ++i) {
|
|
15966
|
+
pt = points[i];
|
|
15967
|
+
vx = pt.x - origin.x;
|
|
15968
|
+
vy = pt.y - origin.y;
|
|
15969
|
+
dp = axis.vx * vx + axis.vy * vy;
|
|
15970
|
+
min = Math.min(min, dp);
|
|
15971
|
+
max = Math.max(max, dp);
|
|
15972
|
+
}
|
|
15973
|
+
|
|
15974
|
+
return {
|
|
15975
|
+
min: min,
|
|
15976
|
+
max: max
|
|
15977
|
+
};
|
|
15978
|
+
}
|
|
15979
|
+
|
|
15980
|
+
function toAxis(p0, p1) {
|
|
15981
|
+
var vx = p1.x - p0.x;
|
|
15982
|
+
var vy = p1.y - p0.y;
|
|
15983
|
+
var ln = Math.sqrt(vx * vx + vy * vy);
|
|
15984
|
+
|
|
15985
|
+
return {
|
|
15986
|
+
vx: (p1.x - p0.x) / ln,
|
|
15987
|
+
vy: (p1.y - p0.y) / ln,
|
|
15988
|
+
origin: p0,
|
|
15989
|
+
ln: ln
|
|
15990
|
+
};
|
|
15991
|
+
}
|
|
15992
|
+
|
|
15993
|
+
var HitBox = function() {
|
|
15994
|
+
this._rotation = 0;
|
|
15995
|
+
this._rect = {
|
|
15996
|
+
x: 0,
|
|
15997
|
+
y: 0,
|
|
15998
|
+
w: 0,
|
|
15999
|
+
h: 0
|
|
16000
|
+
};
|
|
16001
|
+
};
|
|
16002
|
+
|
|
16003
|
+
merge$1(HitBox.prototype, {
|
|
16004
|
+
center: function() {
|
|
16005
|
+
var r = this._rect;
|
|
16006
|
+
return {
|
|
16007
|
+
x: r.x + r.w / 2,
|
|
16008
|
+
y: r.y + r.h / 2
|
|
16009
|
+
};
|
|
16010
|
+
},
|
|
16011
|
+
|
|
16012
|
+
update: function(center, rect, rotation) {
|
|
16013
|
+
this._rotation = rotation;
|
|
16014
|
+
this._rect = {
|
|
16015
|
+
x: rect.x + center.x,
|
|
16016
|
+
y: rect.y + center.y,
|
|
16017
|
+
w: rect.w,
|
|
16018
|
+
h: rect.h
|
|
16019
|
+
};
|
|
16020
|
+
},
|
|
16021
|
+
|
|
16022
|
+
contains: function(point) {
|
|
16023
|
+
var me = this;
|
|
16024
|
+
var margin = 1;
|
|
16025
|
+
var rect = me._rect;
|
|
16026
|
+
|
|
16027
|
+
point = rotated(point, me.center(), -me._rotation);
|
|
16028
|
+
|
|
16029
|
+
return !(point.x < rect.x - margin
|
|
16030
|
+
|| point.y < rect.y - margin
|
|
16031
|
+
|| point.x > rect.x + rect.w + margin * 2
|
|
16032
|
+
|| point.y > rect.y + rect.h + margin * 2);
|
|
16033
|
+
},
|
|
16034
|
+
|
|
16035
|
+
// Separating Axis Theorem
|
|
16036
|
+
// https://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169
|
|
16037
|
+
intersects: function(other) {
|
|
16038
|
+
var r0 = this._points();
|
|
16039
|
+
var r1 = other._points();
|
|
16040
|
+
var axes = [
|
|
16041
|
+
toAxis(r0[0], r0[1]),
|
|
16042
|
+
toAxis(r0[0], r0[3])
|
|
16043
|
+
];
|
|
16044
|
+
var i, pr0, pr1;
|
|
16045
|
+
|
|
16046
|
+
if (this._rotation !== other._rotation) {
|
|
16047
|
+
// Only separate with r1 axis if the rotation is different,
|
|
16048
|
+
// else it's enough to separate r0 and r1 with r0 axis only!
|
|
16049
|
+
axes.push(
|
|
16050
|
+
toAxis(r1[0], r1[1]),
|
|
16051
|
+
toAxis(r1[0], r1[3])
|
|
16052
|
+
);
|
|
16053
|
+
}
|
|
16054
|
+
|
|
16055
|
+
for (i = 0; i < axes.length; ++i) {
|
|
16056
|
+
pr0 = projected(r0, axes[i]);
|
|
16057
|
+
pr1 = projected(r1, axes[i]);
|
|
16058
|
+
|
|
16059
|
+
if (pr0.max < pr1.min || pr1.max < pr0.min) {
|
|
16060
|
+
return false;
|
|
16061
|
+
}
|
|
16062
|
+
}
|
|
16063
|
+
|
|
16064
|
+
return true;
|
|
16065
|
+
},
|
|
16066
|
+
|
|
16067
|
+
/**
|
|
16068
|
+
* @private
|
|
16069
|
+
*/
|
|
16070
|
+
_points: function() {
|
|
16071
|
+
var me = this;
|
|
16072
|
+
var rect = me._rect;
|
|
16073
|
+
var angle = me._rotation;
|
|
16074
|
+
var center = me.center();
|
|
16075
|
+
|
|
16076
|
+
return [
|
|
16077
|
+
rotated({x: rect.x, y: rect.y}, center, angle),
|
|
16078
|
+
rotated({x: rect.x + rect.w, y: rect.y}, center, angle),
|
|
16079
|
+
rotated({x: rect.x + rect.w, y: rect.y + rect.h}, center, angle),
|
|
16080
|
+
rotated({x: rect.x, y: rect.y + rect.h}, center, angle)
|
|
16081
|
+
];
|
|
16082
|
+
}
|
|
16083
|
+
});
|
|
16084
|
+
|
|
16085
|
+
function coordinates(el, model, geometry) {
|
|
16086
|
+
var point = model.positioner(el, model);
|
|
16087
|
+
var vx = point.vx;
|
|
16088
|
+
var vy = point.vy;
|
|
16089
|
+
|
|
16090
|
+
if (!vx && !vy) {
|
|
16091
|
+
// if aligned center, we don't want to offset the center point
|
|
16092
|
+
return {x: point.x, y: point.y};
|
|
16093
|
+
}
|
|
16094
|
+
|
|
16095
|
+
var w = geometry.w;
|
|
16096
|
+
var h = geometry.h;
|
|
16097
|
+
|
|
16098
|
+
// take in account the label rotation
|
|
16099
|
+
var rotation = model.rotation;
|
|
16100
|
+
var dx = Math.abs(w / 2 * Math.cos(rotation)) + Math.abs(h / 2 * Math.sin(rotation));
|
|
16101
|
+
var dy = Math.abs(w / 2 * Math.sin(rotation)) + Math.abs(h / 2 * Math.cos(rotation));
|
|
16102
|
+
|
|
16103
|
+
// scale the unit vector (vx, vy) to get at least dx or dy equal to
|
|
16104
|
+
// w or h respectively (else we would calculate the distance to the
|
|
16105
|
+
// ellipse inscribed in the bounding rect)
|
|
16106
|
+
var vs = 1 / Math.max(Math.abs(vx), Math.abs(vy));
|
|
16107
|
+
dx *= vx * vs;
|
|
16108
|
+
dy *= vy * vs;
|
|
16109
|
+
|
|
16110
|
+
// finally, include the explicit offset
|
|
16111
|
+
dx += model.offset * vx;
|
|
16112
|
+
dy += model.offset * vy;
|
|
16113
|
+
|
|
16114
|
+
return {
|
|
16115
|
+
x: point.x + dx,
|
|
16116
|
+
y: point.y + dy
|
|
16117
|
+
};
|
|
16118
|
+
}
|
|
16119
|
+
|
|
16120
|
+
function collide(labels, collider) {
|
|
16121
|
+
var i, j, s0, s1;
|
|
16122
|
+
|
|
16123
|
+
// IMPORTANT Iterate in the reverse order since items at the end of the
|
|
16124
|
+
// list have an higher weight/priority and thus should be less impacted
|
|
16125
|
+
// by the overlapping strategy.
|
|
16126
|
+
|
|
16127
|
+
for (i = labels.length - 1; i >= 0; --i) {
|
|
16128
|
+
s0 = labels[i].$layout;
|
|
16129
|
+
|
|
16130
|
+
for (j = i - 1; j >= 0 && s0._visible; --j) {
|
|
16131
|
+
s1 = labels[j].$layout;
|
|
16132
|
+
|
|
16133
|
+
if (s1._visible && s0._box.intersects(s1._box)) {
|
|
16134
|
+
collider(s0, s1);
|
|
16135
|
+
}
|
|
16136
|
+
}
|
|
16137
|
+
}
|
|
16138
|
+
|
|
16139
|
+
return labels;
|
|
16140
|
+
}
|
|
16141
|
+
|
|
16142
|
+
function compute(labels) {
|
|
16143
|
+
var i, ilen, label, state, geometry, center, proxy;
|
|
16144
|
+
|
|
16145
|
+
// Initialize labels for overlap detection
|
|
16146
|
+
for (i = 0, ilen = labels.length; i < ilen; ++i) {
|
|
16147
|
+
label = labels[i];
|
|
16148
|
+
state = label.$layout;
|
|
16149
|
+
|
|
16150
|
+
if (state._visible) {
|
|
16151
|
+
// Chart.js 3 removed el._model in favor of getProps(), making harder to
|
|
16152
|
+
// abstract reading values in positioners. Also, using string arrays to
|
|
16153
|
+
// read values (i.e. var {a,b,c} = el.getProps(["a","b","c"])) would make
|
|
16154
|
+
// positioners inefficient in the normal case (i.e. not the final values)
|
|
16155
|
+
// and the code a bit ugly, so let's use a Proxy instead.
|
|
16156
|
+
proxy = new Proxy(label._el, {get: (el, p) => el.getProps([p], true)[p]});
|
|
16157
|
+
|
|
16158
|
+
geometry = label.geometry();
|
|
16159
|
+
center = coordinates(proxy, label.model(), geometry);
|
|
16160
|
+
state._box.update(center, geometry, label.rotation());
|
|
16161
|
+
}
|
|
16162
|
+
}
|
|
16163
|
+
|
|
16164
|
+
// Auto hide overlapping labels
|
|
16165
|
+
return collide(labels, function(s0, s1) {
|
|
16166
|
+
var h0 = s0._hidable;
|
|
16167
|
+
var h1 = s1._hidable;
|
|
16168
|
+
|
|
16169
|
+
if ((h0 && h1) || h1) {
|
|
16170
|
+
s1._visible = false;
|
|
16171
|
+
} else if (h0) {
|
|
16172
|
+
s0._visible = false;
|
|
16173
|
+
}
|
|
16174
|
+
});
|
|
16175
|
+
}
|
|
16176
|
+
|
|
16177
|
+
var layout = {
|
|
16178
|
+
prepare: function(datasets) {
|
|
16179
|
+
var labels = [];
|
|
16180
|
+
var i, j, ilen, jlen, label;
|
|
16181
|
+
|
|
16182
|
+
for (i = 0, ilen = datasets.length; i < ilen; ++i) {
|
|
16183
|
+
for (j = 0, jlen = datasets[i].length; j < jlen; ++j) {
|
|
16184
|
+
label = datasets[i][j];
|
|
16185
|
+
labels.push(label);
|
|
16186
|
+
label.$layout = {
|
|
16187
|
+
_box: new HitBox(),
|
|
16188
|
+
_hidable: false,
|
|
16189
|
+
_visible: true,
|
|
16190
|
+
_set: i,
|
|
16191
|
+
_idx: label._index
|
|
16192
|
+
};
|
|
16193
|
+
}
|
|
16194
|
+
}
|
|
16195
|
+
|
|
16196
|
+
// TODO New `z` option: labels with a higher z-index are drawn
|
|
16197
|
+
// of top of the ones with a lower index. Lowest z-index labels
|
|
16198
|
+
// are also discarded first when hiding overlapping labels.
|
|
16199
|
+
labels.sort(function(a, b) {
|
|
16200
|
+
var sa = a.$layout;
|
|
16201
|
+
var sb = b.$layout;
|
|
16202
|
+
|
|
16203
|
+
return sa._idx === sb._idx
|
|
16204
|
+
? sb._set - sa._set
|
|
16205
|
+
: sb._idx - sa._idx;
|
|
16206
|
+
});
|
|
16207
|
+
|
|
16208
|
+
this.update(labels);
|
|
16209
|
+
|
|
16210
|
+
return labels;
|
|
16211
|
+
},
|
|
16212
|
+
|
|
16213
|
+
update: function(labels) {
|
|
16214
|
+
var dirty = false;
|
|
16215
|
+
var i, ilen, label, model, state;
|
|
16216
|
+
|
|
16217
|
+
for (i = 0, ilen = labels.length; i < ilen; ++i) {
|
|
16218
|
+
label = labels[i];
|
|
16219
|
+
model = label.model();
|
|
16220
|
+
state = label.$layout;
|
|
16221
|
+
state._hidable = model && model.display === 'auto';
|
|
16222
|
+
state._visible = label.visible();
|
|
16223
|
+
dirty |= state._hidable;
|
|
16224
|
+
}
|
|
16225
|
+
|
|
16226
|
+
if (dirty) {
|
|
16227
|
+
compute(labels);
|
|
16228
|
+
}
|
|
16229
|
+
},
|
|
16230
|
+
|
|
16231
|
+
lookup: function(labels, point) {
|
|
16232
|
+
var i, state;
|
|
16233
|
+
|
|
16234
|
+
// IMPORTANT Iterate in the reverse order since items at the end of
|
|
16235
|
+
// the list have an higher z-index, thus should be picked first.
|
|
16236
|
+
|
|
16237
|
+
for (i = labels.length - 1; i >= 0; --i) {
|
|
16238
|
+
state = labels[i].$layout;
|
|
16239
|
+
|
|
16240
|
+
if (state && state._visible && state._box.contains(point)) {
|
|
16241
|
+
return labels[i];
|
|
16242
|
+
}
|
|
16243
|
+
}
|
|
16244
|
+
|
|
16245
|
+
return null;
|
|
16246
|
+
},
|
|
16247
|
+
|
|
16248
|
+
draw: function(chart, labels) {
|
|
16249
|
+
var i, ilen, label, state, geometry, center;
|
|
16250
|
+
|
|
16251
|
+
for (i = 0, ilen = labels.length; i < ilen; ++i) {
|
|
16252
|
+
label = labels[i];
|
|
16253
|
+
state = label.$layout;
|
|
16254
|
+
|
|
16255
|
+
if (state._visible) {
|
|
16256
|
+
geometry = label.geometry();
|
|
16257
|
+
center = coordinates(label._el, label.model(), geometry);
|
|
16258
|
+
state._box.update(center, geometry, label.rotation());
|
|
16259
|
+
label.draw(chart, center);
|
|
16260
|
+
}
|
|
16261
|
+
}
|
|
16262
|
+
}
|
|
16263
|
+
};
|
|
16264
|
+
|
|
16265
|
+
var formatter = function(value) {
|
|
16266
|
+
if (isNullOrUndef(value)) {
|
|
16267
|
+
return null;
|
|
16268
|
+
}
|
|
16269
|
+
|
|
16270
|
+
var label = value;
|
|
16271
|
+
var keys, klen, k;
|
|
16272
|
+
if (isObject(value)) {
|
|
16273
|
+
if (!isNullOrUndef(value.label)) {
|
|
16274
|
+
label = value.label;
|
|
16275
|
+
} else if (!isNullOrUndef(value.r)) {
|
|
16276
|
+
label = value.r;
|
|
16277
|
+
} else {
|
|
16278
|
+
label = '';
|
|
16279
|
+
keys = Object.keys(value);
|
|
16280
|
+
for (k = 0, klen = keys.length; k < klen; ++k) {
|
|
16281
|
+
label += (k !== 0 ? ', ' : '') + keys[k] + ': ' + value[keys[k]];
|
|
16282
|
+
}
|
|
16283
|
+
}
|
|
16284
|
+
}
|
|
16285
|
+
|
|
16286
|
+
return '' + label;
|
|
16287
|
+
};
|
|
16288
|
+
|
|
16289
|
+
/**
|
|
16290
|
+
* IMPORTANT: make sure to also update tests and TypeScript definition
|
|
16291
|
+
* files (`/test/specs/defaults.spec.js` and `/types/options.d.ts`)
|
|
16292
|
+
*/
|
|
16293
|
+
|
|
16294
|
+
var defaults = {
|
|
16295
|
+
align: 'center',
|
|
16296
|
+
anchor: 'center',
|
|
16297
|
+
backgroundColor: null,
|
|
16298
|
+
borderColor: null,
|
|
16299
|
+
borderRadius: 0,
|
|
16300
|
+
borderWidth: 0,
|
|
16301
|
+
clamp: false,
|
|
16302
|
+
clip: false,
|
|
16303
|
+
color: undefined,
|
|
16304
|
+
display: true,
|
|
16305
|
+
font: {
|
|
16306
|
+
family: undefined,
|
|
16307
|
+
lineHeight: 1.2,
|
|
16308
|
+
size: undefined,
|
|
16309
|
+
style: undefined,
|
|
16310
|
+
weight: null
|
|
16311
|
+
},
|
|
16312
|
+
formatter: formatter,
|
|
16313
|
+
labels: undefined,
|
|
16314
|
+
listeners: {},
|
|
16315
|
+
offset: 4,
|
|
16316
|
+
opacity: 1,
|
|
16317
|
+
padding: {
|
|
16318
|
+
top: 4,
|
|
16319
|
+
right: 4,
|
|
16320
|
+
bottom: 4,
|
|
16321
|
+
left: 4
|
|
16322
|
+
},
|
|
16323
|
+
rotation: 0,
|
|
16324
|
+
textAlign: 'start',
|
|
16325
|
+
textStrokeColor: undefined,
|
|
16326
|
+
textStrokeWidth: 0,
|
|
16327
|
+
textShadowBlur: 0,
|
|
16328
|
+
textShadowColor: undefined
|
|
16329
|
+
};
|
|
16330
|
+
|
|
16331
|
+
/**
|
|
16332
|
+
* @see https://github.com/chartjs/Chart.js/issues/4176
|
|
16333
|
+
*/
|
|
16334
|
+
|
|
16335
|
+
var EXPANDO_KEY = '$datalabels';
|
|
16336
|
+
var DEFAULT_KEY = '$default';
|
|
16337
|
+
|
|
16338
|
+
function configure$2(dataset, options) {
|
|
16339
|
+
var override = dataset.datalabels;
|
|
16340
|
+
var listeners = {};
|
|
16341
|
+
var configs = [];
|
|
16342
|
+
var labels, keys;
|
|
16343
|
+
|
|
16344
|
+
if (override === false) {
|
|
16345
|
+
return null;
|
|
16346
|
+
}
|
|
16347
|
+
if (override === true) {
|
|
16348
|
+
override = {};
|
|
16349
|
+
}
|
|
16350
|
+
|
|
16351
|
+
options = merge$1({}, [options, override]);
|
|
16352
|
+
labels = options.labels || {};
|
|
16353
|
+
keys = Object.keys(labels);
|
|
16354
|
+
delete options.labels;
|
|
16355
|
+
|
|
16356
|
+
if (keys.length) {
|
|
16357
|
+
keys.forEach(function(key) {
|
|
16358
|
+
if (labels[key]) {
|
|
16359
|
+
configs.push(merge$1({}, [
|
|
16360
|
+
options,
|
|
16361
|
+
labels[key],
|
|
16362
|
+
{_key: key}
|
|
16363
|
+
]));
|
|
16364
|
+
}
|
|
16365
|
+
});
|
|
16366
|
+
} else {
|
|
16367
|
+
// Default label if no "named" label defined.
|
|
16368
|
+
configs.push(options);
|
|
16369
|
+
}
|
|
16370
|
+
|
|
16371
|
+
// listeners: {<event-type>: {<label-key>: <fn>}}
|
|
16372
|
+
listeners = configs.reduce(function(target, config) {
|
|
16373
|
+
each(config.listeners || {}, function(fn, event) {
|
|
16374
|
+
target[event] = target[event] || {};
|
|
16375
|
+
target[event][config._key || DEFAULT_KEY] = fn;
|
|
16376
|
+
});
|
|
16377
|
+
|
|
16378
|
+
delete config.listeners;
|
|
16379
|
+
return target;
|
|
16380
|
+
}, {});
|
|
16381
|
+
|
|
16382
|
+
return {
|
|
16383
|
+
labels: configs,
|
|
16384
|
+
listeners: listeners
|
|
16385
|
+
};
|
|
16386
|
+
}
|
|
16387
|
+
|
|
16388
|
+
function dispatchEvent(chart, listeners, label, event) {
|
|
16389
|
+
if (!listeners) {
|
|
16390
|
+
return;
|
|
16391
|
+
}
|
|
16392
|
+
|
|
16393
|
+
var context = label.$context;
|
|
16394
|
+
var groups = label.$groups;
|
|
16395
|
+
var callback$1;
|
|
16396
|
+
|
|
16397
|
+
if (!listeners[groups._set]) {
|
|
16398
|
+
return;
|
|
16399
|
+
}
|
|
16400
|
+
|
|
16401
|
+
callback$1 = listeners[groups._set][groups._key];
|
|
16402
|
+
if (!callback$1) {
|
|
16403
|
+
return;
|
|
16404
|
+
}
|
|
16405
|
+
|
|
16406
|
+
if (callback(callback$1, [context, event]) === true) {
|
|
16407
|
+
// Users are allowed to tweak the given context by injecting values that can be
|
|
16408
|
+
// used in scriptable options to display labels differently based on the current
|
|
16409
|
+
// event (e.g. highlight an hovered label). That's why we update the label with
|
|
16410
|
+
// the output context and schedule a new chart render by setting it dirty.
|
|
16411
|
+
chart[EXPANDO_KEY]._dirty = true;
|
|
16412
|
+
label.update(context);
|
|
16413
|
+
}
|
|
16414
|
+
}
|
|
16415
|
+
|
|
16416
|
+
function dispatchMoveEvents(chart, listeners, previous, label, event) {
|
|
16417
|
+
var enter, leave;
|
|
16418
|
+
|
|
16419
|
+
if (!previous && !label) {
|
|
16420
|
+
return;
|
|
16421
|
+
}
|
|
16422
|
+
|
|
16423
|
+
if (!previous) {
|
|
16424
|
+
enter = true;
|
|
16425
|
+
} else if (!label) {
|
|
16426
|
+
leave = true;
|
|
16427
|
+
} else if (previous !== label) {
|
|
16428
|
+
leave = enter = true;
|
|
16429
|
+
}
|
|
16430
|
+
|
|
16431
|
+
if (leave) {
|
|
16432
|
+
dispatchEvent(chart, listeners.leave, previous, event);
|
|
16433
|
+
}
|
|
16434
|
+
if (enter) {
|
|
16435
|
+
dispatchEvent(chart, listeners.enter, label, event);
|
|
16436
|
+
}
|
|
16437
|
+
}
|
|
16438
|
+
|
|
16439
|
+
function handleMoveEvents(chart, event) {
|
|
16440
|
+
var expando = chart[EXPANDO_KEY];
|
|
16441
|
+
var listeners = expando._listeners;
|
|
16442
|
+
var previous, label;
|
|
16443
|
+
|
|
16444
|
+
if (!listeners.enter && !listeners.leave) {
|
|
16445
|
+
return;
|
|
16446
|
+
}
|
|
16447
|
+
|
|
16448
|
+
if (event.type === 'mousemove') {
|
|
16449
|
+
label = layout.lookup(expando._labels, event);
|
|
16450
|
+
} else if (event.type !== 'mouseout') {
|
|
16451
|
+
return;
|
|
16452
|
+
}
|
|
16453
|
+
|
|
16454
|
+
previous = expando._hovered;
|
|
16455
|
+
expando._hovered = label;
|
|
16456
|
+
dispatchMoveEvents(chart, listeners, previous, label, event);
|
|
16457
|
+
}
|
|
16458
|
+
|
|
16459
|
+
function handleClickEvents(chart, event) {
|
|
16460
|
+
var expando = chart[EXPANDO_KEY];
|
|
16461
|
+
var handlers = expando._listeners.click;
|
|
16462
|
+
var label = handlers && layout.lookup(expando._labels, event);
|
|
16463
|
+
if (label) {
|
|
16464
|
+
dispatchEvent(chart, handlers, label, event);
|
|
16465
|
+
}
|
|
16466
|
+
}
|
|
16467
|
+
|
|
16468
|
+
var plugin$1 = {
|
|
16469
|
+
id: 'datalabels',
|
|
16470
|
+
|
|
16471
|
+
defaults: defaults,
|
|
16472
|
+
|
|
16473
|
+
beforeInit: function(chart) {
|
|
16474
|
+
chart[EXPANDO_KEY] = {
|
|
16475
|
+
_actives: []
|
|
16476
|
+
};
|
|
16477
|
+
},
|
|
16478
|
+
|
|
16479
|
+
beforeUpdate: function(chart) {
|
|
16480
|
+
var expando = chart[EXPANDO_KEY];
|
|
16481
|
+
expando._listened = false;
|
|
16482
|
+
expando._listeners = {}; // {<event-type>: {<dataset-index>: {<label-key>: <fn>}}}
|
|
16483
|
+
expando._datasets = []; // per dataset labels: [Label[]]
|
|
16484
|
+
expando._labels = []; // layouted labels: Label[]
|
|
16485
|
+
},
|
|
16486
|
+
|
|
16487
|
+
afterDatasetUpdate: function(chart, args, options) {
|
|
16488
|
+
var datasetIndex = args.index;
|
|
16489
|
+
var expando = chart[EXPANDO_KEY];
|
|
16490
|
+
var labels = expando._datasets[datasetIndex] = [];
|
|
16491
|
+
var visible = chart.isDatasetVisible(datasetIndex);
|
|
16492
|
+
var dataset = chart.data.datasets[datasetIndex];
|
|
16493
|
+
var config = configure$2(dataset, options);
|
|
16494
|
+
var elements = args.meta.data || [];
|
|
16495
|
+
var ctx = chart.ctx;
|
|
16496
|
+
var i, j, ilen, jlen, cfg, key, el, label;
|
|
16497
|
+
|
|
16498
|
+
ctx.save();
|
|
16499
|
+
|
|
16500
|
+
for (i = 0, ilen = elements.length; i < ilen; ++i) {
|
|
16501
|
+
el = elements[i];
|
|
16502
|
+
el[EXPANDO_KEY] = [];
|
|
16503
|
+
|
|
16504
|
+
if (visible && el && chart.getDataVisibility(i) && !el.skip) {
|
|
16505
|
+
for (j = 0, jlen = config.labels.length; j < jlen; ++j) {
|
|
16506
|
+
cfg = config.labels[j];
|
|
16507
|
+
key = cfg._key;
|
|
16508
|
+
|
|
16509
|
+
label = new Label(cfg, ctx, el, i);
|
|
16510
|
+
label.$groups = {
|
|
16511
|
+
_set: datasetIndex,
|
|
16512
|
+
_key: key || DEFAULT_KEY
|
|
16513
|
+
};
|
|
16514
|
+
label.$context = {
|
|
16515
|
+
active: false,
|
|
16516
|
+
chart: chart,
|
|
16517
|
+
dataIndex: i,
|
|
16518
|
+
dataset: dataset,
|
|
16519
|
+
datasetIndex: datasetIndex
|
|
16520
|
+
};
|
|
16521
|
+
|
|
16522
|
+
label.update(label.$context);
|
|
16523
|
+
el[EXPANDO_KEY].push(label);
|
|
16524
|
+
labels.push(label);
|
|
16525
|
+
}
|
|
16526
|
+
}
|
|
16527
|
+
}
|
|
16528
|
+
|
|
16529
|
+
ctx.restore();
|
|
16530
|
+
|
|
16531
|
+
// Store listeners at the chart level and per event type to optimize
|
|
16532
|
+
// cases where no listeners are registered for a specific event.
|
|
16533
|
+
merge$1(expando._listeners, config.listeners, {
|
|
16534
|
+
merger: function(event, target, source) {
|
|
16535
|
+
target[event] = target[event] || {};
|
|
16536
|
+
target[event][args.index] = source[event];
|
|
16537
|
+
expando._listened = true;
|
|
16538
|
+
}
|
|
16539
|
+
});
|
|
16540
|
+
},
|
|
16541
|
+
|
|
16542
|
+
afterUpdate: function(chart) {
|
|
16543
|
+
chart[EXPANDO_KEY]._labels = layout.prepare(chart[EXPANDO_KEY]._datasets);
|
|
16544
|
+
},
|
|
16545
|
+
|
|
16546
|
+
// Draw labels on top of all dataset elements
|
|
16547
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/29
|
|
16548
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/32
|
|
16549
|
+
afterDatasetsDraw: function(chart) {
|
|
16550
|
+
layout.draw(chart, chart[EXPANDO_KEY]._labels);
|
|
16551
|
+
},
|
|
16552
|
+
|
|
16553
|
+
beforeEvent: function(chart, args) {
|
|
16554
|
+
// If there is no listener registered for this chart, `listened` will be false,
|
|
16555
|
+
// meaning we can immediately ignore the incoming event and avoid useless extra
|
|
16556
|
+
// computation for users who don't implement label interactions.
|
|
16557
|
+
if (chart[EXPANDO_KEY]._listened) {
|
|
16558
|
+
var event = args.event;
|
|
16559
|
+
switch (event.type) {
|
|
16560
|
+
case 'mousemove':
|
|
16561
|
+
case 'mouseout':
|
|
16562
|
+
handleMoveEvents(chart, event);
|
|
16563
|
+
break;
|
|
16564
|
+
case 'click':
|
|
16565
|
+
handleClickEvents(chart, event);
|
|
16566
|
+
break;
|
|
16567
|
+
}
|
|
16568
|
+
}
|
|
16569
|
+
},
|
|
16570
|
+
|
|
16571
|
+
afterEvent: function(chart) {
|
|
16572
|
+
var expando = chart[EXPANDO_KEY];
|
|
16573
|
+
var previous = expando._actives;
|
|
16574
|
+
var actives = expando._actives = chart.getActiveElements();
|
|
16575
|
+
var updates = utils.arrayDiff(previous, actives);
|
|
16576
|
+
var i, ilen, j, jlen, update, label, labels;
|
|
16577
|
+
|
|
16578
|
+
for (i = 0, ilen = updates.length; i < ilen; ++i) {
|
|
16579
|
+
update = updates[i];
|
|
16580
|
+
if (update[1]) {
|
|
16581
|
+
labels = update[0].element[EXPANDO_KEY] || [];
|
|
16582
|
+
for (j = 0, jlen = labels.length; j < jlen; ++j) {
|
|
16583
|
+
label = labels[j];
|
|
16584
|
+
label.$context.active = (update[1] === 1);
|
|
16585
|
+
label.update(label.$context);
|
|
16586
|
+
}
|
|
16587
|
+
}
|
|
16588
|
+
}
|
|
16589
|
+
|
|
16590
|
+
if (expando._dirty || updates.length) {
|
|
16591
|
+
layout.update(expando._labels);
|
|
16592
|
+
chart.render();
|
|
16593
|
+
}
|
|
16594
|
+
|
|
16595
|
+
delete expando._dirty;
|
|
16596
|
+
}
|
|
16597
|
+
};
|
|
16598
|
+
|
|
15247
16599
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15248
16600
|
function SeriesLineChart({ orientation, title, data, options, className, units, content }) {
|
|
15249
16601
|
var _a, _b;
|
|
@@ -15345,9 +16697,791 @@ function SeriesLineChart({ orientation, title, data, options, className, units,
|
|
|
15345
16697
|
},
|
|
15346
16698
|
},
|
|
15347
16699
|
};
|
|
15348
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [
|
|
16700
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin$1] }));
|
|
16701
|
+
}
|
|
16702
|
+
|
|
16703
|
+
/*!
|
|
16704
|
+
* @energiency/chartjs-plugin-piechart-outlabels v1.3.4
|
|
16705
|
+
* http://www.chartjs.org
|
|
16706
|
+
* (c) 2017-2025 @energiency/chartjs-plugin-piechart-outlabels contributors
|
|
16707
|
+
* Released under the MIT license
|
|
16708
|
+
*/
|
|
16709
|
+
|
|
16710
|
+
/**
|
|
16711
|
+
* @module Options
|
|
16712
|
+
*/
|
|
16713
|
+
|
|
16714
|
+
var customDefaults = {
|
|
16715
|
+
PLUGIN_KEY: '$outlabels',
|
|
16716
|
+
|
|
16717
|
+
/**
|
|
16718
|
+
* The color used to draw the background of the label rect.
|
|
16719
|
+
* @member {String|Array|Function|null}
|
|
16720
|
+
* @default null (adaptive background)
|
|
16721
|
+
*/
|
|
16722
|
+
backgroundColor: function (context) {
|
|
16723
|
+
return context.dataset.backgroundColor;
|
|
16724
|
+
},
|
|
16725
|
+
|
|
16726
|
+
/**
|
|
16727
|
+
* The color used to draw the border of the label rect.
|
|
16728
|
+
* @member {String|Array|Function|null}
|
|
16729
|
+
* @default null (adaptive border color)
|
|
16730
|
+
*/
|
|
16731
|
+
borderColor: function (context) {
|
|
16732
|
+
return context.dataset.backgroundColor;
|
|
16733
|
+
},
|
|
16734
|
+
|
|
16735
|
+
/**
|
|
16736
|
+
* The color used to draw the line between label and arc of the chart.
|
|
16737
|
+
* @member {String|Array|Function|null}
|
|
16738
|
+
* @default null (adaptive line color)
|
|
16739
|
+
*/
|
|
16740
|
+
lineColor: function (context) {
|
|
16741
|
+
return context.dataset.backgroundColor;
|
|
16742
|
+
},
|
|
16743
|
+
|
|
16744
|
+
/**
|
|
16745
|
+
* The border radius used to add rounded corners to the label rect.
|
|
16746
|
+
* @member {Number|Array|Function}
|
|
16747
|
+
* @default 0 (not rounded)
|
|
16748
|
+
*/
|
|
16749
|
+
borderRadius: 0,
|
|
16750
|
+
|
|
16751
|
+
/**
|
|
16752
|
+
* The border width of the surrounding frame.
|
|
16753
|
+
* @member {Number|Array|Function}
|
|
16754
|
+
* @default 0 (no border)
|
|
16755
|
+
*/
|
|
16756
|
+
borderWidth: 0,
|
|
16757
|
+
|
|
16758
|
+
/**
|
|
16759
|
+
* The width (thickness) of the line between label and chart arc.
|
|
16760
|
+
* @member {Number|Array|Function}
|
|
16761
|
+
* @default 2
|
|
16762
|
+
*/
|
|
16763
|
+
lineWidth: 2,
|
|
16764
|
+
|
|
16765
|
+
/**
|
|
16766
|
+
* The color used to draw the label text.
|
|
16767
|
+
* @member {String|Array|Function}
|
|
16768
|
+
* @default white
|
|
16769
|
+
*/
|
|
16770
|
+
color: 'white',
|
|
16771
|
+
|
|
16772
|
+
/**
|
|
16773
|
+
* Whether to display labels global (boolean) or per data (function)
|
|
16774
|
+
* @member {Boolean|Array|Function}
|
|
16775
|
+
* @default true
|
|
16776
|
+
*/
|
|
16777
|
+
display: true,
|
|
16778
|
+
|
|
16779
|
+
/**
|
|
16780
|
+
* The font options used to draw the label text.
|
|
16781
|
+
* @member {Object|Array|Function}
|
|
16782
|
+
* @prop {Boolean} font.family - defaults to Chart.defaults.global.defaultFontFamily
|
|
16783
|
+
* @prop {Boolean} font.size - defaults to Chart.defaults.global.defaultFontSize
|
|
16784
|
+
* @prop {Boolean} font.style - defaults to Chart.defaults.global.defaultFontStyle
|
|
16785
|
+
* @prop {Boolean} font.weight - defaults to 'normal'
|
|
16786
|
+
* @prop {Boolean} font.maxSize - defaults to undefined (unlimited)
|
|
16787
|
+
* @prop {Boolean} font.minSize - defaults to undefined (unlimited)
|
|
16788
|
+
* @prop {Boolean} font.resizable - defaults to true
|
|
16789
|
+
* @default Chart.defaults.global.defaultFont.*
|
|
16790
|
+
*/
|
|
16791
|
+
font: {
|
|
16792
|
+
family: undefined,
|
|
16793
|
+
size: undefined,
|
|
16794
|
+
style: undefined,
|
|
16795
|
+
weight: null,
|
|
16796
|
+
maxSize: null,
|
|
16797
|
+
minSize: null,
|
|
16798
|
+
resizable: true,
|
|
16799
|
+
},
|
|
16800
|
+
|
|
16801
|
+
/**
|
|
16802
|
+
* The line height (in pixel) to use for multi-lines labels.
|
|
16803
|
+
* @member {Number|Array|Function|undefined}
|
|
16804
|
+
* @default 1.2
|
|
16805
|
+
*/
|
|
16806
|
+
lineHeight: 1.2,
|
|
16807
|
+
|
|
16808
|
+
/**
|
|
16809
|
+
* The padding (in pixels) to apply between the text and the surrounding frame.
|
|
16810
|
+
* @member {Number|Object|Array|Function}
|
|
16811
|
+
* @prop {Number} padding.top - Space above the text.
|
|
16812
|
+
* @prop {Number} padding.right - Space on the right of the text.
|
|
16813
|
+
* @prop {Number} padding.bottom - Space below the text.
|
|
16814
|
+
* @prop {Number} padding.left - Space on the left of the text.
|
|
16815
|
+
* @default 4 (all values)
|
|
16816
|
+
*/
|
|
16817
|
+
padding: {
|
|
16818
|
+
top: 2,
|
|
16819
|
+
right: 2,
|
|
16820
|
+
bottom: 2,
|
|
16821
|
+
left: 2,
|
|
16822
|
+
},
|
|
16823
|
+
|
|
16824
|
+
/**
|
|
16825
|
+
* Text alignment for multi-lines labels ('left'|'right'|'start'|'center'|'end').
|
|
16826
|
+
* @member {String|Array|Function}
|
|
16827
|
+
* @default 'center'
|
|
16828
|
+
*/
|
|
16829
|
+
textAlign: 'center',
|
|
16830
|
+
|
|
16831
|
+
/**
|
|
16832
|
+
* The radius of distance where the label will be drawn
|
|
16833
|
+
* @member {Number|Array|Function|undefined}
|
|
16834
|
+
* @default 30
|
|
16835
|
+
*/
|
|
16836
|
+
stretch: 12,
|
|
16837
|
+
|
|
16838
|
+
/**
|
|
16839
|
+
* The length of the horizontal part of line between label and chart arc.
|
|
16840
|
+
* @member {Number}
|
|
16841
|
+
* @default 30
|
|
16842
|
+
*/
|
|
16843
|
+
horizontalStrechPad: 12,
|
|
16844
|
+
|
|
16845
|
+
/**
|
|
16846
|
+
* The text of the label.
|
|
16847
|
+
* @member {String}
|
|
16848
|
+
* @default '%l %p' (label name and value percentage)
|
|
16849
|
+
*/
|
|
16850
|
+
text: '%l %p',
|
|
16851
|
+
|
|
16852
|
+
/**
|
|
16853
|
+
* The max level of zoom (out) for pie/doughnut chart in percent.
|
|
16854
|
+
* @member {Number}
|
|
16855
|
+
* @default 50 (%)
|
|
16856
|
+
*/
|
|
16857
|
+
maxZoomOutPercentage: 50,
|
|
16858
|
+
|
|
16859
|
+
/**
|
|
16860
|
+
* The count of numbers after the point separator for float values of percent property
|
|
16861
|
+
* @member {Number}
|
|
16862
|
+
* @default 1
|
|
16863
|
+
*/
|
|
16864
|
+
percentPrecision: 1,
|
|
16865
|
+
|
|
16866
|
+
/**
|
|
16867
|
+
* The count of numbers after the point separator for float values of value property
|
|
16868
|
+
* @member {Number}
|
|
16869
|
+
* @default 3
|
|
16870
|
+
*/
|
|
16871
|
+
valuePrecision: 3,
|
|
16872
|
+
};
|
|
16873
|
+
|
|
16874
|
+
const chartStates = new WeakMap();
|
|
16875
|
+
|
|
16876
|
+
function getState(chart) {
|
|
16877
|
+
let state = chartStates.get(chart);
|
|
16878
|
+
if (!state) {
|
|
16879
|
+
state = { sizeChanged: false, fitting: false };
|
|
16880
|
+
chartStates.set(chart, state);
|
|
16881
|
+
}
|
|
16882
|
+
return state;
|
|
16883
|
+
}
|
|
16884
|
+
|
|
16885
|
+
function removeState(chart) {
|
|
16886
|
+
chartStates.delete(chart);
|
|
16887
|
+
}
|
|
16888
|
+
|
|
16889
|
+
var positioners = {
|
|
16890
|
+
center: function (arc, stretch) {
|
|
16891
|
+
var angle = (arc.startAngle + arc.endAngle) / 2;
|
|
16892
|
+
var cosA = Math.cos(angle);
|
|
16893
|
+
var sinA = Math.sin(angle);
|
|
16894
|
+
var d = arc.outerRadius;
|
|
16895
|
+
|
|
16896
|
+
var stretchedD = d + stretch;
|
|
16897
|
+
return {
|
|
16898
|
+
x: arc.x + cosA * stretchedD,
|
|
16899
|
+
y: arc.y + sinA * stretchedD,
|
|
16900
|
+
d: stretchedD,
|
|
16901
|
+
arc: arc,
|
|
16902
|
+
anchor: { x: arc.x + cosA * d, y: arc.y + sinA * d },
|
|
16903
|
+
copy: { x: arc.x + cosA * stretchedD, y: arc.y + sinA * stretchedD },
|
|
16904
|
+
};
|
|
16905
|
+
},
|
|
16906
|
+
|
|
16907
|
+
moveFromAnchor: function (center, dist) {
|
|
16908
|
+
var arc = center.arc;
|
|
16909
|
+
var d = center.d;
|
|
16910
|
+
var angle = (arc.startAngle + arc.endAngle) / 2;
|
|
16911
|
+
var cosA = Math.cos(angle);
|
|
16912
|
+
var sinA = Math.sin(angle);
|
|
16913
|
+
|
|
16914
|
+
d += dist;
|
|
16915
|
+
|
|
16916
|
+
return {
|
|
16917
|
+
x: arc.x + cosA * d,
|
|
16918
|
+
y: arc.y + sinA * d,
|
|
16919
|
+
d: d,
|
|
16920
|
+
arc: arc,
|
|
16921
|
+
anchor: center.anchor,
|
|
16922
|
+
copy: {
|
|
16923
|
+
x: arc.x + cosA * d,
|
|
16924
|
+
y: arc.y + sinA * d,
|
|
16925
|
+
},
|
|
16926
|
+
};
|
|
16927
|
+
},
|
|
16928
|
+
};
|
|
16929
|
+
|
|
16930
|
+
function toFontString(font) {
|
|
16931
|
+
if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
|
|
16932
|
+
return null;
|
|
16933
|
+
}
|
|
16934
|
+
|
|
16935
|
+
return (
|
|
16936
|
+
(font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family
|
|
16937
|
+
);
|
|
16938
|
+
}
|
|
16939
|
+
|
|
16940
|
+
function textSize(ctx, lines, font) {
|
|
16941
|
+
var items = [].concat(lines);
|
|
16942
|
+
var ilen = items.length;
|
|
16943
|
+
var prev = ctx.font;
|
|
16944
|
+
var width = 0;
|
|
16945
|
+
var i;
|
|
16946
|
+
|
|
16947
|
+
ctx.font = font.string;
|
|
16948
|
+
|
|
16949
|
+
for (i = 0; i < ilen; ++i) {
|
|
16950
|
+
width = Math.max(ctx.measureText(items[i]).width, width);
|
|
16951
|
+
}
|
|
16952
|
+
|
|
16953
|
+
ctx.font = prev;
|
|
16954
|
+
|
|
16955
|
+
return {
|
|
16956
|
+
height: ilen * font.lineHeight,
|
|
16957
|
+
width,
|
|
16958
|
+
};
|
|
16959
|
+
}
|
|
16960
|
+
|
|
16961
|
+
function adaptTextSizeToDimensions(width, height, minimum, maximum) {
|
|
16962
|
+
const diag = Math.sqrt(Math.pow(width || 100, 2) + Math.pow(height || 100, 2));
|
|
16963
|
+
const size = Math.round(diag * 0.02);
|
|
16964
|
+
|
|
16965
|
+
if (minimum && size < minimum) {
|
|
16966
|
+
return minimum;
|
|
16967
|
+
}
|
|
16968
|
+
if (maximum && size > maximum) {
|
|
16969
|
+
return maximum;
|
|
16970
|
+
}
|
|
16971
|
+
return size;
|
|
16972
|
+
}
|
|
16973
|
+
|
|
16974
|
+
function parseFont(value, width, height) {
|
|
16975
|
+
var size = valueOrDefault(value.size, Chart$1.defaults.defaultFontSize);
|
|
16976
|
+
|
|
16977
|
+
if (value.resizable) {
|
|
16978
|
+
size = adaptTextSizeToDimensions(width, height, value.minSize, value.maxSize);
|
|
16979
|
+
}
|
|
16980
|
+
|
|
16981
|
+
var font = {
|
|
16982
|
+
family: valueOrDefault(value.family, Chart$1.defaults.defaultFontFamily),
|
|
16983
|
+
lineHeight: toLineHeight(value.lineHeight, size),
|
|
16984
|
+
lineWidth: toLineHeight(value.lineWidth, size),
|
|
16985
|
+
size,
|
|
16986
|
+
style: valueOrDefault(value.style, Chart$1.defaults.defaultFontStyle),
|
|
16987
|
+
weight: valueOrDefault(value.weight, null),
|
|
16988
|
+
string: '',
|
|
16989
|
+
};
|
|
16990
|
+
|
|
16991
|
+
font.string = toFontString(font);
|
|
16992
|
+
return font;
|
|
16993
|
+
}
|
|
16994
|
+
|
|
16995
|
+
var PLUGIN_KEY$1 = customDefaults.PLUGIN_KEY;
|
|
16996
|
+
|
|
16997
|
+
function collides(rect, otherRect) {
|
|
16998
|
+
return (
|
|
16999
|
+
rect.x < otherRect.x + otherRect.width &&
|
|
17000
|
+
rect.x + rect.width > otherRect.x &&
|
|
17001
|
+
rect.y < otherRect.y + otherRect.height &&
|
|
17002
|
+
rect.y + rect.height > otherRect.y
|
|
17003
|
+
);
|
|
15349
17004
|
}
|
|
15350
17005
|
|
|
17006
|
+
var classes = {
|
|
17007
|
+
OutLabel: function (chart, index, ctx, config, context) {
|
|
17008
|
+
// Check whether the label should be displayed
|
|
17009
|
+
if (!resolve([config.display, true], context, index)) {
|
|
17010
|
+
throw new Error('Label display property is set to false.');
|
|
17011
|
+
}
|
|
17012
|
+
|
|
17013
|
+
// Init text
|
|
17014
|
+
var value = context.dataset.data[index];
|
|
17015
|
+
var label = context.labels[index];
|
|
17016
|
+
var text = resolve([config.text, customDefaults.text], context, index);
|
|
17017
|
+
/* Replace label marker */
|
|
17018
|
+
text = text.replace(/%l/gi, label);
|
|
17019
|
+
|
|
17020
|
+
/* Replace value marker with possible precision value */
|
|
17021
|
+
(text.match(/%v\.?(\d*)/gi) || [])
|
|
17022
|
+
.map(function (val) {
|
|
17023
|
+
var prec = val.replace(/%v\./gi, '');
|
|
17024
|
+
if (prec.length) {
|
|
17025
|
+
return +prec;
|
|
17026
|
+
}
|
|
17027
|
+
return config.valuePrecision || customDefaults.valuePrecision;
|
|
17028
|
+
})
|
|
17029
|
+
.forEach(function (val) {
|
|
17030
|
+
text = text.replace(/%v\.?(\d*)/i, value.toFixed(val));
|
|
17031
|
+
});
|
|
17032
|
+
|
|
17033
|
+
/* Replace percent marker with possible precision value */
|
|
17034
|
+
(text.match(/%p\.?(\d*)/gi) || [])
|
|
17035
|
+
.map(function (val) {
|
|
17036
|
+
var prec = val.replace(/%p\./gi, '');
|
|
17037
|
+
if (prec.length) {
|
|
17038
|
+
return +prec;
|
|
17039
|
+
}
|
|
17040
|
+
return config.percentPrecision || customDefaults.percentPrecision;
|
|
17041
|
+
})
|
|
17042
|
+
.forEach(function (val) {
|
|
17043
|
+
text = text.replace(/%p\.?(\d*)/i, (context.percent * 100).toFixed(val) + '%');
|
|
17044
|
+
});
|
|
17045
|
+
|
|
17046
|
+
// Count lines
|
|
17047
|
+
var lines = text.match(/[^\r\n]+/g) || [];
|
|
17048
|
+
|
|
17049
|
+
// Remove unnecessary spaces
|
|
17050
|
+
for (var i = 0; i < lines.length; ++i) {
|
|
17051
|
+
lines[i] = lines[i].trim();
|
|
17052
|
+
}
|
|
17053
|
+
|
|
17054
|
+
/* ===================== CONSTRUCTOR ==================== */
|
|
17055
|
+
this.init = function (text, lines) {
|
|
17056
|
+
// If everything ok -> begin initializing
|
|
17057
|
+
this.encodedText = config.text;
|
|
17058
|
+
this.text = text;
|
|
17059
|
+
this.lines = lines;
|
|
17060
|
+
this.label = label;
|
|
17061
|
+
this.value = value;
|
|
17062
|
+
|
|
17063
|
+
// Init style
|
|
17064
|
+
this.style = {
|
|
17065
|
+
backgroundColor: resolve(
|
|
17066
|
+
[config.backgroundColor, customDefaults.backgroundColor, 'black'],
|
|
17067
|
+
context,
|
|
17068
|
+
index,
|
|
17069
|
+
),
|
|
17070
|
+
borderColor: resolve([config.borderColor, customDefaults.borderColor, 'black'], context, index),
|
|
17071
|
+
borderRadius: resolve([config.borderRadius, 0], context, index),
|
|
17072
|
+
borderWidth: resolve([config.borderWidth, 0], context, index),
|
|
17073
|
+
lineWidth: resolve([config.lineWidth, 2], context, index),
|
|
17074
|
+
lineColor: resolve([config.lineColor, customDefaults.lineColor, 'black'], context, index),
|
|
17075
|
+
color: resolve([config.color, 'white'], context, index),
|
|
17076
|
+
font: parseFont(
|
|
17077
|
+
resolve([config.font, { resizable: true }]),
|
|
17078
|
+
ctx.canvas.style.width.slice(0, -2),
|
|
17079
|
+
ctx.canvas.style.height.slice(0, -2),
|
|
17080
|
+
),
|
|
17081
|
+
padding: toPadding(resolve([config.padding, 0], context, index)),
|
|
17082
|
+
textAlign: resolve([config.textAlign, 'left'], context, index),
|
|
17083
|
+
};
|
|
17084
|
+
|
|
17085
|
+
this.stretch = resolve([config.stretch, customDefaults.stretch], context, index);
|
|
17086
|
+
this.horizontalStrechPad = resolve(
|
|
17087
|
+
[config.horizontalStrechPad, customDefaults.horizontalStrechPad],
|
|
17088
|
+
context,
|
|
17089
|
+
index,
|
|
17090
|
+
);
|
|
17091
|
+
this.size = textSize(ctx, this.lines, this.style.font);
|
|
17092
|
+
|
|
17093
|
+
this.offsetStep = this.size.width / 20;
|
|
17094
|
+
this.offset = {
|
|
17095
|
+
x: 0,
|
|
17096
|
+
y: 0,
|
|
17097
|
+
};
|
|
17098
|
+
};
|
|
17099
|
+
|
|
17100
|
+
this.init(text, lines);
|
|
17101
|
+
|
|
17102
|
+
/* COMPUTING RECTS PART */
|
|
17103
|
+
this.computeLabelRect = function () {
|
|
17104
|
+
var width =
|
|
17105
|
+
this.textRect.width + 2 * this.style.borderWidth + this.style.padding.left + this.style.padding.right;
|
|
17106
|
+
var height =
|
|
17107
|
+
this.textRect.height + 2 * this.style.borderWidth + this.style.padding.top + this.style.padding.bottom;
|
|
17108
|
+
|
|
17109
|
+
var x = this.textRect.x - this.style.borderWidth;
|
|
17110
|
+
var y = this.textRect.y - this.style.borderWidth;
|
|
17111
|
+
|
|
17112
|
+
return {
|
|
17113
|
+
x: x,
|
|
17114
|
+
y: y,
|
|
17115
|
+
width: width,
|
|
17116
|
+
height: height,
|
|
17117
|
+
isLeft: this.textRect.isLeft,
|
|
17118
|
+
isTop: this.textRect.isTop,
|
|
17119
|
+
};
|
|
17120
|
+
};
|
|
17121
|
+
|
|
17122
|
+
this.computeTextRect = function () {
|
|
17123
|
+
const isLeft = this.center.x - this.center.anchor.x < 0;
|
|
17124
|
+
const isTop = this.center.y - this.center.anchor.y < 0;
|
|
17125
|
+
const shift = isLeft ? -(this.horizontalStrechPad + this.size.width) : this.horizontalStrechPad;
|
|
17126
|
+
return {
|
|
17127
|
+
x: this.center.x - this.style.padding.left + shift,
|
|
17128
|
+
y: this.center.y - this.size.height / 2,
|
|
17129
|
+
width: this.size.width,
|
|
17130
|
+
height: this.size.height,
|
|
17131
|
+
isLeft,
|
|
17132
|
+
isTop,
|
|
17133
|
+
};
|
|
17134
|
+
};
|
|
17135
|
+
|
|
17136
|
+
/* ======================= DRAWING ======================= */
|
|
17137
|
+
// Draw label text
|
|
17138
|
+
this.drawText = function (ctx) {
|
|
17139
|
+
var align = this.style.textAlign;
|
|
17140
|
+
var font = this.style.font;
|
|
17141
|
+
var lh = font.lineHeight;
|
|
17142
|
+
var color = this.style.color;
|
|
17143
|
+
var ilen = this.lines.length;
|
|
17144
|
+
var x, y, idx;
|
|
17145
|
+
|
|
17146
|
+
if (!ilen || !color) {
|
|
17147
|
+
return;
|
|
17148
|
+
}
|
|
17149
|
+
|
|
17150
|
+
x = this.textRect.x;
|
|
17151
|
+
y = this.textRect.y + lh / 2;
|
|
17152
|
+
|
|
17153
|
+
if (align === 'center') {
|
|
17154
|
+
x += this.textRect.width / 2;
|
|
17155
|
+
} else if (align === 'end' || align === 'right') {
|
|
17156
|
+
x += this.textRect.width;
|
|
17157
|
+
}
|
|
17158
|
+
|
|
17159
|
+
ctx.font = this.style.font.string;
|
|
17160
|
+
ctx.fillStyle = color;
|
|
17161
|
+
ctx.textAlign = align;
|
|
17162
|
+
ctx.textBaseline = 'middle';
|
|
17163
|
+
|
|
17164
|
+
for (idx = 0; idx < ilen; ++idx) {
|
|
17165
|
+
ctx.fillText(
|
|
17166
|
+
this.lines[idx],
|
|
17167
|
+
Math.round(x) + this.style.padding.left,
|
|
17168
|
+
Math.round(y),
|
|
17169
|
+
Math.round(this.textRect.width),
|
|
17170
|
+
);
|
|
17171
|
+
y += lh;
|
|
17172
|
+
}
|
|
17173
|
+
};
|
|
17174
|
+
|
|
17175
|
+
// Draw label box
|
|
17176
|
+
this.drawLabel = function (ctx) {
|
|
17177
|
+
ctx.beginPath();
|
|
17178
|
+
|
|
17179
|
+
ctx.roundRect(
|
|
17180
|
+
Math.round(this.labelRect.x),
|
|
17181
|
+
Math.round(this.labelRect.y),
|
|
17182
|
+
Math.round(this.labelRect.width),
|
|
17183
|
+
Math.round(this.labelRect.height),
|
|
17184
|
+
this.style.borderRadius,
|
|
17185
|
+
);
|
|
17186
|
+
ctx.closePath();
|
|
17187
|
+
|
|
17188
|
+
if (this.style.backgroundColor) {
|
|
17189
|
+
ctx.fillStyle = this.style.backgroundColor || 'transparent';
|
|
17190
|
+
ctx.fill();
|
|
17191
|
+
}
|
|
17192
|
+
|
|
17193
|
+
if (this.style.borderColor && this.style.borderWidth) {
|
|
17194
|
+
ctx.strokeStyle = this.style.borderColor;
|
|
17195
|
+
ctx.lineWidth = this.style.borderWidth;
|
|
17196
|
+
ctx.lineJoin = 'miter';
|
|
17197
|
+
ctx.stroke();
|
|
17198
|
+
}
|
|
17199
|
+
};
|
|
17200
|
+
|
|
17201
|
+
this.ccw = function (A, B, C) {
|
|
17202
|
+
return (C.y - A.y) * (B.x - A.x) > (B.y - A.y) * (C.x - A.x);
|
|
17203
|
+
};
|
|
17204
|
+
|
|
17205
|
+
this.intersects = function (A, B, C, D) {
|
|
17206
|
+
return this.ccw(A, C, D) !== this.ccw(B, C, D) && this.ccw(A, B, C) !== this.ccw(A, B, D);
|
|
17207
|
+
};
|
|
17208
|
+
|
|
17209
|
+
this.drawLine = function (ctx) {
|
|
17210
|
+
if (!this.lines.length) {
|
|
17211
|
+
return;
|
|
17212
|
+
}
|
|
17213
|
+
ctx.save();
|
|
17214
|
+
|
|
17215
|
+
ctx.strokeStyle = this.style.lineColor;
|
|
17216
|
+
ctx.lineWidth = this.style.lineWidth;
|
|
17217
|
+
ctx.lineJoin = 'miter';
|
|
17218
|
+
ctx.beginPath();
|
|
17219
|
+
ctx.moveTo(this.center.anchor.x, this.center.anchor.y);
|
|
17220
|
+
ctx.lineTo(this.center.copy.x, this.center.copy.y);
|
|
17221
|
+
ctx.stroke();
|
|
17222
|
+
|
|
17223
|
+
ctx.beginPath();
|
|
17224
|
+
ctx.moveTo(this.center.copy.x, this.center.copy.y);
|
|
17225
|
+
const xOffset = this.textRect.width + this.style.padding.width;
|
|
17226
|
+
const intersect = this.intersects(
|
|
17227
|
+
this.textRect,
|
|
17228
|
+
{
|
|
17229
|
+
x: this.textRect.x + this.textRect.width,
|
|
17230
|
+
y: this.textRect.y + this.textRect.height,
|
|
17231
|
+
},
|
|
17232
|
+
this.center.copy,
|
|
17233
|
+
{
|
|
17234
|
+
x: this.textRect.x,
|
|
17235
|
+
y: this.textRect.y + this.textRect.height / 2,
|
|
17236
|
+
},
|
|
17237
|
+
);
|
|
17238
|
+
ctx.lineTo(this.textRect.x + (intersect ? xOffset : 0), this.textRect.y + this.textRect.height / 2);
|
|
17239
|
+
ctx.stroke();
|
|
17240
|
+
ctx.restore();
|
|
17241
|
+
};
|
|
17242
|
+
|
|
17243
|
+
this.draw = function (ctx) {
|
|
17244
|
+
if (chart.getDataVisibility(index)) {
|
|
17245
|
+
this.drawLabel(ctx);
|
|
17246
|
+
this.drawText(ctx);
|
|
17247
|
+
this.drawLine(ctx);
|
|
17248
|
+
}
|
|
17249
|
+
};
|
|
17250
|
+
|
|
17251
|
+
// eslint-disable-next-line max-statements
|
|
17252
|
+
this.update = function (view, elements, max) {
|
|
17253
|
+
this.center = positioners.center(view, this.stretch);
|
|
17254
|
+
|
|
17255
|
+
let valid = false;
|
|
17256
|
+
let steps = 30;
|
|
17257
|
+
|
|
17258
|
+
while (!valid && steps > 0) {
|
|
17259
|
+
this.textRect = this.computeTextRect();
|
|
17260
|
+
this.labelRect = this.computeLabelRect();
|
|
17261
|
+
|
|
17262
|
+
valid = true;
|
|
17263
|
+
|
|
17264
|
+
for (var e = 0; e < max; ++e) {
|
|
17265
|
+
var element = elements[e][PLUGIN_KEY$1];
|
|
17266
|
+
if (!element || !chart.getDataVisibility(index)) {
|
|
17267
|
+
continue;
|
|
17268
|
+
}
|
|
17269
|
+
|
|
17270
|
+
if (collides(this.labelRect, element.labelRect)) {
|
|
17271
|
+
valid = false;
|
|
17272
|
+
break;
|
|
17273
|
+
}
|
|
17274
|
+
}
|
|
17275
|
+
|
|
17276
|
+
if (!valid) {
|
|
17277
|
+
this.center = positioners.moveFromAnchor(this.center, 5);
|
|
17278
|
+
}
|
|
17279
|
+
|
|
17280
|
+
steps--;
|
|
17281
|
+
}
|
|
17282
|
+
};
|
|
17283
|
+
},
|
|
17284
|
+
};
|
|
17285
|
+
|
|
17286
|
+
defaults$1.plugins.outlabels = customDefaults;
|
|
17287
|
+
|
|
17288
|
+
var PLUGIN_KEY = customDefaults.PLUGIN_KEY;
|
|
17289
|
+
|
|
17290
|
+
function configure$1(dataset, options) {
|
|
17291
|
+
var override = dataset.outlabels;
|
|
17292
|
+
var config = {};
|
|
17293
|
+
|
|
17294
|
+
if (override === false) {
|
|
17295
|
+
return null;
|
|
17296
|
+
}
|
|
17297
|
+
if (override === true) {
|
|
17298
|
+
override = {};
|
|
17299
|
+
}
|
|
17300
|
+
|
|
17301
|
+
return Object.assign({}, config, options, override);
|
|
17302
|
+
}
|
|
17303
|
+
|
|
17304
|
+
/**
|
|
17305
|
+
* Returns the bounding box of the given label elements.
|
|
17306
|
+
*
|
|
17307
|
+
* @param {*} elements List of chart elements
|
|
17308
|
+
* @returns Bounding box
|
|
17309
|
+
*/
|
|
17310
|
+
function getBoundingBox(elements) {
|
|
17311
|
+
const rect = { left: Infinity, right: -Infinity, top: Infinity, bottom: -Infinity };
|
|
17312
|
+
|
|
17313
|
+
for (let i = 0, l = elements.length; i < l; i++) {
|
|
17314
|
+
const outlabel = elements[i][PLUGIN_KEY];
|
|
17315
|
+
if (!outlabel || !outlabel.labelRect) {
|
|
17316
|
+
continue;
|
|
17317
|
+
}
|
|
17318
|
+
|
|
17319
|
+
const { labelRect } = outlabel;
|
|
17320
|
+
const { x, y, width, height } = labelRect;
|
|
17321
|
+
|
|
17322
|
+
rect.left = Math.min(rect.left, x);
|
|
17323
|
+
rect.right = Math.max(rect.right, x + width);
|
|
17324
|
+
rect.top = Math.min(rect.top, y);
|
|
17325
|
+
rect.bottom = Math.max(rect.bottom, y + height);
|
|
17326
|
+
}
|
|
17327
|
+
|
|
17328
|
+
return {
|
|
17329
|
+
...rect,
|
|
17330
|
+
width: rect.right - rect.left,
|
|
17331
|
+
height: rect.bottom - rect.top,
|
|
17332
|
+
};
|
|
17333
|
+
}
|
|
17334
|
+
|
|
17335
|
+
/**
|
|
17336
|
+
* Returns the zoom percentage required to fit the given bounding box within the given bounding box.
|
|
17337
|
+
*
|
|
17338
|
+
* @param {*} boundingBoxToResize
|
|
17339
|
+
* @param {*} boundingBoxToFitWithin
|
|
17340
|
+
* @returns Zoom percentage
|
|
17341
|
+
*/
|
|
17342
|
+
function getResizeZoomPercentage(boundingBoxToResize, boundingBoxToFitWithin) {
|
|
17343
|
+
const { width, height } = boundingBoxToFitWithin;
|
|
17344
|
+
const deltas = [
|
|
17345
|
+
((boundingBoxToFitWithin.left - boundingBoxToResize.left) / width) * 2,
|
|
17346
|
+
((boundingBoxToFitWithin.top - boundingBoxToResize.top) / height) * 2,
|
|
17347
|
+
((boundingBoxToResize.right - boundingBoxToFitWithin.right) / width) * 2,
|
|
17348
|
+
((boundingBoxToResize.bottom - boundingBoxToFitWithin.bottom) / height) * 2,
|
|
17349
|
+
];
|
|
17350
|
+
|
|
17351
|
+
const maxDelta = Math.max(0, ...deltas);
|
|
17352
|
+
return 1 - maxDelta;
|
|
17353
|
+
}
|
|
17354
|
+
|
|
17355
|
+
/**
|
|
17356
|
+
* Updates the labels of the given elements.
|
|
17357
|
+
* @param {*} elements
|
|
17358
|
+
*/
|
|
17359
|
+
function updateLabels(elements) {
|
|
17360
|
+
for (let i = 0, l = elements.length; i < l; i++) {
|
|
17361
|
+
const element = elements[i];
|
|
17362
|
+
const outlabel = element[PLUGIN_KEY];
|
|
17363
|
+
if (!outlabel) {
|
|
17364
|
+
continue;
|
|
17365
|
+
}
|
|
17366
|
+
|
|
17367
|
+
outlabel.update(element, elements, i);
|
|
17368
|
+
}
|
|
17369
|
+
}
|
|
17370
|
+
|
|
17371
|
+
function fitChartArea(chart) {
|
|
17372
|
+
const ctrl = chart._metasets[0].controller;
|
|
17373
|
+
const meta = ctrl.getMeta();
|
|
17374
|
+
const elements = meta.data || [];
|
|
17375
|
+
|
|
17376
|
+
const boundingBox = getBoundingBox(elements);
|
|
17377
|
+
const zoom = getResizeZoomPercentage(boundingBox, chart.chartArea);
|
|
17378
|
+
|
|
17379
|
+
if (zoom && zoom !== 1) {
|
|
17380
|
+
ctrl.outerRadius = ctrl.outerRadius * zoom;
|
|
17381
|
+
ctrl.innerRadius *= zoom;
|
|
17382
|
+
|
|
17383
|
+
ctrl.updateElements(meta.data, 0, meta.data.length, 'none');
|
|
17384
|
+
return true;
|
|
17385
|
+
}
|
|
17386
|
+
|
|
17387
|
+
return false;
|
|
17388
|
+
}
|
|
17389
|
+
|
|
17390
|
+
var plugin = {
|
|
17391
|
+
id: 'outlabels',
|
|
17392
|
+
resize: function (chart) {
|
|
17393
|
+
getState(chart).sizeChanged = true;
|
|
17394
|
+
},
|
|
17395
|
+
afterUpdate: (chart) => {
|
|
17396
|
+
const ctrl = chart._metasets[0].controller;
|
|
17397
|
+
const meta = ctrl.getMeta();
|
|
17398
|
+
const elements = meta.data || [];
|
|
17399
|
+
|
|
17400
|
+
let fit = false;
|
|
17401
|
+
// Limit the number of steps to prevent infinite loops
|
|
17402
|
+
// It seems that using the number of elements will ensure that the chart
|
|
17403
|
+
// fits by positioning all labels in successive resizes
|
|
17404
|
+
let maxSteps = elements.length;
|
|
17405
|
+
|
|
17406
|
+
// Avoid to draw labels while fitting the chart area
|
|
17407
|
+
getState(chart).fitting = true;
|
|
17408
|
+
|
|
17409
|
+
while (!fit && maxSteps-- > 0) {
|
|
17410
|
+
updateLabels(elements);
|
|
17411
|
+
fit = !fitChartArea(chart);
|
|
17412
|
+
}
|
|
17413
|
+
|
|
17414
|
+
getState(chart).fitting = false;
|
|
17415
|
+
},
|
|
17416
|
+
afterDatasetUpdate: function (chart, args, options) {
|
|
17417
|
+
var labels = chart.config.data.labels;
|
|
17418
|
+
var dataset = chart.data.datasets[args.index];
|
|
17419
|
+
var config = configure$1(dataset, options);
|
|
17420
|
+
var display = config && config.display;
|
|
17421
|
+
var elements = args.meta.data || [];
|
|
17422
|
+
var ctx = chart.ctx;
|
|
17423
|
+
var el, label, percent, newLabel, context, i;
|
|
17424
|
+
ctx.save();
|
|
17425
|
+
|
|
17426
|
+
for (i = 0; i < elements.length; ++i) {
|
|
17427
|
+
el = elements[i];
|
|
17428
|
+
label = el[PLUGIN_KEY];
|
|
17429
|
+
percent = dataset.data[i] / args.meta.total;
|
|
17430
|
+
newLabel = null;
|
|
17431
|
+
|
|
17432
|
+
if (display && el && !el.hidden) {
|
|
17433
|
+
try {
|
|
17434
|
+
context = {
|
|
17435
|
+
chart: chart,
|
|
17436
|
+
dataIndex: i,
|
|
17437
|
+
dataset: dataset,
|
|
17438
|
+
labels: labels,
|
|
17439
|
+
datasetIndex: args.index,
|
|
17440
|
+
percent: percent,
|
|
17441
|
+
};
|
|
17442
|
+
newLabel = new classes.OutLabel(chart, i, ctx, config, context);
|
|
17443
|
+
} catch (e) {
|
|
17444
|
+
newLabel = null;
|
|
17445
|
+
}
|
|
17446
|
+
}
|
|
17447
|
+
|
|
17448
|
+
if (
|
|
17449
|
+
label &&
|
|
17450
|
+
newLabel &&
|
|
17451
|
+
!getState(chart).sizeChanged &&
|
|
17452
|
+
label.label === newLabel.label &&
|
|
17453
|
+
label.encodedText === newLabel.encodedText
|
|
17454
|
+
) {
|
|
17455
|
+
newLabel.offset = label.offset;
|
|
17456
|
+
}
|
|
17457
|
+
el[PLUGIN_KEY] = newLabel;
|
|
17458
|
+
}
|
|
17459
|
+
|
|
17460
|
+
ctx.restore();
|
|
17461
|
+
getState(chart).sizeChanged = false;
|
|
17462
|
+
},
|
|
17463
|
+
afterDatasetDraw: function (chart, args) {
|
|
17464
|
+
var elements = args.meta.data || [];
|
|
17465
|
+
var ctx = chart.ctx;
|
|
17466
|
+
|
|
17467
|
+
if (getState(chart).fitting) {
|
|
17468
|
+
return;
|
|
17469
|
+
}
|
|
17470
|
+
|
|
17471
|
+
elements.forEach((el, index) => {
|
|
17472
|
+
const outlabelPlugin = el[PLUGIN_KEY];
|
|
17473
|
+
if (!outlabelPlugin) {
|
|
17474
|
+
return;
|
|
17475
|
+
}
|
|
17476
|
+
outlabelPlugin.update(el, elements, index);
|
|
17477
|
+
outlabelPlugin.draw(ctx);
|
|
17478
|
+
});
|
|
17479
|
+
},
|
|
17480
|
+
afterDestroy: function (chart) {
|
|
17481
|
+
removeState(chart);
|
|
17482
|
+
},
|
|
17483
|
+
};
|
|
17484
|
+
|
|
15351
17485
|
Chart$1.register(ArcElement, plugin_tooltip, plugin_legend);
|
|
15352
17486
|
const PieChart = (props) => {
|
|
15353
17487
|
const { data, title, options, units, content } = props;
|
|
@@ -15425,7 +17559,7 @@ const PieChart = (props) => {
|
|
|
15425
17559
|
},
|
|
15426
17560
|
},
|
|
15427
17561
|
};
|
|
15428
|
-
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [
|
|
17562
|
+
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin] });
|
|
15429
17563
|
};
|
|
15430
17564
|
|
|
15431
17565
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
@@ -15502,13 +17636,14 @@ function LineChart({ title, data, options, className, units, content }) {
|
|
|
15502
17636
|
},
|
|
15503
17637
|
},
|
|
15504
17638
|
};
|
|
15505
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [
|
|
17639
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin$1] }));
|
|
15506
17640
|
}
|
|
15507
17641
|
|
|
15508
17642
|
function DataGrid({ title, data, className }) {
|
|
15509
17643
|
var _a;
|
|
15510
|
-
const { columns, rows, grouped = false, grouping } = data;
|
|
17644
|
+
const { columns, rows, units, grouped = false, grouping } = data;
|
|
15511
17645
|
const [expandedGroups, setExpandedGroups] = 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)) || []));
|
|
17646
|
+
console.log('units==>', units);
|
|
15512
17647
|
const toggleGroup = (groupValue) => {
|
|
15513
17648
|
const newExpanded = new Set(expandedGroups);
|
|
15514
17649
|
if (newExpanded.has(groupValue)) {
|
|
@@ -15519,6 +17654,30 @@ function DataGrid({ title, data, className }) {
|
|
|
15519
17654
|
}
|
|
15520
17655
|
setExpandedGroups(newExpanded);
|
|
15521
17656
|
};
|
|
17657
|
+
const formatValueWithUnit = (value, columnIndex) => {
|
|
17658
|
+
if (value === null || value === undefined)
|
|
17659
|
+
return "—";
|
|
17660
|
+
const unit = units === null || units === void 0 ? void 0 : units[columnIndex];
|
|
17661
|
+
// Format the value with commas if it's a number or numeric string
|
|
17662
|
+
let valueStr;
|
|
17663
|
+
if (typeof value === 'number') {
|
|
17664
|
+
valueStr = value.toLocaleString();
|
|
17665
|
+
}
|
|
17666
|
+
else {
|
|
17667
|
+
const numValue = parseFloat(String(value));
|
|
17668
|
+
valueStr = !isNaN(numValue) ? numValue.toLocaleString() : String(value);
|
|
17669
|
+
}
|
|
17670
|
+
// If no unit or unit length > 3, return value only
|
|
17671
|
+
if (!unit || unit.length > 3) {
|
|
17672
|
+
return valueStr;
|
|
17673
|
+
}
|
|
17674
|
+
// If unit is $, display unit before value
|
|
17675
|
+
if (unit === '$') {
|
|
17676
|
+
return `${unit}${valueStr}`;
|
|
17677
|
+
}
|
|
17678
|
+
// Otherwise display value then unit
|
|
17679
|
+
return `${valueStr}${unit}`;
|
|
17680
|
+
};
|
|
15522
17681
|
// Backward compatibility: if no data or not grouped, show original table
|
|
15523
17682
|
if (!columns || columns.length === 0 || (!grouped && (!rows || rows.length === 0))) {
|
|
15524
17683
|
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" }) }));
|
|
@@ -15530,7 +17689,7 @@ function DataGrid({ title, data, className }) {
|
|
|
15530
17689
|
const renderGroupedTable = () => {
|
|
15531
17690
|
if (!(grouping === null || grouping === void 0 ? void 0 : grouping.sections))
|
|
15532
17691
|
return null;
|
|
15533
|
-
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.
|
|
17692
|
+
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) => {
|
|
15534
17693
|
const isExpanded = expandedGroups.has(section.group_value);
|
|
15535
17694
|
return (jsxRuntimeExports.jsxs(React__default.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(ChevronDown, { className: "w-4 h-4 text-blue-600" })) : (jsxRuntimeExports.jsx(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: (() => {
|
|
15536
17695
|
var _a;
|
|
@@ -15542,7 +17701,7 @@ function DataGrid({ title, data, className }) {
|
|
|
15542
17701
|
if (sectionStats[column] &&
|
|
15543
17702
|
typeof sectionStats[column].total === 'number' &&
|
|
15544
17703
|
!isNaN(sectionStats[column].total)) {
|
|
15545
|
-
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[column].total
|
|
17704
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: formatValueWithUnit(sectionStats[column].total, columnIndex) }));
|
|
15546
17705
|
}
|
|
15547
17706
|
// If exact match fails, try to find by partial match
|
|
15548
17707
|
const matchingKey = Object.keys(sectionStats).find(key => key.toLowerCase().includes(column.toLowerCase()) ||
|
|
@@ -15550,17 +17709,17 @@ function DataGrid({ title, data, className }) {
|
|
|
15550
17709
|
if (matchingKey && sectionStats[matchingKey] &&
|
|
15551
17710
|
typeof sectionStats[matchingKey].total === 'number' &&
|
|
15552
17711
|
!isNaN(sectionStats[matchingKey].total)) {
|
|
15553
|
-
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[matchingKey].total
|
|
17712
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: formatValueWithUnit(sectionStats[matchingKey].total, columnIndex) }));
|
|
15554
17713
|
}
|
|
15555
17714
|
return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
|
|
15556
17715
|
})() })) }, columnIndex)))] }), (!section.collapsible || isExpanded) && section.rows.map((row, rowIndex) => (jsxRuntimeExports.jsxs("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
15557
17716
|
? "bg-white"
|
|
15558
|
-
: "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
|
|
17717
|
+
: "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}`));
|
|
15559
17718
|
}) })] }));
|
|
15560
17719
|
};
|
|
15561
|
-
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.
|
|
17720
|
+
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
|
|
15562
17721
|
? "bg-white"
|
|
15563
|
-
: "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
|
|
17722
|
+
: "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))) })] }));
|
|
15564
17723
|
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: {
|
|
15565
17724
|
color: "#0F172A"
|
|
15566
17725
|
}, 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: (() => {
|
|
@@ -15572,7 +17731,10 @@ function DataGrid({ title, data, className }) {
|
|
|
15572
17731
|
}
|
|
15573
17732
|
});
|
|
15574
17733
|
});
|
|
15575
|
-
return Object.entries(totals).map(([column, total], index) =>
|
|
17734
|
+
return Object.entries(totals).map(([column, total], index) => {
|
|
17735
|
+
const columnIndex = columns.findIndex(col => col === column);
|
|
17736
|
+
return (jsxRuntimeExports.jsxs("span", { className: "font-medium", children: ["Total ", column, ": ", formatValueWithUnit(total, columnIndex)] }, index));
|
|
17737
|
+
});
|
|
15576
17738
|
})() })] })) : (jsxRuntimeExports.jsxs("span", { children: ["Showing ", rows.length, " row", rows.length !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] })) })] }));
|
|
15577
17739
|
}
|
|
15578
17740
|
|
|
@@ -36685,11 +38847,12 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36685
38847
|
return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36686
38848
|
}
|
|
36687
38849
|
function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36688
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
38850
|
+
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;
|
|
36689
38851
|
const hasCalledRef = useRef(false);
|
|
36690
38852
|
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) || [];
|
|
36691
38853
|
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) || [];
|
|
36692
38854
|
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) || "";
|
|
38855
|
+
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) || [];
|
|
36693
38856
|
const isEmpty = columns.length === 0 || rows.length === 0;
|
|
36694
38857
|
const handleRefresh = async () => {
|
|
36695
38858
|
if (query) {
|
|
@@ -36723,9 +38886,10 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36723
38886
|
}
|
|
36724
38887
|
const transformedData = {
|
|
36725
38888
|
columns: columns,
|
|
38889
|
+
units: units,
|
|
36726
38890
|
rows: rows,
|
|
36727
|
-
grouped: ((
|
|
36728
|
-
grouping: ((
|
|
38891
|
+
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,
|
|
38892
|
+
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)
|
|
36729
38893
|
};
|
|
36730
38894
|
return (jsxRuntimeExports.jsx(DataGrid, { title: gridTitle, data: transformedData, className: "" }));
|
|
36731
38895
|
}
|
|
@@ -36875,7 +39039,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36875
39039
|
useEffect(() => {
|
|
36876
39040
|
const handleTriggerAgent = (event) => {
|
|
36877
39041
|
const { widgetId, query, agentType: eventAgentType, datasetId } = event.detail;
|
|
36878
|
-
console.log('event.detail==>', event.detail);
|
|
36879
39042
|
if (widgetId === widget.id) {
|
|
36880
39043
|
let messageContent = query;
|
|
36881
39044
|
// Customize message based on agent type
|
|
@@ -40755,7 +42918,7 @@ function SavedPages({ onEditPage, widgetBackendUrl }) {
|
|
|
40755
42918
|
if (isLoading) {
|
|
40756
42919
|
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" }) }));
|
|
40757
42920
|
}
|
|
40758
|
-
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(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(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(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(Edit2, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => handleDeletePage(page.id), children: jsxRuntimeExports.jsx(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: () => {
|
|
42921
|
+
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(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(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(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(Edit2, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => handleDeletePage(page.id), children: jsxRuntimeExports.jsx(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: () => {
|
|
40759
42922
|
setIsCreateModalOpen(false);
|
|
40760
42923
|
setNewPageTitle("");
|
|
40761
42924
|
setNewPageIsPublic(false);
|