diff --git a/src/components/Charts/AxisBottom.tsx b/src/components/Charts/AxisBottom.tsx index 03072d721dbad11497d126199b3594569762dd58..f3d5a103b785210f8bbbab855863e6aee5711671 100644 --- a/src/components/Charts/AxisBottom.tsx +++ b/src/components/Charts/AxisBottom.tsx @@ -22,10 +22,6 @@ function TextAxis(props: TextTypeProps) { selectedDate, dataload.date ) - - const isEven = (n: number) => { - return n % 2 == 0 - } const style = isSelectedDate ? 'tick-text tick-text-selected chart-ticks-x-text' : 'tick-text chart-ticks-x-text' @@ -49,25 +45,12 @@ function TextAxis(props: TextTypeProps) { case TimeStep.DAY: return ( <text y="10" dy="0.71em" transform={`translate(${width})`}> - {isEven(index) ? ( - <> - <tspan className={style} x="0" textAnchor="middle"> - {dataload.date.toLocaleString({ weekday: 'narrow' })} - </tspan> - <tspan className={style} x="0" dy="1.2em" textAnchor="middle"> - {dataload.date.toLocaleString({ day: 'numeric' })} - </tspan> - </> - ) : ( - <tspan - className={style + ' separator'} - dx="0" - dy="8px" - textAnchor="middle" - > - . - </tspan> - )} + <tspan className={style} x="0" textAnchor="middle"> + {dataload.date.toLocaleString({ weekday: 'narrow' })} + </tspan> + <tspan className={style} x="0" dy="1.2em" textAnchor="middle"> + {dataload.date.toLocaleString({ day: '2-digit' })} + </tspan> </text> ) case TimeStep.HOUR: @@ -140,7 +123,6 @@ const AxisBottom = (props: AxisBottomProps) => { width={xScale.bandwidth() / 2} selectedDate={selectedDate} /> - {dateChartService.compareStepDate( timeStep, DateTime.local(), diff --git a/src/components/Charts/BarChart.tsx b/src/components/Charts/BarChart.tsx index 05e6503dcb5edaaf9a0310d6292213ef0295a272..45f1ec10d4874413736f09106962645b82265510 100644 --- a/src/components/Charts/BarChart.tsx +++ b/src/components/Charts/BarChart.tsx @@ -79,12 +79,8 @@ const BarChart: React.FC<BarChartProps> = (props: BarChartProps) => { const maxCompare = chartData.comparisonData ? Math.max(...chartData.comparisonData.map(d => d.value)) : 0 - if (timeStep === TimeStep.DAY || timeStep === TimeStep.HALF_AN_HOUR) { - const actualMonth = - timeStep === TimeStep.DAY - ? selectedDate.startOf('month').month - : selectedDate.startOf('week').month + const actualMonth = selectedDate.startOf('week').month const actualYear = selectedDate.startOf('week').year const key = `${actualMonth}/${actualYear}-${isHome}-${fluidTypes.join( '-' @@ -94,9 +90,9 @@ const BarChart: React.FC<BarChartProps> = (props: BarChartProps) => { } const maxLoad = maxLoads[key] || 0 if (showCompare) { - return Math.round(Math.max(maxLoad, maxCompare)) + return Math.max(maxLoad, maxCompare) } - return maxLoad > 0 ? Math.round(maxLoad) : 15 + return maxLoad > 0 ? maxLoad : 15 } else { let max = chartData.actualData ? Math.max(...chartData.actualData.map(d => d.value)) diff --git a/src/components/FluidChart/FluidChartSlide.tsx b/src/components/FluidChart/FluidChartSlide.tsx index 7bb66fb103e37e54e8d3c99e7116bae145e2b076..0fcef191a450843652ad11cadd9a791125a071a5 100644 --- a/src/components/FluidChart/FluidChartSlide.tsx +++ b/src/components/FluidChart/FluidChartSlide.tsx @@ -87,8 +87,23 @@ const FluidChartSlide: React.FC<FluidChartSlideProps> = ({ // Full month + last day of the previous month for TimeStep.HALF_AN_HOUR const maxTimePeriod = { - startDate: lastSlideDate.startOf('month'), - endDate: lastSlideDate.endOf('month'), + startDate: + timeStep === TimeStep.HALF_AN_HOUR + ? lastSlideDate.startOf('month') + : lastSlideDate.startOf('week').startOf('month').weekday === 1 + ? lastSlideDate.startOf('week').startOf('month') + : lastSlideDate + .startOf('week') + .startOf('month') + .plus({ days: +7 }) + .startOf('week'), + endDate: + timeStep === TimeStep.HALF_AN_HOUR + ? lastSlideDate.endOf('month') + : lastSlideDate.startOf('week').month !== + lastSlideDate.endOf('week').month + ? lastSlideDate.endOf('week') + : lastSlideDate.endOf('month').endOf('week'), } const compareMaxTimePeriod = maxTimePeriod diff --git a/src/services/consumption.service.ts b/src/services/consumption.service.ts index 0436e02e10b26eee6f953beef696e408a540f067..ea15fc730b7523c5247562448cc81da0d0dd7276 100644 --- a/src/services/consumption.service.ts +++ b/src/services/consumption.service.ts @@ -88,7 +88,6 @@ export default class ConsumptionDataManager { timePeriod, compareTimePeriod || null ) - // validating output data toBeAgreggatedData.push({ @@ -98,6 +97,7 @@ export default class ConsumptionDataManager { } const aggregatedData = this.aggregateGraphData(toBeAgreggatedData) + // mapping result to contract mappedData = aggregatedData @@ -389,7 +389,6 @@ export default class ConsumptionDataManager { for (const singleFluidChart of singleFluidCharts) { if (!singleFluidChart.chartData) break - if (!singleFluidChart.chartData.actualData[i]) break const value = singleFluidChart.chartData.actualData[i].value if ( diff --git a/src/services/dateChart.service.ts b/src/services/dateChart.service.ts index fa05215758ec8d330aeea9b058132efc02444432..49a1921f3cc685a4d4b84eb00bdffc24728b9b68 100644 --- a/src/services/dateChart.service.ts +++ b/src/services/dateChart.service.ts @@ -39,21 +39,12 @@ export default class DateChartService { endDate: date.plus({ months: -12 * index }), } case TimeStep.DAY: - date = referenceDate.set({ - day: 1, - hour: 0, - minute: 0, - second: 0, - millisecond: 0, - }) + date = referenceDate + .endOf('week') + .set({ hour: 0, minute: 0, second: 0, millisecond: 0 }) return { - startDate: date.plus({ month: -index }).startOf('day'), - endDate: date - .plus({ - month: -index, - }) - .endOf('month') - .startOf('day'), + startDate: date.plus({ days: -7 * index - (7 - 1) }), + endDate: date.plus({ days: -7 * index }), } case TimeStep.HOUR: date = referenceDate.set({ @@ -238,14 +229,10 @@ export default class DateChartService { break case TimeStep.DAY: incrementedDate = initialdate.plus({ day: increment }) - if ( - initialdate.day === initialdate.daysInMonth && - incrementedDate.day && - incrementedDate.day !== initialdate.daysInMonth - 1 - ) { - incrementIndex = -1 - } else if (initialdate.day === 1 && incrementedDate.day !== 2) { + if (initialdate.weekday === 1 && incrementedDate.weekday === 7) { incrementIndex = 1 + } else if (initialdate.weekday === 7 && incrementedDate.weekday === 1) { + incrementIndex = -1 } else { incrementIndex = 0 } diff --git a/src/services/timePeriod.service.ts b/src/services/timePeriod.service.ts index ffe91665f3ed6a4115dd1e9382cfb0ff7055e107..efa5c017338e52e0bc0752e27f14acbc3a6b0c5e 100644 --- a/src/services/timePeriod.service.ts +++ b/src/services/timePeriod.service.ts @@ -122,9 +122,9 @@ export default class TimePeriodService { case TimeStep.HOUR: return DateTime.local(startDate.year, startDate.month, startDate.day) case TimeStep.DAY: - return DateTime.local(startDate.year, startDate.month, 1) + return DateTime.local(startDate.year, startDate.month, startDate.day) .setLocale('fr-CA') - .startOf('month') + .startOf('week') case TimeStep.MONTH: return DateTime.local(startDate.year, startDate.month, 1) case TimeStep.YEAR: diff --git a/src/styles/base/_typography.scss b/src/styles/base/_typography.scss index f80e3e5b9af9b7d06910d8451928b94612875aac..9a379223a73f0f966f44ebe6c7c73a113a8b244c 100644 --- a/src/styles/base/_typography.scss +++ b/src/styles/base/_typography.scss @@ -279,7 +279,7 @@ p { font-size: 1rem; line-height: 120%; @media #{$large-phone} { - font-size: 0.685rem; + font-size: 0.875rem; } } .chart-ticks-y-text { diff --git a/src/styles/components/_barchart.scss b/src/styles/components/_barchart.scss index 83019797cc2e8909fa3122dc936bc86ac714e1a5..d4329e36c73af5810ae7cdf7a83add0210ae4709 100644 --- a/src/styles/components/_barchart.scss +++ b/src/styles/components/_barchart.scss @@ -9,11 +9,6 @@ fill: $grey-bright; } } - .separator { - text-align: center; - margin: 0 2px; - font-size: 1rem !important; - } } .background-true { opacity: 0.1;