Skip to content
Snippets Groups Projects
Commit 08fe45d3 authored by Romain CREY's avatar Romain CREY
Browse files

fix: comments MR + start of month

parent d398ea8d
No related branches found
No related tags found
3 merge requests!103Support,!102Dev,!68Features/scale graph
......@@ -12,12 +12,9 @@ import ChallengeCardContainer from 'components/ContainerComponents/ChallengeCard
import KonnectorViewerContainer from 'components/ContainerComponents/KonnectorViewerContainer/KonnectorViewerContainer'
const HomeViewContainer: React.FC = () => {
const {
fluidTypes,
previousTimeStep,
setPreviousTimeStep,
chartIsLoaded,
} = useContext(AppContext)
const { fluidTypes, previousTimeStep, setPreviousTimeStep } = useContext(
AppContext
)
const [timeStep, setTimeStep] = useState<TimeStep>(
previousTimeStep && previousTimeStep !== TimeStep.HALF_AN_HOUR
? previousTimeStep
......
......@@ -16,12 +16,7 @@ interface AxisRightProps {
const AxisRight = (props: AxisRightProps) => {
const { yScale, fluidTypes, width, marginRight, marginTop, t } = props
let isHome
if (!window.location.hash.split('/')[2]) {
isHome = true
} else {
isHome = false
}
const isHome: boolean = !window.location.hash.split('/')[2] ? true : false
const fluidStyle =
fluidTypes.length > 1 || isHome ? 'MULTIFLUID' : FluidType[fluidTypes[0]]
const yAxisRef = useRef<SVGGElement>(null)
......
import React, { useContext, useEffect, useState } from 'react'
import React, { useContext, useEffect } from 'react'
import { scaleBand, ScaleBand, scaleLinear, ScaleLinear } from 'd3-scale'
import {
IDataload,
......@@ -78,14 +78,18 @@ const BarChart: React.FC<BarChartProps> = (props: BarChartProps) => {
const getMaxLoad = () => {
if (
(timeStep === TimeStep.DAY || timeStep === TimeStep.HALF_AN_HOUR) &&
!showCompare
(timeStep === TimeStep.DAY && !showCompare) ||
timeStep === TimeStep.HALF_AN_HOUR
) {
const actualMonth = selectedDate.startOf('week').month
const actualYear = selectedDate.startOf('week').year
const key = `${actualMonth}/${actualYear}-${isHome}-${fluidTypes
.sort()
.join('-')}-${timeStep}`
if (DateTime.local() < selectedDate && !maxLoads[key]) {
maxLoads[key] = 15
}
return maxLoads[key] > 0 ? maxLoads[key] : 15
} else {
let max = chartData.actualData
......@@ -119,13 +123,12 @@ const BarChart: React.FC<BarChartProps> = (props: BarChartProps) => {
const yScale: ScaleLinear<number, number> = scaleLinear()
.domain([0, getMaxLoad()])
.range([getContentHeight(), 0])
const size = Object.keys(maxLoads).length
useEffect(() => {
if (size > 0) {
if (Object.keys(maxLoads).length > 0) {
setChartIsLoaded(true)
}
}, [size, maxLoads])
}, [maxLoads])
useEffect(() => {
setChartIsLoaded(true)
}, [])
......
......@@ -54,12 +54,8 @@ const FluidChartSlide: React.FC<FluidChartSlideProps> = ({
const { setChartIsLoaded, maxLoads, chartIsLoaded } = useContext(AppContext)
let isHome: boolean
if (!window.location.hash.split('/')[2]) {
isHome = true
} else {
isHome = false
}
const isHome: boolean = !window.location.hash.split('/')[2] ? true : false
useEffect(() => {
let subscribed = true
async function loadData() {
......@@ -99,14 +95,14 @@ const FluidChartSlide: React.FC<FluidChartSlideProps> = ({
startDate:
timeStep === TimeStep.HALF_AN_HOUR
? selectedDate.startOf('month')
: selectedDate.startOf('month').startOf('week').month !==
selectedDate.startOf('month').endOf('week').month
? selectedDate
: selectedDate.startOf('week').startOf('month').weekdayLong ===
'lundi'
? selectedDate.startOf('week').startOf('month')
: selectedDate
.startOf('week')
.startOf('month')
.plus({ days: +7 })
.startOf('week')
: selectedDate.startOf('week').startOf('month'),
.startOf('week'),
endDate:
timeStep === TimeStep.HALF_AN_HOUR
? selectedDate.endOf('month')
......@@ -133,8 +129,6 @@ const FluidChartSlide: React.FC<FluidChartSlideProps> = ({
maxLoads[key] = graphMaxLoad
key in maxLoads ? (maxLoads[key] = graphMaxLoad) : null
if (subscribed && graphMaxLoad) {
setIsLoaded(true)
setChartIsLoaded(true)
......
......@@ -43,7 +43,7 @@ export default class ConsumptionDataValidator {
)
if (timeStep == TimeStep.HALF_AN_HOUR && interval.length('hour') > 24)
return false
if (timeStep == TimeStep.DAY && interval.length('day') > 40) return false
if (timeStep == TimeStep.DAY && interval.length('day') > 36) return false
if (timeStep == TimeStep.MONTH && interval.length('month') > 12)
return false
if (timeStep == TimeStep.YEAR && interval.length('year') > 10) return false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment