diff --git a/src/client/app/components/CompareLineChartComponent.tsx b/src/client/app/components/CompareLineChartComponent.tsx
index 872620060f..a541547bd0 100644
--- a/src/client/app/components/CompareLineChartComponent.tsx
+++ b/src/client/app/components/CompareLineChartComponent.tsx
@@ -135,14 +135,15 @@ export default function CompareLineChartComponent() {
}
// Adding information to the shifted data so that it can be plotted on the same graph with current data
+ const shiftedLabel = translate('shifted');
const updateDataNew = dataNew.map(item => ({
...item,
- name: 'Shifted ' + item.name,
+ name: `${shiftedLabel} ${item.name}`,
line: { ...item.line, color: '#1AA5F0' },
xaxis: 'x2',
text: Array.isArray(item.text)
- ? item.text.map(text => text.replace('
', '
Shifted '))
- : item.text?.replace('
', '
Shifted ')
+ ? item.text.map(text => text.replace('
', `
${shiftedLabel} `))
+ : item.text?.replace('
', `
${shiftedLabel} `)
}));
return (
@@ -177,67 +178,67 @@ export default function CompareLineChartComponent() {
}
>
-
);
-}
-
-/**
- * If the number of points differs for the original and shifted lines, the data will not appear at the same places horizontally.
- * The time interval in the original and shifted line for the actual readings can have issues.
- * While the requested time ranges should be the same, the actually returned readings may differ.
- * This can happen if there are readings missing including start, end or between. If the number of readings vary then there is an issue.
- * If not, it is unlikely but can happen if there are missing readings in both lines that do not align but there are the same number missing in both.
- * This is an ugly edge case that OED is not going to try to catch now.
- * Use the last index in Redux state as a proxy for the number since need that below.
- * @param originalReading original data to compare
- * @param shiftedReading shifted data to compare
- */
-function checkReceivedData(originalReading: any, shiftedReading: any) {
- let numberPointsSame = true;
- if (originalReading.length !== shiftedReading.length) {
- // If the number of points vary then then scales will not line up point by point. Warn the user.
- numberPointsSame = false;
- showWarnNotification(
- `The original line has ${originalReading.length} readings but the shifted line has ${shiftedReading.length}`
- + ' readings which means the points will not align horizontally.'
- );
- }
- // Now see if the original and shifted lines overlap.
- if (moment(shiftedReading.at(-1).toString()) > moment(originalReading.at(0).toString())) {
- showInfoNotification(
- `The shifted line overlaps the original line starting at ${originalReading[0]}`,
- toast.POSITION.TOP_RIGHT,
- 15000
- );
- }
+ /**
+ * If the number of points differs for the original and shifted lines, the data will not appear at the same places horizontally.
+ * The time interval in the original and shifted line for the actual readings can have issues.
+ * While the requested time ranges should be the same, the actually returned readings may differ.
+ * This can happen if there are readings missing including start, end or between. If the number of readings vary then there is an issue.
+ * If not, it is unlikely but can happen if there are missing readings in both lines that do not align but there are the same number missing in both.
+ * This is an ugly edge case that OED is not going to try to catch now.
+ * Use the last index in Redux state as a proxy for the number since need that below.
+ * @param originalReading original data to compare
+ * @param shiftedReading shifted data to compare
+ */
+ function checkReceivedData(originalReading: any, shiftedReading: any) {
+ let numberPointsSame = true;
+ if (originalReading.length !== shiftedReading.length) {
+ // If the number of points vary then then scales will not line up point by point. Warn the user.
+ numberPointsSame = false;
+ showWarnNotification(
+ `${translate('compare.line.original.shifted.count.first')} ${originalReading.length} ` +
+ `${translate('compare.line.original.shifted.count.second')} ${shiftedReading.length} ` +
+ `${translate('compare.line.original.shifted.count.third')}`
+ );
+ }
+ // Now see if the original and shifted lines overlap.
+ if (moment(shiftedReading.at(-1).toString()) > moment(originalReading.at(0).toString())) {
+ showInfoNotification(
+ `${translate('compare.line.shifted.overlaps.start.prefix')} ${originalReading[0]}`,
+ toast.POSITION.TOP_RIGHT,
+ 15000
+ );
+ }
- // Now see if day of the week aligns.
- // If the number of points is not the same then no horizontal alignment so do not tell user.
- const firstOriginReadingDay = moment(originalReading.at(0)?.toString());
- const firstShiftedReadingDay = moment(shiftedReading.at(0)?.toString());
- if (numberPointsSame && firstOriginReadingDay.day() === firstShiftedReadingDay.day()) {
- showInfoNotification('Days of week align (unless missing readings)',
- toast.POSITION.TOP_RIGHT,
- 15000
- );
- }
- // Now see if the month and day align. If the number of points is not the same then no horizontal
- // alignment so do not tell user. Check if the first reading matches because only notify if this is true.
- if (numberPointsSame && monthDateSame(firstOriginReadingDay, firstShiftedReadingDay)) {
- // Loop over all readings but the first. Really okay to do first but just checked that one.
- // Note length of original and shifted same so just use original.
- let message = 'The month and day of the month align for the original and shifted readings';
- for (let i = 1; i < originalReading.length; i++) {
- if (!monthDateSame(moment(originalReading.at(i)?.toString()), moment(shiftedReading.at(i)?.toString()))) {
- // Mismatch so inform user. Should be due to leap year crossing and differing leap year.
- // Only tell first mistmatch
- message += ` until original reading at date ${moment(originalReading.at(i)?.toString()).format('ll')}`;
- break;
+ // Now see if day of the week aligns.
+ // If the number of points is not the same then no horizontal alignment so do not tell user.
+ const firstOriginReadingDay = moment(originalReading.at(0)?.toString());
+ const firstShiftedReadingDay = moment(shiftedReading.at(0)?.toString());
+ if (numberPointsSame && firstOriginReadingDay.day() === firstShiftedReadingDay.day()) {
+ showInfoNotification(translate('compare.line.days.align'),
+ toast.POSITION.TOP_RIGHT,
+ 15000
+ );
+ }
+ // Now see if the month and day align. If the number of points is not the same then no horizontal
+ // alignment so do not tell user. Check if the first reading matches because only notify if this is true.
+ if (numberPointsSame && monthDateSame(firstOriginReadingDay, firstShiftedReadingDay)) {
+ // Loop over all readings but the first. Really okay to do first but just checked that one.
+ // Note length of original and shifted same so just use original.
+ let message = translate('compare.line.month.day.align');
+ for (let i = 1; i < originalReading.length; i++) {
+ if (!monthDateSame(moment(originalReading.at(i)?.toString()), moment(shiftedReading.at(i)?.toString()))) {
+ // Mismatch so inform user. Should be due to leap year crossing and differing leap year.
+ // Only tell first mistmatch
+ message += `${translate('compare.line.month.day.align.until.prefix')} ${moment(originalReading.at(i)?.toString()).format('ll')}`;
+ break;
+ }
}
+ showInfoNotification(message, toast.POSITION.TOP_RIGHT, 15000);
}
- showInfoNotification(message, toast.POSITION.TOP_RIGHT, 15000);
}
+
}
/**
diff --git a/src/client/app/translations/data.ts b/src/client/app/translations/data.ts
index bf9886cd54..b7e3533f4c 100644
--- a/src/client/app/translations/data.ts
+++ b/src/client/app/translations/data.ts
@@ -61,7 +61,14 @@ const LocaleTranslationData = {
"close": "Close",
"compare.bar": "Compare bar",
"compare.line": "Compare line",
+ "compare.line.days.align": "Days of week align (unless missing readings)",
"compare.line.days.enter": "Enter in days and then hit enter",
+ "compare.line.month.day.align": "The month and day of the month align for the original and shifted readings",
+ "compare.line.month.day.align.until.prefix": " until original reading at date {date}",
+ "compare.line.original.shifted.count.first": "The original line has ",
+ "compare.line.original.shifted.count.second": " readings but the shifted line has ",
+ "compare.line.original.shifted.count.third": ", which means the points will not align horizontally.",
+ "compare.line.shifted.overlaps.start.prefix": "The shifted line overlaps the original line starting at ",
"compare.period": "Compare Period",
"compare.raw": "Cannot create comparison graph on raw units such as temperature",
"confirm.action": "Confirm Action",
@@ -497,7 +504,7 @@ const LocaleTranslationData = {
"select.shift.amount": "Select shift amount",
"select.unit": "Select Unit",
"shift.date.interval": "Shift Date Interval",
- "shifted.data.crosses.leap.year.to.non.leap.year": "Shifted data crosses a leap year so the graph might not align appropriately",
+ "shifted": "Shifted",
"show": "Show",
"show.all.logs": "Show All Logs ",
"show.grid": "Show grid",
@@ -670,7 +677,14 @@ const LocaleTranslationData = {
"close": "Close\u{26A1}",
"compare.bar": "Compare Bar\u{26A1}",
"compare.line": "Compare line\u{26A1}",
+ "compare.line.days.align": "Days of week align (unless missing readings)\u{26A1}",
"compare.line.days.enter": "Enter in days and then hit enter\u{26A1}",
+ "compare.line.month.day.align": "The month and day of the month align for the original and shifted readings\u{26A1}",
+ "compare.line.month.day.align.until.prefix": " until original reading at date {date}\u{26A1}",
+ "compare.line.original.shifted.count.first": "The original line has \u{26A1}",
+ "compare.line.original.shifted.count.second": " readings but the shifted line has \u{26A1}",
+ "compare.line.original.shifted.count.third": ", which means the points will not align horizontally.\u{26A1}",
+ "compare.line.shifted.overlaps.start.prefix": "The shifted line overlaps the original line starting at \u{26A1}",
"compare.period": "Compare Period\u{26A1}",
"compare.raw": "Cannot create comparison graph on raw units such as temperature\u{26A1}",
"confirm.action": "Confirm Action\u{26A1}",
@@ -1106,7 +1120,7 @@ const LocaleTranslationData = {
"select.shift.amount": "Select shift amount\u{26A1}",
"select.unit": "Select Unit\u{26A1}",
"shift.date.interval": "Shift Date Interval\u{26A1}",
- "shifted.data.crosses.leap.year.to.non.leap.year": "Shifted data crosses a leap year so the graph might not align appropriately\u{26A1}",
+ "shifted": "Shifted\u{26A1}",
"show": "Montrer",
"show.all.logs": "Show All Logs\u{26A1} ",
"show.grid": "Show grid\u{26A1}",
@@ -1279,7 +1293,14 @@ const LocaleTranslationData = {
"close": "Cerrar",
"compare.bar": "Compare bar\u{26A1}",
"compare.line": "Compare line\u{26A1}",
+ "compare.line.days.align": "Days of week align (unless missing readings)\u{26A1}",
"compare.line.days.enter": "Enter in days and then hit enter\u{26A1}",
+ "compare.line.month.day.align": "The month and day of the month align for the original and shifted readings\u{26A1}",
+ "compare.line.month.day.align.until.prefix": " until original reading at date {date}\u{26A1}",
+ "compare.line.original.shifted.count.first": "The original line has \u{26A1}",
+ "compare.line.original.shifted.count.second": " readings but the shifted line has \u{26A1}",
+ "compare.line.original.shifted.count.third": ", which means the points will not align horizontally.\u{26A1}",
+ "compare.line.shifted.overlaps.start.prefix": "The shifted line overlaps the original line starting at \u{26A1}",
"compare.period": "Compare Period\u{26A1}",
"compare.raw": "No se puede crear un gráfico de comparación con unidades crudas como temperatura",
"confirm.action": "Confirmar acción",
@@ -1714,7 +1735,7 @@ const LocaleTranslationData = {
"select.shift.amount": "Select shift amount\u{26A1}",
"select.unit": "Seleccionar unidad",
"shift.date.interval": "Shift Date Interval\u{26A1}",
- "shifted.data.crosses.leap.year.to.non.leap.year": "Shifted data crosses a leap year so the graph might not align appropriately\u{26A1}",
+ "shifted": "Shifted\u{26A1}",
"show": "Mostrar",
"show.all.logs": "Show All Logs\u{26A1} ",
"show.grid": "Mostrar rejilla",