@aclymatepackages/modules 2.0.15 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.object.assign.js");
|
|
4
|
-
require("core-js/modules/es.weak-map.js");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,23 +8,19 @@ exports.default = void 0;
|
|
|
9
8
|
require("core-js/modules/es.array.reduce.js");
|
|
10
9
|
require("core-js/modules/es.object.from-entries.js");
|
|
11
10
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
12
|
-
var _react =
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
12
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
14
13
|
var _recharts = require("recharts");
|
|
15
14
|
var _material = require("@mui/material");
|
|
16
15
|
var _formatters = require("@aclymatepackages/formatters");
|
|
17
16
|
var _otherHelpers = require("@aclymatepackages/other-helpers");
|
|
18
|
-
var _converters = require("@aclymatepackages/converters");
|
|
19
17
|
var _chartHelpers = require("@aclymatepackages/chart-helpers");
|
|
20
18
|
var _subcategories = require("@aclymatepackages/subcategories");
|
|
21
19
|
var _EmissionsCustomTooltip = _interopRequireDefault(require("./EmissionsCustomTooltip"));
|
|
22
20
|
var _useChartWarningLabels = _interopRequireDefault(require("./useChartWarningLabels"));
|
|
23
21
|
const _excluded = ["totalEmissionsSumTons"],
|
|
24
|
-
_excluded2 = ["
|
|
25
|
-
_excluded3 = ["subcategory", "color"];
|
|
22
|
+
_excluded2 = ["subcategory", "color"];
|
|
26
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
28
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
24
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
30
25
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
31
26
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -113,70 +108,16 @@ const addTrendlineToChartData = chartData => {
|
|
|
113
108
|
});
|
|
114
109
|
});
|
|
115
110
|
};
|
|
116
|
-
const
|
|
117
|
-
let {
|
|
118
|
-
x,
|
|
119
|
-
y,
|
|
120
|
-
label
|
|
121
|
-
} = _ref8;
|
|
122
|
-
const CHIP_HEIGHT_PX = 24;
|
|
123
|
-
const {
|
|
124
|
-
palette
|
|
125
|
-
} = (0, _material.useTheme)();
|
|
126
|
-
const [chipWidth, setChipWidth] = (0, _react.useState)(0);
|
|
127
|
-
const chipRef = (0, _react.useRef)();
|
|
128
|
-
(0, _react.useEffect)(() => {
|
|
129
|
-
if (chipRef.current) {
|
|
130
|
-
setChipWidth(chipRef.current.offsetWidth);
|
|
131
|
-
}
|
|
132
|
-
}, [chipRef]);
|
|
133
|
-
return /*#__PURE__*/_react.default.createElement(_material.Chip, {
|
|
134
|
-
elevation: 3,
|
|
135
|
-
ref: chipRef,
|
|
136
|
-
label: label,
|
|
137
|
-
style: {
|
|
138
|
-
position: "absolute",
|
|
139
|
-
top: y - CHIP_HEIGHT_PX / 2,
|
|
140
|
-
left: x - chipWidth / 2,
|
|
141
|
-
background: (0, _converters.hexToRgba)(palette.backgroundGray.main, 0.85)
|
|
142
|
-
},
|
|
143
|
-
size: "small"
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
const ChartLineLabelSetter = _ref9 => {
|
|
147
|
-
let {
|
|
148
|
-
viewBox,
|
|
149
|
-
labels,
|
|
150
|
-
setLabels,
|
|
151
|
-
label
|
|
152
|
-
} = _ref9,
|
|
153
|
-
otherProps = _objectWithoutProperties(_ref9, _excluded2);
|
|
154
|
-
(0, _react.useEffect)(() => {
|
|
155
|
-
const {
|
|
156
|
-
y
|
|
157
|
-
} = viewBox;
|
|
158
|
-
if (!labels.find(existingLabel => existingLabel.label === label)) {
|
|
159
|
-
setLabels(existingLabels => [...existingLabels, _objectSpread({
|
|
160
|
-
y,
|
|
161
|
-
label
|
|
162
|
-
}, otherProps)]);
|
|
163
|
-
}
|
|
164
|
-
}, [viewBox, label, labels, setLabels, otherProps]);
|
|
165
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
166
|
-
};
|
|
167
|
-
const LabeledEmissionsChart = _ref10 => {
|
|
111
|
+
const LabeledEmissionsChart = _ref8 => {
|
|
168
112
|
var _data$, _data;
|
|
169
113
|
let {
|
|
170
|
-
graphPeriod,
|
|
171
114
|
data,
|
|
172
115
|
type,
|
|
173
116
|
displayUnitLabel,
|
|
174
117
|
chartArray,
|
|
175
118
|
aspect = 3,
|
|
176
|
-
showTooltip
|
|
177
|
-
|
|
178
|
-
baseline
|
|
179
|
-
} = _ref10;
|
|
119
|
+
showTooltip
|
|
120
|
+
} = _ref8;
|
|
180
121
|
const {
|
|
181
122
|
palette
|
|
182
123
|
} = (0, _material.useTheme)();
|
|
@@ -188,60 +129,10 @@ const LabeledEmissionsChart = _ref10 => {
|
|
|
188
129
|
warningField: "warning",
|
|
189
130
|
barSumField: "totalEmissionsSumTons"
|
|
190
131
|
});
|
|
191
|
-
const [chartWidth, setChartWidth] = (0, _react.useState)(0);
|
|
192
|
-
const [referenceLineLabels, setReferenceLineLabels] = (0, _react.useState)([]);
|
|
193
|
-
const chartContainerRef = (0, _react.useRef)();
|
|
194
|
-
(0, _react.useEffect)(() => {
|
|
195
|
-
if (chartContainerRef.current) {
|
|
196
|
-
setChartWidth(chartContainerRef.current.offsetWidth);
|
|
197
|
-
}
|
|
198
|
-
}, [chartContainerRef]);
|
|
199
132
|
const isTrendLineGood = ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.trendLine) > ((_data = data[data.length - 1]) === null || _data === void 0 ? void 0 : _data.trendLine);
|
|
200
133
|
const ChartElement = type === "bar" ? _recharts.Bar : _recharts.Area;
|
|
201
|
-
const buildReferenceLinesArray = () => {
|
|
202
|
-
if (!baseline) {
|
|
203
|
-
return [];
|
|
204
|
-
}
|
|
205
|
-
const baselineReferenceLine = {
|
|
206
|
-
value: baseline,
|
|
207
|
-
label: "".concat((0, _formatters.ucFirstLetters)(graphPeriod), "ly Baseline"),
|
|
208
|
-
labelPosition: "top"
|
|
209
|
-
};
|
|
210
|
-
const ghgReductionLine = {
|
|
211
|
-
value: baseline * 0.5,
|
|
212
|
-
label: "GHG Reduction Mandate (50% by 2030)",
|
|
213
|
-
labelPosition: "top"
|
|
214
|
-
};
|
|
215
|
-
const companyPledgeLabel = "Company pledge to reduce emissions by ".concat(netZeroPercentage, "% by 2030");
|
|
216
|
-
const pledgeReductionValue = baseline * (1 - netZeroPercentage / 100);
|
|
217
|
-
if (!netZeroPercentage) {
|
|
218
|
-
return [baselineReferenceLine, ghgReductionLine];
|
|
219
|
-
}
|
|
220
|
-
if (netZeroPercentage >= 55) {
|
|
221
|
-
return [baselineReferenceLine, ghgReductionLine, {
|
|
222
|
-
value: pledgeReductionValue,
|
|
223
|
-
label: companyPledgeLabel,
|
|
224
|
-
labelPosition: "bottom"
|
|
225
|
-
}];
|
|
226
|
-
}
|
|
227
|
-
return [baselineReferenceLine, {
|
|
228
|
-
label: companyPledgeLabel,
|
|
229
|
-
value: pledgeReductionValue,
|
|
230
|
-
labelPosition: "bottom"
|
|
231
|
-
}];
|
|
232
|
-
};
|
|
233
|
-
const referenceLines = buildReferenceLinesArray();
|
|
234
|
-
|
|
235
|
-
//This weird hack is needed because for some reason every label shows up in referenceLineLabels twice.
|
|
236
|
-
const uniqueReferenceLineLabels = [...new Set(referenceLineLabels.map(_ref11 => {
|
|
237
|
-
let {
|
|
238
|
-
label
|
|
239
|
-
} = _ref11;
|
|
240
|
-
return label;
|
|
241
|
-
}))].map(label => referenceLineLabels.find(lineLabel => lineLabel.label === label));
|
|
242
134
|
return /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
243
|
-
position: "relative"
|
|
244
|
-
ref: chartContainerRef
|
|
135
|
+
position: "relative"
|
|
245
136
|
}, /*#__PURE__*/_react.default.createElement(_recharts.ResponsiveContainer, {
|
|
246
137
|
aspect: aspect
|
|
247
138
|
}, /*#__PURE__*/_react.default.createElement(_recharts.ComposedChart, {
|
|
@@ -265,12 +156,12 @@ const LabeledEmissionsChart = _ref10 => {
|
|
|
265
156
|
categoriesArray: chartArray,
|
|
266
157
|
displayUnitLabel: displayUnitLabel
|
|
267
158
|
})
|
|
268
|
-
}), chartArray.map(
|
|
159
|
+
}), chartArray.map(_ref9 => {
|
|
269
160
|
let {
|
|
270
161
|
subcategory,
|
|
271
162
|
color
|
|
272
|
-
} =
|
|
273
|
-
otherProps = _objectWithoutProperties(
|
|
163
|
+
} = _ref9,
|
|
164
|
+
otherProps = _objectWithoutProperties(_ref9, _excluded2);
|
|
274
165
|
return /*#__PURE__*/_react.default.createElement(ChartElement, _extends({
|
|
275
166
|
key: "emissions-chart-element-".concat(subcategory),
|
|
276
167
|
type: "monotone",
|
|
@@ -288,29 +179,9 @@ const LabeledEmissionsChart = _ref10 => {
|
|
|
288
179
|
strokeWidth: 4,
|
|
289
180
|
dot: false,
|
|
290
181
|
strokeDasharray: "5 5"
|
|
291
|
-
}),
|
|
292
|
-
let {
|
|
293
|
-
label,
|
|
294
|
-
value,
|
|
295
|
-
labelPosition
|
|
296
|
-
} = _ref13;
|
|
297
|
-
return /*#__PURE__*/_react.default.createElement(_recharts.ReferenceLine, {
|
|
298
|
-
key: "chart-reference-line-".concat(idx),
|
|
299
|
-
y: value,
|
|
300
|
-
strokeWidth: 2,
|
|
301
|
-
stroke: palette.backgroundGray.dark,
|
|
302
|
-
label: /*#__PURE__*/_react.default.createElement(ChartLineLabelSetter, {
|
|
303
|
-
label: label,
|
|
304
|
-
labels: referenceLineLabels,
|
|
305
|
-
setLabels: setReferenceLineLabels
|
|
306
|
-
})
|
|
307
|
-
});
|
|
308
|
-
}))), warningLabels, !!uniqueReferenceLineLabels.length && uniqueReferenceLineLabels.map((label, idx) => /*#__PURE__*/_react.default.createElement(ReferenceLineLabelChips, _extends({
|
|
309
|
-
key: "reference-line-label-chip-".concat(idx),
|
|
310
|
-
x: chartWidth / 2
|
|
311
|
-
}, label))));
|
|
182
|
+
}))), warningLabels);
|
|
312
183
|
};
|
|
313
|
-
const EmissionsChart =
|
|
184
|
+
const EmissionsChart = _ref10 => {
|
|
314
185
|
let {
|
|
315
186
|
dataArray: emissions,
|
|
316
187
|
type,
|
|
@@ -327,7 +198,7 @@ const EmissionsChart = _ref14 => {
|
|
|
327
198
|
branding,
|
|
328
199
|
netZeroPercentage,
|
|
329
200
|
noLine = true
|
|
330
|
-
} =
|
|
201
|
+
} = _ref10;
|
|
331
202
|
const {
|
|
332
203
|
chartLabelsArray,
|
|
333
204
|
scopesArray,
|
|
@@ -341,8 +212,8 @@ const EmissionsChart = _ref14 => {
|
|
|
341
212
|
buildRealDataObj,
|
|
342
213
|
viewMode
|
|
343
214
|
});
|
|
344
|
-
const convertChartDataObject = (chartDataObj, converter) => Object.fromEntries(Object.entries(chartDataObj).map(
|
|
345
|
-
let [key, value] =
|
|
215
|
+
const convertChartDataObject = (chartDataObj, converter) => Object.fromEntries(Object.entries(chartDataObj).map(_ref11 => {
|
|
216
|
+
let [key, value] = _ref11;
|
|
346
217
|
if (typeof value !== "number") {
|
|
347
218
|
return [key, value];
|
|
348
219
|
}
|
|
@@ -353,28 +224,28 @@ const EmissionsChart = _ref14 => {
|
|
|
353
224
|
}));
|
|
354
225
|
if (isPercentageChart) {
|
|
355
226
|
const percentageConvertedChartData = preliminaryChartData.map(chartDataObj => {
|
|
356
|
-
const objectSubcategoryProperties = Object.keys(chartDataObj).filter(key => _subcategories.subcategories.find(
|
|
227
|
+
const objectSubcategoryProperties = Object.keys(chartDataObj).filter(key => _subcategories.subcategories.find(_ref12 => {
|
|
357
228
|
let {
|
|
358
229
|
subcategory
|
|
359
|
-
} =
|
|
230
|
+
} = _ref12;
|
|
360
231
|
return subcategory === key;
|
|
361
232
|
}));
|
|
362
233
|
const objectSubcategoryValues = objectSubcategoryProperties.map(subcategory => ({
|
|
363
234
|
key: subcategory,
|
|
364
235
|
value: chartDataObj[subcategory]
|
|
365
236
|
}));
|
|
366
|
-
const periodEmissionsSum = objectSubcategoryValues.reduce((sum,
|
|
237
|
+
const periodEmissionsSum = objectSubcategoryValues.reduce((sum, _ref13) => {
|
|
367
238
|
let {
|
|
368
239
|
value
|
|
369
|
-
} =
|
|
240
|
+
} = _ref13;
|
|
370
241
|
return value + sum;
|
|
371
242
|
}, 0);
|
|
372
243
|
const percentageConverter = value => value / periodEmissionsSum * 100;
|
|
373
|
-
const newObject = Object.fromEntries(objectSubcategoryValues.map(
|
|
244
|
+
const newObject = Object.fromEntries(objectSubcategoryValues.map(_ref14 => {
|
|
374
245
|
let {
|
|
375
246
|
key,
|
|
376
247
|
value
|
|
377
|
-
} =
|
|
248
|
+
} = _ref14;
|
|
378
249
|
return [key, value];
|
|
379
250
|
}));
|
|
380
251
|
return convertChartDataObject(newObject, percentageConverter);
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -10,15 +10,13 @@ import {
|
|
|
10
10
|
Bar,
|
|
11
11
|
ComposedChart,
|
|
12
12
|
Line,
|
|
13
|
-
ReferenceLine,
|
|
14
13
|
Tooltip as ChartTooltip,
|
|
15
14
|
} from "recharts";
|
|
16
15
|
|
|
17
|
-
import { Grid, Box,
|
|
16
|
+
import { Grid, Box, useTheme } from "@mui/material";
|
|
18
17
|
|
|
19
|
-
import { formatDecimal
|
|
18
|
+
import { formatDecimal } from "@aclymatepackages/formatters";
|
|
20
19
|
import { sumTonsCo2e } from "@aclymatepackages/other-helpers";
|
|
21
|
-
import { hexToRgba } from "@aclymatepackages/converters";
|
|
22
20
|
import {
|
|
23
21
|
buildScopesRealDataObj,
|
|
24
22
|
buildSubcategoriesDataObj,
|
|
@@ -108,67 +106,13 @@ const addTrendlineToChartData = (chartData) => {
|
|
|
108
106
|
}));
|
|
109
107
|
};
|
|
110
108
|
|
|
111
|
-
const ReferenceLineLabelChips = ({ x, y, label }) => {
|
|
112
|
-
const CHIP_HEIGHT_PX = 24;
|
|
113
|
-
|
|
114
|
-
const { palette } = useTheme();
|
|
115
|
-
|
|
116
|
-
const [chipWidth, setChipWidth] = useState(0);
|
|
117
|
-
const chipRef = useRef();
|
|
118
|
-
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
if (chipRef.current) {
|
|
121
|
-
setChipWidth(chipRef.current.offsetWidth);
|
|
122
|
-
}
|
|
123
|
-
}, [chipRef]);
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<Chip
|
|
127
|
-
elevation={3}
|
|
128
|
-
ref={chipRef}
|
|
129
|
-
label={label}
|
|
130
|
-
style={{
|
|
131
|
-
position: "absolute",
|
|
132
|
-
top: y - CHIP_HEIGHT_PX / 2,
|
|
133
|
-
left: x - chipWidth / 2,
|
|
134
|
-
background: hexToRgba(palette.backgroundGray.main, 0.85),
|
|
135
|
-
}}
|
|
136
|
-
size="small"
|
|
137
|
-
/>
|
|
138
|
-
);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const ChartLineLabelSetter = ({
|
|
142
|
-
viewBox,
|
|
143
|
-
labels,
|
|
144
|
-
setLabels,
|
|
145
|
-
label,
|
|
146
|
-
...otherProps
|
|
147
|
-
}) => {
|
|
148
|
-
useEffect(() => {
|
|
149
|
-
const { y } = viewBox;
|
|
150
|
-
|
|
151
|
-
if (!labels.find((existingLabel) => existingLabel.label === label)) {
|
|
152
|
-
setLabels((existingLabels) => [
|
|
153
|
-
...existingLabels,
|
|
154
|
-
{ y, label, ...otherProps },
|
|
155
|
-
]);
|
|
156
|
-
}
|
|
157
|
-
}, [viewBox, label, labels, setLabels, otherProps]);
|
|
158
|
-
|
|
159
|
-
return <></>;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
109
|
const LabeledEmissionsChart = ({
|
|
163
|
-
graphPeriod,
|
|
164
110
|
data,
|
|
165
111
|
type,
|
|
166
112
|
displayUnitLabel,
|
|
167
113
|
chartArray,
|
|
168
114
|
aspect = 3,
|
|
169
115
|
showTooltip,
|
|
170
|
-
netZeroPercentage,
|
|
171
|
-
baseline,
|
|
172
116
|
}) => {
|
|
173
117
|
const { palette } = useTheme();
|
|
174
118
|
|
|
@@ -178,78 +122,12 @@ const LabeledEmissionsChart = ({
|
|
|
178
122
|
barSumField: "totalEmissionsSumTons",
|
|
179
123
|
});
|
|
180
124
|
|
|
181
|
-
const [chartWidth, setChartWidth] = useState(0);
|
|
182
|
-
const [referenceLineLabels, setReferenceLineLabels] = useState([]);
|
|
183
|
-
|
|
184
|
-
const chartContainerRef = useRef();
|
|
185
|
-
|
|
186
|
-
useEffect(() => {
|
|
187
|
-
if (chartContainerRef.current) {
|
|
188
|
-
setChartWidth(chartContainerRef.current.offsetWidth);
|
|
189
|
-
}
|
|
190
|
-
}, [chartContainerRef]);
|
|
191
|
-
|
|
192
125
|
const isTrendLineGood = data[0]?.trendLine > data[data.length - 1]?.trendLine;
|
|
193
126
|
|
|
194
127
|
const ChartElement = type === "bar" ? Bar : Area;
|
|
195
128
|
|
|
196
|
-
const buildReferenceLinesArray = () => {
|
|
197
|
-
if (!baseline) {
|
|
198
|
-
return [];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const baselineReferenceLine = {
|
|
202
|
-
value: baseline,
|
|
203
|
-
label: `${ucFirstLetters(graphPeriod)}ly Baseline`,
|
|
204
|
-
labelPosition: "top",
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const ghgReductionLine = {
|
|
208
|
-
value: baseline * 0.5,
|
|
209
|
-
label: "GHG Reduction Mandate (50% by 2030)",
|
|
210
|
-
labelPosition: "top",
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const companyPledgeLabel = `Company pledge to reduce emissions by ${netZeroPercentage}% by 2030`;
|
|
214
|
-
const pledgeReductionValue = baseline * (1 - netZeroPercentage / 100);
|
|
215
|
-
|
|
216
|
-
if (!netZeroPercentage) {
|
|
217
|
-
return [baselineReferenceLine, ghgReductionLine];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (netZeroPercentage >= 55) {
|
|
221
|
-
return [
|
|
222
|
-
baselineReferenceLine,
|
|
223
|
-
ghgReductionLine,
|
|
224
|
-
{
|
|
225
|
-
value: pledgeReductionValue,
|
|
226
|
-
label: companyPledgeLabel,
|
|
227
|
-
labelPosition: "bottom",
|
|
228
|
-
},
|
|
229
|
-
];
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return [
|
|
233
|
-
baselineReferenceLine,
|
|
234
|
-
{
|
|
235
|
-
label: companyPledgeLabel,
|
|
236
|
-
value: pledgeReductionValue,
|
|
237
|
-
labelPosition: "bottom",
|
|
238
|
-
},
|
|
239
|
-
];
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const referenceLines = buildReferenceLinesArray();
|
|
243
|
-
|
|
244
|
-
//This weird hack is needed because for some reason every label shows up in referenceLineLabels twice.
|
|
245
|
-
const uniqueReferenceLineLabels = [
|
|
246
|
-
...new Set(referenceLineLabels.map(({ label }) => label)),
|
|
247
|
-
].map((label) =>
|
|
248
|
-
referenceLineLabels.find((lineLabel) => lineLabel.label === label)
|
|
249
|
-
);
|
|
250
|
-
|
|
251
129
|
return (
|
|
252
|
-
<Box position="relative"
|
|
130
|
+
<Box position="relative">
|
|
253
131
|
<ResponsiveContainer aspect={aspect}>
|
|
254
132
|
<ComposedChart width={500} height={300} data={data}>
|
|
255
133
|
<XAxis dataKey="label" interval="preserveStartEnd" height={20} />
|
|
@@ -296,33 +174,9 @@ const LabeledEmissionsChart = ({
|
|
|
296
174
|
dot={false}
|
|
297
175
|
strokeDasharray="5 5"
|
|
298
176
|
/>
|
|
299
|
-
{!!referenceLines.length &&
|
|
300
|
-
referenceLines.map(({ label, value, labelPosition }, idx) => (
|
|
301
|
-
<ReferenceLine
|
|
302
|
-
key={`chart-reference-line-${idx}`}
|
|
303
|
-
y={value}
|
|
304
|
-
strokeWidth={2}
|
|
305
|
-
stroke={palette.backgroundGray.dark}
|
|
306
|
-
label={
|
|
307
|
-
<ChartLineLabelSetter
|
|
308
|
-
label={label}
|
|
309
|
-
labels={referenceLineLabels}
|
|
310
|
-
setLabels={setReferenceLineLabels}
|
|
311
|
-
/>
|
|
312
|
-
}
|
|
313
|
-
/>
|
|
314
|
-
))}
|
|
315
177
|
</ComposedChart>
|
|
316
178
|
</ResponsiveContainer>
|
|
317
179
|
{warningLabels}
|
|
318
|
-
{!!uniqueReferenceLineLabels.length &&
|
|
319
|
-
uniqueReferenceLineLabels.map((label, idx) => (
|
|
320
|
-
<ReferenceLineLabelChips
|
|
321
|
-
key={`reference-line-label-chip-${idx}`}
|
|
322
|
-
x={chartWidth / 2}
|
|
323
|
-
{...label}
|
|
324
|
-
/>
|
|
325
|
-
))}
|
|
326
180
|
</Box>
|
|
327
181
|
);
|
|
328
182
|
};
|
|
@@ -17,7 +17,7 @@ const ReportGraphContentLayout = ({
|
|
|
17
17
|
showTooltip,
|
|
18
18
|
}) => {
|
|
19
19
|
return (
|
|
20
|
-
<Box style={{ height: height || "auto" }}>
|
|
20
|
+
<Box p={2} style={{ height: height || "auto" }}>
|
|
21
21
|
<Grid container spacing={2}>
|
|
22
22
|
<Grid item md={4} xs={12} container direction="column" spacing={2}>
|
|
23
23
|
<Grid item>
|