@headless-adminapp/fluent 0.0.17-alpha.7 → 1.0.0
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/App/App.d.ts +0 -1
- package/App/App.js +2 -4
- package/App/AppHeaderContianer.d.ts +5 -1
- package/App/AppHeaderContianer.js +43 -26
- package/App/AppLogo.js +15 -4
- package/App/AppUI.js +9 -1
- package/App/LayoutProvider.d.ts +7 -0
- package/App/LayoutProvider.js +17 -0
- package/App/NavigationContainer.d.ts +10 -1
- package/App/NavigationContainer.js +22 -22
- package/App/QuickActionItem.js +2 -2
- package/App/utils.js +3 -4
- package/CommandBar/Button.d.ts +2 -1
- package/CommandBar/Button.js +2 -2
- package/CommandBar/Divider.d.ts +2 -1
- package/CommandBar/Divider.js +2 -2
- package/CommandBar/IconButton.d.ts +2 -1
- package/CommandBar/IconButton.js +2 -2
- package/CommandBar/Label.d.ts +2 -1
- package/CommandBar/Label.js +2 -2
- package/CommandBar/MenuButton.d.ts +2 -1
- package/CommandBar/MenuButton.js +3 -3
- package/CommandBar/MenuItem.js +5 -4
- package/CommandBar/MenuItems.js +4 -4
- package/CommandBar/MenuList.js +5 -4
- package/CommandBar/Wrapper.d.ts +2 -2
- package/CommandBar/Wrapper.js +2 -2
- package/CommandBar/index.d.ts +6 -6
- package/DataGrid/ActionCell.d.ts +1 -1
- package/DataGrid/ActionCell.js +8 -4
- package/DataGrid/CustomizeColumns/AddColumns.js +35 -37
- package/DataGrid/CustomizeColumns/ColumnItem.js +8 -6
- package/DataGrid/CustomizeColumns/CustomizeColumns.d.ts +2 -2
- package/DataGrid/CustomizeColumns/CustomizeColumns.js +3 -6
- package/DataGrid/FormSubgridViewSelector.js +1 -5
- package/DataGrid/GridColumnHeader/ConditionValueControl.js +19 -25
- package/DataGrid/GridColumnHeader/FilterForm.js +9 -10
- package/DataGrid/GridColumnHeader/OperatorSelect.js +10 -3
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +22 -13
- package/DataGrid/GridColumnHeader/utils.js +10 -7
- package/DataGrid/GridHeaderDesktop.js +4 -5
- package/DataGrid/GridHeaderMobile.d.ts +5 -0
- package/DataGrid/GridHeaderMobile.js +29 -0
- package/DataGrid/GridListContainer.d.ts +12 -0
- package/DataGrid/GridListContainer.js +93 -0
- package/DataGrid/GridPaginationContainer.js +1 -2
- package/DataGrid/GridTableContainer.js +113 -77
- package/DataGrid/TableCell/TableCellBase.d.ts +2 -2
- package/DataGrid/TableCell/TableCellBase.js +6 -1
- package/DataGrid/TableCell/TableCellCheckbox.js +6 -5
- package/DataGrid/TableCell/TableCellChoice.d.ts +15 -0
- package/DataGrid/TableCell/TableCellChoice.js +30 -0
- package/DataGrid/TableCell/TableCellLink.d.ts +2 -1
- package/DataGrid/TableCell/TableCellLink.js +13 -5
- package/DataGrid/TableCell/TableCellText.js +9 -4
- package/DataGrid/types.d.ts +5 -0
- package/DataGrid/types.js +2 -0
- package/DataGrid/useTableColumns.d.ts +2 -3
- package/DataGrid/useTableColumns.js +297 -155
- package/DialogContainer/AlertDialog.js +3 -6
- package/DialogContainer/ConfirmDialog.js +5 -9
- package/DialogContainer/DialogContainer.js +2 -13
- package/DialogContainer/ErrorDialog.js +3 -6
- package/DialogContainer/PromptDialog.d.ts +13 -2
- package/DialogContainer/PromptDialog.js +44 -39
- package/Insights/CommandBarContainer.d.ts +1 -0
- package/Insights/CommandBarContainer.js +18 -0
- package/Insights/FilterBarContainer.d.ts +1 -0
- package/Insights/FilterBarContainer.js +99 -0
- package/Insights/Grid.d.ts +6 -0
- package/Insights/Grid.js +26 -0
- package/Insights/InsightsContainer.d.ts +1 -0
- package/Insights/InsightsContainer.js +35 -0
- package/Insights/WidgetChartContainer.d.ts +7 -0
- package/Insights/WidgetChartContainer.js +56 -0
- package/Insights/WidgetDataGridContainer.d.ts +4 -0
- package/Insights/WidgetDataGridContainer.js +80 -0
- package/Insights/WidgetTableContainer.d.ts +7 -0
- package/Insights/WidgetTableContainer.js +57 -0
- package/Insights/WidgetTileContainer.d.ts +7 -0
- package/Insights/WidgetTileContainer.js +24 -0
- package/Insights/WidgetTitleBar.d.ts +7 -0
- package/Insights/WidgetTitleBar.js +21 -0
- package/Insights/Widgets.d.ts +4 -0
- package/Insights/Widgets.js +57 -0
- package/Insights/charts/AreaChart.d.ts +5 -0
- package/Insights/charts/AreaChart.js +20 -0
- package/Insights/charts/BarChart.d.ts +5 -0
- package/Insights/charts/BarChart.js +20 -0
- package/Insights/charts/ComposedChart.d.ts +5 -0
- package/Insights/charts/ComposedChart.js +19 -0
- package/Insights/charts/CustomTooltipContent.d.ts +7 -0
- package/Insights/charts/CustomTooltipContent.js +25 -0
- package/Insights/charts/GaugeChart.d.ts +5 -0
- package/Insights/charts/GaugeChart.js +8 -0
- package/Insights/charts/LineChart.d.ts +5 -0
- package/Insights/charts/LineChart.js +21 -0
- package/Insights/charts/OhlcChart.d.ts +6 -0
- package/Insights/charts/OhlcChart.js +119 -0
- package/Insights/charts/PieChart.d.ts +5 -0
- package/Insights/charts/PieChart.js +54 -0
- package/Insights/charts/RadarChart.d.ts +5 -0
- package/Insights/charts/RadarChart.js +38 -0
- package/Insights/charts/ScatterChart.d.ts +5 -0
- package/Insights/charts/ScatterChart.js +81 -0
- package/Insights/charts/constants.d.ts +1 -0
- package/Insights/charts/constants.js +25 -0
- package/Insights/charts/formatters.d.ts +14 -0
- package/Insights/charts/formatters.js +186 -0
- package/Insights/charts/index.d.ts +4 -0
- package/Insights/charts/index.js +13 -0
- package/Insights/charts/renderers.d.ts +10 -0
- package/Insights/charts/renderers.js +64 -0
- package/Insights/hooks/useQueriesData.d.ts +7 -0
- package/Insights/hooks/useQueriesData.js +90 -0
- package/Insights/hooks/useWidgetDetail.d.ts +10 -0
- package/Insights/hooks/useWidgetDetail.js +39 -0
- package/OverflowCommandBar/OverflowCommandBar.js +1 -4
- package/OverflowCommandBar/OverflowMenu.js +5 -17
- package/OverflowCommandBar/render.js +3 -4
- package/OverflowCommandBar/utils.js +2 -3
- package/PageBoard/BoardColumn.d.ts +5 -0
- package/PageBoard/BoardColumn.js +9 -0
- package/PageBoard/BoardColumnCard.d.ts +12 -0
- package/PageBoard/BoardColumnCard.js +29 -0
- package/PageBoard/BoardColumnUI.d.ts +2 -0
- package/PageBoard/BoardColumnUI.js +76 -0
- package/PageBoard/BoardingColumnCardLoading.d.ts +1 -0
- package/PageBoard/BoardingColumnCardLoading.js +21 -0
- package/PageBoard/Header.d.ts +7 -0
- package/PageBoard/Header.js +31 -0
- package/PageBoard/PageBoard.d.ts +7 -0
- package/PageBoard/PageBoard.js +46 -0
- package/PageBoard/index.d.ts +1 -0
- package/PageBoard/index.js +5 -0
- package/PageCalendar/CalendarSection.d.ts +20 -0
- package/PageCalendar/CalendarSection.js +108 -0
- package/PageCalendar/EventDialog/AttributeController.d.ts +10 -0
- package/PageCalendar/EventDialog/AttributeController.js +17 -0
- package/PageCalendar/EventDialog/EventDialog.d.ts +25 -0
- package/PageCalendar/EventDialog/EventDialog.js +21 -0
- package/PageCalendar/EventDialog/EventFormBody.d.ts +18 -0
- package/PageCalendar/EventDialog/EventFormBody.js +69 -0
- package/PageCalendar/EventDialog/EventFormContent.d.ts +10 -0
- package/PageCalendar/EventDialog/EventFormContent.js +27 -0
- package/PageCalendar/EventDialog/types.d.ts +3 -0
- package/PageCalendar/EventDialog/types.js +2 -0
- package/PageCalendar/EventDialog/utils.d.ts +23 -0
- package/PageCalendar/EventDialog/utils.js +57 -0
- package/PageCalendar/Header.d.ts +8 -0
- package/PageCalendar/Header.js +35 -0
- package/PageCalendar/PageCalendar.d.ts +7 -0
- package/PageCalendar/PageCalendar.js +231 -0
- package/PageCalendar/TitleSelector.d.ts +10 -0
- package/PageCalendar/TitleSelector.js +73 -0
- package/PageCalendar/ViewSelector.d.ts +8 -0
- package/PageCalendar/ViewSelector.js +52 -0
- package/PageCalendar/baseEventAttributes.d.ts +35 -0
- package/PageCalendar/baseEventAttributes.js +38 -0
- package/PageCalendar/context.d.ts +20 -0
- package/PageCalendar/context.js +5 -0
- package/PageCalendar/hooks/index.d.ts +1 -0
- package/PageCalendar/hooks/index.js +17 -0
- package/PageCalendar/hooks/useConfig.d.ts +3 -0
- package/PageCalendar/hooks/useConfig.js +8 -0
- package/PageCalendar/index.d.ts +1 -0
- package/PageCalendar/index.js +5 -0
- package/PageCalendar/renderEventContent.d.ts +2 -0
- package/PageCalendar/renderEventContent.js +22 -0
- package/PageCalendar/types.d.ts +5 -0
- package/PageCalendar/types.js +9 -0
- package/PageCalendar/utils.d.ts +3 -0
- package/PageCalendar/utils.js +17 -0
- package/PageEntityForm/CommandContainer.js +9 -5
- package/PageEntityForm/PageCustomEntityForm.d.ts +15 -0
- package/PageEntityForm/PageCustomEntityForm.js +17 -0
- package/PageEntityForm/PageEntityFormDesktopContainer.js +42 -22
- package/PageEntityForm/ProcessFlow.d.ts +10 -0
- package/PageEntityForm/ProcessFlow.js +84 -0
- package/PageEntityForm/RecordAvatar.d.ts +2 -0
- package/PageEntityForm/RecordAvatar.js +83 -0
- package/PageEntityForm/RecordCard.d.ts +1 -1
- package/PageEntityForm/RecordCard.js +60 -53
- package/PageEntityForm/RecordCardLoading.d.ts +8 -0
- package/PageEntityForm/RecordCardLoading.js +24 -0
- package/PageEntityForm/RecordSetNavigatorContainer.js +1 -2
- package/PageEntityForm/RelatedViewSelector.d.ts +0 -2
- package/PageEntityForm/RelatedViewSelector.js +37 -11
- package/PageEntityForm/SectionContainer.d.ts +2 -2
- package/PageEntityForm/SectionContainer.js +77 -13
- package/PageEntityForm/StandardControl.d.ts +1 -22
- package/PageEntityForm/StandardControl.js +103 -117
- package/PageEntityForm/SubgridControl.d.ts +1 -0
- package/PageEntityForm/SubgridControl.js +4 -2
- package/PageEntityForm/UploadImageDialog.d.ts +12 -0
- package/PageEntityForm/UploadImageDialog.js +114 -0
- package/PageEntityView/FormSubgridContainer.js +5 -2
- package/PageEntityView/FormSubgridNotAvailableContainer.d.ts +2 -0
- package/PageEntityView/FormSubgridNotAvailableContainer.js +48 -0
- package/PageEntityView/PageEntityView.js +4 -1
- package/PageEntityView/PageEntityViewDesktopFrame.js +1 -0
- package/PageEntityView/PageEntityViewMobileContainer.d.ts +2 -0
- package/PageEntityView/PageEntityViewMobileContainer.js +14 -0
- package/PageEntityView/PageEntityViewStringContext.d.ts +2 -0
- package/PageEntityView/PageEntityViewStringContext.js +2 -0
- package/PageInsights/PageInsights.d.ts +9 -0
- package/PageInsights/PageInsights.js +25 -0
- package/PageInsights/index.d.ts +1 -0
- package/PageInsights/index.js +6 -0
- package/ToastNotificationContainer/index.js +1 -2
- package/componentStore.d.ts +2 -0
- package/componentStore.js +5 -0
- package/components/BodyLoading.d.ts +1 -1
- package/components/BodyLoading.js +13 -8
- package/components/DndProvider.d.ts +12 -0
- package/components/DndProvider.js +68 -0
- package/components/LoginForm.js +5 -21
- package/form/FormControl.js +19 -41
- package/form/controls/AttachmentControl.d.ts +27 -0
- package/form/controls/AttachmentControl.js +220 -0
- package/form/controls/AttachmentsControl.d.ts +6 -0
- package/form/controls/AttachmentsControl.js +35 -0
- package/form/controls/CurrencyControl.js +38 -6
- package/form/controls/DateControl.d.ts +1 -1
- package/form/controls/DateControl.js +15 -3
- package/form/controls/DateRangeControl.js +4 -6
- package/form/controls/DateTimeControl.d.ts +1 -1
- package/form/controls/DateTimeControl.js +107 -12
- package/form/controls/DecimalControl.d.ts +5 -0
- package/form/controls/DecimalControl.js +52 -0
- package/form/controls/DurationControl.d.ts +4 -0
- package/form/controls/DurationControl.js +209 -0
- package/form/controls/EmailControl.d.ts +1 -1
- package/form/controls/EmailControl.js +5 -5
- package/form/controls/IntegerControl.d.ts +4 -0
- package/form/controls/IntegerControl.js +25 -0
- package/form/controls/LookupControl.d.ts +1 -0
- package/form/controls/LookupControl.js +57 -13
- package/form/controls/MultiSelectControl.js +3 -3
- package/form/controls/MultiSelectLookupControl.js +16 -17
- package/form/controls/PasswordControl.js +1 -1
- package/form/controls/RichTextControl.d.ts +5 -0
- package/form/controls/RichTextControl.js +33 -0
- package/form/controls/SelectControl.js +4 -5
- package/form/controls/SwitchControl.d.ts +1 -1
- package/form/controls/SwitchControl.js +4 -2
- package/form/controls/TelephoneControl.d.ts +1 -1
- package/form/controls/TelephoneControl.js +26 -4
- package/form/controls/TextAreaControl.d.ts +1 -1
- package/form/controls/TextAreaControl.js +6 -6
- package/form/controls/TextControl.js +4 -4
- package/form/controls/UrlControl.d.ts +4 -0
- package/form/controls/UrlControl.js +16 -0
- package/form/controls/useLookupData.js +26 -41
- package/form/layout/FormSection/FormSection.js +10 -3
- package/form/layout/FormTab/FormTab.js +4 -4
- package/form/types.d.ts +2 -2
- package/package.json +17 -12
- package/styles.css +149 -0
- package/types/index.d.ts +18 -0
- package/utils/avatar.d.ts +2 -0
- package/utils/avatar.js +45 -0
- package/App/AppProvider.d.ts +0 -9
- package/App/AppProvider.js +0 -50
- package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +0 -9
- package/DataGrid/ScrollbarWithMoreDataRequest.js +0 -33
- package/DataGrid/getAttributeFormattedValue.d.ts +0 -16
- package/DataGrid/getAttributeFormattedValue.js +0 -92
- package/form/controls/NumberControl.d.ts +0 -4
- package/form/controls/NumberControl.js +0 -16
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Widgets = Widgets;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const hooks_1 = require("@headless-adminapp/app/hooks");
|
|
6
|
+
const insights_1 = require("@headless-adminapp/app/insights");
|
|
7
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
8
|
+
const widget_1 = require("@headless-adminapp/app/widget");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const Grid_1 = require("./Grid");
|
|
11
|
+
const WidgetChartContainer_1 = require("./WidgetChartContainer");
|
|
12
|
+
const WidgetDataGridContainer_1 = require("./WidgetDataGridContainer");
|
|
13
|
+
const WidgetTableContainer_1 = require("./WidgetTableContainer");
|
|
14
|
+
const WidgetTileContainer_1 = require("./WidgetTileContainer");
|
|
15
|
+
const WidgetProvider = ({ children, widget, }) => {
|
|
16
|
+
const contextValue = (0, mutable_1.useCreateContextStore)({
|
|
17
|
+
widget,
|
|
18
|
+
data: widget.defaultData,
|
|
19
|
+
});
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
contextValue.setValue({
|
|
22
|
+
widget,
|
|
23
|
+
data: widget.defaultData,
|
|
24
|
+
});
|
|
25
|
+
}, [contextValue, widget]);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(widget_1.WidgetContext.Provider, { value: contextValue, children: children }));
|
|
27
|
+
};
|
|
28
|
+
function Widgets({ widgets, }) {
|
|
29
|
+
const isMobile = (0, hooks_1.useIsMobile)();
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGrid, { children: widgets.map((widget, index) => {
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGridItem, { row: widget.rows, column: isMobile ? 12 : widget.columns, children: (0, jsx_runtime_1.jsx)(WidgetProvider, { widget: widget, children: (0, jsx_runtime_1.jsx)(WidgetItem, {}) }) }, widget.title + String(index)));
|
|
32
|
+
}) }));
|
|
33
|
+
}
|
|
34
|
+
function WidgetItem() {
|
|
35
|
+
const insightState = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (state) => state);
|
|
36
|
+
const widgetState = (0, mutable_1.useContextSelector)(widget_1.WidgetContext, (state) => state);
|
|
37
|
+
const widget = widgetState.widget;
|
|
38
|
+
const content = typeof widget.content === 'function'
|
|
39
|
+
? widget.content(insightState, widgetState)
|
|
40
|
+
: widget.content;
|
|
41
|
+
if (content.type === 'tile') {
|
|
42
|
+
return (0, jsx_runtime_1.jsx)(WidgetTileContainer_1.WidgetTileContainer, { content: content });
|
|
43
|
+
}
|
|
44
|
+
if (content.type === 'chart') {
|
|
45
|
+
return (0, jsx_runtime_1.jsx)(WidgetChartContainer_1.WidgetChartContainer, { content: content });
|
|
46
|
+
}
|
|
47
|
+
if (content.type === 'grid') {
|
|
48
|
+
return (0, jsx_runtime_1.jsx)(WidgetDataGridContainer_1.WidgetDataGridContainer, { content: content });
|
|
49
|
+
}
|
|
50
|
+
if (content.type === 'table') {
|
|
51
|
+
return (0, jsx_runtime_1.jsx)(WidgetTableContainer_1.WidgetTableContainer, { content: content });
|
|
52
|
+
}
|
|
53
|
+
if (content.type === 'custom') {
|
|
54
|
+
return (0, jsx_runtime_1.jsx)(content.Component, {});
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AreaChart = AreaChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const recharts_1 = require("recharts");
|
|
7
|
+
const CustomTooltipContent_1 = require("./CustomTooltipContent");
|
|
8
|
+
const formatters_1 = require("./formatters");
|
|
9
|
+
const renderers_1 = require("./renderers");
|
|
10
|
+
function AreaChart({ dataset, chartInfo, }) {
|
|
11
|
+
const xAxis = chartInfo.xAxis;
|
|
12
|
+
const yAxis = chartInfo.yAxis;
|
|
13
|
+
const areas = chartInfo.areas;
|
|
14
|
+
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
15
|
+
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.AreaChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderAreas)(areas, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
17
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
18
|
+
opacity: 0.5,
|
|
19
|
+
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BarChart = BarChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const recharts_1 = require("recharts");
|
|
7
|
+
const CustomTooltipContent_1 = require("./CustomTooltipContent");
|
|
8
|
+
const formatters_1 = require("./formatters");
|
|
9
|
+
const renderers_1 = require("./renderers");
|
|
10
|
+
function BarChart({ dataset, chartInfo, }) {
|
|
11
|
+
const xAxis = chartInfo.xAxis;
|
|
12
|
+
const yAxis = chartInfo.yAxis;
|
|
13
|
+
const bars = chartInfo.bars;
|
|
14
|
+
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
15
|
+
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { data: dataset[0], stackOffset: chartInfo.stackOffset, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderBars)(bars, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
17
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
18
|
+
opacity: 0.5,
|
|
19
|
+
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComposedChart = ComposedChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const recharts_1 = require("recharts");
|
|
7
|
+
const CustomTooltipContent_1 = require("./CustomTooltipContent");
|
|
8
|
+
const formatters_1 = require("./formatters");
|
|
9
|
+
const renderers_1 = require("./renderers");
|
|
10
|
+
function ComposedChart({ dataset, chartInfo, }) {
|
|
11
|
+
const xAxis = chartInfo.xAxis;
|
|
12
|
+
const yAxis = chartInfo.yAxis;
|
|
13
|
+
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
14
|
+
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ComposedChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis, !!chartInfo.bars?.length), (0, renderers_1.renderLines)(chartInfo.lines ?? [], dataset), (0, renderers_1.renderAreas)(chartInfo.areas ?? [], dataset), (0, renderers_1.renderBars)(chartInfo.bars ?? [], dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
16
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
17
|
+
opacity: 0.5,
|
|
18
|
+
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const CustomTooltipContent: ({ active, payload, label, xAxisFormatter, yAxisFormatter, }: {
|
|
2
|
+
active?: boolean;
|
|
3
|
+
payload?: any[];
|
|
4
|
+
label: string;
|
|
5
|
+
xAxisFormatter: (value: unknown) => string;
|
|
6
|
+
yAxisFormatter: (value: unknown) => string;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomTooltipContent = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const CustomTooltipContent = ({ active, payload, label, xAxisFormatter, yAxisFormatter, }) => {
|
|
7
|
+
if (!active || !payload?.length) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexDirection: 'column',
|
|
13
|
+
boxShadow: react_components_1.tokens.shadow16,
|
|
14
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
15
|
+
padding: 8,
|
|
16
|
+
borderRadius: 4,
|
|
17
|
+
gap: 4,
|
|
18
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: xAxisFormatter(label) }), (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
19
|
+
width: 8,
|
|
20
|
+
height: 8,
|
|
21
|
+
background: item.color,
|
|
22
|
+
borderRadius: 4,
|
|
23
|
+
} }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4, marginLeft: 8 }, children: item.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: yAxisFormatter(item.value) })] }, item.name + String(index)))) })] }));
|
|
24
|
+
};
|
|
25
|
+
exports.CustomTooltipContent = CustomTooltipContent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GaugeChart = GaugeChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
|
+
function GaugeChart(_props) {
|
|
7
|
+
return (0, jsx_runtime_1.jsx)("div", { children: "Not supported yet" });
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LineChart = LineChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const recharts_1 = require("recharts");
|
|
7
|
+
const CustomTooltipContent_1 = require("./CustomTooltipContent");
|
|
8
|
+
const formatters_1 = require("./formatters");
|
|
9
|
+
const renderers_1 = require("./renderers");
|
|
10
|
+
function LineChart({ dataset, chartInfo, }) {
|
|
11
|
+
const xAxis = chartInfo.xAxis;
|
|
12
|
+
const yAxis = chartInfo.yAxis;
|
|
13
|
+
const lines = chartInfo.lines;
|
|
14
|
+
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
15
|
+
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
16
|
+
console.log('dataset', dataset, chartInfo);
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderLines)(lines, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
18
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
19
|
+
opacity: 0.5,
|
|
20
|
+
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DateAxisTickInterval, OhlcChartInfo } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
export declare const barSizeInTime: (interval: DateAxisTickInterval) => number;
|
|
3
|
+
export declare function OhlcChart({ dataset, chartInfo, }: Readonly<{
|
|
4
|
+
dataset: any[];
|
|
5
|
+
chartInfo: OhlcChartInfo;
|
|
6
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.barSizeInTime = void 0;
|
|
4
|
+
exports.OhlcChart = OhlcChart;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
7
|
+
const insights_1 = require("@headless-adminapp/core/experience/insights");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const recharts_1 = require("recharts");
|
|
10
|
+
const formatters_1 = require("./formatters");
|
|
11
|
+
const renderers_1 = require("./renderers");
|
|
12
|
+
const barSizeInTime = (interval) => {
|
|
13
|
+
switch (interval) {
|
|
14
|
+
case insights_1.DateAxisTickInterval.Minute:
|
|
15
|
+
return 60000 * 0.6;
|
|
16
|
+
case insights_1.DateAxisTickInterval.Hour:
|
|
17
|
+
return 3600000 * 0.6;
|
|
18
|
+
case insights_1.DateAxisTickInterval.Day:
|
|
19
|
+
return 86400000 * 0.6;
|
|
20
|
+
case insights_1.DateAxisTickInterval.Week:
|
|
21
|
+
return 604800000 * 0.6;
|
|
22
|
+
case insights_1.DateAxisTickInterval.Month:
|
|
23
|
+
return 2628000000 * 0.6;
|
|
24
|
+
case insights_1.DateAxisTickInterval.Year:
|
|
25
|
+
return 31540000000 * 0.6;
|
|
26
|
+
default:
|
|
27
|
+
return 60000 * 0.6;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.barSizeInTime = barSizeInTime;
|
|
31
|
+
function OhlcChart({ dataset, chartInfo, }) {
|
|
32
|
+
const bar = chartInfo.bars[0];
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
const data = dataset[bar.dataIndex ?? 0];
|
|
35
|
+
const domain = (0, react_1.useMemo)(() => {
|
|
36
|
+
if (chartInfo.yAxis.domain &&
|
|
37
|
+
typeof chartInfo.yAxis.domain[0] === 'number' &&
|
|
38
|
+
typeof chartInfo.yAxis.domain[1] === 'number') {
|
|
39
|
+
return chartInfo.yAxis.domain;
|
|
40
|
+
}
|
|
41
|
+
const dataMin = Math.min(...data.map((entry) => entry[bar.low.dataKey]), ...data.map((entry) => entry[bar.open.dataKey]), ...data.map((entry) => entry[bar.close.dataKey]), ...data.map((entry) => entry[bar.high.dataKey]));
|
|
42
|
+
const dataMax = Math.max(...data.map((entry) => entry[bar.low.dataKey]), ...data.map((entry) => entry[bar.open.dataKey]), ...data.map((entry) => entry[bar.close.dataKey]), ...data.map((entry) => entry[bar.high.dataKey]));
|
|
43
|
+
return [dataMin, dataMax];
|
|
44
|
+
}, [bar, chartInfo.yAxis.domain, data]);
|
|
45
|
+
const xAxis = chartInfo.xAxis;
|
|
46
|
+
const xAxisFormatter = (0, formatters_1.createAxisFormatter)(xAxis.tick);
|
|
47
|
+
const xAxisLongFormatter = (0, formatters_1.createLongAxisFormatter)(chartInfo.xAxis.tick);
|
|
48
|
+
const yAxisLongFormatter = (0, formatters_1.createLongAxisFormatter)(chartInfo.yAxis.tick);
|
|
49
|
+
console.log('temp.data', dataset, chartInfo);
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ScatterChart, { data: data, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)({
|
|
51
|
+
...chartInfo.yAxis,
|
|
52
|
+
domain,
|
|
53
|
+
}), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: xAxis.dataKey, name: xAxis.name, tickFormatter: xAxisFormatter, tickLine: false, minTickGap: 10, padding: "gap", axisLine: {
|
|
54
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
55
|
+
}, fontSize: react_components_1.tokens.fontSizeBase100, tick: {
|
|
56
|
+
fill: react_components_1.tokens.colorNeutralForeground1,
|
|
57
|
+
opacity: 0.5,
|
|
58
|
+
}, scale: xAxis.tick.type === 'time' ? 'time' : 'auto', type: xAxis.tick.type === 'category' ? 'category' : 'number', domain: xAxis.domain, height: 16 }), (0, jsx_runtime_1.jsx)(recharts_1.Scatter, { yAxisId: "left", data: data, markerWidth: 1, width: 1, strokeWidth: 1,
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
shape: (props) => renderShape(props, {
|
|
61
|
+
bar,
|
|
62
|
+
chartInfo,
|
|
63
|
+
}) }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
64
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
65
|
+
opacity: 0.5,
|
|
66
|
+
}, content: ({ active, payload }) => {
|
|
67
|
+
if (!active || !payload?.length) {
|
|
68
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
69
|
+
}
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)(OhclTooltipContent, { payload: payload[0], bar: bar, xAxisFormatter: xAxisLongFormatter, yAxisFormatter: yAxisLongFormatter }));
|
|
71
|
+
} })] }) }));
|
|
72
|
+
}
|
|
73
|
+
function OhclTooltipContent({ payload, bar, xAxisFormatter, yAxisFormatter, }) {
|
|
74
|
+
const items = [];
|
|
75
|
+
items.push({
|
|
76
|
+
name: bar.open.dataLabel,
|
|
77
|
+
value: payload.payload[bar.open.dataKey],
|
|
78
|
+
});
|
|
79
|
+
items.push({
|
|
80
|
+
name: bar.high.dataLabel,
|
|
81
|
+
value: payload.payload[bar.high.dataKey],
|
|
82
|
+
});
|
|
83
|
+
items.push({
|
|
84
|
+
name: bar.low.dataLabel,
|
|
85
|
+
value: payload.payload[bar.low.dataKey],
|
|
86
|
+
});
|
|
87
|
+
items.push({
|
|
88
|
+
name: bar.close.dataLabel,
|
|
89
|
+
value: payload.payload[bar.close.dataKey],
|
|
90
|
+
});
|
|
91
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
92
|
+
display: 'flex',
|
|
93
|
+
flexDirection: 'column',
|
|
94
|
+
boxShadow: react_components_1.tokens.shadow16,
|
|
95
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
96
|
+
padding: 8,
|
|
97
|
+
borderRadius: 4,
|
|
98
|
+
gap: 4,
|
|
99
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: xAxisFormatter(payload.value) }), (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }), items.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: item.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: yAxisFormatter(item.value) })] }, item.name + String(index))))] }) }));
|
|
100
|
+
}
|
|
101
|
+
function renderShape(props, { chartInfo, bar, }) {
|
|
102
|
+
const { x, width, payload, yAxis, xAxis } = props;
|
|
103
|
+
const xValue = payload[xAxis.dataKey];
|
|
104
|
+
const open = payload[bar.open.dataKey];
|
|
105
|
+
const close = payload[bar.close.dataKey];
|
|
106
|
+
const high = payload[bar.high.dataKey];
|
|
107
|
+
const low = payload[bar.low.dataKey];
|
|
108
|
+
const color = open < close
|
|
109
|
+
? bar.colors?.[0] ?? react_components_1.tokens.colorPaletteGreenForeground1
|
|
110
|
+
: bar.colors?.[1] ?? react_components_1.tokens.colorPaletteRedForeground1;
|
|
111
|
+
const xPosition = xAxis.scale(xValue);
|
|
112
|
+
let xWidth = 30;
|
|
113
|
+
if (chartInfo.xAxis.tick.type === 'time' && chartInfo.xAxis.tick.interval) {
|
|
114
|
+
xWidth =
|
|
115
|
+
xAxis.scale(xValue + (0, exports.barSizeInTime)(chartInfo.xAxis.tick.interval)) -
|
|
116
|
+
xPosition;
|
|
117
|
+
}
|
|
118
|
+
return ((0, jsx_runtime_1.jsxs)("g", { children: [(0, jsx_runtime_1.jsx)(recharts_1.Rectangle, { x: x + width / 2, y: yAxis.scale(high), width: 1, height: yAxis.scale(low) - yAxis.scale(high), fill: color, stroke: color, strokeWidth: 1 }), (0, jsx_runtime_1.jsx)(recharts_1.Rectangle, { x: xPosition - xWidth / 2, y: Math.min(yAxis.scale(open), yAxis.scale(close)), width: xWidth, height: Math.abs(yAxis.scale(close) - yAxis.scale(open)), fill: color, stroke: color, strokeWidth: 1 })] }));
|
|
119
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PieChart = PieChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
7
|
+
const recharts_1 = require("recharts");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const formatters_1 = require("./formatters");
|
|
10
|
+
function PieChart({ dataset, chartInfo, }) {
|
|
11
|
+
const RADIAN = Math.PI / 180;
|
|
12
|
+
const renderCustomizedLabel = ({ cx, cy, midAngle, innerRadius, outerRadius, percent, }) => {
|
|
13
|
+
const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
|
|
14
|
+
const x = cx + radius * Math.cos(-midAngle * RADIAN);
|
|
15
|
+
const y = cy + radius * Math.sin(-midAngle * RADIAN);
|
|
16
|
+
if (percent < 0.05) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("text", { x: x, y: y, fill: "white", textAnchor: x > cx ? 'start' : 'end', dominantBaseline: "central", fontSize: react_components_1.tokens.fontSizeBase100, children: `${(percent * 100).toFixed(0)}%` }));
|
|
20
|
+
};
|
|
21
|
+
const item = chartInfo.pie[0];
|
|
22
|
+
const nameFormatter = (0, formatters_1.createLongAxisFormatter)(item.nameTick);
|
|
23
|
+
const valueFormatter = (0, formatters_1.createLongAxisFormatter)(item.dataTick);
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.PieChart, { children: [(0, jsx_runtime_1.jsx)(recharts_1.Pie, { data: dataset[item.dataIndex ?? 0], cx: "50%", cy: "50%", labelLine: false, label: renderCustomizedLabel, outerRadius: 80, dataKey: item.dataKey, nameKey: item.nameKey, children: dataset[item.dataIndex ?? 0].map((entry, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Cell, { fill: item.colorKey && entry[item.colorKey]
|
|
25
|
+
? entry[item.colorKey]
|
|
26
|
+
: (item.colors ?? constants_1.defaultColors)[index % (item.colors ?? constants_1.defaultColors).length] }, 'cell-' + String(index)))) }), chartInfo.showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { align: "right", layout: "vertical", verticalAlign: "top", wrapperStyle: {
|
|
27
|
+
fontSize: react_components_1.tokens.fontSizeBase100,
|
|
28
|
+
fontFamily: react_components_1.tokens.fontFamilyBase,
|
|
29
|
+
overflow: 'auto',
|
|
30
|
+
top: 5,
|
|
31
|
+
bottom: 5,
|
|
32
|
+
} })), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
33
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
34
|
+
opacity: 0.5,
|
|
35
|
+
}, content: ({ payload }) => renderTooltipContent({
|
|
36
|
+
payload,
|
|
37
|
+
nameFormatter,
|
|
38
|
+
valueFormatter,
|
|
39
|
+
}) })] }) }));
|
|
40
|
+
}
|
|
41
|
+
function renderTooltipContent({ payload, nameFormatter, valueFormatter, }) {
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
flexDirection: 'column',
|
|
45
|
+
boxShadow: react_components_1.tokens.shadow16,
|
|
46
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
47
|
+
padding: 8,
|
|
48
|
+
borderRadius: 4,
|
|
49
|
+
gap: 4,
|
|
50
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload?.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: {
|
|
51
|
+
color: react_components_1.tokens.colorNeutralForeground4,
|
|
52
|
+
marginLeft: 8,
|
|
53
|
+
}, children: nameFormatter(item.name) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: valueFormatter(item.value) })] }, index))) }) }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RadarChart = RadarChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
7
|
+
const recharts_1 = require("recharts");
|
|
8
|
+
const formatters_1 = require("./formatters");
|
|
9
|
+
function RadarChart({ dataset, chartInfo, }) {
|
|
10
|
+
const data = dataset[0];
|
|
11
|
+
const radar = chartInfo.radar[0];
|
|
12
|
+
const nameFormatter = (0, formatters_1.createLongAxisFormatter)(radar.nameTick);
|
|
13
|
+
const valueFormatter = (0, formatters_1.createLongAxisFormatter)(radar.dataTick);
|
|
14
|
+
const tickFormatter = (0, formatters_1.createAxisFormatter)(radar.dataTick);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.RadarChart, { cx: "50%", cy: "50%", outerRadius: "80%", data: data, children: [(0, jsx_runtime_1.jsx)(recharts_1.PolarGrid, { stroke: react_components_1.tokens.colorNeutralBackground6, opacity: 0.5 }), (0, jsx_runtime_1.jsx)(recharts_1.PolarAngleAxis, { dataKey: radar.nameKey, fontSize: react_components_1.tokens.fontSizeBase100, tickFormatter: nameFormatter }), (0, jsx_runtime_1.jsx)(recharts_1.PolarRadiusAxis, { fontSize: react_components_1.tokens.fontSizeBase100, tickFormatter: tickFormatter }), (0, jsx_runtime_1.jsx)(recharts_1.Radar, { dataKey: radar.dataKey, stroke: radar.color ?? '#8884d8', fill: radar.color ?? '#8884d8', fillOpacity: 0.6 }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
16
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
17
|
+
opacity: 0.5,
|
|
18
|
+
}, content: ({ payload }) => renderTooltipContent({
|
|
19
|
+
payload,
|
|
20
|
+
nameFormatter,
|
|
21
|
+
valueFormatter,
|
|
22
|
+
radar,
|
|
23
|
+
}) })] }) }));
|
|
24
|
+
}
|
|
25
|
+
function renderTooltipContent({ payload, nameFormatter, valueFormatter, radar, }) {
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
27
|
+
display: 'flex',
|
|
28
|
+
flexDirection: 'column',
|
|
29
|
+
boxShadow: react_components_1.tokens.shadow16,
|
|
30
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
31
|
+
padding: 8,
|
|
32
|
+
borderRadius: 4,
|
|
33
|
+
gap: 4,
|
|
34
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload?.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: {
|
|
35
|
+
color: react_components_1.tokens.colorNeutralForeground4,
|
|
36
|
+
marginLeft: 8,
|
|
37
|
+
}, children: nameFormatter(item.payload[radar.nameKey]) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: valueFormatter(item.value) })] }, index))) }) }));
|
|
38
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScatterChart = ScatterChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const recharts_1 = require("recharts");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const formatters_1 = require("./formatters");
|
|
10
|
+
const renderers_1 = require("./renderers");
|
|
11
|
+
function ScatterChart({ dataset, chartInfo, }) {
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ScatterChart, { children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(chartInfo.xAxis), (0, renderers_1.renderYAxis)(chartInfo.yAxis), (0, jsx_runtime_1.jsx)(recharts_1.ZAxis, { type: "number", dataKey: chartInfo.zAxis.dataKey, range: chartInfo.zAxis.range, name: chartInfo.zAxis.name }), chartInfo.scatters.map((scatter, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Scatter, { yAxisId: "left", name: scatter.dataLabel, data: dataset[scatter.dataIndex ?? 0], dataKey: scatter.dataKey, fill: scatter.color ?? constants_1.defaultColors[index] }, index))), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: false, content: (props) => {
|
|
13
|
+
if (!props.active || !props.payload?.length) {
|
|
14
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
15
|
+
}
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(ScatterTooltipContent, { active: props.active, payload: props.payload, chartInfo: chartInfo, dataset: dataset }));
|
|
17
|
+
} })] }) }));
|
|
18
|
+
}
|
|
19
|
+
const ScatterTooltipContent = (props) => {
|
|
20
|
+
const chartInfo = props.chartInfo;
|
|
21
|
+
const dataset = props.dataset;
|
|
22
|
+
const xAxis = chartInfo.xAxis;
|
|
23
|
+
const yAxis = chartInfo.yAxis;
|
|
24
|
+
const zAxis = chartInfo.zAxis;
|
|
25
|
+
const xPayload = props.payload[0];
|
|
26
|
+
const yPayload = props.payload[1];
|
|
27
|
+
const xValue = xPayload.value;
|
|
28
|
+
const yValue = yPayload.value;
|
|
29
|
+
const findKey = xValue + ':' + yValue;
|
|
30
|
+
const items = (0, react_1.useMemo)(() => {
|
|
31
|
+
const _items = [];
|
|
32
|
+
if (!xAxis.dataKey || !yAxis.dataKey || !zAxis.dataKey) {
|
|
33
|
+
return _items;
|
|
34
|
+
}
|
|
35
|
+
const datasetDict = dataset.map((data) => {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
return data.reduce((acc, entry) => {
|
|
38
|
+
const key = entry[xAxis.dataKey] + ':' + entry[yAxis.dataKey];
|
|
39
|
+
acc[key] = entry;
|
|
40
|
+
return acc;
|
|
41
|
+
}, {});
|
|
42
|
+
});
|
|
43
|
+
for (let i = 0; i < chartInfo.scatters.length; i++) {
|
|
44
|
+
const scatter = chartInfo.scatters[i];
|
|
45
|
+
const zValue = datasetDict[scatter.dataIndex ?? 0]?.[findKey]?.[zAxis.dataKey];
|
|
46
|
+
if (zValue === undefined) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
_items.push({
|
|
50
|
+
name: scatter.dataLabel,
|
|
51
|
+
value: zValue,
|
|
52
|
+
color: scatter.color ?? constants_1.defaultColors[i],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return _items;
|
|
56
|
+
}, [
|
|
57
|
+
chartInfo.scatters,
|
|
58
|
+
dataset,
|
|
59
|
+
findKey,
|
|
60
|
+
xAxis.dataKey,
|
|
61
|
+
yAxis.dataKey,
|
|
62
|
+
zAxis.dataKey,
|
|
63
|
+
]);
|
|
64
|
+
const xAxisFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
65
|
+
const yAxisFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
66
|
+
const zAxisFormatter = (0, formatters_1.createLongAxisFormatter)(zAxis.tick);
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
68
|
+
display: 'flex',
|
|
69
|
+
flexDirection: 'column',
|
|
70
|
+
boxShadow: react_components_1.tokens.shadow16,
|
|
71
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
72
|
+
padding: 8,
|
|
73
|
+
borderRadius: 4,
|
|
74
|
+
gap: 4,
|
|
75
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: xAxis.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: xAxisFormatter(xValue) })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: yAxis.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: yAxisFormatter(yValue) })] }), (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }), items.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
76
|
+
width: 8,
|
|
77
|
+
height: 8,
|
|
78
|
+
background: item.color,
|
|
79
|
+
borderRadius: 4,
|
|
80
|
+
} }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4, marginLeft: 8 }, children: item.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: zAxisFormatter(item.value) })] }, index)))] }) }));
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const defaultColors: string[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultColors = void 0;
|
|
4
|
+
exports.defaultColors = [
|
|
5
|
+
'#0088FE',
|
|
6
|
+
'#00C49F',
|
|
7
|
+
'#FFBB28',
|
|
8
|
+
'#FF8042',
|
|
9
|
+
'#0088FE',
|
|
10
|
+
'#00C49F',
|
|
11
|
+
'#FFBB28',
|
|
12
|
+
'#FF8042',
|
|
13
|
+
'#0088FE',
|
|
14
|
+
'#00C49F',
|
|
15
|
+
'#FFBB28',
|
|
16
|
+
'#FF8042',
|
|
17
|
+
'#0088FE',
|
|
18
|
+
'#00C49F',
|
|
19
|
+
'#FFBB28',
|
|
20
|
+
'#FF8042',
|
|
21
|
+
'#0088FE',
|
|
22
|
+
'#00C49F',
|
|
23
|
+
'#FFBB28',
|
|
24
|
+
'#FF8042',
|
|
25
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AllAxisTick } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
interface FormatNumberOptions {
|
|
3
|
+
digit?: number;
|
|
4
|
+
minDigit?: number;
|
|
5
|
+
maxDigit?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const formatCurrencyWithSuffix: (input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
|
|
8
|
+
export declare const formatDate: (input: Date | string | number | undefined | null, format: string) => string;
|
|
9
|
+
export declare const formatCurrency: (input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
|
|
10
|
+
export declare const formatNumber: (input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
|
|
11
|
+
export declare function createAxisFormatter(tick: AllAxisTick): (value: number) => string;
|
|
12
|
+
export type Formatter = (value: unknown) => string;
|
|
13
|
+
export declare function createLongAxisFormatter(tick: AllAxisTick): Formatter;
|
|
14
|
+
export {};
|