From 80a299cb9fedf28dca1b4636e9a089fbceacd189 Mon Sep 17 00:00:00 2001
From: Yoan VALLET <ext.sopra.yvallet@grandlyon.com>
Date: Wed, 10 Mar 2021 11:14:30 +0100
Subject: [PATCH] feat: display only mondays for duel > 2 weeks

---
 src/components/Charts/AxisBottom.tsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/components/Charts/AxisBottom.tsx b/src/components/Charts/AxisBottom.tsx
index d2e8bffd2..559f144fb 100644
--- a/src/components/Charts/AxisBottom.tsx
+++ b/src/components/Charts/AxisBottom.tsx
@@ -15,7 +15,7 @@ interface TextTypeProps {
   timeStep: TimeStep
   width: number
   selectedDate: DateTime
-  isDuel?: boolean
+  displayAllDays?: boolean
 }
 
 function TextAxis({
@@ -24,7 +24,7 @@ function TextAxis({
   timeStep,
   width,
   selectedDate,
-  isDuel,
+  displayAllDays,
 }: TextTypeProps) {
   const dateChartService = new DateChartService()
   const isSelectedDate = dateChartService.compareStepDate(
@@ -56,7 +56,7 @@ function TextAxis({
     case TimeStep.DAY:
       return (
         <text y="10" dy="0.71em" transform={`translate(${width})`}>
-          {isDuel ? (
+          {displayAllDays ? (
             <>
               <tspan className={style} x="0" textAnchor="middle">
                 {dataload.date.toLocaleString({ weekday: 'narrow' })}
@@ -128,11 +128,12 @@ const AxisBottom: React.FC<AxisBottomProps> = ({
   height,
   marginLeft,
   marginBottom,
-  isDuel,
+  isDuel = false,
 }: AxisBottomProps) => {
   const { selectedDate } = useSelector((state: AppStore) => state.ecolyo.chart)
   const dashArray = `${height / 30} ${height / 30}`
   const dateChartService = new DateChartService()
+  const displayAllDays: boolean = isDuel && data.length <= 15
   return (
     <g
       className="axis x"
@@ -153,7 +154,7 @@ const AxisBottom: React.FC<AxisBottomProps> = ({
             timeStep={timeStep}
             width={xScale.bandwidth() / 2}
             selectedDate={selectedDate}
-            isDuel={isDuel}
+            displayAllDays={displayAllDays}
           />
           {dateChartService.compareStepDate(
             timeStep,
-- 
GitLab