statewise-chart-processor 1.0.1 → 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/index.js +39 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
function processStateChartData(chartData, reportHeader, tableHeaders, areaType) {
|
|
2
|
+
if (!chartData || !chartData.length) return null;
|
|
3
|
+
const finalData = { State: {} };
|
|
4
|
+
chartData.forEach(value => {
|
|
5
|
+
if (value.district && value.district !== '(NULL)') {
|
|
6
|
+
if (!finalData.State[value.state]) {
|
|
7
|
+
finalData.State[value.state] = { State: value.state };
|
|
8
|
+
}
|
|
9
|
+
if (!finalData.State[value.state][value.district]) {
|
|
10
|
+
finalData.State[value.state][value.district] = { district: value.district };
|
|
11
|
+
}
|
|
12
|
+
if (!finalData.State[value.state][value.district][value.area_type]) {
|
|
13
|
+
finalData.State[value.state][value.district][value.area_type] = { report_header: [] };
|
|
14
|
+
}
|
|
15
|
+
// Fill report_header for this area_type
|
|
16
|
+
Object.entries(reportHeader).forEach(([colname, headerName]) => {
|
|
17
|
+
finalData.State[value.state][value.district][value.area_type].report_header.push({
|
|
18
|
+
name: headerName,
|
|
19
|
+
total: value[colname]
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
// Fill missing area types with zeroes
|
|
23
|
+
areaType.forEach(type => {
|
|
24
|
+
if (!finalData.State[value.state][value.district][type]) {
|
|
25
|
+
finalData.State[value.state][value.district][type] = { report_header: [] };
|
|
26
|
+
Object.entries(reportHeader).forEach(([colname, headerName]) => {
|
|
27
|
+
finalData.State[value.state][value.district][type].report_header.push({
|
|
28
|
+
name: headerName,
|
|
29
|
+
total: 0
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return finalData;
|
|
37
|
+
}
|
|
1
38
|
async function workersChartData(parameterData, chartData, tablewiseChartData) {
|
|
2
39
|
chartData = chartData[0];
|
|
3
40
|
tablewiseChartData = tablewiseChartData[0];
|
|
@@ -771,5 +808,6 @@ module.exports = {
|
|
|
771
808
|
workersChartData,
|
|
772
809
|
processstatewisechart,
|
|
773
810
|
processChartData,
|
|
774
|
-
processCentralChartData
|
|
811
|
+
processCentralChartData,
|
|
812
|
+
processStateChartData
|
|
775
813
|
};
|
package/package.json
CHANGED