Skip to content
Snippets Groups Projects
Commit bc69618d authored by Guilhem CARRON's avatar Guilhem CARRON
Browse files

Merge branch 'features/US365-change_fluid_navigation' of...

Merge branch 'features/US365-change_fluid_navigation' of https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo into features/US365-change_fluid_navigation
parents 77d011c5 e938bb83
No related branches found
No related tags found
1 merge request!248Features/us365 change fluid navigation
import React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { AppStore } from 'store'
import { addMaxLoad } from 'store/chart/chart.actions'
import { scaleBand, ScaleBand, scaleLinear, ScaleLinear } from 'd3-scale'
import { DateTime } from 'luxon'
......@@ -63,8 +60,6 @@ const BarChart: React.FC<BarChartProps> = (props: BarChartProps) => {
isSwitching,
isHome,
} = props as PropsWithDefaults
const dispatch = useDispatch()
const { maxLoads } = useSelector((state: AppStore) => state.ecolyo.chart)
const getContentWidth = () => {
return width - marginLeft - marginRight
......@@ -78,38 +73,11 @@ 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 actualYear = selectedDate.startOf('week').year
const key = `${actualMonth}/${actualYear}-${isHome}-${fluidTypes.join(
'-'
)}-${timeStep}`
let maxLoad = 0
if (
DateTime.local().setZone('utc', {
keepLocalTime: true,
}) < selectedDate &&
!maxLoads.has(key)
) {
maxLoad = 15
dispatch(addMaxLoad(new Map().set(key, maxLoad)))
} else {
maxLoad = maxLoads.get(key) || 0
}
if (showCompare) {
return Math.round(Math.max(maxLoad, maxCompare))
}
return maxLoad > 0 ? Math.round(maxLoad) : 15
} else {
let max = chartData.actualData
? Math.max(...chartData.actualData.map(d => d.value))
: 0
max = max <= 0 ? 15 : max
return showCompare ? Math.max(max, maxCompare) : max
}
let max = chartData.actualData
? Math.max(...chartData.actualData.map(d => d.value))
: 0
max = max <= 0 ? 15 : max
return showCompare ? Math.max(max, maxCompare) : max
}
const xScale: ScaleBand<string> = scaleBand()
......
......@@ -31,6 +31,7 @@ const DateNavigatorFormat: React.FC<DateNavigatorFormatProps> = ({
}),
]
case TimeStep.DAY:
case TimeStep.WEEK:
return [
date.toLocaleString({
weekday: 'long',
......@@ -40,17 +41,6 @@ const DateNavigatorFormat: React.FC<DateNavigatorFormatProps> = ({
month: 'long',
}),
]
case TimeStep.HOUR:
return [
date.toLocaleString({
hour: 'numeric',
}),
date.toLocaleString({
weekday: 'long',
day: '2-digit',
month: 'long',
}),
]
case TimeStep.HALF_AN_HOUR:
return [
date.toLocaleString({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment