@aclymatepackages/modules 1.0.11 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EmissionsChart.js +3 -2
- package/dist/components/EmissionsPieChart.js +3 -2
- package/dist/components/EmissionsSummarySentence.js +19 -4
- package/dist/components/ReportGraphContentLayout.js +4 -2
- package/dist/components/ReportSummaryBlock.js +228 -0
- package/dist/index.js +5 -12
- package/package.json +3 -3
- package/src/components/EmissionsChart.js +2 -1
- package/src/components/EmissionsPieChart.js +2 -1
- package/src/components/EmissionsSummarySentence.js +15 -5
- package/src/components/ReportGraphContentLayout.js +2 -0
- package/src/components/ReportSummaryBlock.js +217 -0
- package/src/index.js +2 -4
- package/dist/components/FuelTypesSelect.js +0 -35
- package/dist/components/ReportContentTitle.js +0 -18
- package/dist/components/SummaryBlock.js +0 -39
- package/src/components/FuelTypesSelect.js +0 -29
- package/src/components/ReportContentTitle.js +0 -8
- package/src/components/SummaryBlock.js +0 -36
|
@@ -348,7 +348,8 @@ const EmissionsChart = _ref13 => {
|
|
|
348
348
|
showTooltip,
|
|
349
349
|
startDate,
|
|
350
350
|
convertCarbonUnits,
|
|
351
|
-
displayUnitLabel
|
|
351
|
+
displayUnitLabel,
|
|
352
|
+
scopes
|
|
352
353
|
} = _ref13;
|
|
353
354
|
const {
|
|
354
355
|
chartLabelsArray,
|
|
@@ -357,7 +358,7 @@ const EmissionsChart = _ref13 => {
|
|
|
357
358
|
subcategoriesArray,
|
|
358
359
|
period,
|
|
359
360
|
groupedEmissions
|
|
360
|
-
} = (0, _chartHelpers.buildEmissionGroupData)(emissions, graphPeriod, startDate);
|
|
361
|
+
} = (0, _chartHelpers.buildEmissionGroupData)(emissions, graphPeriod, startDate, scopes);
|
|
361
362
|
const isDataProjected = findIsDataProjected(latestEmissionDate);
|
|
362
363
|
const isFirstPeriodEstimated = findIsFirstPeriodEstimated(chartLabelsArray, graphPeriod);
|
|
363
364
|
const buildProjectionObj = viewMode === "subcategories" ? buildSubcategoriesProjectionObj : buildScopesProjectionObj;
|
|
@@ -63,10 +63,11 @@ const EmissionsPieChart = _ref2 => {
|
|
|
63
63
|
let {
|
|
64
64
|
dataArray: emissions,
|
|
65
65
|
viewMode = "subcategories",
|
|
66
|
-
pieChartRef
|
|
66
|
+
pieChartRef,
|
|
67
|
+
scopes
|
|
67
68
|
} = _ref2;
|
|
68
69
|
const subcategoriesArray = (0, _subcategories.buildSubcategoriesArray)(emissions);
|
|
69
|
-
const scopesArray = (0, _subcategories.buildScopesArray)();
|
|
70
|
+
const scopesArray = scopes || (0, _subcategories.buildScopesArray)();
|
|
70
71
|
const emissionsSum = (0, _otherHelpers.sumTonsCo2e)(emissions);
|
|
71
72
|
const formatChartPieSlices = () => {
|
|
72
73
|
const filterFunction = subcategory => emission => {
|
|
@@ -5,17 +5,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _atoms = require("@aclymatepackages/atoms");
|
|
8
10
|
var _formatters = require("@aclymatepackages/formatters");
|
|
9
11
|
var _otherHelpers = require("@aclymatepackages/other-helpers");
|
|
10
|
-
var _material = require("@mui/material");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
const EmissionsSummarySentence = _ref => {
|
|
13
14
|
let {
|
|
14
15
|
label,
|
|
15
|
-
emissions
|
|
16
|
+
emissions,
|
|
17
|
+
color,
|
|
18
|
+
scope
|
|
16
19
|
} = _ref;
|
|
17
|
-
return /*#__PURE__*/_react.default.createElement(_material.
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
21
|
+
container: true,
|
|
22
|
+
spacing: 1,
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
wrap: "nowrap"
|
|
25
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
26
|
+
item: true
|
|
27
|
+
}, /*#__PURE__*/_react.default.createElement(_atoms.CategoriesAvatar, {
|
|
28
|
+
scope: scope,
|
|
29
|
+
color: color
|
|
30
|
+
})), /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
31
|
+
item: true
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
18
33
|
variant: "body2"
|
|
19
|
-
}, label, ": ", (0, _formatters.formatDecimal)((0, _otherHelpers.sumTonsCo2e)(emissions)), " tons CO2e");
|
|
34
|
+
}, label, ": ", (0, _formatters.formatDecimal)((0, _otherHelpers.sumTonsCo2e)(emissions)), " tons CO2e")));
|
|
20
35
|
};
|
|
21
36
|
var _default = exports.default = EmissionsSummarySentence;
|
|
@@ -17,7 +17,8 @@ const ReportGraphContentLayout = _ref => {
|
|
|
17
17
|
emissions,
|
|
18
18
|
interval = "quarter",
|
|
19
19
|
isPercentageChart,
|
|
20
|
-
height
|
|
20
|
+
height,
|
|
21
|
+
scopes
|
|
21
22
|
} = _ref;
|
|
22
23
|
return /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
23
24
|
p: 2,
|
|
@@ -52,7 +53,8 @@ const ReportGraphContentLayout = _ref => {
|
|
|
52
53
|
unitConverter: tons => tons,
|
|
53
54
|
aspect: 2,
|
|
54
55
|
isPercentageChart: isPercentageChart,
|
|
55
|
-
showTooltip: false
|
|
56
|
+
showTooltip: false,
|
|
57
|
+
scopes: scopes
|
|
56
58
|
}))));
|
|
57
59
|
};
|
|
58
60
|
var _default = exports.default = ReportGraphContentLayout;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
9
|
+
require("core-js/modules/es.string.match.js");
|
|
10
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
12
|
+
require("core-js/modules/es.array.sort.js");
|
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
|
14
|
+
var _material = require("@mui/material");
|
|
15
|
+
var _modules = require("@aclymatepackages/modules");
|
|
16
|
+
var _otherHelpers = require("@aclymatepackages/other-helpers");
|
|
17
|
+
var _emissionsCalcs = require("@aclymatepackages/emissions-calcs");
|
|
18
|
+
var _converters = require("@aclymatepackages/converters");
|
|
19
|
+
var _themes = _interopRequireDefault(require("@aclymatepackages/themes"));
|
|
20
|
+
var _subcategories = require("@aclymatepackages/subcategories");
|
|
21
|
+
var _EmissionsSummarySentence = _interopRequireDefault(require("./EmissionsSummarySentence"));
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
24
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
27
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
28
|
+
const adjustHexColorHue = function adjustHexColorHue(hexColor) {
|
|
29
|
+
let hueChange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
|
|
30
|
+
const rgbaColor = (0, _converters.hexToRgba)(hexColor);
|
|
31
|
+
const extractColorValueFromString = color => color.match(/\d+/g).map(value => Number(value));
|
|
32
|
+
|
|
33
|
+
//This function was assisted by Chat GPT
|
|
34
|
+
const rgbaToHslParams = () => {
|
|
35
|
+
const [r, g, b] = extractColorValueFromString(rgbaColor);
|
|
36
|
+
const rFraction = r / 255;
|
|
37
|
+
const gFraction = g / 255;
|
|
38
|
+
const bFraction = b / 255;
|
|
39
|
+
const fractionsArray = [rFraction, gFraction, bFraction];
|
|
40
|
+
const maxValue = Math.max(...fractionsArray);
|
|
41
|
+
const minValue = Math.min(...fractionsArray);
|
|
42
|
+
const luminance = (maxValue + minValue) / 2;
|
|
43
|
+
const maxMinDelta = maxValue - minValue;
|
|
44
|
+
const calcSaturationValue = () => {
|
|
45
|
+
if (maxValue === minValue) {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
if (luminance > 0.5) {
|
|
49
|
+
return maxMinDelta / (2 - maxValue - minValue);
|
|
50
|
+
}
|
|
51
|
+
return maxMinDelta / (maxValue + minValue);
|
|
52
|
+
};
|
|
53
|
+
const saturation = calcSaturationValue();
|
|
54
|
+
const calcHueValue = () => {
|
|
55
|
+
if (maxValue === minValue) {
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
if (maxValue === rFraction) {
|
|
59
|
+
return (gFraction - bFraction) / maxMinDelta + (gFraction < bFraction ? 6 : 0);
|
|
60
|
+
}
|
|
61
|
+
if (maxValue === gFraction) {
|
|
62
|
+
return (bFraction - rFraction) / maxMinDelta + 2;
|
|
63
|
+
}
|
|
64
|
+
return (rFraction - gFraction) / maxMinDelta + 4;
|
|
65
|
+
};
|
|
66
|
+
const hue = Math.round(calcHueValue() * 60) % 360;
|
|
67
|
+
return {
|
|
68
|
+
hue,
|
|
69
|
+
saturation: Math.round(saturation * 100),
|
|
70
|
+
luminance: Math.round(luminance * 100)
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const {
|
|
74
|
+
hue,
|
|
75
|
+
saturation,
|
|
76
|
+
luminance
|
|
77
|
+
} = rgbaToHslParams();
|
|
78
|
+
const adjustHue = () => {
|
|
79
|
+
const adjustedHue = hue + hueChange;
|
|
80
|
+
if (adjustedHue < 360) {
|
|
81
|
+
return adjustedHue;
|
|
82
|
+
}
|
|
83
|
+
return adjustedHue - 360;
|
|
84
|
+
};
|
|
85
|
+
const adjustedHue = adjustHue();
|
|
86
|
+
|
|
87
|
+
//This functions was assisted by Chat GPT
|
|
88
|
+
const hslToHex = hue => {
|
|
89
|
+
const saturationFraction = saturation / 100;
|
|
90
|
+
const luminanceFraction = luminance / 100;
|
|
91
|
+
const chroma = (1 - Math.abs(2 * luminanceFraction - 1)) * saturationFraction;
|
|
92
|
+
const chromaScaled = chroma * (1 - Math.abs(hue / 60 % 2 - 1));
|
|
93
|
+
const lightnessAdjustment = luminanceFraction - chroma / 2;
|
|
94
|
+
const findRgbParts = () => {
|
|
95
|
+
if (hue >= 0 && hue < 60) {
|
|
96
|
+
return {
|
|
97
|
+
rFraction: chroma,
|
|
98
|
+
gFraction: chromaScaled,
|
|
99
|
+
bFraction: 0
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (hue >= 60 && hue < 120) {
|
|
103
|
+
return {
|
|
104
|
+
rFraction: chromaScaled,
|
|
105
|
+
gFraction: chroma,
|
|
106
|
+
bFraction: 0
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (hue >= 120 && hue < 180) {
|
|
110
|
+
return {
|
|
111
|
+
rFraction: 0,
|
|
112
|
+
gFraction: chroma,
|
|
113
|
+
bFraction: chromaScaled
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (hue >= 180 && hue < 240) {
|
|
117
|
+
return {
|
|
118
|
+
rFraction: 0,
|
|
119
|
+
gFraction: chromaScaled,
|
|
120
|
+
bFraction: chroma
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (hue >= 240 && hue < 300) {
|
|
124
|
+
return {
|
|
125
|
+
rFraction: chromaScaled,
|
|
126
|
+
gFraction: 0,
|
|
127
|
+
bFraction: chroma
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
rFraction: chroma,
|
|
132
|
+
gFraction: 0,
|
|
133
|
+
bFraction: chromaScaled
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
const {
|
|
137
|
+
rFraction,
|
|
138
|
+
gFraction,
|
|
139
|
+
bFraction
|
|
140
|
+
} = findRgbParts();
|
|
141
|
+
const buildFullRgbColors = fraction => Math.round((fraction + lightnessAdjustment) * 255);
|
|
142
|
+
const red = buildFullRgbColors(rFraction);
|
|
143
|
+
const green = buildFullRgbColors(gFraction);
|
|
144
|
+
const blue = buildFullRgbColors(bFraction);
|
|
145
|
+
const toHex = color => color.toString(16).padStart(2, "0");
|
|
146
|
+
return "#".concat(toHex(red)).concat(toHex(green)).concat(toHex(blue));
|
|
147
|
+
};
|
|
148
|
+
return hslToHex(adjustedHue);
|
|
149
|
+
};
|
|
150
|
+
const ReportSummaryBlock = _ref => {
|
|
151
|
+
let {
|
|
152
|
+
emissions,
|
|
153
|
+
interval,
|
|
154
|
+
branding
|
|
155
|
+
} = _ref;
|
|
156
|
+
const buildScopesArrayWithColors = () => {
|
|
157
|
+
const colorizeScopesArray = (scopesArray, colorsArray) => scopesArray.map((scopeObj, idx) => _objectSpread(_objectSpread({}, scopeObj), {}, {
|
|
158
|
+
color: colorsArray[idx]
|
|
159
|
+
}));
|
|
160
|
+
const scopesArray = [1, 2, 3].map(scope => {
|
|
161
|
+
const scopeEmissions = (0, _emissionsCalcs.filterEmissionsByScope)(emissions, scope);
|
|
162
|
+
const totalTonsCo2e = (0, _otherHelpers.sumTonsCo2e)(scopeEmissions);
|
|
163
|
+
return {
|
|
164
|
+
scope,
|
|
165
|
+
subcategory: "scope".concat(scope),
|
|
166
|
+
name: "Scope ".concat(scope),
|
|
167
|
+
emissions: scopeEmissions,
|
|
168
|
+
totalTonsCo2e,
|
|
169
|
+
icon: /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
170
|
+
variant: "h6"
|
|
171
|
+
}, scope)
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
if (!branding) {
|
|
175
|
+
const colorsArray = _subcategories.scopesList.map(_ref2 => {
|
|
176
|
+
var _mainTheme$palette$co;
|
|
177
|
+
let {
|
|
178
|
+
color
|
|
179
|
+
} = _ref2;
|
|
180
|
+
return (_mainTheme$palette$co = _themes.default.palette[color]) === null || _mainTheme$palette$co === void 0 ? void 0 : _mainTheme$palette$co.main;
|
|
181
|
+
});
|
|
182
|
+
return colorizeScopesArray(scopesArray, colorsArray);
|
|
183
|
+
}
|
|
184
|
+
const {
|
|
185
|
+
primaryColor,
|
|
186
|
+
secondaryColor
|
|
187
|
+
} = branding;
|
|
188
|
+
if (!primaryColor || !secondaryColor) {
|
|
189
|
+
return scopesArray;
|
|
190
|
+
}
|
|
191
|
+
const sortedScopes = scopesArray.sort((a, b) => b.totalTonsCo2e - a.totalTonsCo2e);
|
|
192
|
+
const adjustedPrimaryColor = adjustHexColorHue(primaryColor);
|
|
193
|
+
const colorsArray = [primaryColor, secondaryColor, adjustedPrimaryColor];
|
|
194
|
+
return colorizeScopesArray(sortedScopes, colorsArray).sort((a, b) => a.scope - b.scope);
|
|
195
|
+
};
|
|
196
|
+
const scopesWithColors = buildScopesArrayWithColors();
|
|
197
|
+
const chartScopes = branding ? scopesWithColors : null;
|
|
198
|
+
return /*#__PURE__*/_react.default.createElement(_modules.ReportGraphContentLayout, {
|
|
199
|
+
scopes: chartScopes,
|
|
200
|
+
contentTitle: (0, _otherHelpers.buildEmissionsSummarySentence)({
|
|
201
|
+
label: "Total Emissions",
|
|
202
|
+
emissions
|
|
203
|
+
}),
|
|
204
|
+
interval: interval,
|
|
205
|
+
emissions: emissions,
|
|
206
|
+
contentRows: [/*#__PURE__*/_react.default.createElement(_modules.EmissionsPieChart, {
|
|
207
|
+
dataArray: emissions,
|
|
208
|
+
viewMode: "scopes",
|
|
209
|
+
scopes: chartScopes
|
|
210
|
+
}), /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
211
|
+
variant: "subtitle1"
|
|
212
|
+
}, "Emissions Scope Breakdown"), ...scopesWithColors.map((_ref3, idx) => {
|
|
213
|
+
let {
|
|
214
|
+
scope,
|
|
215
|
+
emissions,
|
|
216
|
+
color
|
|
217
|
+
} = _ref3;
|
|
218
|
+
return /*#__PURE__*/_react.default.createElement(_EmissionsSummarySentence.default, {
|
|
219
|
+
key: "summary-sentence-".concat(idx),
|
|
220
|
+
label: "Total Scope ".concat(scope),
|
|
221
|
+
emissions: emissions,
|
|
222
|
+
scope: scope,
|
|
223
|
+
color: color
|
|
224
|
+
});
|
|
225
|
+
})]
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
var _default = exports.default = ReportSummaryBlock;
|
package/dist/index.js
CHANGED
|
@@ -81,28 +81,22 @@ Object.defineProperty(exports, "PlacesAutocomplete", {
|
|
|
81
81
|
return _PlacesAutocomplete.default;
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
|
-
Object.defineProperty(exports, "ReportContentTitle", {
|
|
85
|
-
enumerable: true,
|
|
86
|
-
get: function get() {
|
|
87
|
-
return _ReportContentTitle.default;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
84
|
Object.defineProperty(exports, "ReportGraphContentLayout", {
|
|
91
85
|
enumerable: true,
|
|
92
86
|
get: function get() {
|
|
93
87
|
return _ReportGraphContentLayout.default;
|
|
94
88
|
}
|
|
95
89
|
});
|
|
96
|
-
Object.defineProperty(exports, "
|
|
90
|
+
Object.defineProperty(exports, "ReportSummaryBlock", {
|
|
97
91
|
enumerable: true,
|
|
98
92
|
get: function get() {
|
|
99
|
-
return
|
|
93
|
+
return _ReportSummaryBlock.default;
|
|
100
94
|
}
|
|
101
95
|
});
|
|
102
|
-
Object.defineProperty(exports, "
|
|
96
|
+
Object.defineProperty(exports, "StripeElements", {
|
|
103
97
|
enumerable: true,
|
|
104
98
|
get: function get() {
|
|
105
|
-
return
|
|
99
|
+
return _StripeElements.default;
|
|
106
100
|
}
|
|
107
101
|
});
|
|
108
102
|
Object.defineProperty(exports, "YesNoQuestion", {
|
|
@@ -140,7 +134,6 @@ var _EmissionsCustomTooltip = _interopRequireDefault(require("./components/Emiss
|
|
|
140
134
|
var _EmissionsPieChart = _interopRequireDefault(require("./components/EmissionsPieChart"));
|
|
141
135
|
var _useChartWarningLabels = _interopRequireDefault(require("./components/useChartWarningLabels"));
|
|
142
136
|
var _EmissionsSummaryTable = _interopRequireDefault(require("./components/EmissionsSummaryTable"));
|
|
143
|
-
var
|
|
144
|
-
var _SummaryBlock = _interopRequireDefault(require("./components/SummaryBlock"));
|
|
137
|
+
var _ReportSummaryBlock = _interopRequireDefault(require("./components/ReportSummaryBlock"));
|
|
145
138
|
var _ReportGraphContentLayout = _interopRequireDefault(require("./components/ReportGraphContentLayout"));
|
|
146
139
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aclymatepackages/modules",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Aclymate modules",
|
|
5
5
|
"author": "William Loopesko",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@aclymatepackages/array-immutability-helpers": "^1.0.0",
|
|
9
|
-
"@aclymatepackages/atoms": "^1.0.
|
|
10
|
-
"@aclymatepackages/chart-helpers": "^1.0.
|
|
9
|
+
"@aclymatepackages/atoms": "^1.0.10",
|
|
10
|
+
"@aclymatepackages/chart-helpers": "^1.0.6",
|
|
11
11
|
"@aclymatepackages/constants": "^1.0.0",
|
|
12
12
|
"@aclymatepackages/converters": "^1.0.0",
|
|
13
13
|
"@aclymatepackages/date-helpers": "^1.0.0",
|
|
@@ -412,6 +412,7 @@ const EmissionsChart = ({
|
|
|
412
412
|
startDate,
|
|
413
413
|
convertCarbonUnits,
|
|
414
414
|
displayUnitLabel,
|
|
415
|
+
scopes,
|
|
415
416
|
}) => {
|
|
416
417
|
const {
|
|
417
418
|
chartLabelsArray,
|
|
@@ -420,7 +421,7 @@ const EmissionsChart = ({
|
|
|
420
421
|
subcategoriesArray,
|
|
421
422
|
period,
|
|
422
423
|
groupedEmissions,
|
|
423
|
-
} = buildEmissionGroupData(emissions, graphPeriod, startDate);
|
|
424
|
+
} = buildEmissionGroupData(emissions, graphPeriod, startDate, scopes);
|
|
424
425
|
|
|
425
426
|
const isDataProjected = findIsDataProjected(latestEmissionDate);
|
|
426
427
|
const isFirstPeriodEstimated = findIsFirstPeriodEstimated(
|
|
@@ -49,9 +49,10 @@ const EmissionsPieChart = ({
|
|
|
49
49
|
dataArray: emissions,
|
|
50
50
|
viewMode = "subcategories",
|
|
51
51
|
pieChartRef,
|
|
52
|
+
scopes,
|
|
52
53
|
}) => {
|
|
53
54
|
const subcategoriesArray = buildSubcategoriesArray(emissions);
|
|
54
|
-
const scopesArray = buildScopesArray();
|
|
55
|
+
const scopesArray = scopes || buildScopesArray();
|
|
55
56
|
|
|
56
57
|
const emissionsSum = sumTonsCo2e(emissions);
|
|
57
58
|
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { Typography, Grid } from "@mui/material";
|
|
4
|
+
|
|
5
|
+
import { CategoriesAvatar } from "@aclymatepackages/atoms";
|
|
2
6
|
import { formatDecimal } from "@aclymatepackages/formatters";
|
|
3
7
|
import { sumTonsCo2e } from "@aclymatepackages/other-helpers";
|
|
4
|
-
import { Typography } from "@mui/material";
|
|
5
8
|
|
|
6
|
-
const EmissionsSummarySentence = ({ label, emissions }) => (
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const EmissionsSummarySentence = ({ label, emissions, color, scope }) => (
|
|
10
|
+
<Grid container spacing={1} alignItems="center" wrap="nowrap">
|
|
11
|
+
<Grid item>
|
|
12
|
+
<CategoriesAvatar scope={scope} color={color} />
|
|
13
|
+
</Grid>
|
|
14
|
+
<Grid item>
|
|
15
|
+
<Typography variant="body2">
|
|
16
|
+
{label}: {formatDecimal(sumTonsCo2e(emissions))} tons CO2e
|
|
17
|
+
</Typography>
|
|
18
|
+
</Grid>
|
|
19
|
+
</Grid>
|
|
10
20
|
);
|
|
11
21
|
|
|
12
22
|
export default EmissionsSummarySentence;
|
|
@@ -13,6 +13,7 @@ const ReportGraphContentLayout = ({
|
|
|
13
13
|
interval = "quarter",
|
|
14
14
|
isPercentageChart,
|
|
15
15
|
height,
|
|
16
|
+
scopes,
|
|
16
17
|
}) => {
|
|
17
18
|
return (
|
|
18
19
|
<Box p={2} style={{ height: height || "auto" }}>
|
|
@@ -38,6 +39,7 @@ const ReportGraphContentLayout = ({
|
|
|
38
39
|
aspect={2}
|
|
39
40
|
isPercentageChart={isPercentageChart}
|
|
40
41
|
showTooltip={false}
|
|
42
|
+
scopes={scopes}
|
|
41
43
|
/>
|
|
42
44
|
</Grid>
|
|
43
45
|
</Grid>
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { Typography } from "@mui/material";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
EmissionsPieChart,
|
|
7
|
+
ReportGraphContentLayout,
|
|
8
|
+
} from "@aclymatepackages/modules";
|
|
9
|
+
import {
|
|
10
|
+
buildEmissionsSummarySentence,
|
|
11
|
+
sumTonsCo2e,
|
|
12
|
+
} from "@aclymatepackages/other-helpers";
|
|
13
|
+
import { filterEmissionsByScope } from "@aclymatepackages/emissions-calcs";
|
|
14
|
+
import { hexToRgba } from "@aclymatepackages/converters";
|
|
15
|
+
import mainTheme from "@aclymatepackages/themes";
|
|
16
|
+
import { scopesList } from "@aclymatepackages/subcategories";
|
|
17
|
+
|
|
18
|
+
import EmissionsSummarySentence from "./EmissionsSummarySentence";
|
|
19
|
+
|
|
20
|
+
const adjustHexColorHue = (hexColor, hueChange = 20) => {
|
|
21
|
+
const rgbaColor = hexToRgba(hexColor);
|
|
22
|
+
|
|
23
|
+
const extractColorValueFromString = (color) =>
|
|
24
|
+
color.match(/\d+/g).map((value) => Number(value));
|
|
25
|
+
|
|
26
|
+
//This function was assisted by Chat GPT
|
|
27
|
+
const rgbaToHslParams = () => {
|
|
28
|
+
const [r, g, b] = extractColorValueFromString(rgbaColor);
|
|
29
|
+
|
|
30
|
+
const rFraction = r / 255;
|
|
31
|
+
const gFraction = g / 255;
|
|
32
|
+
const bFraction = b / 255;
|
|
33
|
+
|
|
34
|
+
const fractionsArray = [rFraction, gFraction, bFraction];
|
|
35
|
+
|
|
36
|
+
const maxValue = Math.max(...fractionsArray);
|
|
37
|
+
const minValue = Math.min(...fractionsArray);
|
|
38
|
+
|
|
39
|
+
const luminance = (maxValue + minValue) / 2;
|
|
40
|
+
|
|
41
|
+
const maxMinDelta = maxValue - minValue;
|
|
42
|
+
const calcSaturationValue = () => {
|
|
43
|
+
if (maxValue === minValue) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
if (luminance > 0.5) {
|
|
47
|
+
return maxMinDelta / (2 - maxValue - minValue);
|
|
48
|
+
}
|
|
49
|
+
return maxMinDelta / (maxValue + minValue);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const saturation = calcSaturationValue();
|
|
53
|
+
|
|
54
|
+
const calcHueValue = () => {
|
|
55
|
+
if (maxValue === minValue) {
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (maxValue === rFraction) {
|
|
60
|
+
return (
|
|
61
|
+
(gFraction - bFraction) / maxMinDelta +
|
|
62
|
+
(gFraction < bFraction ? 6 : 0)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (maxValue === gFraction) {
|
|
67
|
+
return (bFraction - rFraction) / maxMinDelta + 2;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (rFraction - gFraction) / maxMinDelta + 4;
|
|
71
|
+
};
|
|
72
|
+
const hue = Math.round(calcHueValue() * 60) % 360;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
hue,
|
|
76
|
+
saturation: Math.round(saturation * 100),
|
|
77
|
+
luminance: Math.round(luminance * 100),
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const { hue, saturation, luminance } = rgbaToHslParams();
|
|
82
|
+
const adjustHue = () => {
|
|
83
|
+
const adjustedHue = hue + hueChange;
|
|
84
|
+
if (adjustedHue < 360) {
|
|
85
|
+
return adjustedHue;
|
|
86
|
+
}
|
|
87
|
+
return adjustedHue - 360;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const adjustedHue = adjustHue();
|
|
91
|
+
|
|
92
|
+
//This functions was assisted by Chat GPT
|
|
93
|
+
const hslToHex = (hue) => {
|
|
94
|
+
const saturationFraction = saturation / 100;
|
|
95
|
+
const luminanceFraction = luminance / 100;
|
|
96
|
+
|
|
97
|
+
const chroma =
|
|
98
|
+
(1 - Math.abs(2 * luminanceFraction - 1)) * saturationFraction;
|
|
99
|
+
const chromaScaled = chroma * (1 - Math.abs(((hue / 60) % 2) - 1));
|
|
100
|
+
const lightnessAdjustment = luminanceFraction - chroma / 2;
|
|
101
|
+
|
|
102
|
+
const findRgbParts = () => {
|
|
103
|
+
if (hue >= 0 && hue < 60) {
|
|
104
|
+
return { rFraction: chroma, gFraction: chromaScaled, bFraction: 0 };
|
|
105
|
+
}
|
|
106
|
+
if (hue >= 60 && hue < 120) {
|
|
107
|
+
return { rFraction: chromaScaled, gFraction: chroma, bFraction: 0 };
|
|
108
|
+
}
|
|
109
|
+
if (hue >= 120 && hue < 180) {
|
|
110
|
+
return { rFraction: 0, gFraction: chroma, bFraction: chromaScaled };
|
|
111
|
+
}
|
|
112
|
+
if (hue >= 180 && hue < 240) {
|
|
113
|
+
return { rFraction: 0, gFraction: chromaScaled, bFraction: chroma };
|
|
114
|
+
}
|
|
115
|
+
if (hue >= 240 && hue < 300) {
|
|
116
|
+
return { rFraction: chromaScaled, gFraction: 0, bFraction: chroma };
|
|
117
|
+
}
|
|
118
|
+
return { rFraction: chroma, gFraction: 0, bFraction: chromaScaled };
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const { rFraction, gFraction, bFraction } = findRgbParts();
|
|
122
|
+
|
|
123
|
+
const buildFullRgbColors = (fraction) =>
|
|
124
|
+
Math.round((fraction + lightnessAdjustment) * 255);
|
|
125
|
+
|
|
126
|
+
const red = buildFullRgbColors(rFraction);
|
|
127
|
+
const green = buildFullRgbColors(gFraction);
|
|
128
|
+
const blue = buildFullRgbColors(bFraction);
|
|
129
|
+
|
|
130
|
+
const toHex = (color) => color.toString(16).padStart(2, "0");
|
|
131
|
+
|
|
132
|
+
return `#${toHex(red)}${toHex(green)}${toHex(blue)}`;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return hslToHex(adjustedHue);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const ReportSummaryBlock = ({ emissions, interval, branding }) => {
|
|
139
|
+
const buildScopesArrayWithColors = () => {
|
|
140
|
+
const colorizeScopesArray = (scopesArray, colorsArray) =>
|
|
141
|
+
scopesArray.map((scopeObj, idx) => ({
|
|
142
|
+
...scopeObj,
|
|
143
|
+
color: colorsArray[idx],
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
const scopesArray = [1, 2, 3].map((scope) => {
|
|
147
|
+
const scopeEmissions = filterEmissionsByScope(emissions, scope);
|
|
148
|
+
const totalTonsCo2e = sumTonsCo2e(scopeEmissions);
|
|
149
|
+
return {
|
|
150
|
+
scope,
|
|
151
|
+
subcategory: `scope${scope}`,
|
|
152
|
+
name: `Scope ${scope}`,
|
|
153
|
+
emissions: scopeEmissions,
|
|
154
|
+
totalTonsCo2e,
|
|
155
|
+
icon: <Typography variant="h6">{scope}</Typography>,
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
if (!branding) {
|
|
160
|
+
const colorsArray = scopesList.map(
|
|
161
|
+
({ color }) => mainTheme.palette[color]?.main
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
return colorizeScopesArray(scopesArray, colorsArray);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const { primaryColor, secondaryColor } = branding;
|
|
168
|
+
if (!primaryColor || !secondaryColor) {
|
|
169
|
+
return scopesArray;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const sortedScopes = scopesArray.sort(
|
|
173
|
+
(a, b) => b.totalTonsCo2e - a.totalTonsCo2e
|
|
174
|
+
);
|
|
175
|
+
const adjustedPrimaryColor = adjustHexColorHue(primaryColor);
|
|
176
|
+
|
|
177
|
+
const colorsArray = [primaryColor, secondaryColor, adjustedPrimaryColor];
|
|
178
|
+
return colorizeScopesArray(sortedScopes, colorsArray).sort(
|
|
179
|
+
(a, b) => a.scope - b.scope
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const scopesWithColors = buildScopesArrayWithColors();
|
|
184
|
+
|
|
185
|
+
const chartScopes = branding ? scopesWithColors : null;
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<ReportGraphContentLayout
|
|
189
|
+
scopes={chartScopes}
|
|
190
|
+
contentTitle={buildEmissionsSummarySentence({
|
|
191
|
+
label: "Total Emissions",
|
|
192
|
+
emissions,
|
|
193
|
+
})}
|
|
194
|
+
interval={interval}
|
|
195
|
+
emissions={emissions}
|
|
196
|
+
contentRows={[
|
|
197
|
+
<EmissionsPieChart
|
|
198
|
+
dataArray={emissions}
|
|
199
|
+
viewMode="scopes"
|
|
200
|
+
scopes={chartScopes}
|
|
201
|
+
/>,
|
|
202
|
+
<Typography variant="subtitle1">Emissions Scope Breakdown</Typography>,
|
|
203
|
+
...scopesWithColors.map(({ scope, emissions, color }, idx) => (
|
|
204
|
+
<EmissionsSummarySentence
|
|
205
|
+
key={`summary-sentence-${idx}`}
|
|
206
|
+
label={`Total Scope ${scope}`}
|
|
207
|
+
emissions={emissions}
|
|
208
|
+
scope={scope}
|
|
209
|
+
color={color}
|
|
210
|
+
/>
|
|
211
|
+
)),
|
|
212
|
+
]}
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export default ReportSummaryBlock;
|
package/src/index.js
CHANGED
|
@@ -15,8 +15,7 @@ import EmissionsCustomTooltip from "./components/EmissionsCustomTooltip";
|
|
|
15
15
|
import EmissionsPieChart from "./components/EmissionsPieChart";
|
|
16
16
|
import useChartWarningLabels from "./components/useChartWarningLabels";
|
|
17
17
|
import EmissionsSummaryTable from "./components/EmissionsSummaryTable";
|
|
18
|
-
import
|
|
19
|
-
import SummaryBlock from "./components/SummaryBlock";
|
|
18
|
+
import ReportSummaryBlock from "./components/ReportSummaryBlock";
|
|
20
19
|
import ReportGraphContentLayout from "./components/ReportGraphContentLayout";
|
|
21
20
|
|
|
22
21
|
export {
|
|
@@ -37,7 +36,6 @@ export {
|
|
|
37
36
|
EmissionsPieChart,
|
|
38
37
|
useChartWarningLabels,
|
|
39
38
|
EmissionsSummaryTable,
|
|
40
|
-
|
|
41
|
-
SummaryBlock,
|
|
39
|
+
ReportSummaryBlock,
|
|
42
40
|
ReportGraphContentLayout,
|
|
43
41
|
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _atoms = require("@aclymatepackages/atoms");
|
|
9
|
-
var _formatters = require("@aclymatepackages/formatters");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
const FuelTypesSelect = _ref => {
|
|
12
|
-
let {
|
|
13
|
-
fuelType,
|
|
14
|
-
editVehicle,
|
|
15
|
-
availableFuelTypes,
|
|
16
|
-
id,
|
|
17
|
-
smallFont,
|
|
18
|
-
variant,
|
|
19
|
-
noLabel
|
|
20
|
-
} = _ref;
|
|
21
|
-
return /*#__PURE__*/_react.default.createElement(_atoms.Select, {
|
|
22
|
-
id: id,
|
|
23
|
-
size: "small",
|
|
24
|
-
label: noLabel || "Fuel Type",
|
|
25
|
-
value: fuelType || "",
|
|
26
|
-
editValue: editVehicle,
|
|
27
|
-
options: availableFuelTypes.map(option => ({
|
|
28
|
-
label: (0, _formatters.ucFirstLetters)(option),
|
|
29
|
-
value: option
|
|
30
|
-
})),
|
|
31
|
-
smallFont: smallFont,
|
|
32
|
-
variant: variant
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
var _default = exports.default = FuelTypesSelect;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _material = require("@mui/material");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const ReportContentTitle = _ref => {
|
|
11
|
-
let {
|
|
12
|
-
title
|
|
13
|
-
} = _ref;
|
|
14
|
-
return /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
15
|
-
variant: "subtitle1"
|
|
16
|
-
}, title);
|
|
17
|
-
};
|
|
18
|
-
var _default = exports.default = ReportContentTitle;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _material = require("@mui/material");
|
|
9
|
-
var _emissionsCalcs = require("@aclymatepackages/emissions-calcs");
|
|
10
|
-
var _otherHelpers = require("@aclymatepackages/other-helpers");
|
|
11
|
-
var _EmissionsPieChart = _interopRequireDefault(require("./EmissionsPieChart"));
|
|
12
|
-
var _ReportContentTitle = _interopRequireDefault(require("./ReportContentTitle"));
|
|
13
|
-
var _ReportGraphContentLayout = _interopRequireDefault(require("./ReportGraphContentLayout"));
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
const SummaryBlock = _ref => {
|
|
16
|
-
let {
|
|
17
|
-
emissions,
|
|
18
|
-
interval
|
|
19
|
-
} = _ref;
|
|
20
|
-
return /*#__PURE__*/_react.default.createElement(_ReportGraphContentLayout.default, {
|
|
21
|
-
contentTitle: (0, _otherHelpers.buildEmissionsSummarySentence)({
|
|
22
|
-
label: "Total Emissions",
|
|
23
|
-
emissions
|
|
24
|
-
}),
|
|
25
|
-
interval: interval,
|
|
26
|
-
emissions: emissions,
|
|
27
|
-
contentRows: [/*#__PURE__*/_react.default.createElement(_EmissionsPieChart.default, {
|
|
28
|
-
dataArray: emissions,
|
|
29
|
-
viewMode: "scopes"
|
|
30
|
-
}), /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
31
|
-
variant: "subtitle1"
|
|
32
|
-
}, "Emissions Summary"), [1, 2, 3].map((scope, idx) => /*#__PURE__*/_react.default.createElement(EmissionsSummarySentence, {
|
|
33
|
-
key: "summary-sentence-".concat(idx),
|
|
34
|
-
label: "Total Scope ".concat(scope),
|
|
35
|
-
emissions: (0, _emissionsCalcs.filterEmissionsByScope)(emissions, scope)
|
|
36
|
-
}))]
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
var _default = exports.default = SummaryBlock;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { Select } from "@aclymatepackages/atoms";
|
|
4
|
-
import { ucFirstLetters } from "@aclymatepackages/formatters";
|
|
5
|
-
|
|
6
|
-
const FuelTypesSelect = ({
|
|
7
|
-
fuelType,
|
|
8
|
-
editVehicle,
|
|
9
|
-
availableFuelTypes,
|
|
10
|
-
id,
|
|
11
|
-
smallFont,
|
|
12
|
-
variant,
|
|
13
|
-
noLabel,
|
|
14
|
-
}) => (
|
|
15
|
-
<Select
|
|
16
|
-
id={id}
|
|
17
|
-
size="small"
|
|
18
|
-
label={noLabel || "Fuel Type"}
|
|
19
|
-
value={fuelType || ""}
|
|
20
|
-
editValue={editVehicle}
|
|
21
|
-
options={availableFuelTypes.map((option) => ({
|
|
22
|
-
label: ucFirstLetters(option),
|
|
23
|
-
value: option,
|
|
24
|
-
}))}
|
|
25
|
-
smallFont={smallFont}
|
|
26
|
-
variant={variant}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
export default FuelTypesSelect;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { Typography } from "@mui/material";
|
|
4
|
-
|
|
5
|
-
import { filterEmissionsByScope } from "@aclymatepackages/emissions-calcs";
|
|
6
|
-
import { buildEmissionsSummarySentence } from "@aclymatepackages/other-helpers";
|
|
7
|
-
|
|
8
|
-
import EmissionsPieChart from "./EmissionsPieChart";
|
|
9
|
-
import ReportContentTitle from "./ReportContentTitle";
|
|
10
|
-
import ReportGraphContentLayout from "./ReportGraphContentLayout";
|
|
11
|
-
|
|
12
|
-
const SummaryBlock = ({ emissions, interval }) => {
|
|
13
|
-
return (
|
|
14
|
-
<ReportGraphContentLayout
|
|
15
|
-
contentTitle={buildEmissionsSummarySentence({
|
|
16
|
-
label: "Total Emissions",
|
|
17
|
-
emissions,
|
|
18
|
-
})}
|
|
19
|
-
interval={interval}
|
|
20
|
-
emissions={emissions}
|
|
21
|
-
contentRows={[
|
|
22
|
-
<EmissionsPieChart dataArray={emissions} viewMode="scopes" />,
|
|
23
|
-
<Typography variant="subtitle1">Emissions Summary</Typography>,
|
|
24
|
-
[1, 2, 3].map((scope, idx) => (
|
|
25
|
-
<EmissionsSummarySentence
|
|
26
|
-
key={`summary-sentence-${idx}`}
|
|
27
|
-
label={`Total Scope ${scope}`}
|
|
28
|
-
emissions={filterEmissionsByScope(emissions, scope)}
|
|
29
|
-
/>
|
|
30
|
-
)),
|
|
31
|
-
]}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default SummaryBlock;
|