@msrajawat298/do-graphs 1.0.0 → 1.0.2
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/README.md +1 -1
- package/dist/App.js +124 -124
- package/dist/App.test.js +8 -8
- package/dist/Components/Charts/Bar/Form.js +231 -231
- package/dist/Components/Charts/Bar/Format.js +43 -43
- package/dist/Components/Charts/Bar/index.js +106 -106
- package/dist/Components/Charts/DoughnutAndPie/Form.js +232 -232
- package/dist/Components/Charts/DoughnutAndPie/Format.js +52 -52
- package/dist/Components/Charts/DoughnutAndPie/index.js +106 -106
- package/dist/Components/Charts/DrawGraph.js +32 -32
- package/dist/Components/Charts/Line/Form.js +231 -231
- package/dist/Components/Charts/Line/Format.js +47 -47
- package/dist/Components/Charts/Line/index.js +106 -106
- package/dist/Components/Charts/MixedChart/index.js +107 -107
- package/dist/Components/Charts/Options.js +139 -139
- package/dist/Components/Charts/PolarArea/Form.js +225 -225
- package/dist/Components/Charts/PolarArea/Format.js +42 -42
- package/dist/Components/Charts/PolarArea/index.js +106 -106
- package/dist/Components/Charts/Progess/Form.js +107 -107
- package/dist/Components/Charts/Progess/index.js +119 -119
- package/dist/Components/Charts/Scatter/Form.js +225 -225
- package/dist/Components/Charts/Scatter/Format.js +45 -45
- package/dist/Components/Charts/Scatter/index.js +106 -106
- package/dist/Components/Charts/Table/Form.js +70 -70
- package/dist/Components/Charts/Table/Styles.js +27 -27
- package/dist/Components/Charts/Table/index.js +56 -56
- package/dist/Components/Common/CustomComponent/index.js +83 -83
- package/dist/Components/Common/Menu/DynamicMenu/List.js +43 -43
- package/dist/Components/Common/Menu/DynamicMenu/index.js +155 -155
- package/dist/Components/Common/Menu/index.js +24 -24
- package/dist/Components/Common/Model/Model.js +56 -56
- package/dist/Components/Common/MultipleSelectDropdown/index.js +124 -124
- package/dist/Components/Common/NotFound/index.js +19 -19
- package/dist/Components/Common/Title/Form.js +36 -36
- package/dist/Components/Common/Title/Styles.js +16 -16
- package/dist/Components/Common/Title/index.js +41 -41
- package/dist/Components/Common/Widget/index.js +407 -407
- package/dist/Pages/Dashboard/CreatePage.js +115 -115
- package/dist/Pages/Dashboard/index.js +150 -150
- package/dist/Pages/LayoutPages/index.js +143 -143
- package/dist/Pages/Layouts/index.js +52 -52
- package/dist/Services/Menu.js +58 -58
- package/dist/Services/Routing.js +80 -80
- package/dist/Utility/Contexts.js +20 -20
- package/dist/Utility/Main.js +368 -368
- package/dist/Utility/Routes.js +10 -10
- package/dist/index.js +15 -15
- package/dist/reportWebVitals.js +13 -13
- package/dist/setupTests.js +5 -5
- package/package.json +4 -3
- package/dist/Assets/Fonts/NotoSans-Bold.ttf +0 -0
- package/dist/Assets/Fonts/NotoSans-Medium.ttf +0 -0
- package/dist/Assets/Fonts/NotoSans-Regular.ttf +0 -0
- package/dist/Assets/Fonts/NotoSans-SemiBold.ttf +0 -0
- package/dist/Assets/Images/analytic-graph.png +0 -0
- package/dist/Assets/Images/bar-graph.png +0 -0
- package/dist/Assets/Images/bubble-chart.png +0 -0
- package/dist/Assets/Images/coding.png +0 -0
- package/dist/Assets/Images/doughnut.png +0 -0
- package/dist/Assets/Images/horizontal-bar-graph.png +0 -0
- package/dist/Assets/Images/line-chart.png +0 -0
- package/dist/Assets/Images/mixed-chart.png +0 -0
- package/dist/Assets/Images/pie-chart.png +0 -0
- package/dist/Assets/Images/polar-chart.png +0 -0
- package/dist/Assets/Images/progress-bar.png +0 -0
- package/dist/Assets/Images/scatter-graph.png +0 -0
- package/dist/Assets/Images/table.png +0 -0
- package/dist/Assets/Images/travel.png +0 -0
package/dist/Utility/Main.js
CHANGED
|
@@ -1,368 +1,368 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
-
if (ar || !(i in from)) {
|
|
40
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
-
ar[i] = from[i];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
-
};
|
|
46
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
47
|
-
import BarImage from '../Assets/Images/bar-graph.png';
|
|
48
|
-
import LineImage from '../Assets/Images/line-chart.png';
|
|
49
|
-
import HorizontalBarImage from '../Assets/Images/horizontal-bar-graph.png';
|
|
50
|
-
import MizedChartImage from '../Assets/Images/mixed-chart.png';
|
|
51
|
-
import DoughnutChartImage from '../Assets/Images/doughnut.png';
|
|
52
|
-
import PieChartImage from '../Assets/Images/pie-chart.png';
|
|
53
|
-
import PolarChartImage from '../Assets/Images/polar-chart.png';
|
|
54
|
-
import ScatterChartImage from '../Assets/Images/scatter-graph.png';
|
|
55
|
-
import TableChartImage from '../Assets/Images/table.png';
|
|
56
|
-
import ProgressChartImage from '../Assets/Images/progress-bar.png';
|
|
57
|
-
import Coding from '../Assets/Images/coding.png';
|
|
58
|
-
import Bar from '../Components/Charts/Bar';
|
|
59
|
-
import Line from '../Components/Charts/Line';
|
|
60
|
-
import MixedChart from '../Components/Charts/MixedChart';
|
|
61
|
-
import DoughnutAndPie from '../Components/Charts/DoughnutAndPie';
|
|
62
|
-
import PolarArea from '../Components/Charts/PolarArea';
|
|
63
|
-
import TableChart from '../Components/Charts/Table';
|
|
64
|
-
import Scatter from '../Components/Charts/Scatter';
|
|
65
|
-
import ProgressChart from '../Components/Charts/Progess';
|
|
66
|
-
import { toast } from 'react-toastify';
|
|
67
|
-
import CustomComponent from '../Components/Common/CustomComponent';
|
|
68
|
-
export var ChartTypes;
|
|
69
|
-
(function (ChartTypes) {
|
|
70
|
-
ChartTypes["BAR"] = "bar";
|
|
71
|
-
ChartTypes["LINE"] = "line";
|
|
72
|
-
ChartTypes["DOUGHNUT"] = "doughnut";
|
|
73
|
-
ChartTypes["PIE"] = "pie";
|
|
74
|
-
ChartTypes["BUBBLE"] = "bubble";
|
|
75
|
-
ChartTypes["POLAR"] = "polarArea";
|
|
76
|
-
ChartTypes["RADAR"] = "radar";
|
|
77
|
-
ChartTypes["SCATTER"] = "scatter";
|
|
78
|
-
ChartTypes["GEO"] = "choropleth";
|
|
79
|
-
ChartTypes["TABLE"] = "table";
|
|
80
|
-
ChartTypes["MIXED"] = "mixed";
|
|
81
|
-
ChartTypes["PROGRESS"] = "progress";
|
|
82
|
-
})(ChartTypes || (ChartTypes = {}));
|
|
83
|
-
export var GraphConfigs = {
|
|
84
|
-
POINT_FONT_SIZE: 10,
|
|
85
|
-
DEFAULT_BGCOLOR: ['#fd746c', '#ff9068'],
|
|
86
|
-
TICK_FONT_SIZE: 10,
|
|
87
|
-
FONT_FAMILY: "Noto Sans"
|
|
88
|
-
};
|
|
89
|
-
export var ModelTypes;
|
|
90
|
-
(function (ModelTypes) {
|
|
91
|
-
ModelTypes["CONFIGURE"] = "configure";
|
|
92
|
-
ModelTypes["FORM"] = "form";
|
|
93
|
-
ModelTypes["SIDE_FORM"] = "side_form";
|
|
94
|
-
})(ModelTypes || (ModelTypes = {}));
|
|
95
|
-
export var Modules;
|
|
96
|
-
(function (Modules) {
|
|
97
|
-
Modules["DASHBOARD"] = "dashboard";
|
|
98
|
-
Modules["MENU"] = "menu";
|
|
99
|
-
Modules["TITLE"] = "title";
|
|
100
|
-
})(Modules || (Modules = {}));
|
|
101
|
-
export var ChartCategories = [
|
|
102
|
-
{
|
|
103
|
-
id: 1,
|
|
104
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.BAR,
|
|
105
|
-
title: 'Bar',
|
|
106
|
-
image: BarImage
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
id: 2,
|
|
110
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.LINE,
|
|
111
|
-
title: 'Line',
|
|
112
|
-
image: LineImage
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
id: 3,
|
|
116
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.BAR,
|
|
117
|
-
title: 'Horizontal Bar',
|
|
118
|
-
image: HorizontalBarImage
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
id: 4,
|
|
122
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.LINE,
|
|
123
|
-
title: 'Mixed Chart',
|
|
124
|
-
image: MizedChartImage
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
id: 5,
|
|
128
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.DOUGHNUT,
|
|
129
|
-
title: 'Douhgnut',
|
|
130
|
-
image: DoughnutChartImage
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
id: 6,
|
|
134
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PIE,
|
|
135
|
-
title: 'Pie',
|
|
136
|
-
image: PieChartImage
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
id: 7,
|
|
140
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.POLAR,
|
|
141
|
-
title: 'Polar',
|
|
142
|
-
image: PolarChartImage
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
id: 8,
|
|
146
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.SCATTER,
|
|
147
|
-
title: 'Scatter',
|
|
148
|
-
image: ScatterChartImage
|
|
149
|
-
},
|
|
150
|
-
// {
|
|
151
|
-
// id: 9,
|
|
152
|
-
// name: ChartTypes?.GEO,
|
|
153
|
-
// title: 'Geography',
|
|
154
|
-
// image: GeogrpahyChartImage
|
|
155
|
-
// },
|
|
156
|
-
{
|
|
157
|
-
id: 10,
|
|
158
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.TABLE,
|
|
159
|
-
title: 'Table',
|
|
160
|
-
image: TableChartImage
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
id: 11,
|
|
164
|
-
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PROGRESS,
|
|
165
|
-
title: 'Progress',
|
|
166
|
-
image: ProgressChartImage
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
id: 12,
|
|
170
|
-
name: 'custom',
|
|
171
|
-
title: 'Custom',
|
|
172
|
-
image: Coding
|
|
173
|
-
}
|
|
174
|
-
];
|
|
175
|
-
export var storeLocal = function (key, value) {
|
|
176
|
-
return localStorage.setItem(key, value);
|
|
177
|
-
};
|
|
178
|
-
export var getLocal = function (key) {
|
|
179
|
-
return localStorage.getItem(key);
|
|
180
|
-
};
|
|
181
|
-
export var renderHtmlData = function (component, props) {
|
|
182
|
-
switch (component) {
|
|
183
|
-
case ChartTypes.BAR:
|
|
184
|
-
return _jsx(Bar, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
185
|
-
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.LINE:
|
|
186
|
-
return _jsx(Line, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
187
|
-
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.MIXED:
|
|
188
|
-
return _jsx(MixedChart, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
189
|
-
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.DOUGHNUT:
|
|
190
|
-
return _jsx(DoughnutAndPie, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, chart: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.DOUGHNUT, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
191
|
-
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PIE:
|
|
192
|
-
return _jsx(DoughnutAndPie, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, chart: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PIE, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
193
|
-
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.POLAR:
|
|
194
|
-
return _jsx(PolarArea, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
195
|
-
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.SCATTER:
|
|
196
|
-
return _jsx(Scatter, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
197
|
-
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.TABLE:
|
|
198
|
-
return _jsx(TableChart, { title: props === null || props === void 0 ? void 0 : props.title, tableData: props === null || props === void 0 ? void 0 : props.tableData, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
199
|
-
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PROGRESS:
|
|
200
|
-
return _jsx(ProgressChart, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
201
|
-
case 'custom':
|
|
202
|
-
return _jsx(CustomComponent, { isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, component: props === null || props === void 0 ? void 0 : props.component, layoutId: props === null || props === void 0 ? void 0 : props.id });
|
|
203
|
-
default:
|
|
204
|
-
return '';
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
export var APIRequestMethods;
|
|
208
|
-
(function (APIRequestMethods) {
|
|
209
|
-
APIRequestMethods["GET"] = "GET";
|
|
210
|
-
APIRequestMethods["POST"] = "POST";
|
|
211
|
-
APIRequestMethods["DELETE"] = "DELETE";
|
|
212
|
-
APIRequestMethods["PATCH"] = "PATCH";
|
|
213
|
-
APIRequestMethods["PUT"] = "PUT";
|
|
214
|
-
})(APIRequestMethods || (APIRequestMethods = {}));
|
|
215
|
-
export var fetchApi = function (apiCall, drawData, chart_type, modelEdit, chartOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
|
216
|
-
var config, res, result, i, colValues, j, arr, labels, j, maxArr, hasStateLegend, _loop_1, i, sumMaxArr, error_1;
|
|
217
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
218
|
-
return __generator(this, function (_y) {
|
|
219
|
-
switch (_y.label) {
|
|
220
|
-
case 0:
|
|
221
|
-
_y.trys.push([0, 5, , 6]);
|
|
222
|
-
if (!((apiCall === null || apiCall === void 0 ? void 0 : apiCall.display) && !modelEdit)) return [3 /*break*/, 4];
|
|
223
|
-
config = {
|
|
224
|
-
method: apiCall === null || apiCall === void 0 ? void 0 : apiCall.method,
|
|
225
|
-
headers: JSON.parse(apiCall === null || apiCall === void 0 ? void 0 : apiCall.headers)
|
|
226
|
-
};
|
|
227
|
-
if ((apiCall === null || apiCall === void 0 ? void 0 : apiCall.method) !== (APIRequestMethods === null || APIRequestMethods === void 0 ? void 0 : APIRequestMethods.GET)) {
|
|
228
|
-
config['body'] = apiCall === null || apiCall === void 0 ? void 0 : apiCall.body;
|
|
229
|
-
}
|
|
230
|
-
return [4 /*yield*/, fetch(apiCall === null || apiCall === void 0 ? void 0 : apiCall.uri, config)];
|
|
231
|
-
case 1:
|
|
232
|
-
res = _y.sent();
|
|
233
|
-
if (!(res === null || res === void 0 ? void 0 : res.ok)) return [3 /*break*/, 3];
|
|
234
|
-
return [4 /*yield*/, (res === null || res === void 0 ? void 0 : res.json())];
|
|
235
|
-
case 2:
|
|
236
|
-
result = _y.sent();
|
|
237
|
-
if (chart_type === (ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.TABLE)) {
|
|
238
|
-
for (i = 0; i < ((_a = result === null || result === void 0 ? void 0 : result.message) === null || _a === void 0 ? void 0 : _a.length); i++) {
|
|
239
|
-
colValues = [];
|
|
240
|
-
for (j = 0; j < ((_b = drawData === null || drawData === void 0 ? void 0 : drawData.columns) === null || _b === void 0 ? void 0 : _b.length); j++) {
|
|
241
|
-
colValues.push(((_d = (_c = result === null || result === void 0 ? void 0 : result.message) === null || _c === void 0 ? void 0 : _c[i]) === null || _d === void 0 ? void 0 : _d[(_e = drawData === null || drawData === void 0 ? void 0 : drawData.columns) === null || _e === void 0 ? void 0 : _e[j]]) || '');
|
|
242
|
-
}
|
|
243
|
-
drawData['rows'][i] = colValues;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
else if (chart_type === (ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PROGRESS)) {
|
|
247
|
-
arr = [];
|
|
248
|
-
labels = [];
|
|
249
|
-
for (j = 0; j < ((_f = result === null || result === void 0 ? void 0 : result.message) === null || _f === void 0 ? void 0 : _f.length); j++) {
|
|
250
|
-
arr.push((_h = (_g = result === null || result === void 0 ? void 0 : result.message) === null || _g === void 0 ? void 0 : _g[j]) === null || _h === void 0 ? void 0 : _h[apiCall === null || apiCall === void 0 ? void 0 : apiCall.yAxisField[0]]);
|
|
251
|
-
labels.push((_k = (_j = result === null || result === void 0 ? void 0 : result.message) === null || _j === void 0 ? void 0 : _j[j]) === null || _k === void 0 ? void 0 : _k[apiCall === null || apiCall === void 0 ? void 0 : apiCall.xAxisField[0]]);
|
|
252
|
-
}
|
|
253
|
-
drawData['datasets'] = arr;
|
|
254
|
-
drawData['labels'] = labels;
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
maxArr = [];
|
|
258
|
-
hasStateLegend = ['Per Capita Income(INR)', 'CPI (Ratio)', 'WPI (Ratio)', 'Per Capita Electricity Consumption (KWH)', 'Credit to Deposit Ratio', 'Overall Fish Production (Tons/Ha)', 'Total Egg Production (Mn.)', 'Poultry Meat Production (Mn. Tn.)', 'Total Milk Production (Mn. Tn.)', 'No. of AI Procedures Conducted in Sector', 'Manufacturing GSVA (INR Lakh Cr.)', 'GVA per Factory (INR Cr./Unit)', 'Overall Exports (INR Cr.)', 'No. of Operational Factories under ASI Frame', 'Increase in No. of MSMEs Registered on UDYAM Registration Portal', 'MSME credit as a % of GSDP (%)', 'Advances to MSME (INR Cr.)', 'Total Energy Consumption of Industries based on ASI (INR Thousand Cr.)', 'Percentage of Manufacturing to Total Working Population', 'Employment Generated under PMEGP (000s)', 'No. of establishments registered with EPFO', 'No. of members enrolled under EPFO in the State'];
|
|
259
|
-
_loop_1 = function (i) {
|
|
260
|
-
var arr = [];
|
|
261
|
-
var labels = [];
|
|
262
|
-
for (var j = 0; j < ((_m = result === null || result === void 0 ? void 0 : result.message) === null || _m === void 0 ? void 0 : _m.length); j++) {
|
|
263
|
-
arr.push(((_p = (_o = result === null || result === void 0 ? void 0 : result.message) === null || _o === void 0 ? void 0 : _o[j]) === null || _p === void 0 ? void 0 : _p[apiCall === null || apiCall === void 0 ? void 0 : apiCall.yAxisField[i]]) || 0);
|
|
264
|
-
labels.push((_r = (_q = result === null || result === void 0 ? void 0 : result.message) === null || _q === void 0 ? void 0 : _q[j]) === null || _r === void 0 ? void 0 : _r[apiCall === null || apiCall === void 0 ? void 0 : apiCall.xAxisField[0]]);
|
|
265
|
-
}
|
|
266
|
-
drawData['datasets'][i]['data'] = arr;
|
|
267
|
-
drawData['labels'] = labels;
|
|
268
|
-
drawData['datasets'][i]['datalabels']['formatter'] = function (value) {
|
|
269
|
-
var _a, _b;
|
|
270
|
-
return ((_a = drawData['datasets'][i]) === null || _a === void 0 ? void 0 : _a.addPointLabel) ? value + ((_b = drawData['datasets'][i]) === null || _b === void 0 ? void 0 : _b.addPointLabel) : value;
|
|
271
|
-
};
|
|
272
|
-
var parseBody = (apiCall === null || apiCall === void 0 ? void 0 : apiCall.body) ? JSON.parse(apiCall['body']) : null;
|
|
273
|
-
if ((_s = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _s === void 0 ? void 0 : _s.includes('India')) {
|
|
274
|
-
var getIndex = (_t = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _t === void 0 ? void 0 : _t.indexOf('India');
|
|
275
|
-
var removeElement = (_u = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _u === void 0 ? void 0 : _u.splice(getIndex, 1);
|
|
276
|
-
parseBody['state_array'] = __spreadArray(__spreadArray([], parseBody['state_array'], true), ['India'], false);
|
|
277
|
-
}
|
|
278
|
-
if ((_v = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _v === void 0 ? void 0 : _v.length) {
|
|
279
|
-
if (hasStateLegend === null || hasStateLegend === void 0 ? void 0 : hasStateLegend.includes(drawData === null || drawData === void 0 ? void 0 : drawData.title)) {
|
|
280
|
-
drawData['datasets'][i]['label'] = ((_w = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _w === void 0 ? void 0 : _w[i]) || 'NA';
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
var getMax = Math.max.apply(Math, arr);
|
|
284
|
-
maxArr === null || maxArr === void 0 ? void 0 : maxArr.push(getMax);
|
|
285
|
-
};
|
|
286
|
-
for (i = 0; i < ((_l = drawData === null || drawData === void 0 ? void 0 : drawData.datasets) === null || _l === void 0 ? void 0 : _l.length); i++) {
|
|
287
|
-
_loop_1(i);
|
|
288
|
-
}
|
|
289
|
-
sumMaxArr = maxArr === null || maxArr === void 0 ? void 0 : maxArr.reduce(function (a, b) { return a + b; }, 0);
|
|
290
|
-
if ((_x = [ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.MIXED, ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.BAR, ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.LINE]) === null || _x === void 0 ? void 0 : _x.includes(chart_type)) {
|
|
291
|
-
chartOptions['scales']['y']['max'] = sumMaxArr * 1.2;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return [2 /*return*/, drawData];
|
|
295
|
-
case 3:
|
|
296
|
-
if (!(res === null || res === void 0 ? void 0 : res.ok)) {
|
|
297
|
-
drawData['datasets'] = [];
|
|
298
|
-
drawData['labels'] = [];
|
|
299
|
-
}
|
|
300
|
-
_y.label = 4;
|
|
301
|
-
case 4: return [3 /*break*/, 6];
|
|
302
|
-
case 5:
|
|
303
|
-
error_1 = _y.sent();
|
|
304
|
-
toast.error(error_1 === null || error_1 === void 0 ? void 0 : error_1.toString());
|
|
305
|
-
return [3 /*break*/, 6];
|
|
306
|
-
case 6: return [2 /*return*/];
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
}); };
|
|
310
|
-
export var titleStyleConfig = function () {
|
|
311
|
-
return {
|
|
312
|
-
backgroundColor: '#fff',
|
|
313
|
-
color: '#000'
|
|
314
|
-
};
|
|
315
|
-
};
|
|
316
|
-
export var chartDrawData = function (props, layout, chartDatasets) {
|
|
317
|
-
var _a;
|
|
318
|
-
var getLayout = (_a = layout === null || layout === void 0 ? void 0 : layout.find(function (it) { return (it === null || it === void 0 ? void 0 : it.i) === (props === null || props === void 0 ? void 0 : props.layoutId); })) === null || _a === void 0 ? void 0 : _a.props;
|
|
319
|
-
var getStyles = getLayout === null || getLayout === void 0 ? void 0 : getLayout.styles;
|
|
320
|
-
var getUrl = getLayout === null || getLayout === void 0 ? void 0 : getLayout.url;
|
|
321
|
-
var getUrlTitle = getLayout === null || getLayout === void 0 ? void 0 : getLayout.urlTitle;
|
|
322
|
-
var getFilters = getLayout === null || getLayout === void 0 ? void 0 : getLayout.filters;
|
|
323
|
-
return {
|
|
324
|
-
title: props === null || props === void 0 ? void 0 : props.title,
|
|
325
|
-
labels: props === null || props === void 0 ? void 0 : props.labels,
|
|
326
|
-
datasets: chartDatasets,
|
|
327
|
-
styles: getStyles ? getStyles : titleStyleConfig(),
|
|
328
|
-
urlTitle: getUrlTitle ? getUrlTitle : '',
|
|
329
|
-
url: getUrl ? getUrl : '',
|
|
330
|
-
filters: getFilters || [],
|
|
331
|
-
apiCall: (props === null || props === void 0 ? void 0 : props.apiCall) ? props === null || props === void 0 ? void 0 : props.apiCall : {}
|
|
332
|
-
};
|
|
333
|
-
};
|
|
334
|
-
export var updateChartLayoutDetails = function (field, data, layout, layoutId) {
|
|
335
|
-
for (var i = 0; i < (layout === null || layout === void 0 ? void 0 : layout.length); i++) {
|
|
336
|
-
if (layout[i]['i'] === layoutId) {
|
|
337
|
-
if (field.includes('labels')) {
|
|
338
|
-
layout[i]['props']['labels'] = data['labels'];
|
|
339
|
-
}
|
|
340
|
-
if (field.includes('datasets')) {
|
|
341
|
-
layout[i]['props']['datasets'] = data['datasets'];
|
|
342
|
-
}
|
|
343
|
-
if (field.includes('options')) {
|
|
344
|
-
layout[i]['props']['chartOptions'] = data;
|
|
345
|
-
}
|
|
346
|
-
if (field.includes('title')) {
|
|
347
|
-
layout[i]['props']['title'] = data['title'];
|
|
348
|
-
}
|
|
349
|
-
if (field.includes('styles')) {
|
|
350
|
-
layout[i]['props']['styles'] = data['styles'];
|
|
351
|
-
}
|
|
352
|
-
if (field.includes('url')) {
|
|
353
|
-
layout[i]['props']['url'] = data['url'];
|
|
354
|
-
}
|
|
355
|
-
if (field.includes('filters')) {
|
|
356
|
-
layout[i]['props']['filters'] = data['filters'];
|
|
357
|
-
}
|
|
358
|
-
if (field.includes('apiCall')) {
|
|
359
|
-
layout[i]['props']['apiCall'] = data['apiCall'];
|
|
360
|
-
}
|
|
361
|
-
if (field.includes('urlTitle')) {
|
|
362
|
-
layout[i]['props']['urlTitle'] = data['urlTitle'];
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
return layout;
|
|
367
|
-
};
|
|
368
|
-
export var STORAGE_KEY = 'chartData';
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
46
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
47
|
+
import BarImage from '../Assets/Images/bar-graph.png';
|
|
48
|
+
import LineImage from '../Assets/Images/line-chart.png';
|
|
49
|
+
import HorizontalBarImage from '../Assets/Images/horizontal-bar-graph.png';
|
|
50
|
+
import MizedChartImage from '../Assets/Images/mixed-chart.png';
|
|
51
|
+
import DoughnutChartImage from '../Assets/Images/doughnut.png';
|
|
52
|
+
import PieChartImage from '../Assets/Images/pie-chart.png';
|
|
53
|
+
import PolarChartImage from '../Assets/Images/polar-chart.png';
|
|
54
|
+
import ScatterChartImage from '../Assets/Images/scatter-graph.png';
|
|
55
|
+
import TableChartImage from '../Assets/Images/table.png';
|
|
56
|
+
import ProgressChartImage from '../Assets/Images/progress-bar.png';
|
|
57
|
+
import Coding from '../Assets/Images/coding.png';
|
|
58
|
+
import Bar from '../Components/Charts/Bar';
|
|
59
|
+
import Line from '../Components/Charts/Line';
|
|
60
|
+
import MixedChart from '../Components/Charts/MixedChart';
|
|
61
|
+
import DoughnutAndPie from '../Components/Charts/DoughnutAndPie';
|
|
62
|
+
import PolarArea from '../Components/Charts/PolarArea';
|
|
63
|
+
import TableChart from '../Components/Charts/Table';
|
|
64
|
+
import Scatter from '../Components/Charts/Scatter';
|
|
65
|
+
import ProgressChart from '../Components/Charts/Progess';
|
|
66
|
+
import { toast } from 'react-toastify';
|
|
67
|
+
import CustomComponent from '../Components/Common/CustomComponent';
|
|
68
|
+
export var ChartTypes;
|
|
69
|
+
(function (ChartTypes) {
|
|
70
|
+
ChartTypes["BAR"] = "bar";
|
|
71
|
+
ChartTypes["LINE"] = "line";
|
|
72
|
+
ChartTypes["DOUGHNUT"] = "doughnut";
|
|
73
|
+
ChartTypes["PIE"] = "pie";
|
|
74
|
+
ChartTypes["BUBBLE"] = "bubble";
|
|
75
|
+
ChartTypes["POLAR"] = "polarArea";
|
|
76
|
+
ChartTypes["RADAR"] = "radar";
|
|
77
|
+
ChartTypes["SCATTER"] = "scatter";
|
|
78
|
+
ChartTypes["GEO"] = "choropleth";
|
|
79
|
+
ChartTypes["TABLE"] = "table";
|
|
80
|
+
ChartTypes["MIXED"] = "mixed";
|
|
81
|
+
ChartTypes["PROGRESS"] = "progress";
|
|
82
|
+
})(ChartTypes || (ChartTypes = {}));
|
|
83
|
+
export var GraphConfigs = {
|
|
84
|
+
POINT_FONT_SIZE: 10,
|
|
85
|
+
DEFAULT_BGCOLOR: ['#fd746c', '#ff9068'],
|
|
86
|
+
TICK_FONT_SIZE: 10,
|
|
87
|
+
FONT_FAMILY: "Noto Sans"
|
|
88
|
+
};
|
|
89
|
+
export var ModelTypes;
|
|
90
|
+
(function (ModelTypes) {
|
|
91
|
+
ModelTypes["CONFIGURE"] = "configure";
|
|
92
|
+
ModelTypes["FORM"] = "form";
|
|
93
|
+
ModelTypes["SIDE_FORM"] = "side_form";
|
|
94
|
+
})(ModelTypes || (ModelTypes = {}));
|
|
95
|
+
export var Modules;
|
|
96
|
+
(function (Modules) {
|
|
97
|
+
Modules["DASHBOARD"] = "dashboard";
|
|
98
|
+
Modules["MENU"] = "menu";
|
|
99
|
+
Modules["TITLE"] = "title";
|
|
100
|
+
})(Modules || (Modules = {}));
|
|
101
|
+
export var ChartCategories = [
|
|
102
|
+
{
|
|
103
|
+
id: 1,
|
|
104
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.BAR,
|
|
105
|
+
title: 'Bar',
|
|
106
|
+
image: BarImage
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 2,
|
|
110
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.LINE,
|
|
111
|
+
title: 'Line',
|
|
112
|
+
image: LineImage
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: 3,
|
|
116
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.BAR,
|
|
117
|
+
title: 'Horizontal Bar',
|
|
118
|
+
image: HorizontalBarImage
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: 4,
|
|
122
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.LINE,
|
|
123
|
+
title: 'Mixed Chart',
|
|
124
|
+
image: MizedChartImage
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: 5,
|
|
128
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.DOUGHNUT,
|
|
129
|
+
title: 'Douhgnut',
|
|
130
|
+
image: DoughnutChartImage
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: 6,
|
|
134
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PIE,
|
|
135
|
+
title: 'Pie',
|
|
136
|
+
image: PieChartImage
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: 7,
|
|
140
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.POLAR,
|
|
141
|
+
title: 'Polar',
|
|
142
|
+
image: PolarChartImage
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: 8,
|
|
146
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.SCATTER,
|
|
147
|
+
title: 'Scatter',
|
|
148
|
+
image: ScatterChartImage
|
|
149
|
+
},
|
|
150
|
+
// {
|
|
151
|
+
// id: 9,
|
|
152
|
+
// name: ChartTypes?.GEO,
|
|
153
|
+
// title: 'Geography',
|
|
154
|
+
// image: GeogrpahyChartImage
|
|
155
|
+
// },
|
|
156
|
+
{
|
|
157
|
+
id: 10,
|
|
158
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.TABLE,
|
|
159
|
+
title: 'Table',
|
|
160
|
+
image: TableChartImage
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: 11,
|
|
164
|
+
name: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PROGRESS,
|
|
165
|
+
title: 'Progress',
|
|
166
|
+
image: ProgressChartImage
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: 12,
|
|
170
|
+
name: 'custom',
|
|
171
|
+
title: 'Custom',
|
|
172
|
+
image: Coding
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
export var storeLocal = function (key, value) {
|
|
176
|
+
return localStorage.setItem(key, value);
|
|
177
|
+
};
|
|
178
|
+
export var getLocal = function (key) {
|
|
179
|
+
return localStorage.getItem(key);
|
|
180
|
+
};
|
|
181
|
+
export var renderHtmlData = function (component, props) {
|
|
182
|
+
switch (component) {
|
|
183
|
+
case ChartTypes.BAR:
|
|
184
|
+
return _jsx(Bar, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
185
|
+
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.LINE:
|
|
186
|
+
return _jsx(Line, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
187
|
+
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.MIXED:
|
|
188
|
+
return _jsx(MixedChart, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
189
|
+
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.DOUGHNUT:
|
|
190
|
+
return _jsx(DoughnutAndPie, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, chart: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.DOUGHNUT, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
191
|
+
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PIE:
|
|
192
|
+
return _jsx(DoughnutAndPie, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, chart: ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PIE, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
193
|
+
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.POLAR:
|
|
194
|
+
return _jsx(PolarArea, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
195
|
+
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.SCATTER:
|
|
196
|
+
return _jsx(Scatter, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
197
|
+
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.TABLE:
|
|
198
|
+
return _jsx(TableChart, { title: props === null || props === void 0 ? void 0 : props.title, tableData: props === null || props === void 0 ? void 0 : props.tableData, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, chartOptions: props === null || props === void 0 ? void 0 : props.chartOptions, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
199
|
+
case ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PROGRESS:
|
|
200
|
+
return _jsx(ProgressChart, { title: props === null || props === void 0 ? void 0 : props.title, labels: props === null || props === void 0 ? void 0 : props.labels, datasets: props === null || props === void 0 ? void 0 : props.datasets, isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, layoutId: props === null || props === void 0 ? void 0 : props.id, apiCall: props === null || props === void 0 ? void 0 : props.apiCall });
|
|
201
|
+
case 'custom':
|
|
202
|
+
return _jsx(CustomComponent, { isConfigEdit: props === null || props === void 0 ? void 0 : props.isConfigEdit, component: props === null || props === void 0 ? void 0 : props.component, layoutId: props === null || props === void 0 ? void 0 : props.id });
|
|
203
|
+
default:
|
|
204
|
+
return '';
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export var APIRequestMethods;
|
|
208
|
+
(function (APIRequestMethods) {
|
|
209
|
+
APIRequestMethods["GET"] = "GET";
|
|
210
|
+
APIRequestMethods["POST"] = "POST";
|
|
211
|
+
APIRequestMethods["DELETE"] = "DELETE";
|
|
212
|
+
APIRequestMethods["PATCH"] = "PATCH";
|
|
213
|
+
APIRequestMethods["PUT"] = "PUT";
|
|
214
|
+
})(APIRequestMethods || (APIRequestMethods = {}));
|
|
215
|
+
export var fetchApi = function (apiCall, drawData, chart_type, modelEdit, chartOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
|
216
|
+
var config, res, result, i, colValues, j, arr, labels, j, maxArr, hasStateLegend, _loop_1, i, sumMaxArr, error_1;
|
|
217
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
218
|
+
return __generator(this, function (_y) {
|
|
219
|
+
switch (_y.label) {
|
|
220
|
+
case 0:
|
|
221
|
+
_y.trys.push([0, 5, , 6]);
|
|
222
|
+
if (!((apiCall === null || apiCall === void 0 ? void 0 : apiCall.display) && !modelEdit)) return [3 /*break*/, 4];
|
|
223
|
+
config = {
|
|
224
|
+
method: apiCall === null || apiCall === void 0 ? void 0 : apiCall.method,
|
|
225
|
+
headers: JSON.parse(apiCall === null || apiCall === void 0 ? void 0 : apiCall.headers)
|
|
226
|
+
};
|
|
227
|
+
if ((apiCall === null || apiCall === void 0 ? void 0 : apiCall.method) !== (APIRequestMethods === null || APIRequestMethods === void 0 ? void 0 : APIRequestMethods.GET)) {
|
|
228
|
+
config['body'] = apiCall === null || apiCall === void 0 ? void 0 : apiCall.body;
|
|
229
|
+
}
|
|
230
|
+
return [4 /*yield*/, fetch(apiCall === null || apiCall === void 0 ? void 0 : apiCall.uri, config)];
|
|
231
|
+
case 1:
|
|
232
|
+
res = _y.sent();
|
|
233
|
+
if (!(res === null || res === void 0 ? void 0 : res.ok)) return [3 /*break*/, 3];
|
|
234
|
+
return [4 /*yield*/, (res === null || res === void 0 ? void 0 : res.json())];
|
|
235
|
+
case 2:
|
|
236
|
+
result = _y.sent();
|
|
237
|
+
if (chart_type === (ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.TABLE)) {
|
|
238
|
+
for (i = 0; i < ((_a = result === null || result === void 0 ? void 0 : result.message) === null || _a === void 0 ? void 0 : _a.length); i++) {
|
|
239
|
+
colValues = [];
|
|
240
|
+
for (j = 0; j < ((_b = drawData === null || drawData === void 0 ? void 0 : drawData.columns) === null || _b === void 0 ? void 0 : _b.length); j++) {
|
|
241
|
+
colValues.push(((_d = (_c = result === null || result === void 0 ? void 0 : result.message) === null || _c === void 0 ? void 0 : _c[i]) === null || _d === void 0 ? void 0 : _d[(_e = drawData === null || drawData === void 0 ? void 0 : drawData.columns) === null || _e === void 0 ? void 0 : _e[j]]) || '');
|
|
242
|
+
}
|
|
243
|
+
drawData['rows'][i] = colValues;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else if (chart_type === (ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.PROGRESS)) {
|
|
247
|
+
arr = [];
|
|
248
|
+
labels = [];
|
|
249
|
+
for (j = 0; j < ((_f = result === null || result === void 0 ? void 0 : result.message) === null || _f === void 0 ? void 0 : _f.length); j++) {
|
|
250
|
+
arr.push((_h = (_g = result === null || result === void 0 ? void 0 : result.message) === null || _g === void 0 ? void 0 : _g[j]) === null || _h === void 0 ? void 0 : _h[apiCall === null || apiCall === void 0 ? void 0 : apiCall.yAxisField[0]]);
|
|
251
|
+
labels.push((_k = (_j = result === null || result === void 0 ? void 0 : result.message) === null || _j === void 0 ? void 0 : _j[j]) === null || _k === void 0 ? void 0 : _k[apiCall === null || apiCall === void 0 ? void 0 : apiCall.xAxisField[0]]);
|
|
252
|
+
}
|
|
253
|
+
drawData['datasets'] = arr;
|
|
254
|
+
drawData['labels'] = labels;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
maxArr = [];
|
|
258
|
+
hasStateLegend = ['Per Capita Income(INR)', 'CPI (Ratio)', 'WPI (Ratio)', 'Per Capita Electricity Consumption (KWH)', 'Credit to Deposit Ratio', 'Overall Fish Production (Tons/Ha)', 'Total Egg Production (Mn.)', 'Poultry Meat Production (Mn. Tn.)', 'Total Milk Production (Mn. Tn.)', 'No. of AI Procedures Conducted in Sector', 'Manufacturing GSVA (INR Lakh Cr.)', 'GVA per Factory (INR Cr./Unit)', 'Overall Exports (INR Cr.)', 'No. of Operational Factories under ASI Frame', 'Increase in No. of MSMEs Registered on UDYAM Registration Portal', 'MSME credit as a % of GSDP (%)', 'Advances to MSME (INR Cr.)', 'Total Energy Consumption of Industries based on ASI (INR Thousand Cr.)', 'Percentage of Manufacturing to Total Working Population', 'Employment Generated under PMEGP (000s)', 'No. of establishments registered with EPFO', 'No. of members enrolled under EPFO in the State', 'IIP (Index)'];
|
|
259
|
+
_loop_1 = function (i) {
|
|
260
|
+
var arr = [];
|
|
261
|
+
var labels = [];
|
|
262
|
+
for (var j = 0; j < ((_m = result === null || result === void 0 ? void 0 : result.message) === null || _m === void 0 ? void 0 : _m.length); j++) {
|
|
263
|
+
arr.push(((_p = (_o = result === null || result === void 0 ? void 0 : result.message) === null || _o === void 0 ? void 0 : _o[j]) === null || _p === void 0 ? void 0 : _p[apiCall === null || apiCall === void 0 ? void 0 : apiCall.yAxisField[i]]) || 0);
|
|
264
|
+
labels.push((_r = (_q = result === null || result === void 0 ? void 0 : result.message) === null || _q === void 0 ? void 0 : _q[j]) === null || _r === void 0 ? void 0 : _r[apiCall === null || apiCall === void 0 ? void 0 : apiCall.xAxisField[0]]);
|
|
265
|
+
}
|
|
266
|
+
drawData['datasets'][i]['data'] = arr;
|
|
267
|
+
drawData['labels'] = labels;
|
|
268
|
+
drawData['datasets'][i]['datalabels']['formatter'] = function (value) {
|
|
269
|
+
var _a, _b;
|
|
270
|
+
return ((_a = drawData['datasets'][i]) === null || _a === void 0 ? void 0 : _a.addPointLabel) ? value + ((_b = drawData['datasets'][i]) === null || _b === void 0 ? void 0 : _b.addPointLabel) : value;
|
|
271
|
+
};
|
|
272
|
+
var parseBody = (apiCall === null || apiCall === void 0 ? void 0 : apiCall.body) ? JSON.parse(apiCall['body']) : null;
|
|
273
|
+
if ((_s = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _s === void 0 ? void 0 : _s.includes('India')) {
|
|
274
|
+
var getIndex = (_t = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _t === void 0 ? void 0 : _t.indexOf('India');
|
|
275
|
+
var removeElement = (_u = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _u === void 0 ? void 0 : _u.splice(getIndex, 1);
|
|
276
|
+
parseBody['state_array'] = __spreadArray(__spreadArray([], parseBody['state_array'], true), ['India'], false);
|
|
277
|
+
}
|
|
278
|
+
if ((_v = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _v === void 0 ? void 0 : _v.length) {
|
|
279
|
+
if (hasStateLegend === null || hasStateLegend === void 0 ? void 0 : hasStateLegend.includes(drawData === null || drawData === void 0 ? void 0 : drawData.title)) {
|
|
280
|
+
drawData['datasets'][i]['label'] = ((_w = parseBody === null || parseBody === void 0 ? void 0 : parseBody.state_array) === null || _w === void 0 ? void 0 : _w[i]) || 'NA';
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
var getMax = Math.max.apply(Math, arr);
|
|
284
|
+
maxArr === null || maxArr === void 0 ? void 0 : maxArr.push(getMax);
|
|
285
|
+
};
|
|
286
|
+
for (i = 0; i < ((_l = drawData === null || drawData === void 0 ? void 0 : drawData.datasets) === null || _l === void 0 ? void 0 : _l.length); i++) {
|
|
287
|
+
_loop_1(i);
|
|
288
|
+
}
|
|
289
|
+
sumMaxArr = maxArr === null || maxArr === void 0 ? void 0 : maxArr.reduce(function (a, b) { return a + b; }, 0);
|
|
290
|
+
if ((_x = [ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.MIXED, ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.BAR, ChartTypes === null || ChartTypes === void 0 ? void 0 : ChartTypes.LINE]) === null || _x === void 0 ? void 0 : _x.includes(chart_type)) {
|
|
291
|
+
chartOptions['scales']['y']['max'] = sumMaxArr * 1.2;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return [2 /*return*/, drawData];
|
|
295
|
+
case 3:
|
|
296
|
+
if (!(res === null || res === void 0 ? void 0 : res.ok)) {
|
|
297
|
+
drawData['datasets'] = [];
|
|
298
|
+
drawData['labels'] = [];
|
|
299
|
+
}
|
|
300
|
+
_y.label = 4;
|
|
301
|
+
case 4: return [3 /*break*/, 6];
|
|
302
|
+
case 5:
|
|
303
|
+
error_1 = _y.sent();
|
|
304
|
+
toast.error(error_1 === null || error_1 === void 0 ? void 0 : error_1.toString());
|
|
305
|
+
return [3 /*break*/, 6];
|
|
306
|
+
case 6: return [2 /*return*/];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}); };
|
|
310
|
+
export var titleStyleConfig = function () {
|
|
311
|
+
return {
|
|
312
|
+
backgroundColor: '#fff',
|
|
313
|
+
color: '#000'
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
export var chartDrawData = function (props, layout, chartDatasets) {
|
|
317
|
+
var _a;
|
|
318
|
+
var getLayout = (_a = layout === null || layout === void 0 ? void 0 : layout.find(function (it) { return (it === null || it === void 0 ? void 0 : it.i) === (props === null || props === void 0 ? void 0 : props.layoutId); })) === null || _a === void 0 ? void 0 : _a.props;
|
|
319
|
+
var getStyles = getLayout === null || getLayout === void 0 ? void 0 : getLayout.styles;
|
|
320
|
+
var getUrl = getLayout === null || getLayout === void 0 ? void 0 : getLayout.url;
|
|
321
|
+
var getUrlTitle = getLayout === null || getLayout === void 0 ? void 0 : getLayout.urlTitle;
|
|
322
|
+
var getFilters = getLayout === null || getLayout === void 0 ? void 0 : getLayout.filters;
|
|
323
|
+
return {
|
|
324
|
+
title: props === null || props === void 0 ? void 0 : props.title,
|
|
325
|
+
labels: props === null || props === void 0 ? void 0 : props.labels,
|
|
326
|
+
datasets: chartDatasets,
|
|
327
|
+
styles: getStyles ? getStyles : titleStyleConfig(),
|
|
328
|
+
urlTitle: getUrlTitle ? getUrlTitle : '',
|
|
329
|
+
url: getUrl ? getUrl : '',
|
|
330
|
+
filters: getFilters || [],
|
|
331
|
+
apiCall: (props === null || props === void 0 ? void 0 : props.apiCall) ? props === null || props === void 0 ? void 0 : props.apiCall : {}
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
export var updateChartLayoutDetails = function (field, data, layout, layoutId) {
|
|
335
|
+
for (var i = 0; i < (layout === null || layout === void 0 ? void 0 : layout.length); i++) {
|
|
336
|
+
if (layout[i]['i'] === layoutId) {
|
|
337
|
+
if (field.includes('labels')) {
|
|
338
|
+
layout[i]['props']['labels'] = data['labels'];
|
|
339
|
+
}
|
|
340
|
+
if (field.includes('datasets')) {
|
|
341
|
+
layout[i]['props']['datasets'] = data['datasets'];
|
|
342
|
+
}
|
|
343
|
+
if (field.includes('options')) {
|
|
344
|
+
layout[i]['props']['chartOptions'] = data;
|
|
345
|
+
}
|
|
346
|
+
if (field.includes('title')) {
|
|
347
|
+
layout[i]['props']['title'] = data['title'];
|
|
348
|
+
}
|
|
349
|
+
if (field.includes('styles')) {
|
|
350
|
+
layout[i]['props']['styles'] = data['styles'];
|
|
351
|
+
}
|
|
352
|
+
if (field.includes('url')) {
|
|
353
|
+
layout[i]['props']['url'] = data['url'];
|
|
354
|
+
}
|
|
355
|
+
if (field.includes('filters')) {
|
|
356
|
+
layout[i]['props']['filters'] = data['filters'];
|
|
357
|
+
}
|
|
358
|
+
if (field.includes('apiCall')) {
|
|
359
|
+
layout[i]['props']['apiCall'] = data['apiCall'];
|
|
360
|
+
}
|
|
361
|
+
if (field.includes('urlTitle')) {
|
|
362
|
+
layout[i]['props']['urlTitle'] = data['urlTitle'];
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return layout;
|
|
367
|
+
};
|
|
368
|
+
export var STORAGE_KEY = 'chartData';
|