component-shared 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/Components/Charts/AreaChart.d.ts +19 -0
- package/Components/Charts/AreaChart.js +59 -0
- package/Components/Charts/AreaChart.js.map +1 -0
- package/Components/Charts/BarChart.d.ts +20 -0
- package/Components/Charts/BarChart.js +81 -0
- package/Components/Charts/BarChart.js.map +1 -0
- package/Components/Charts/DoughnutChart.d.ts +12 -0
- package/Components/Charts/DoughnutChart.js +81 -0
- package/Components/Charts/DoughnutChart.js.map +1 -0
- package/Components/Charts/HorizontalBarChart.d.ts +38 -0
- package/Components/Charts/HorizontalBarChart.js +83 -0
- package/Components/Charts/HorizontalBarChart.js.map +1 -0
- package/Components/Charts/LineChart.d.ts +21 -0
- package/Components/Charts/LineChart.js +133 -0
- package/Components/Charts/LineChart.js.map +1 -0
- package/Components/Charts/PieChart.d.ts +20 -0
- package/Components/Charts/PieChart.js +123 -0
- package/Components/Charts/PieChart.js.map +1 -0
- package/Components/Charts/index.d.ts +5 -0
- package/Components/Charts/index.js +6 -0
- package/Components/Charts/index.js.map +1 -0
- package/Components/Charts/type.d.ts +6 -0
- package/Components/Charts/type.js +2 -0
- package/Components/Charts/type.js.map +1 -0
- package/Components/CopyToClipboard/index.d.ts +23 -0
- package/Components/CopyToClipboard/index.js +54 -0
- package/Components/CopyToClipboard/index.js.map +1 -0
- package/Components/CopyToClipboard/indexv2.d.ts +30 -0
- package/Components/CopyToClipboard/indexv2.js +63 -0
- package/Components/CopyToClipboard/indexv2.js.map +1 -0
- package/Components/DropZone/components/DropzoneArea.d.ts +31 -0
- package/Components/DropZone/components/DropzoneArea.js +221 -0
- package/Components/DropZone/components/DropzoneArea.js.map +1 -0
- package/Components/DropZone/components/DropzoneAreaBase.d.ts +4 -0
- package/Components/DropZone/components/DropzoneAreaBase.js +555 -0
- package/Components/DropZone/components/DropzoneAreaBase.js.map +1 -0
- package/Components/DropZone/components/DropzoneDialog.d.ts +33 -0
- package/Components/DropZone/components/DropzoneDialog.js +222 -0
- package/Components/DropZone/components/DropzoneDialog.js.map +1 -0
- package/Components/DropZone/components/DropzoneDialogBase.d.ts +27 -0
- package/Components/DropZone/components/DropzoneDialogBase.js +152 -0
- package/Components/DropZone/components/DropzoneDialogBase.js.map +1 -0
- package/Components/DropZone/components/PreviewList.d.ts +3 -0
- package/Components/DropZone/components/PreviewList.js +132 -0
- package/Components/DropZone/components/PreviewList.js.map +1 -0
- package/Components/DropZone/components/SnackbarContentWrapper.d.ts +3 -0
- package/Components/DropZone/components/SnackbarContentWrapper.js +94 -0
- package/Components/DropZone/components/SnackbarContentWrapper.js.map +1 -0
- package/Components/DropZone/helpers.d.ts +5 -0
- package/Components/DropZone/helpers.js +64 -0
- package/Components/DropZone/helpers.js.map +1 -0
- package/Components/DropZone/index.d.ts +120 -0
- package/Components/EditAvatar/index.d.ts +26 -0
- package/Components/EditAvatar/index.js +137 -0
- package/Components/EditAvatar/index.js.map +1 -0
- package/Components/FlexInfiniteScroll/index.d.ts +26 -0
- package/Components/FlexInfiniteScroll/index.js +82 -0
- package/Components/FlexInfiniteScroll/index.js.map +1 -0
- package/Components/Helper/LazySpinner.d.ts +5 -0
- package/Components/Helper/LazySpinner.js +33 -0
- package/Components/Helper/LazySpinner.js.map +1 -0
- package/Components/Helper/RoleKey.d.ts +9 -0
- package/Components/Helper/RoleKey.js +15 -0
- package/Components/Helper/RoleKey.js.map +1 -0
- package/Components/Helper/index.d.ts +41 -0
- package/Components/Helper/index.js +247 -0
- package/Components/Helper/index.js.map +1 -0
- package/Components/HocLazyView/index.d.ts +51 -0
- package/Components/HocLazyView/index.js +123 -0
- package/Components/HocLazyView/index.js.map +1 -0
- package/Components/HtmlTooltip/index.d.ts +3 -0
- package/Components/HtmlTooltip/index.js +28 -0
- package/Components/HtmlTooltip/index.js.map +1 -0
- package/Components/Icons/index.d.ts +6 -0
- package/Components/Icons/index.js +52 -0
- package/Components/Icons/index.js.map +1 -0
- package/Components/LazySpinner.css +6 -0
- package/Components/MapLayout/index.d.ts +33 -0
- package/Components/MapLayout/index.js +80 -0
- package/Components/MapLayout/index.js.map +1 -0
- package/Components/MessageBox/index.d.ts +28 -0
- package/Components/MessageBox/index.js +93 -0
- package/Components/MessageBox/index.js.map +1 -0
- package/Components/Models/index.d.ts +641 -0
- package/Components/Models/index.js +87 -0
- package/Components/Models/index.js.map +1 -0
- package/Components/Redux/core/CRUDSlice.d.ts +20 -0
- package/Components/Redux/core/CRUDSlice.js +62 -0
- package/Components/Redux/core/CRUDSlice.js.map +1 -0
- package/Components/Redux/core/type.d.ts +11 -0
- package/Components/Redux/core/type.js +9 -0
- package/Components/Redux/core/type.js.map +1 -0
- package/Components/SkeletonLazyView/index.d.ts +9 -0
- package/Components/SkeletonLazyView/index.js +38 -0
- package/Components/SkeletonLazyView/index.js.map +1 -0
- package/Components/SkeletonService/index.d.ts +15 -0
- package/Components/SkeletonService/index.js +57 -0
- package/Components/SkeletonService/index.js.map +1 -0
- package/Components/SubComponent/index.d.ts +151 -0
- package/Components/SubComponent/index.js +883 -0
- package/Components/SubComponent/index.js.map +1 -0
- package/Components/SubComponent/v2/index.d.ts +20 -0
- package/Components/SubComponent/v2/index.js +58 -0
- package/Components/SubComponent/v2/index.js.map +1 -0
- package/Components/SubUserInputModels/ContactInfoForm/index.d.ts +11 -0
- package/Components/SubUserInputModels/ContactInfoForm/index.js +130 -0
- package/Components/SubUserInputModels/ContactInfoForm/index.js.map +1 -0
- package/Components/SubUserInputModels/index.d.ts +59 -0
- package/Components/SubUserInputModels/index.js +928 -0
- package/Components/SubUserInputModels/index.js.map +1 -0
- package/Components/SwitchComponent/index.d.ts +21 -0
- package/Components/SwitchComponent/index.js +71 -0
- package/Components/SwitchComponent/index.js.map +1 -0
- package/Components/TemplateModal/index.d.ts +29 -0
- package/Components/TemplateModal/index.js +94 -0
- package/Components/TemplateModal/index.js.map +1 -0
- package/Components/TemplateTable/FormTest/index.d.ts +4 -0
- package/Components/TemplateTable/FormTest/index.js +22 -0
- package/Components/TemplateTable/FormTest/index.js.map +1 -0
- package/Components/TemplateTable/InputFormBase/index.d.ts +23 -0
- package/Components/TemplateTable/InputFormBase/index.js +111 -0
- package/Components/TemplateTable/InputFormBase/index.js.map +1 -0
- package/Components/TemplateTable/InputFormModal/index.d.ts +22 -0
- package/Components/TemplateTable/InputFormModal/index.js +103 -0
- package/Components/TemplateTable/InputFormModal/index.js.map +1 -0
- package/Components/TemplateTable/ItemRowMenu/index.d.ts +13 -0
- package/Components/TemplateTable/ItemRowMenu/index.js +49 -0
- package/Components/TemplateTable/ItemRowMenu/index.js.map +1 -0
- package/Components/TemplateTable/PanelAction/index.d.ts +11 -0
- package/Components/TemplateTable/PanelAction/index.js +51 -0
- package/Components/TemplateTable/PanelAction/index.js.map +1 -0
- package/Components/TemplateTable/TableContext/index.d.ts +1 -0
- package/Components/TemplateTable/TableContext/index.js +2 -0
- package/Components/TemplateTable/TableContext/index.js.map +1 -0
- package/Components/TemplateTable/helper.d.ts +3 -0
- package/Components/TemplateTable/helper.js +20 -0
- package/Components/TemplateTable/helper.js.map +1 -0
- package/Components/TemplateTable/index.d.ts +49 -0
- package/Components/TemplateTable/index.js +208 -0
- package/Components/TemplateTable/index.js.map +1 -0
- package/Components/UploadLayout/ProgressItem.d.ts +27 -0
- package/Components/UploadLayout/ProgressItem.js +210 -0
- package/Components/UploadLayout/ProgressItem.js.map +1 -0
- package/Components/UploadLayout/UploadArea.d.ts +9 -0
- package/Components/UploadLayout/UploadArea.js +58 -0
- package/Components/UploadLayout/UploadArea.js.map +1 -0
- package/Components/UploadLayout/UploadMonitor.d.ts +42 -0
- package/Components/UploadLayout/UploadMonitor.js +259 -0
- package/Components/UploadLayout/UploadMonitor.js.map +1 -0
- package/Components/UploadLayout/UploadPannel.d.ts +4 -0
- package/Components/UploadLayout/UploadPannel.js +20 -0
- package/Components/UploadLayout/UploadPannel.js.map +1 -0
- package/Components/UploadLayout/UploadStatus.d.ts +21 -0
- package/Components/UploadLayout/UploadStatus.js +184 -0
- package/Components/UploadLayout/UploadStatus.js.map +1 -0
- package/Components/UploadLayout/index.d.ts +69 -0
- package/Components/UploadLayout/index.js +265 -0
- package/Components/UploadLayout/index.js.map +1 -0
- package/Components/UploadLayout/types.d.ts +10 -0
- package/Components/UploadLayout/types.js +2 -0
- package/Components/UploadLayout/types.js.map +1 -0
- package/Components/Views/Billing/BillingForm/index.d.ts +16 -0
- package/Components/Views/Billing/BillingForm/index.js +49 -0
- package/Components/Views/Billing/BillingForm/index.js.map +1 -0
- package/Components/Views/Billing/ItemBillingRowMenu/index.d.ts +23 -0
- package/Components/Views/Billing/ItemBillingRowMenu/index.js +153 -0
- package/Components/Views/Billing/ItemBillingRowMenu/index.js.map +1 -0
- package/Components/Views/Billing/MenuMore/index.d.ts +6 -0
- package/Components/Views/Billing/MenuMore/index.js +89 -0
- package/Components/Views/Billing/MenuMore/index.js.map +1 -0
- package/Components/Views/Billing/SubBillingFormComponent/index.d.ts +14 -0
- package/Components/Views/Billing/SubBillingFormComponent/index.js +306 -0
- package/Components/Views/Billing/SubBillingFormComponent/index.js.map +1 -0
- package/Components/Views/BillingDetail/BillingDetailForm/index.d.ts +16 -0
- package/Components/Views/BillingDetail/BillingDetailForm/index.js +49 -0
- package/Components/Views/BillingDetail/BillingDetailForm/index.js.map +1 -0
- package/Components/Views/BillingDetail/SubComponent/index.d.ts +10 -0
- package/Components/Views/BillingDetail/SubComponent/index.js +152 -0
- package/Components/Views/BillingDetail/SubComponent/index.js.map +1 -0
- package/Components/Views/DashBoard/Common/index.d.ts +18 -0
- package/Components/Views/DashBoard/Common/index.js +55 -0
- package/Components/Views/DashBoard/Common/index.js.map +1 -0
- package/Components/Views/DashBoard/DeliveryInfo/index.d.ts +17 -0
- package/Components/Views/DashBoard/DeliveryInfo/index.js +92 -0
- package/Components/Views/DashBoard/DeliveryInfo/index.js.map +1 -0
- package/Components/Views/DashBoard/OverViewInfo/index.d.ts +29 -0
- package/Components/Views/DashBoard/OverViewInfo/index.js +237 -0
- package/Components/Views/DashBoard/OverViewInfo/index.js.map +1 -0
- package/Components/Views/DashBoard/PanelIntro/index.d.ts +4 -0
- package/Components/Views/DashBoard/PanelIntro/index.js +76 -0
- package/Components/Views/DashBoard/PanelIntro/index.js.map +1 -0
- package/Components/Views/DashBoard/SummaryPanel/index.d.ts +20 -0
- package/Components/Views/DashBoard/SummaryPanel/index.js +229 -0
- package/Components/Views/DashBoard/SummaryPanel/index.js.map +1 -0
- package/Components/Views/DashBoard/TopChannel/index.d.ts +13 -0
- package/Components/Views/DashBoard/TopChannel/index.js +89 -0
- package/Components/Views/DashBoard/TopChannel/index.js.map +1 -0
- package/Components/Views/DashBoard/TopViewTable/index.d.ts +12 -0
- package/Components/Views/DashBoard/TopViewTable/index.js +79 -0
- package/Components/Views/DashBoard/TopViewTable/index.js.map +1 -0
- package/Components/Views/DashBoard/type.d.ts +9 -0
- package/Components/Views/DashBoard/type.js +2 -0
- package/Components/Views/DashBoard/type.js.map +1 -0
- package/Components/Views/Helper/index.d.ts +2 -0
- package/Components/Views/Helper/index.js +10 -0
- package/Components/Views/Helper/index.js.map +1 -0
- package/Components/YoutubeImage/index.d.ts +45 -0
- package/Components/YoutubeImage/index.js +52 -0
- package/Components/YoutubeImage/index.js.map +1 -0
- package/Components/excel-icon-disabled.svg +16 -0
- package/Components/excel-icon.svg +9 -0
- package/Components/index.css +0 -0
- package/Components/index.d.ts +120 -0
- package/ComponentsV2/GlobalModal/index.d.ts +37 -0
- package/ComponentsV2/GlobalModal/index.js +100 -0
- package/ComponentsV2/GlobalModal/index.js.map +1 -0
- package/ComponentsV2/HeightEqualWidth/index.d.ts +8 -0
- package/ComponentsV2/HeightEqualWidth/index.js +41 -0
- package/ComponentsV2/HeightEqualWidth/index.js.map +1 -0
- package/ComponentsV2/LazyView/index.d.ts +6 -0
- package/ComponentsV2/LazyView/index.js +30 -0
- package/ComponentsV2/LazyView/index.js.map +1 -0
- package/ComponentsV2/LoadingAnimation/LoadingSquare.d.ts +3 -0
- package/ComponentsV2/LoadingAnimation/LoadingSquare.js +203 -0
- package/ComponentsV2/LoadingAnimation/LoadingSquare.js.map +1 -0
- package/ComponentsV2/LoadingAnimation/index.d.ts +9 -0
- package/ComponentsV2/LoadingAnimation/index.js +25 -0
- package/ComponentsV2/LoadingAnimation/index.js.map +1 -0
- package/ComponentsV2/TableTemplate/CRUDPannel.d.ts +22 -0
- package/ComponentsV2/TableTemplate/CRUDPannel.js +199 -0
- package/ComponentsV2/TableTemplate/CRUDPannel.js.map +1 -0
- package/ComponentsV2/TableTemplate/CreateTableTemplate.d.ts +60 -0
- package/ComponentsV2/TableTemplate/CreateTableTemplate.js +330 -0
- package/ComponentsV2/TableTemplate/CreateTableTemplate.js.map +1 -0
- package/ComponentsV2/TableTemplate/CustomGridFilterPanel.d.ts +6 -0
- package/ComponentsV2/TableTemplate/CustomGridFilterPanel.js +71 -0
- package/ComponentsV2/TableTemplate/CustomGridFilterPanel.js.map +1 -0
- package/ComponentsV2/TableTemplate/CustomerGridToolbar.d.ts +2 -0
- package/ComponentsV2/TableTemplate/CustomerGridToolbar.js +45 -0
- package/ComponentsV2/TableTemplate/CustomerGridToolbar.js.map +1 -0
- package/ComponentsV2/TableTemplate/ItemRowMenu/index.d.ts +14 -0
- package/ComponentsV2/TableTemplate/ItemRowMenu/index.js +49 -0
- package/ComponentsV2/TableTemplate/ItemRowMenu/index.js.map +1 -0
- package/ComponentsV2/TableTemplate/MapOperators.d.ts +5 -0
- package/ComponentsV2/TableTemplate/MapOperators.js +49 -0
- package/ComponentsV2/TableTemplate/MapOperators.js.map +1 -0
- package/ComponentsV2/TableTemplate/NoRowsOverlay.d.ts +5 -0
- package/ComponentsV2/TableTemplate/NoRowsOverlay.js +39 -0
- package/ComponentsV2/TableTemplate/NoRowsOverlay.js.map +1 -0
- package/ComponentsV2/TableTemplate/TableConverter.d.ts +33 -0
- package/ComponentsV2/TableTemplate/TableConverter.js +112 -0
- package/ComponentsV2/TableTemplate/TableConverter.js.map +1 -0
- package/ComponentsV2/TableTemplate/TableFormatter.d.ts +10 -0
- package/ComponentsV2/TableTemplate/TableFormatter.js +122 -0
- package/ComponentsV2/TableTemplate/TableFormatter.js.map +1 -0
- package/ComponentsV2/TableTemplate/TableTemplateContext.d.ts +16 -0
- package/ComponentsV2/TableTemplate/TableTemplateContext.js +6 -0
- package/ComponentsV2/TableTemplate/TableTemplateContext.js.map +1 -0
- package/ComponentsV2/TableTemplate/index.d.ts +14 -0
- package/ComponentsV2/TableTemplate/index.js +9 -0
- package/ComponentsV2/TableTemplate/index.js.map +1 -0
- package/ComponentsV2/TableTemplate/type.d.ts +59 -0
- package/ComponentsV2/TableTemplate/type.js +14 -0
- package/ComponentsV2/TableTemplate/type.js.map +1 -0
- package/ComponentsV2/index.css +4 -0
- package/ComponentsV2/index.d.ts +4 -0
- package/ComponentsV2/index.js +6 -0
- package/ComponentsV2/index.js.map +1 -0
- package/Services/Getway/RequestHelper.d.ts +2 -0
- package/Services/Getway/RequestHelper.js +51 -0
- package/Services/Getway/RequestHelper.js.map +1 -0
- package/Services/Getway/index.d.ts +3 -0
- package/Services/Getway/index.js +14 -0
- package/Services/Getway/index.js.map +1 -0
- package/Services/ServiceBase.d.ts +32 -0
- package/Services/ServiceBase.js +523 -0
- package/Services/ServiceBase.js.map +1 -0
- package/_virtual/_rollupPluginBabelHelpers.js +393 -0
- package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/index.css +2 -0
- package/index.css.map +1 -0
- package/package.json +118 -0
- package/types/clipboard-copy.d.ts +6 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { ScatterDataPoint, ChartDataset } from 'chart.js';
|
|
3
|
+
interface IProps {
|
|
4
|
+
data?: ChartDataset<'line', (number | ScatterDataPoint | null)[]>[];
|
|
5
|
+
IsLoading?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class AreaChart extends Component<IProps> {
|
|
8
|
+
static defaultProps: {
|
|
9
|
+
data: {
|
|
10
|
+
fill: boolean;
|
|
11
|
+
label: string;
|
|
12
|
+
data: number[];
|
|
13
|
+
borderColor: string;
|
|
14
|
+
backgroundColor: string;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
render(): JSX.Element | undefined;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineProperty as _defineProperty, inherits as _inherits, createClass as _createClass, classCallCheck as _classCallCheck, callSuper as _callSuper } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
import { Chart, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler } from 'chart.js';
|
|
5
|
+
import { Line } from 'react-chartjs-2';
|
|
6
|
+
|
|
7
|
+
Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler);
|
|
8
|
+
var labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
9
|
+
var options = {
|
|
10
|
+
responsive: true,
|
|
11
|
+
plugins: {
|
|
12
|
+
legend: {
|
|
13
|
+
position: 'top'
|
|
14
|
+
},
|
|
15
|
+
title: {
|
|
16
|
+
display: true,
|
|
17
|
+
text: 'Chart.js Line Chart'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var defaultData = [{
|
|
22
|
+
fill: true,
|
|
23
|
+
label: 'Audios',
|
|
24
|
+
data: [0, 200, 300, 500, 250, 300, 400, 600, 550],
|
|
25
|
+
borderColor: 'rgb(255, 99, 132)',
|
|
26
|
+
backgroundColor: 'rgba(255, 99, 132, 0.5)'
|
|
27
|
+
}, {
|
|
28
|
+
fill: true,
|
|
29
|
+
label: 'Albums',
|
|
30
|
+
data: [0, 100, 150, 400, 480, 400, 420, 500, 400],
|
|
31
|
+
borderColor: 'rgb(53, 162, 235)',
|
|
32
|
+
backgroundColor: 'rgba(53, 162, 235, 0.5)'
|
|
33
|
+
}];
|
|
34
|
+
var AreaChart = /*#__PURE__*/function (_Component) {
|
|
35
|
+
function AreaChart() {
|
|
36
|
+
_classCallCheck(this, AreaChart);
|
|
37
|
+
return _callSuper(this, AreaChart, arguments);
|
|
38
|
+
}
|
|
39
|
+
_inherits(AreaChart, _Component);
|
|
40
|
+
return _createClass(AreaChart, [{
|
|
41
|
+
key: "render",
|
|
42
|
+
value: function render() {
|
|
43
|
+
if (!this.props.data) return;
|
|
44
|
+
return jsx(Line, {
|
|
45
|
+
options: options,
|
|
46
|
+
data: {
|
|
47
|
+
labels: labels,
|
|
48
|
+
datasets: this.props.data
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}]);
|
|
53
|
+
}(Component);
|
|
54
|
+
_defineProperty(AreaChart, "defaultProps", {
|
|
55
|
+
data: defaultData
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export { AreaChart };
|
|
59
|
+
//# sourceMappingURL=AreaChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaChart.js","sources":["../../../src/Components/Charts/AreaChart.tsx"],"sourcesContent":["import React, { Component } from 'react'\r\nimport { Title, Tooltip, Legend, Filler, ScatterDataPoint, ChartDataset } from 'chart.js'\r\nimport { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement } from 'chart.js'\r\nimport { Line } from 'react-chartjs-2'\r\n\r\nChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler)\r\n\r\nconst labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\r\nconst options = {\r\n responsive: true,\r\n plugins: {\r\n legend: { position: 'top' as const },\r\n title: { display: true, text: 'Chart.js Line Chart' }\r\n }\r\n}\r\nconst defaultData = [\r\n {\r\n fill: true,\r\n label: 'Audios',\r\n data: [0, 200, 300, 500, 250, 300, 400, 600, 550],\r\n borderColor: 'rgb(255, 99, 132)',\r\n backgroundColor: 'rgba(255, 99, 132, 0.5)'\r\n },\r\n {\r\n fill: true,\r\n label: 'Albums',\r\n data: [0, 100, 150, 400, 480, 400, 420, 500, 400],\r\n borderColor: 'rgb(53, 162, 235)',\r\n backgroundColor: 'rgba(53, 162, 235, 0.5)'\r\n }\r\n]\r\n\r\ninterface IProps {\r\n data?: ChartDataset<'line', (number | ScatterDataPoint | null)[]>[]\r\n IsLoading?: boolean\r\n}\r\nexport class AreaChart extends Component<IProps> {\r\n static defaultProps = { data: defaultData }\r\n render() {\r\n if (!this.props.data) return\r\n return <Line options={options} data={{ labels, datasets: this.props.data }} />\r\n }\r\n}\r\n"],"names":["ChartJS","register","CategoryScale","LinearScale","PointElement","LineElement","Title","Tooltip","Legend","Filler","labels","options","responsive","plugins","legend","position","title","display","text","defaultData","fill","label","data","borderColor","backgroundColor","AreaChart","_Component","_classCallCheck","_callSuper","arguments","_inherits","_createClass","key","value","render","props","_jsx","Line","datasets","Component"],"mappings":";;;;;;AAKAA,KAAO,CAACC,QAAQ,CAACC,aAAa,EAAEC,WAAW,EAAEC,YAAY,EAAEC,WAAW,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,CAAC;AAEvG,IAAMC,MAAM,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;AACnG,IAAMC,OAAO,GAAG;AACdC,EAAAA,UAAU,EAAE,IAAI;AAChBC,EAAAA,OAAO,EAAE;AACPC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,QAAQ,EAAE;KAAgB;AACpCC,I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AAAE4B,UAAAA,QAAQ,EAAE,IAAI,CAACH,KAAK,CAACb;AAAM;AAAA,OAAA,CAAI;AAChF;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA,CAL4BiB,SAAiB;gBAAnCd,SAAU,EACC,cAAA,EAAA;AAAEH,EAAAA,IAAI,EAAEH;CAAa,CAAA;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ChartData } from 'chart.js';
|
|
3
|
+
import { ChartOptions } from 'chart.js';
|
|
4
|
+
export declare const options: ChartOptions<'bar'>;
|
|
5
|
+
export declare const monthLabels: string[];
|
|
6
|
+
export declare const data: {
|
|
7
|
+
labels: string[];
|
|
8
|
+
datasets: {
|
|
9
|
+
label: string;
|
|
10
|
+
data: number[];
|
|
11
|
+
backgroundColor: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
interface BarChartProps {
|
|
15
|
+
width?: number | string;
|
|
16
|
+
height?: number | string;
|
|
17
|
+
data: ChartData<'bar', number[], string>;
|
|
18
|
+
}
|
|
19
|
+
export declare const BarChart: FC<BarChartProps>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Chart, CategoryScale, LinearScale, BarElement, Tooltip, Legend } from 'chart.js';
|
|
4
|
+
import { Bar } from 'react-chartjs-2';
|
|
5
|
+
import { faker } from '@faker-js/faker';
|
|
6
|
+
import { FormatterUSD } from 'partner-local-lib/helper';
|
|
7
|
+
|
|
8
|
+
var _excluded = ["data"];
|
|
9
|
+
Chart.register(CategoryScale, LinearScale, BarElement,
|
|
10
|
+
// Title,
|
|
11
|
+
Tooltip, Legend);
|
|
12
|
+
var options = {
|
|
13
|
+
responsive: true,
|
|
14
|
+
maintainAspectRatio: false,
|
|
15
|
+
plugins: {
|
|
16
|
+
legend: {
|
|
17
|
+
position: 'top'
|
|
18
|
+
},
|
|
19
|
+
// title: {
|
|
20
|
+
// display: true,
|
|
21
|
+
// text: 'Chart.js Bar Chart',
|
|
22
|
+
// },
|
|
23
|
+
tooltip: {
|
|
24
|
+
callbacks: {
|
|
25
|
+
label: function label(context) {
|
|
26
|
+
var label = context.dataset.label || context.label || '';
|
|
27
|
+
if (label) {
|
|
28
|
+
label += ': ';
|
|
29
|
+
}
|
|
30
|
+
if (context.parsed.y !== null) {
|
|
31
|
+
label += FormatterUSD().format(context.parsed.y);
|
|
32
|
+
}
|
|
33
|
+
return label;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
scales: {
|
|
39
|
+
yAxes: {
|
|
40
|
+
ticks: {
|
|
41
|
+
callback: function callback(value, index, values) {
|
|
42
|
+
return FormatterUSD().format(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var monthLabels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
49
|
+
var data = {
|
|
50
|
+
labels: monthLabels,
|
|
51
|
+
datasets: [{
|
|
52
|
+
label: 'Dataset 1',
|
|
53
|
+
data: monthLabels.map(function () {
|
|
54
|
+
return faker.datatype.number({
|
|
55
|
+
min: 0,
|
|
56
|
+
max: 1000
|
|
57
|
+
});
|
|
58
|
+
}),
|
|
59
|
+
backgroundColor: 'rgba(255, 99, 132, 0.5)'
|
|
60
|
+
}, {
|
|
61
|
+
label: 'Dataset 2',
|
|
62
|
+
data: monthLabels.map(function () {
|
|
63
|
+
return faker.datatype.number({
|
|
64
|
+
min: 0,
|
|
65
|
+
max: 1000
|
|
66
|
+
});
|
|
67
|
+
}),
|
|
68
|
+
backgroundColor: 'rgba(53, 162, 235, 0.5)'
|
|
69
|
+
}]
|
|
70
|
+
};
|
|
71
|
+
var BarChart = function BarChart(props) {
|
|
72
|
+
var data = props.data,
|
|
73
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
74
|
+
return jsx(Bar, _objectSpread2({
|
|
75
|
+
options: options,
|
|
76
|
+
data: data
|
|
77
|
+
}, other));
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { BarChart, data, monthLabels, options };
|
|
81
|
+
//# sourceMappingURL=BarChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BarChart.js","sources":["../../../src/Components/Charts/BarChart.tsx"],"sourcesContent":["import React, { FC } from 'react'\r\nimport { Chart as ChartJS, CategoryScale, LinearScale, BarElement, Tooltip, Legend, ChartData } from 'chart.js'\r\nimport { Bar } from 'react-chartjs-2'\r\nimport { ChartOptions } from 'chart.js'\r\nimport { faker } from '@faker-js/faker'\r\nimport { FormatterUSD } from 'partner-local-lib/helper'\r\n\r\nChartJS.register(\r\n CategoryScale,\r\n LinearScale,\r\n BarElement,\r\n // Title,\r\n Tooltip,\r\n Legend\r\n)\r\n\r\nexport const options: ChartOptions<'bar'> = {\r\n responsive: true,\r\n maintainAspectRatio: false,\r\n plugins: {\r\n legend: {\r\n position: 'top' as const\r\n },\r\n // title: {\r\n // display: true,\r\n // text: 'Chart.js Bar Chart',\r\n // },\r\n tooltip: {\r\n callbacks: {\r\n label: function (context) {\r\n let label = context.dataset.label || context.label || ''\r\n if (label) {\r\n label += ': '\r\n }\r\n if (context.parsed.y !== null) {\r\n label += FormatterUSD().format(context.parsed.y)\r\n }\r\n return label\r\n }\r\n }\r\n }\r\n },\r\n scales: {\r\n yAxes: {\r\n ticks: {\r\n callback: function (value, index, values) {\r\n return FormatterUSD().format(value as number)\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport const monthLabels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\r\n\r\nexport const data = {\r\n labels: monthLabels,\r\n datasets: [\r\n {\r\n label: 'Dataset 1',\r\n data: monthLabels.map(() => faker.datatype.number({ min: 0, max: 1000 })),\r\n backgroundColor: 'rgba(255, 99, 132, 0.5)'\r\n },\r\n {\r\n label: 'Dataset 2',\r\n data: monthLabels.map(() => faker.datatype.number({ min: 0, max: 1000 })),\r\n backgroundColor: 'rgba(53, 162, 235, 0.5)'\r\n }\r\n ]\r\n}\r\n\r\ninterface BarChartProps {\r\n width?: number | string\r\n height?: number | string\r\n data: ChartData<'bar', number[], string>\r\n}\r\nexport const BarChart: FC<BarChartProps> = (props) => {\r\n const { data, ...other } = props\r\n return <Bar options={options} data={data} {...other} />\r\n}\r\n"],"names":["ChartJS","register","CategoryScale","LinearScale","BarElement","Tooltip","Legend","options","responsive","maintainAspectRatio","plugins","legend","position","tooltip","callbacks","label","context","dataset","parsed","y","FormatterUSD","format","scales","yAxes","ticks","callback","value","index","values","monthLabels","data","labels","datasets","map","faker","datatype","number","min","max","backgroundColor","BarChart","props","other","_objectWithoutProperties","_excluded","_jsx","Bar","_objectSpread"],"mappings":";;;;;;;;AAOAA,KAAO,CAACC,QAAQ,CACdC,aAAa,EACbC,WAAW,EACXC,UAAU;AACV;AACAC,OAAO,EACPC,MAAM,CACP;AAEM,IAAMC,OAAO,GAAwB;AAC1CC,EAAAA,UAAU,EAAE,IAAI;AAChBC,EAAAA,mBAAmB,EAAE,KAAK;AAC1BC,EAAAA,OAAO,EAAE;AACPC,IAAAA,MAAM,EAAE;AACNC,MAAAA,QAAQ,EAAE;KACX;AACD;AACA;AACA;AACA;AACAC,IAAAA,OAAO,EAAE;AACPC,MAAAA,SAAS,EAAE;AACTC,QAAAA,KAAK,EAAE,SAAPA,KAAKA,CAAYC,OAAO,EAAA;AACtB,UAAA,IAAID,KAAK,GAAGC,OAAO,CAACC,OAAO,CAACF,KAAK,IAAIC,OAAO,CAACD,KAAK,IAAI,EAAE;AACxD,UAAA,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QAAAA,GAAG,EAAE;AAAM,OAAA,CAAC;KAAC,CAAA;AACzEC,IAAAA,eAAe,EAAE;GAClB;;IASQC,QAAQ,GAAsB,SAA9BA,QAAQA,CAAuBC,KAAK,EAAI;AACnD,EAAA,IAAQX,IAAI,GAAeW,KAAK,CAAxBX,IAAI;AAAKY,IAAAA,KAAK,GAAAC,wBAAA,CAAKF,KAAK,EAAAG,SAAA,CAAA;AAChC,EAAA,OAAOC,GAAC,CAAAC,GAAG,EAAAC,cAAA,CAAA;AAACxC,IAAAA,OAAO,EAAEA,OAAO;AAAEuB,IAAAA,IAAI,EAAEA;GAAUY,EAAAA,KAAK,EAAI;AACzD;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { IChartDataItem } from './type';
|
|
3
|
+
interface IProps {
|
|
4
|
+
data?: IChartDataItem[];
|
|
5
|
+
}
|
|
6
|
+
export declare class DoughnutChart extends Component<IProps> {
|
|
7
|
+
static defaultProps: {
|
|
8
|
+
data: IChartDataItem[];
|
|
9
|
+
};
|
|
10
|
+
render(): JSX.Element;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { defineProperty as _defineProperty, inherits as _inherits, createClass as _createClass, classCallCheck as _classCallCheck, callSuper as _callSuper } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
import { Chart, ArcElement, Tooltip, Legend } from 'chart.js';
|
|
5
|
+
import { Doughnut } from 'react-chartjs-2';
|
|
6
|
+
|
|
7
|
+
Chart.register(ArcElement, Tooltip, Legend);
|
|
8
|
+
var createChartData = function createChartData(params) {
|
|
9
|
+
var labelName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '# of Votes';
|
|
10
|
+
var initial = {
|
|
11
|
+
labels: [],
|
|
12
|
+
datasets: [{
|
|
13
|
+
label: labelName,
|
|
14
|
+
borderWidth: 1,
|
|
15
|
+
data: [],
|
|
16
|
+
backgroundColor: [],
|
|
17
|
+
borderColor: []
|
|
18
|
+
}]
|
|
19
|
+
};
|
|
20
|
+
return params.reduce(function (acc, cur) {
|
|
21
|
+
var _acc$labels;
|
|
22
|
+
(_acc$labels = acc.labels) === null || _acc$labels === void 0 || _acc$labels.push(cur.label);
|
|
23
|
+
acc.datasets[0].data.push(cur.data);
|
|
24
|
+
if (Array.isArray(acc.datasets[0].backgroundColor)) acc.datasets[0].backgroundColor.push(cur.backgroundColor);
|
|
25
|
+
if (Array.isArray(acc.datasets[0].borderColor)) acc.datasets[0].borderColor.push(cur.borderColor);
|
|
26
|
+
return acc;
|
|
27
|
+
}, initial);
|
|
28
|
+
};
|
|
29
|
+
var defaultData = [{
|
|
30
|
+
label: 'Red',
|
|
31
|
+
data: 12,
|
|
32
|
+
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
33
|
+
borderColor: 'rgba(255, 99, 132, 1)'
|
|
34
|
+
}, {
|
|
35
|
+
label: 'Blue',
|
|
36
|
+
data: 19,
|
|
37
|
+
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
|
38
|
+
borderColor: 'rgba(54, 162, 235, 1)'
|
|
39
|
+
}, {
|
|
40
|
+
label: 'Yellow',
|
|
41
|
+
data: 3,
|
|
42
|
+
backgroundColor: 'rgba(255, 206, 86, 0.2)',
|
|
43
|
+
borderColor: 'rgba(255, 206, 86, 1)'
|
|
44
|
+
}, {
|
|
45
|
+
label: 'Green',
|
|
46
|
+
data: 5,
|
|
47
|
+
backgroundColor: 'rgba(75, 192, 192, 0.2)',
|
|
48
|
+
borderColor: 'rgba(75, 192, 192, 1)'
|
|
49
|
+
}, {
|
|
50
|
+
label: 'Purple',
|
|
51
|
+
data: 2,
|
|
52
|
+
backgroundColor: 'rgba(153, 102, 255, 0.2)',
|
|
53
|
+
borderColor: 'rgba(153, 102, 255, 1)'
|
|
54
|
+
}, {
|
|
55
|
+
label: 'Orange',
|
|
56
|
+
data: 3,
|
|
57
|
+
backgroundColor: 'rgba(255, 159, 64, 0.2)',
|
|
58
|
+
borderColor: 'rgba(255, 159, 64, 1)'
|
|
59
|
+
}];
|
|
60
|
+
var DoughnutChart = /*#__PURE__*/function (_Component) {
|
|
61
|
+
function DoughnutChart() {
|
|
62
|
+
_classCallCheck(this, DoughnutChart);
|
|
63
|
+
return _callSuper(this, DoughnutChart, arguments);
|
|
64
|
+
}
|
|
65
|
+
_inherits(DoughnutChart, _Component);
|
|
66
|
+
return _createClass(DoughnutChart, [{
|
|
67
|
+
key: "render",
|
|
68
|
+
value: function render() {
|
|
69
|
+
var _this$props$data;
|
|
70
|
+
return jsx(Doughnut, {
|
|
71
|
+
data: createChartData((_this$props$data = this.props.data) !== null && _this$props$data !== void 0 ? _this$props$data : [])
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}]);
|
|
75
|
+
}(Component);
|
|
76
|
+
_defineProperty(DoughnutChart, "defaultProps", {
|
|
77
|
+
data: defaultData
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export { DoughnutChart };
|
|
81
|
+
//# sourceMappingURL=DoughnutChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DoughnutChart.js","sources":["../../../src/Components/Charts/DoughnutChart.tsx"],"sourcesContent":["import React, { Component } from 'react'\r\nimport { ChartData } from 'chart.js'\r\nimport { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js'\r\nimport { Doughnut } from 'react-chartjs-2'\r\nimport { IChartDataItem } from './type'\r\n\r\nChartJS.register(ArcElement, Tooltip, Legend)\r\n\r\nconst createChartData = (params: IChartDataItem[], labelName: string = '# of Votes') => {\r\n const initial: ChartData<'doughnut', number[], string> = {\r\n labels: [],\r\n datasets: [{ label: labelName, borderWidth: 1, data: [], backgroundColor: [] as string[], borderColor: [] as string[] }]\r\n }\r\n return params.reduce((acc, cur) => {\r\n acc.labels?.push(cur.label)\r\n acc.datasets[0].data.push(cur.data)\r\n if (Array.isArray(acc.datasets[0].backgroundColor)) acc.datasets[0].backgroundColor.push(cur.backgroundColor)\r\n if (Array.isArray(acc.datasets[0].borderColor)) acc.datasets[0].borderColor.push(cur.borderColor)\r\n return acc\r\n }, initial)\r\n}\r\n\r\nconst defaultData: IChartDataItem[] = [\r\n { label: 'Red', data: 12, backgroundColor: 'rgba(255, 99, 132, 0.2)', borderColor: 'rgba(255, 99, 132, 1)' },\r\n { label: 'Blue', data: 19, backgroundColor: 'rgba(54, 162, 235, 0.2)', borderColor: 'rgba(54, 162, 235, 1)' },\r\n { label: 'Yellow', data: 3, backgroundColor: 'rgba(255, 206, 86, 0.2)', borderColor: 'rgba(255, 206, 86, 1)' },\r\n { label: 'Green', data: 5, backgroundColor: 'rgba(75, 192, 192, 0.2)', borderColor: 'rgba(75, 192, 192, 1)' },\r\n { label: 'Purple', data: 2, backgroundColor: 'rgba(153, 102, 255, 0.2)', borderColor: 'rgba(153, 102, 255, 1)' },\r\n { label: 'Orange', data: 3, backgroundColor: 'rgba(255, 159, 64, 0.2)', borderColor: 'rgba(255, 159, 64, 1)' }\r\n]\r\n\r\ninterface IProps {\r\n data?: IChartDataItem[]\r\n}\r\nexport class DoughnutChart extends Component<IProps> {\r\n static defaultProps = { data: defaultData }\r\n render() {\r\n return <Doughnut data={createChartData(this.props.data ?? [])} />\r\n }\r\n}\r\n"],"names":["ChartJS","register","ArcElement","Tooltip","Legend","createChartData","params","labelName","arguments","length","undefined","initial","labels","datasets","label","borderWidth","data","backgroundColor","borderColor","reduce","acc","cur","_acc$labels","push","Array","isArray","defaultData","DoughnutChart","_Component","_classCallCheck","_callSuper","_inherits","_createClass","key","value","render","_this$props$data","_jsx","Doughnut","props","Component"],"mappings":";;;;;;AAMAA,KAAO,CAACC,QAAQ,CAACC,UAAU,EAAEC,OAAO,EAAEC,MAAM,CAAC;AAE7C,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,M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,QAAA;AAAAC,IAAAA,KAAA,EAEzB,SAAAC,MAAMA,GAAA;AAAA,MAAA,IAAAC,gBAAA;MACJ,OAAOC,IAACC,QAAQ,EAAA;AAACtB,QAAAA,IAAI,EAAEX,eAAe,CAAA+B,CAAAA,gBAAA,GAAC,IAAI,CAACG,KAAK,CAACvB,IAAI,MAAAoB,IAAAA,IAAAA,gBAAA,KAAAA,MAAAA,GAAAA,gBAAA,GAAI,EAAE;QAAK;AACnE;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA,CAJgCI,SAAiB;gBAAvCb,aAAc,EACH,cAAA,EAAA;AAAEX,EAAAA,IAAI,EAAEU;CAAa,CAAA;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { ChartData, ChartOptions } from 'chart.js';
|
|
3
|
+
interface IProps {
|
|
4
|
+
data?: ChartData<'bar', number[], string>;
|
|
5
|
+
options?: ChartOptions<'bar'>;
|
|
6
|
+
title?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class HorizontalBarChart extends Component<IProps> {
|
|
9
|
+
getOptions: (title?: string) => {
|
|
10
|
+
indexAxis: "y";
|
|
11
|
+
elements: {
|
|
12
|
+
bar: {
|
|
13
|
+
borderWidth: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
responsive: boolean;
|
|
17
|
+
plugins: {
|
|
18
|
+
legend: {
|
|
19
|
+
position: "right";
|
|
20
|
+
};
|
|
21
|
+
title: {
|
|
22
|
+
display: boolean;
|
|
23
|
+
text: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
getData: (unitName?: string) => {
|
|
28
|
+
labels: string[];
|
|
29
|
+
datasets: {
|
|
30
|
+
label: string;
|
|
31
|
+
data: number[];
|
|
32
|
+
borderColor: string;
|
|
33
|
+
backgroundColor: string;
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
render(): JSX.Element;
|
|
37
|
+
}
|
|
38
|
+
export default HorizontalBarChart;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { inherits as _inherits, createClass as _createClass, classCallCheck as _classCallCheck, callSuper as _callSuper, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
import { Chart, CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend } from 'chart.js';
|
|
5
|
+
import { Bar } from 'react-chartjs-2';
|
|
6
|
+
import { faker } from '@faker-js/faker';
|
|
7
|
+
|
|
8
|
+
Chart.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend);
|
|
9
|
+
var labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
|
|
10
|
+
var HorizontalBarChart = /*#__PURE__*/function (_Component) {
|
|
11
|
+
function HorizontalBarChart() {
|
|
12
|
+
var _this;
|
|
13
|
+
_classCallCheck(this, HorizontalBarChart);
|
|
14
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
|
+
args[_key] = arguments[_key];
|
|
16
|
+
}
|
|
17
|
+
_this = _callSuper(this, HorizontalBarChart, [].concat(args));
|
|
18
|
+
_defineProperty(_this, "getOptions", function (title) {
|
|
19
|
+
return {
|
|
20
|
+
indexAxis: 'y',
|
|
21
|
+
elements: {
|
|
22
|
+
bar: {
|
|
23
|
+
borderWidth: 2
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
responsive: true,
|
|
27
|
+
plugins: {
|
|
28
|
+
legend: {
|
|
29
|
+
position: 'right'
|
|
30
|
+
},
|
|
31
|
+
title: {
|
|
32
|
+
display: true,
|
|
33
|
+
text: title || 'Horizontal Bar Chart'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
_defineProperty(_this, "getData", function () {
|
|
39
|
+
var unitName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Unit';
|
|
40
|
+
var data = labels.map(function (e) {
|
|
41
|
+
return {
|
|
42
|
+
label: e,
|
|
43
|
+
value: faker.datatype.number({
|
|
44
|
+
min: 0,
|
|
45
|
+
max: 1000
|
|
46
|
+
})
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
var sortData = data.sort(function (a, b) {
|
|
50
|
+
return b.value - a.value;
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
labels: sortData.map(function (e) {
|
|
54
|
+
return e.label;
|
|
55
|
+
}),
|
|
56
|
+
datasets: [{
|
|
57
|
+
label: unitName,
|
|
58
|
+
data: sortData.map(function (e) {
|
|
59
|
+
return e.value;
|
|
60
|
+
}),
|
|
61
|
+
borderColor: 'rgb(255, 99, 133, 0.6)',
|
|
62
|
+
backgroundColor: 'rgba(255, 99, 133, 0.3)'
|
|
63
|
+
}]
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
return _this;
|
|
67
|
+
}
|
|
68
|
+
_inherits(HorizontalBarChart, _Component);
|
|
69
|
+
return _createClass(HorizontalBarChart, [{
|
|
70
|
+
key: "render",
|
|
71
|
+
value: function render() {
|
|
72
|
+
var data = this.props.data || this.getData();
|
|
73
|
+
var options = this.props.options || this.getOptions(this.props.title);
|
|
74
|
+
return jsx(Bar, {
|
|
75
|
+
options: options,
|
|
76
|
+
data: data
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}]);
|
|
80
|
+
}(Component);
|
|
81
|
+
|
|
82
|
+
export { HorizontalBarChart, HorizontalBarChart as default };
|
|
83
|
+
//# sourceMappingURL=HorizontalBarChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HorizontalBarChart.js","sources":["../../../src/Components/Charts/HorizontalBarChart.tsx"],"sourcesContent":["import React, { Component } from 'react'\r\nimport {\r\n Chart as ChartJS,\r\n CategoryScale,\r\n LinearScale,\r\n BarElement,\r\n Title,\r\n Tooltip,\r\n Legend,\r\n ChartData,\r\n ChartOptions,\r\n} from 'chart.js'\r\nimport { Bar } from 'react-chartjs-2'\r\nimport { faker } from '@faker-js/faker'\r\n\r\nChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend)\r\n\r\nconst labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July']\r\n\r\ninterface IProps {\r\n data?: ChartData<'bar', number[], string>\r\n options?: ChartOptions<'bar'>\r\n title?: string\r\n}\r\nexport class HorizontalBarChart extends Component<IProps> {\r\n getOptions = (title?: string) => ({\r\n indexAxis: 'y' as const,\r\n elements: { bar: { borderWidth: 2 } },\r\n responsive: true,\r\n plugins: {\r\n legend: { position: 'right' as const },\r\n title: { display: true, text: title || 'Horizontal Bar Chart' },\r\n },\r\n })\r\n\r\n getData = (unitName: string = 'Unit') => {\r\n const data = labels.map((e) => ({ label: e, value: faker.datatype.number({ min: 0, max: 1000 }) }))\r\n const sortData = data.sort((a, b) => b.value - a.value)\r\n return {\r\n labels: sortData.map((e) => e.label),\r\n datasets: [\r\n {\r\n label: unitName,\r\n data: sortData.map((e) => e.value),\r\n borderColor: 'rgb(255, 99, 133, 0.6)',\r\n backgroundColor: 'rgba(255, 99, 133, 0.3)',\r\n },\r\n ],\r\n }\r\n }\r\n\r\n render() {\r\n const data = this.props.data || this.getData()\r\n const options: ChartOptions<'bar'> = this.props.options || this.getOptions(this.props.title)\r\n return <Bar options={options} data={data} />\r\n }\r\n}\r\nexport default HorizontalBarChart\r\n"],"names":["ChartJS","register","CategoryScale","LinearScale","BarElement","Title","Tooltip","Legend","labels","HorizontalBarChart","_Component","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","title","indexAxis","elements","bar","borderWidth","responsive","plugins","legend","position","display","text","unitName","undefined","data","map","e","label","value","faker","datatype","number","min","max","sortData","sort","a","b","datasets","borderColor","backgroundColor","_inherits","_createClass","key","render","props","getData","options","getOptions","_jsx","Bar","Component"],"mappings":";;;;;;;AAeAA,KAAO,C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AACqB,KAAK,CAACrB,IAAI,IAAI,IAAI,CAACsB,OAAO,EAAE;AAC9C,MAAA,IAAMC,OAAO,GAAwB,IAAI,CAACF,KAAK,CAACE,OAAO,IAAI,IAAI,CAACC,UAAU,CAAC,IAAI,CAACH,KAAK,CAAClC,KAAK,CAAC;MAC5F,OAAOsC,GAAA,CAACC,GAAG,EAAA;AAACH,QAAAA,OAAO,EAAEA,OAAO;AAAEvB,QAAAA,IAAI,EAAEA;AAAI,OAAA,CAAI;AAC9C;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA,CA/BqC2B,SAAiB;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ChartData } from 'chart.js';
|
|
3
|
+
import { ChartOptions } from 'chart.js';
|
|
4
|
+
export declare const options: ChartOptions<'line'>;
|
|
5
|
+
export declare const monthLabels: string[];
|
|
6
|
+
export declare const data: {
|
|
7
|
+
labels: string[];
|
|
8
|
+
datasets: {
|
|
9
|
+
label: string;
|
|
10
|
+
data: number[];
|
|
11
|
+
backgroundColor: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
interface LineChartProps {
|
|
15
|
+
width?: number | string;
|
|
16
|
+
height?: number | string;
|
|
17
|
+
data: ChartData<'line', number[], string>;
|
|
18
|
+
options?: ChartOptions<'line'>;
|
|
19
|
+
}
|
|
20
|
+
export declare const LineChart: FC<LineChartProps>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Chart, CategoryScale, LinearScale, PointElement, LineElement, Tooltip, Filler, Legend } from 'chart.js';
|
|
5
|
+
import { Line } from 'react-chartjs-2';
|
|
6
|
+
import { faker } from '@faker-js/faker';
|
|
7
|
+
import { mergeDeep } from '../Helper/index.js';
|
|
8
|
+
|
|
9
|
+
var _excluded = ["data", "options"];
|
|
10
|
+
Chart.register(CategoryScale, LinearScale, PointElement, LineElement,
|
|
11
|
+
// Title,
|
|
12
|
+
Tooltip, Filler, Legend, {
|
|
13
|
+
id: 'uniqueid5',
|
|
14
|
+
afterDraw: function afterDraw(chart, easing) {
|
|
15
|
+
var _chart$tooltip$getAct, _chart$tooltip;
|
|
16
|
+
var activePoints = (_chart$tooltip$getAct = (_chart$tooltip = chart.tooltip) === null || _chart$tooltip === void 0 ? void 0 : _chart$tooltip.getActiveElements()) !== null && _chart$tooltip$getAct !== void 0 ? _chart$tooltip$getAct : [];
|
|
17
|
+
if (activePoints.length) {
|
|
18
|
+
var _chart$scales$y, _chart$scales$y2;
|
|
19
|
+
var activePoint = activePoints[0];
|
|
20
|
+
var ctx = chart.ctx;
|
|
21
|
+
var x = activePoint.element.x;
|
|
22
|
+
var topY = (_chart$scales$y = chart.scales.y) === null || _chart$scales$y === void 0 ? void 0 : _chart$scales$y.top;
|
|
23
|
+
var bottomY = (_chart$scales$y2 = chart.scales.y) === null || _chart$scales$y2 === void 0 ? void 0 : _chart$scales$y2.bottom;
|
|
24
|
+
ctx.save();
|
|
25
|
+
ctx.beginPath();
|
|
26
|
+
ctx.moveTo(x, topY);
|
|
27
|
+
ctx.lineTo(x, bottomY);
|
|
28
|
+
ctx.lineWidth = 1;
|
|
29
|
+
ctx.strokeStyle = '#a5b4c3';
|
|
30
|
+
ctx.stroke();
|
|
31
|
+
ctx.restore();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
var options = {
|
|
36
|
+
responsive: true,
|
|
37
|
+
maintainAspectRatio: false,
|
|
38
|
+
interaction: {
|
|
39
|
+
mode: 'index',
|
|
40
|
+
intersect: false
|
|
41
|
+
},
|
|
42
|
+
// elements: {
|
|
43
|
+
// line: {
|
|
44
|
+
// tension: 0.1 // smooth lines,
|
|
45
|
+
// },
|
|
46
|
+
// },
|
|
47
|
+
hover: {
|
|
48
|
+
intersect: false
|
|
49
|
+
},
|
|
50
|
+
plugins: {
|
|
51
|
+
legend: {
|
|
52
|
+
position: 'top'
|
|
53
|
+
}
|
|
54
|
+
// title: {
|
|
55
|
+
// display: true,
|
|
56
|
+
// text: 'Chart.js Bar Chart',
|
|
57
|
+
// },
|
|
58
|
+
// tooltip: {
|
|
59
|
+
// callbacks: {
|
|
60
|
+
// label: function (context) {
|
|
61
|
+
// let label = context.label || context.dataset.label || '';
|
|
62
|
+
// if (label) {
|
|
63
|
+
// label += ': ';
|
|
64
|
+
// }
|
|
65
|
+
// if (context.parsed.y !== null) {
|
|
66
|
+
// label += FormatterUSD().format(context.parsed.y);
|
|
67
|
+
// }
|
|
68
|
+
// return label;
|
|
69
|
+
// }
|
|
70
|
+
// }
|
|
71
|
+
// },
|
|
72
|
+
},
|
|
73
|
+
scales: {
|
|
74
|
+
// "yAxes": {
|
|
75
|
+
// ticks: {
|
|
76
|
+
// callback: function (value, index, values) {
|
|
77
|
+
// return FormatterUSD().format(value as number)
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
x: {
|
|
82
|
+
ticks: {
|
|
83
|
+
// For a category axis, the val is the index so the lookup via getLabelForValue is needed
|
|
84
|
+
callback: function callback(val, index, ticks) {
|
|
85
|
+
var amount = Math.floor(ticks.length / 6);
|
|
86
|
+
// Hide every amount tick label
|
|
87
|
+
return index % amount === 0 ? typeof val === 'string' ? val : this.getLabelForValue(val) : null;
|
|
88
|
+
},
|
|
89
|
+
maxRotation: 0,
|
|
90
|
+
align: 'inner'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var monthLabels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
96
|
+
var data = {
|
|
97
|
+
labels: monthLabels,
|
|
98
|
+
datasets: [{
|
|
99
|
+
label: 'Dataset 1',
|
|
100
|
+
data: monthLabels.map(function () {
|
|
101
|
+
return faker.datatype.number({
|
|
102
|
+
min: 0,
|
|
103
|
+
max: 1000
|
|
104
|
+
});
|
|
105
|
+
}),
|
|
106
|
+
backgroundColor: 'rgba(255, 99, 132, 0.5)'
|
|
107
|
+
}, {
|
|
108
|
+
label: 'Dataset 2',
|
|
109
|
+
data: monthLabels.map(function () {
|
|
110
|
+
return faker.datatype.number({
|
|
111
|
+
min: 0,
|
|
112
|
+
max: 1000
|
|
113
|
+
});
|
|
114
|
+
}),
|
|
115
|
+
backgroundColor: 'rgba(53, 162, 235, 0.5)'
|
|
116
|
+
}]
|
|
117
|
+
};
|
|
118
|
+
var LineChart = function LineChart(props) {
|
|
119
|
+
var data = props.data,
|
|
120
|
+
optionProps = props.options,
|
|
121
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
122
|
+
var _useState = useState(mergeDeep({}, options, optionProps !== null && optionProps !== void 0 ? optionProps : {})),
|
|
123
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
124
|
+
opt = _useState2[0];
|
|
125
|
+
_useState2[1];
|
|
126
|
+
return jsx(Line, _objectSpread2({
|
|
127
|
+
options: opt,
|
|
128
|
+
data: data
|
|
129
|
+
}, other));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export { LineChart, data, monthLabels, options };
|
|
133
|
+
//# sourceMappingURL=LineChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LineChart.js","sources":["../../../src/Components/Charts/LineChart.tsx"],"sourcesContent":["import React, { FC, useState } from 'react'\r\nimport { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Tooltip, Legend, ChartData, Filler } from 'chart.js'\r\nimport { Line } from 'react-chartjs-2'\r\nimport { ChartOptions } from 'chart.js'\r\nimport { faker } from '@faker-js/faker'\r\nimport { mergeDeep } from '../Helper'\r\n\r\nChartJS.register(\r\n CategoryScale,\r\n LinearScale,\r\n PointElement,\r\n LineElement,\r\n // Title,\r\n Tooltip,\r\n Filler,\r\n Legend,\r\n {\r\n id: 'uniqueid5', //typescript crashes without id,\r\n afterDraw: (chart, easing) => {\r\n const activePoints = chart.tooltip?.getActiveElements() ?? []\r\n if (activePoints.length) {\r\n const activePoint = activePoints[0]\r\n const ctx = chart.ctx\r\n const x = activePoint.element.x\r\n const topY = chart.scales.y?.top\r\n const bottomY = chart.scales.y?.bottom\r\n ctx.save()\r\n ctx.beginPath()\r\n ctx.moveTo(x, topY)\r\n ctx.lineTo(x, bottomY)\r\n ctx.lineWidth = 1\r\n ctx.strokeStyle = '#a5b4c3'\r\n ctx.stroke()\r\n ctx.restore()\r\n }\r\n }\r\n }\r\n)\r\n\r\nexport const options: ChartOptions<'line'> = {\r\n responsive: true,\r\n maintainAspectRatio: false,\r\n interaction: {\r\n mode: 'index',\r\n intersect: false\r\n },\r\n // elements: {\r\n // line: {\r\n // tension: 0.1 // smooth lines,\r\n // },\r\n // },\r\n hover: {\r\n intersect: false\r\n },\r\n plugins: {\r\n legend: {\r\n position: 'top' as const\r\n }\r\n // title: {\r\n // display: true,\r\n // text: 'Chart.js Bar Chart',\r\n // },\r\n // tooltip: {\r\n // callbacks: {\r\n // label: function (context) {\r\n // let label = context.label || context.dataset.label || '';\r\n // if (label) {\r\n // label += ': ';\r\n // }\r\n // if (context.parsed.y !== null) {\r\n // label += FormatterUSD().format(context.parsed.y);\r\n // }\r\n // return label;\r\n // }\r\n // }\r\n // },\r\n },\r\n scales: {\r\n // \"yAxes\": {\r\n // ticks: {\r\n // callback: function (value, index, values) {\r\n // return FormatterUSD().format(value as number)\r\n // }\r\n // }\r\n // }\r\n x: {\r\n ticks: {\r\n // For a category axis, the val is the index so the lookup via getLabelForValue is needed\r\n callback: function (val, index, ticks) {\r\n const amount = Math.floor(ticks.length / 6)\r\n // Hide every amount tick label\r\n return index % amount === 0 ? (typeof val === 'string' ? val : this.getLabelForValue(val)) : null\r\n },\r\n maxRotation: 0,\r\n align: 'inner'\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport const monthLabels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\r\n\r\nexport const data = {\r\n labels: monthLabels,\r\n datasets: [\r\n {\r\n label: 'Dataset 1',\r\n data: monthLabels.map(() => faker.datatype.number({ min: 0, max: 1000 })),\r\n backgroundColor: 'rgba(255, 99, 132, 0.5)'\r\n },\r\n {\r\n label: 'Dataset 2',\r\n data: monthLabels.map(() => faker.datatype.number({ min: 0, max: 1000 })),\r\n backgroundColor: 'rgba(53, 162, 235, 0.5)'\r\n }\r\n ]\r\n}\r\n\r\ninterface LineChartProps {\r\n width?: number | string\r\n height?: number | string\r\n data: ChartData<'line', number[], string>\r\n options?: ChartOptions<'line'>\r\n}\r\nexport const LineChart: FC<LineChartProps> = (props) => {\r\n const { data, options: optionProps, ...other } = props\r\n const [opt, setOpt] = useState(mergeDeep<ChartOptions<'line'>>({}, options, optionProps ?? {}))\r\n return <Line options={opt} data={data} {...other} />\r\n}\r\n"],"names":["ChartJS","register","CategoryScale","LinearScale","PointElement","LineElement","Tooltip","Filler","Legend","id","afterDraw","chart","easing","_chart$tooltip$getAct","_chart$tooltip","activePoints","tooltip","getActiveElements","length","_chart$scales$y","_chart$scales$y2","activePoint","ctx","x","element","topY","scales","y","top","bottomY","bottom","save","beginPath","moveTo","lineTo","lineWidth","strokeStyle","stroke","restore","options","responsive","maintainAspectRatio","interaction","mode","intersect","hover","plugins","legend","position","ticks","callback","val","index","amount","Math","floor","getLabelForValue","maxRotation","align","monthLabels","data","labels","datasets","label","map","faker","datatype","number","min","max","backgroundColor","LineChart","props","optionProps","other","_objectWithoutProperties","_excluded","_useState","useState","mergeDeep","_useState2","_slicedToArray","opt","setOpt","_jsx","Line","_objectSpread"],"mappings":";;;;;;;;;AAOAA,KAAO,CAACC,QA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,EAAAC,cAAA,CAAA;AAAC/C,IAAAA,OAAO,EAAE2C,GAAG;AAAEtB,IAAAA,IAAI,EAAEA;GAAUc,EAAAA,KAAK,EAAI;AACtD;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component, FC } from 'react';
|
|
2
|
+
import { ChartData } from 'chart.js';
|
|
3
|
+
import { IChartDataItem } from './type';
|
|
4
|
+
interface PieChartProps {
|
|
5
|
+
width?: number | string;
|
|
6
|
+
height?: number | string;
|
|
7
|
+
data: ChartData<'pie', number[], string>;
|
|
8
|
+
disableTooltip?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const PieChartV2: FC<PieChartProps>;
|
|
11
|
+
interface IProps {
|
|
12
|
+
data?: IChartDataItem[];
|
|
13
|
+
}
|
|
14
|
+
export declare class PieChart extends Component<IProps> {
|
|
15
|
+
static defaultProps: {
|
|
16
|
+
data: IChartDataItem[];
|
|
17
|
+
};
|
|
18
|
+
render(): JSX.Element;
|
|
19
|
+
}
|
|
20
|
+
export {};
|