pnp / List-Formatting

List Formatting Samples for use in SharePoint and Microsoft Lists
https://pnp.github.io/List-Formatting/
MIT License
1.7k stars 823 forks source link

Project Gantt Chart #759

Closed gowebUSA closed 4 months ago

gowebUSA commented 6 months ago

Sample (which sample are you talking about)

https://github.com/pnp/List-Formatting/tree/master/view-samples/project-gantt-chart

Question (the more details, the better)

Hi Tecchan1107,

This is the same issue as the Column Gantt Chart you helped me on the Task #752. I tried to follow everything on your JSON and it is not giving me the same result. Please see screenshot.

image

The next screenshot is a list of my columns. Not sure if I gave it to you from Task#752.

image

I appreciate your help again on this.

gowebUSA commented 6 months ago

Here is my JSON.

   {
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "height": "=if(@rowIndex == 0, '88px', '52px')",
      "display": "block",
      "width": "100%",
      "position": "sticky"
    },
    "attributes": {
      "class": "ms-bgColor-neutralLighter--hover"
    },
    "children": [
      {
        "elmType": "div",
        "attributes": {
          "class": "ms-bgColor-themePrimary"
        },
        "style": {
          "width": "100%",
          "display": "=if(@rowIndex == 0, 'flex', 'none')",
          "height": "36px",
          "padding": "0",
          "font-weight": "bold",
          "border-radius": "6px 6px 0 0"
        },
        "children": [
          {
            "elmType": "div",
            "txtContent": "Task",
            "style": {
              "width": "220px",
              "text-align": "left",
              "padding-left": "0.4em",
              "box-sizing": "border-box"
            },
            "attributes": {
              "class": "ms-fontSize-16 ms-fontColor-white"
            }
          },
          {
            "elmType": "div",
            "style": {
              "flex-grow": "1",
              "height": "100%",
              "position": "relative"
            },
            "children": [
              {
                "elmType": "div",
                "txtContent": "=toLocaleDateString([$ProjectStart])",
                "style": {
                  "position": "absolute",
                  "padding": "14px 4px 0 4px",
                  "height": "22px",
                  "border-radius": "6px 6px 0 0"
                },
                "attributes": {
                  "title": "='Project Start: ' + toLocaleDateString([$ProjectStart])",
                  "class": "ms-bgColor-themeDarker ms-fontSize-14 ms-fontColor-white"
                }
              },
              {
                "elmType": "div",
                "txtContent": "=toLocaleDateString([$ProjectDue])",
                "style": {
                  "position": "absolute",
                  "right": "0",
                  "padding": "14px 4px 0 4px",
                  "height": "22px",
                  "border-radius": "6px 6px 0 0"
                },
                "attributes": {
                  "title": "='Project Finish: ' + toLocaleDateString([$ProjectDue])",
                  "class": "ms-bgColor-themeDarker ms-fontSize-14 ms-fontColor-white"
                }
              },
              {
                "elmType": "span",
                "txtContent": "=toLocaleDateString( @now)",
                "style": {
                  "position": "relative",
                  "width": "90px",
                  "z-index": "100",
                  "display": "=if([$ProjectDue] < @now , 'none', 'block')",
                  "left": "=floor( (Number(@now)-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) * 100 ) + '%'",
                  "background-color": "#e1dfdd",
                  "text-align": "center",
                  "padding": "0 3px",
                  "margin": "0 0 0 3px"
                }
              },
              {
                "elmType": "span",
                "attributes": {
                  "class": "ms-fontColor-gray40"
                },
                "style": {
                  "position": "relative",
                  "display": "=if( [$ProjectDue] < @now , 'none', 'block')",
                  "top": "-1.3em",
                  "z-index": "1",
                  "border-left": "5px solid",
                  "height": "800px",
                  "width": "0.1em",
                  "left": "=  (Number(@now)-Number([$ProjectStart])) /  (Number([$ProjectDue])-Number([$ProjectStart]))  * 100  + '%' "
                }
              }
            ]
          }
        ]
      },
      {
        "elmType": "div",
        "style": {
          "width": "100%",
          "display": "flex"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "width": "220px",
              "display": "flex",
              "flex-wrap": "wrap"
            },
            "attributes": {
              "class": ""
            },
            "children": [
              {
                "elmType": "span",
                "style": {
                  "width": "24px",
                  "padding": "6px 0",
                  "text-align": "center",
                  "cursor": "pointer"
                },
                "attributes": {
                  "iconName": "=if([$Progress] >= 1, 'CompletedSolid', if([$Progress] > 0 , 'CortanaLogoReadyOuter', 'CircleRing'))",
                  "title": "='Progress: ' + Number([$Progress] * 100) + '%'",
                  "class": "= 'ms-fontSize-14 ms-fontColor-' + if([$Progress] >= 1, 'green', 'neutralSecondaryAlt')"
                },
                "customRowAction": {
                  "action": "setValue",
                  "actionInput": {
                    "Progress": "=if([$Progress] == 0, if([$TaskType] == 'Task' || [$TaskType] == '', 25 , 100)  , if([$Progress] == 0.25 , 50, if([$Progress] == 0.50, 75, if([$Progress] == 0.75, 100, 0))))"
                  }
                }
              },
              {
                "elmType": "button",
                "txtContent": "[$Title]",
                "customRowAction": {
                  "action": "editProps"
                },
                "style": {
                  "width": "196px",
                  "height": "1.6em",
                  "padding": "0.3em 0 0 0",
                  "border": "none",
                  "background-color": "transparent",
                  "cursor": "pointer",
                  "text-decoration": "none",
                  "text-align": "left",
                  "outline": "none",
                  "display": "inline-block",
                  "overflow": "hidden",
                  "text-overflow": "ellipsis",
                  "white-space": "nowrap"
                },
                "attributes": {
                  "title": "[$Title]",
                  "class": "ms-fontSize-14 ms-fontWeight-semibold ms-fontColor-gray140 ms-fontColor-black--hover"
                }
              },
              {
                "elmType": "span",
                "style": {
                  "width": "24px",
                  "padding": "1px 0 0 0",
                  "text-align": "center"
                },
                "attributes": {
                  "iconName": "=if( ( ([$TaskType] == 'Task' || [$TaskType] == '') && [$TaskDue]< @now && [$Progress] < 1 ) || ([$TaskType] == 'Milestone' && [$TaskStart]< @now && [$Progress] < 1 )  , 'EventDateMissed12', '')",
                  "title": "This task is running late!",
                  "class": "='ms-fontSize-14 ms-fontColor-' + if([$TaskDue]< @now && [$Progress] < 1, 'sharedRed20', 'themePrimary')"
                }
              },
              {
                "elmType": "div",
                "txtContent": "=toLocaleDateString([$TaskStart])",
                "style": {
                  "width": "96px",
                  "padding": "0.1em 0",
                  "text-align": " center",
                  "heigth": "1.4em",
                  "border-radius": "12px",
                  "margin": "0 2px 0 0 "
                },
                "attributes": {
                  "class": "ms-fontSize-12 ms-bgColor-neutralLight"
                }
              },
              {
                "elmType": "div",
                "txtContent": "=toLocaleDateString([$TaskDue])",
                "style": {
                  "width": "96px",
                  "padding": "0.1em 0",
                  "text-align": " center",
                  "border-radius": "12px",
                  "margin": "0 2px 0 0 "
                },
                "attributes": {
                  "class": "ms-fontSize-12 ms-bgColor-neutralLight"
                }
              }
            ]
          },
          {
            "elmType": "div",
            "style": {
              "flex-grow": "1",
              "position": "relative",
              "height": "3.3em",
              "padding": "0.3em 0 0 0"
            },
            "attributes": {
              "class": ""
            },
            "children": [
              {
                "elmType": "div",
                "txtContent": "",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "display": "=if([$TaskType] == 'Task' || [$TaskType] == '' , 'flex', 'none')",
                  "border-radius": "6px",
                  "z-index": "10",
                  "top": "0.6em",
                  "height": "2.4em",
                  "overflow": "hidden",
                  "text-overflow": "ellipsis",
                  "border": "1px solid",
                  "border-color": "#0078db",
                  "background-color": "#cfe6f7",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) * 100  + '%'",
                  "width": "= if( [$TaskDue] > [$ProjectDue],  (Number([$ProjectDue])-Number([$TaskStart])+ 86400000) / (Number([$ProjectDue])-Number([$ProjectStart])+ 86400000) * 100  ,  (Number([$TaskDue])-Number([$TaskStart])+ 86400000) / (Number([$ProjectDue])-Number([$ProjectStart])+ 86400000) * 100 ) + '%'"
                },
                "attributes": {
                  "class": "",
                  "title": ""
                }
              },
              {
                "elmType": "div",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "display": "=if(( [$TaskType] == 'Task' || [$TaskType] == '' ) && [$Progress] > 0, 'flex', 'none')",
                  "border-radius": "=if( [$Progress] < 1, '6px 0 0 6px', '6px')",
                  "z-index": "20",
                  "top": "0.6em",
                  "height": "2.4em",
                  "overflow": "hidden",
                  "text-overflow": "ellipsis",
                  "border": "1px solid",
                  "border-color": "#0078db",
                  "background-color": "#0078db",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) * 100  + '%'",
                  "width": "= if( [$TaskDue] > [$ProjectDue],  ((Number([$ProjectDue])-Number([$TaskStart])+ 86400000) / (Number([$ProjectDue])-Number([$ProjectStart])+ 86400000) * 100) * [$Progress] + '%'  ,  ((Number([$TaskDue])-Number([$TaskStart])+ 86400000) / (Number([$ProjectDue])-Number([$ProjectStart])+ 86400000) * 100 * [$Progress]) + '%'"
                },
                "attributes": {
                  "class": "sp-field-bold",
                  "title": "=[$Title] + ' - ' + toLocaleDateString([$TaskStart]) + ' - ' + toLocaleDateString([$TaskDue])"
                }
              },
              {
                "elmType": "div",
                "txtContent": "",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "border-radius": "6px",
                  "z-index": "50",
                  "top": "0.6em",
                  "height": "2.4em",
                  "overflow": "hidden",
                  "text-overflow": "ellipsis",
                  "border": "=if([$TaskDue]< @now && [$Progress] < 1 && ([$TaskType] == 'Task' || [$TaskType] == '' ), '2px solid #f8b7bd', 'none')",
                  "background-color": "",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) * 100  + '%'",
                  "width": "=if([$TaskType] == 'Milestone', '28px' ,  if( [$TaskDue] > [$ProjectDue],  (Number([$ProjectDue])-Number([$TaskStart])+ 86400000) / (Number([$ProjectDue])-Number([$ProjectStart])+ 86400000) * 100  ,  (Number([$TaskDue])-Number([$TaskStart])+ 86400000) / (Number([$ProjectDue])-Number([$ProjectStart])+ 86400000) * 100 ) + '%'",
                  "margin-left": "=if([$TaskType] == 'Milestone', '-14px' , 0"
                },
                "attributes": {
                  "class": "",
                  "title": ""
                },
                "customCardProps": {
                  "openOnEvent": "hover",
                  "directionalHint": "bottomCenter",
                  "isBeakVisible": true,
                  "beakStyle": {
                    "backgroundColor": "white"
                  },
                  "formatter": {
                    "elmType": "div",
                    "style": {
                      "max-height": "256px",
                      "width": "282px",
                      "display": "flex",
                      "flex-wrap": "wrap",
                      "align-items": "flex-start"
                    },
                    "attributes": {
                      "class": "ms-ContextualMenu-list is-open list-436"
                    },
                    "children": [
                      {
                        "elmType": "div",
                        "txtContent": "[$Title]",
                        "style": {
                          "width": "250px",
                          "height": "40px",
                          "padding": "4px 4px 0 4px",
                          "overflow": "hidden",
                          "text-overflow": "ellipsis"
                        },
                        "attributes": {
                          "class": "ms-fontSize-14 ms-bgColor-themeLight ms-fontWeight-semibold ms-fontColor-gray160"
                        }
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "12",
                          "flex-grow": "1",
                          "height": "34px",
                          "padding": "10px 0 0 0 ",
                          "text-align": "center",
                          "cursor": "pointer"
                        },
                        "attributes": {
                          "iconName": "Edit",
                          "class": "ms-fontSize-14 ms-bgColor-themeLight  ms-fontColor-gray160"
                        },
                        "customRowAction": {
                          "action": "editProps"
                        }
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "100%",
                          "display": "flex",
                          "flex-wrap": "wrap",
                          "align-items": "flex-start",
                          "margin": "2px 0"
                        },
                        "children": [
                          {
                            "elmType": "div",
                            "style": {
                              "width": "24px",
                              "padding": "6px 0",
                              "text-align": " center",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "iconName": "Timeline"
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "0%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "0"
                              }
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "25%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0.25, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "25"
                              }
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "50%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0.5, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "50"
                              }
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "75%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0.75, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "75"
                              }
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "100%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 1, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "100"
                              }
                            }
                          }
                        ]
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "24px",
                          "display": "=if( ( ([$TaskType] == 'Task' || [$TaskType] == '') && [$TaskDue]< @now && [$Progress] < 1 ) || ([$TaskType] == 'Milestone' && [$TaskStart]< @now && [$Progress] < 1 ) , 'block', 'none')",
                          "padding": "6px 0 7px 0",
                          "text-align": " center",
                          "heigth": "1.4em",
                          "margin": "2px 0"
                        },
                        "attributes": {
                          "iconName": "EventDateMissed12",
                          "class": "sp-field-severity--blocked30 ms-fontSize-14 ms-fontColor-sharedRed20"
                        }
                      },
                      {
                        "elmType": "div",
                        "txtContent": "This task is running late!",
                        "style": {
                          "width": "254px",
                          "display": "=if( ( ([$TaskType] == 'Task' || [$TaskType] == '') && [$TaskDue]< @now && [$Progress] < 1 ) || ([$TaskType] == 'Milestone' && [$TaskStart]< @now && [$Progress] < 1 ) , 'block', 'none')",
                          "padding": "4px 0 4px 4px",
                          "text-align": " Left",
                          "heigth": "1.4em",
                          "margin": "2px 0"
                        },
                        "attributes": {
                          "class": "sp-field-severity--blocked30 ms-fontSize-14 ms-fontColor-sharedRed20"
                        }
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "24px",
                          "padding": "6px 0",
                          "text-align": " center",
                          "heigth": "1.4em"
                        },
                        "attributes": {
                          "iconName": "Calendar"
                        }
                      },
                      {
                        "elmType": "div",
                        "txtContent": "=toLocaleDateString([$TaskStart])",
                        "style": {
                          "width": "127px",
                          "padding": "2px 0",
                          "text-align": " center",
                          "border-radius": "14px",
                          "margin": "2px 2px 0 0 ",
                          "height": "1.4em"
                        },
                        "attributes": {
                          "class": "ms-fontSize-14 ms-bgColor-neutralLight"
                        }
                      },
                      {
                        "elmType": "div",
                        "txtContent": "=toLocaleDateString([$TaskDue])",
                        "style": {
                          "width": "127px",
                          "padding": "2px 0",
                          "text-align": " center",
                          "border-radius": "14px",
                          "margin": "2px 2px 0 0 ",
                          "height": "1.4em"
                        },
                        "attributes": {
                          "class": "ms-fontSize-14 ms-bgColor-neutralLight"
                        }
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "24px",
                          "padding": "6px 0",
                          "text-align": " center",
                          "heigth": "1.4em"
                        },
                        "attributes": {
                          "iconName": "Contact",
                          "title": "='Assigned to : ' + [$AssignedToUser.title]"
                        }
                      },
                      {
                        "elmType": "div",
                        "txtContent": "[$AssignedToUser.title]",
                        "style": {
                          "width": "254px",
                          "padding": "4px 0 4px 4px"
                        },
                        "defaultHoverField": "[$AssignedToUser]"
                      },
                      {
                        "elmType": "div",
                        "txtContent": "[$TaskDescription]",
                        "style": {
                          "font-style": "italic",
                          "width": "254px",
                          "padding": "4px 0 4px 4px"
                        }
                      }
                    ]
                  }
                }
              },
              {
                "elmType": "div",
                "txtContent": "",
                "style": {
                  "position": "relative",
                  "box-sizing": "border-box",
                  "display": "=if([$TaskType] == 'Milestone', 'flex', 'none')",
                  "z-index": "10",
                  "top": "0.3em",
                  "height": "3em",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) * 100  + '%'",
                  "margin-left": "-14px",
                  "width": "28px"
                },
                "attributes": {
                  "iconName": "=if([$TaskStart]< @now && [$Progress] < 1, 'EventDateMissed12', 'EventDate'",
                  "title": "=[$Title] + ' - ' + toLocaleDateString([$TaskStart]) ",
                  "class": "='ms-fontSize-24 ' + if([$TaskStart]< @now && [$Progress] < 1, 'ms-fontColor-sharedRed20', 'ms-fontColor-themePrimary') "
                }
              },
              {
                "elmType": "div",
                "txtContent": "=getDate([$TaskStart]) + '-' +  if(getMonth([$TaskStart])==0,'Jan',if(getMonth([$TaskStart])==1,'Feb',if(getMonth([$TaskStart])==2,'Mar',if(getMonth([$TaskStart])==3,'Apr',if(getMonth([$TaskStart])==4,'May',if(getMonth([$TaskStart])==5,'Jun',if(getMonth([$TaskStart])==6,'Jul',if(getMonth([$TaskStart])==7,'Aug',if(getMonth([$TaskStart])==8,'Sep',if(getMonth([$TaskStart])==9,'Oct',if(getMonth([$TaskStart])==10,'Nov',if(getMonth([$TaskStart])==11,'Dec',''))))))))))))",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "display": "=if([$TaskType] == 'Milestone'  , 'flex', 'none')",
                  "z-index": "3",
                  "top": "10px",
                  "height": "24px",
                  "margin-left": "-60px",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) * 100  + '%'",
                  "width": "60px",
                  "text-align": "right"
                },
                "attributes": {
                  "class": "sp-field-bold ms-fontSize-14"
                }
              },
              {
                "elmType": "div",
                "txtContent": "=(Number[$Progress]) * 100 + '%'",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "display": "=if([$TaskType] == 'Task' || [$TaskType] == '' , 'flex', 'none')",
                  "z-index": "3",
                  "top": "10px",
                  "height": "24px",
                  "margin-left": "=if((Number([$TaskDue])-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) <= 0.9  , '10px' , '-40px')",
                  "left": "=if((Number([$TaskDue])-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) <= 0.9 , (Number([$TaskDue])-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) * 100  + '%' , (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectDue])-Number([$ProjectStart])) * 100  + '%' ) ",
                  "width": "40px"
                },
                "attributes": {
                  "class": "sp-field-bold ms-fontSize-14"
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
tecchan1107 commented 6 months ago

Hi @gowebUSA .

Am I correct in understanding that the problem is that "the view does not look like the image in the README"?

If so, check to see if the date is set in ProjectStart or ProjectDue. image

Also, check to see if the columns listed in the View Requirements, such as ProjectStart and ProjectDue, appear on the view. image

tecchan1107 commented 6 months ago

Or is it like you want to produce two Gantt charts, as in the following image? image

If so, I would appreciate it if you could tell me which dates should be shown on the Gantt chart. image

gowebUSA commented 6 months ago

Hi Tecchan1107, I have the ProjectStart and ProjectEnd added on the view. Having the 2 Gantt Charts looks good too. But the main issue I have is the Project Gantt Chart is not showing correctly from the readme image. It is just showing one starting point for all tasks. It is not distinguishing or separating the dates. Thank you for the help.

gowebUSA commented 6 months ago

Hi Tecchan1107. I was wrong on the ProjectDue, I didn't realize that the url is ProjectEnd, so I changed it back. The only issue now is the date on the top and the "Now" date does not show. I also paste the current JSON below. Thank you for your help and Happy New Year.

Project Gantt Chart No Date
      {
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "height": "=if(@rowIndex == 0, '88px', '52px')",
      "display": "block",
      "width": "100%",
      "position": "sticky"
    },
    "attributes": {
      "class": "ms-bgColor-neutralLighter--hover"
    },
    "children": [
      {
        "elmType": "div",
        "attributes": {
          "class": "ms-bgColor-themePrimary"
        },
        "style": {
          "width": "100%",
          "display": "=if(@rowIndex == 0, 'flex', 'none')",
          "height": "36px",
          "padding": "0",
          "font-weight": "bold",
          "border-radius": "6px 6px 0 0"
        },
        "children": [
          {
            "elmType": "div",
            "txtContent": "Task",
            "style": {
              "width": "220px",
              "text-align": "left",
              "padding-left": "0.4em",
              "box-sizing": "border-box"
            },
            "attributes": {
              "class": "ms-fontSize-16 ms-fontColor-white"
            }
          },
          {
            "elmType": "div",
            "style": {
              "flex-grow": "1",
              "height": "100%",
              "position": "relative"
            },
            "children": [
              {
                "elmType": "div",
                "txtContent": "=toLocaleDateString([$ProjectStart])",
                "style": {
                  "position": "absolute",
                  "padding": "14px 4px 0 4px",
                  "height": "22px",
                  "border-radius": "6px 6px 0 0"
                },
                "attributes": {
                  "title": "='Project Start: ' + toLocaleDateString([$ProjectStart])",
                  "class": "ms-bgColor-themeDarker ms-fontSize-14 ms-fontColor-white"
                }
              },
              {
                "elmType": "div",
                "txtContent": "=toLocaleDateString([$ProjectEnd])",
                "style": {
                  "position": "absolute",
                  "right": "0",
                  "padding": "14px 4px 0 4px",
                  "height": "22px",
                  "border-radius": "6px 6px 0 0"
                },
                "attributes": {
                  "title": "='Project Finish: ' + toLocaleDateString([$ProjectEnd])",
                  "class": "ms-bgColor-themeDarker ms-fontSize-14 ms-fontColor-white"
                }
              },
              {
                "elmType": "span",
                "txtContent": "=toLocaleDateString( @now)",
                "style": {
                  "position": "relative",
                  "width": "90px",
                  "z-index": "100",
                  "display": "=if([$ProjectEnd] < @now , 'none', 'block')",
                  "left": "=floor( (Number(@now)-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) * 100 ) + '%'",
                  "background-color": "#e1dfdd",
                  "text-align": "center",
                  "padding": "0 3px",
                  "margin": "0 0 0 3px"
                }
              },
              {
                "elmType": "span",
                "attributes": {
                  "class": "ms-fontColor-gray40"
                },
                "style": {
                  "position": "relative",
                  "display": "=if( [$ProjectEnd] < @now , 'none', 'block')",
                  "top": "-1.3em",
                  "z-index": "1",
                  "border-left": "5px solid",
                  "height": "800px",
                  "width": "0.1em",
                  "left": "=  (Number(@now)-Number([$ProjectStart])) /  (Number([$ProjectEnd])-Number([$ProjectStart]))  * 100  + '%' "
                }
              }
            ]
          }
        ]
      },
      {
        "elmType": "div",
        "style": {
          "width": "100%",
          "display": "flex"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "width": "220px",
              "display": "flex",
              "flex-wrap": "wrap"
            },
            "attributes": {
              "class": ""
            },
            "children": [
              {
                "elmType": "span",
                "style": {
                  "width": "24px",
                  "padding": "6px 0",
                  "text-align": "center",
                  "cursor": "pointer"
                },
                "attributes": {
                  "iconName": "=if([$Progress] >= 1, 'CompletedSolid', if([$Progress] > 0 , 'CortanaLogoReadyOuter', 'CircleRing'))",
                  "title": "='Progress: ' + Number([$Progress] * 100) + '%'",
                  "class": "= 'ms-fontSize-14 ms-fontColor-' + if([$Progress] >= 1, 'green', 'neutralSecondaryAlt')"
                },
                "customRowAction": {
                  "action": "setValue",
                  "actionInput": {
                    "Progress": "=if([$Progress] == 0, if([$TaskType] == 'Task' || [$TaskType] == '', 25 , 100)  , if([$Progress] == 0.25 , 50, if([$Progress] == 0.50, 75, if([$Progress] == 0.75, 100, 0))))"
                  }
                }
              },
              {
                "elmType": "button",
                "txtContent": "[$Title]",
                "customRowAction": {
                  "action": "editProps"
                },
                "style": {
                  "width": "196px",
                  "height": "1.6em",
                  "padding": "0.3em 0 0 0",
                  "border": "none",
                  "background-color": "transparent",
                  "cursor": "pointer",
                  "text-decoration": "none",
                  "text-align": "left",
                  "outline": "none",
                  "display": "inline-block",
                  "overflow": "hidden",
                  "text-overflow": "ellipsis",
                  "white-space": "nowrap"
                },
                "attributes": {
                  "title": "[$Title]",
                  "class": "ms-fontSize-14 ms-fontWeight-semibold ms-fontColor-gray140 ms-fontColor-black--hover"
                }
              },
              {
                "elmType": "span",
                "style": {
                  "width": "24px",
                  "padding": "1px 0 0 0",
                  "text-align": "center"
                },
                "attributes": {
                  "iconName": "=if( ( ([$TaskType] == 'Task' || [$TaskType] == '') && [$TaskDue]< @now && [$Progress] < 1 ) || ([$TaskType] == 'Milestone' && [$TaskStart]< @now && [$Progress] < 1 )  , 'EventDateMissed12', '')",
                  "title": "This task is running late!",
                  "class": "='ms-fontSize-14 ms-fontColor-' + if([$TaskDue]< @now && [$Progress] < 1, 'sharedRed20', 'themePrimary')"
                }
              },
              {
                "elmType": "div",
                "txtContent": "=toLocaleDateString([$TaskStart])",
                "style": {
                  "width": "96px",
                  "padding": "0.1em 0",
                  "text-align": " center",
                  "heigth": "1.4em",
                  "border-radius": "12px",
                  "margin": "0 2px 0 0 "
                },
                "attributes": {
                  "class": "ms-fontSize-12 ms-bgColor-neutralLight"
                }
              },
              {
                "elmType": "div",
                "txtContent": "=toLocaleDateString([$TaskDue])",
                "style": {
                  "width": "96px",
                  "padding": "0.1em 0",
                  "text-align": " center",
                  "border-radius": "12px",
                  "margin": "0 2px 0 0 "
                },
                "attributes": {
                  "class": "ms-fontSize-12 ms-bgColor-neutralLight"
                }
              }
            ]
          },
          {
            "elmType": "div",
            "style": {
              "flex-grow": "1",
              "position": "relative",
              "height": "3.3em",
              "padding": "0.3em 0 0 0"
            },
            "attributes": {
              "class": ""
            },
            "children": [
              {
                "elmType": "div",
                "txtContent": "",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "display": "=if([$TaskType] == 'Task' || [$TaskType] == '' , 'flex', 'none')",
                  "border-radius": "6px",
                  "z-index": "10",
                  "top": "0.6em",
                  "height": "2.4em",
                  "overflow": "hidden",
                  "text-overflow": "ellipsis",
                  "border": "1px solid",
                  "border-color": "#0078db",
                  "background-color": "#cfe6f7",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) * 100  + '%'",
                  "width": "= if( [$TaskDue] > [$ProjectEnd],  (Number([$ProjectEnd])-Number([$TaskStart])+ 86400000) / (Number([$ProjectEnd])-Number([$ProjectStart])+ 86400000) * 100  ,  (Number([$TaskDue])-Number([$TaskStart])+ 86400000) / (Number([$ProjectEnd])-Number([$ProjectStart])+ 86400000) * 100 ) + '%'"
                },
                "attributes": {
                  "class": "",
                  "title": ""
                }
              },
              {
                "elmType": "div",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "display": "=if(( [$TaskType] == 'Task' || [$TaskType] == '' ) && [$Progress] > 0, 'flex', 'none')",
                  "border-radius": "=if( [$Progress] < 1, '6px 0 0 6px', '6px')",
                  "z-index": "20",
                  "top": "0.6em",
                  "height": "2.4em",
                  "overflow": "hidden",
                  "text-overflow": "ellipsis",
                  "border": "1px solid",
                  "border-color": "#0078db",
                  "background-color": "#0078db",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) * 100  + '%'",
                  "width": "= if( [$TaskDue] > [$ProjectEnd],  ((Number([$ProjectEnd])-Number([$TaskStart])+ 86400000) / (Number([$ProjectEnd])-Number([$ProjectStart])+ 86400000) * 100) * [$Progress] + '%'  ,  ((Number([$TaskDue])-Number([$TaskStart])+ 86400000) / (Number([$ProjectEnd])-Number([$ProjectStart])+ 86400000) * 100 * [$Progress]) + '%'"
                },
                "attributes": {
                  "class": "sp-field-bold",
                  "title": "=[$Title] + ' - ' + toLocaleDateString([$TaskStart]) + ' - ' + toLocaleDateString([$TaskDue])"
                }
              },
              {
                "elmType": "div",
                "txtContent": "",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "border-radius": "6px",
                  "z-index": "50",
                  "top": "0.6em",
                  "height": "2.4em",
                  "overflow": "hidden",
                  "text-overflow": "ellipsis",
                  "border": "=if([$TaskDue]< @now && [$Progress] < 1 && ([$TaskType] == 'Task' || [$TaskType] == '' ), '2px solid #f8b7bd', 'none')",
                  "background-color": "",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) * 100  + '%'",
                  "width": "=if([$TaskType] == 'Milestone', '28px' ,  if( [$TaskDue] > [$ProjectEnd],  (Number([$ProjectEnd])-Number([$TaskStart])+ 86400000) / (Number([$ProjectEnd])-Number([$ProjectStart])+ 86400000) * 100  ,  (Number([$TaskDue])-Number([$TaskStart])+ 86400000) / (Number([$ProjectEnd])-Number([$ProjectStart])+ 86400000) * 100 ) + '%'",
                  "margin-left": "=if([$TaskType] == 'Milestone', '-14px' , 0"
                },
                "attributes": {
                  "class": "",
                  "title": ""
                },
                "customCardProps": {
                  "openOnEvent": "hover",
                  "directionalHint": "bottomCenter",
                  "isBeakVisible": true,
                  "beakStyle": {
                    "backgroundColor": "white"
                  },
                  "formatter": {
                    "elmType": "div",
                    "style": {
                      "max-height": "256px",
                      "width": "282px",
                      "display": "flex",
                      "flex-wrap": "wrap",
                      "align-items": "flex-start"
                    },
                    "attributes": {
                      "class": "ms-ContextualMenu-list is-open list-436"
                    },
                    "children": [
                      {
                        "elmType": "div",
                        "txtContent": "[$Title]",
                        "style": {
                          "width": "250px",
                          "height": "40px",
                          "padding": "4px 4px 0 4px",
                          "overflow": "hidden",
                          "text-overflow": "ellipsis"
                        },
                        "attributes": {
                          "class": "ms-fontSize-14 ms-bgColor-themeLight ms-fontWeight-semibold ms-fontColor-gray160"
                        }
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "12",
                          "flex-grow": "1",
                          "height": "34px",
                          "padding": "10px 0 0 0 ",
                          "text-align": "center",
                          "cursor": "pointer"
                        },
                        "attributes": {
                          "iconName": "Edit",
                          "class": "ms-fontSize-14 ms-bgColor-themeLight  ms-fontColor-gray160"
                        },
                        "customRowAction": {
                          "action": "editProps"
                        }
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "100%",
                          "display": "flex",
                          "flex-wrap": "wrap",
                          "align-items": "flex-start",
                          "margin": "2px 0"
                        },
                        "children": [
                          {
                            "elmType": "div",
                            "style": {
                              "width": "24px",
                              "padding": "6px 0",
                              "text-align": " center",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "iconName": "Timeline"
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "0%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "0"
                              }
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "25%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0.25, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "25"
                              }
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "50%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0.5, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "50"
                              }
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "75%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0.75, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "75"
                              }
                            }
                          },
                          {
                            "elmType": "div",
                            "txtContent": "100%",
                            "style": {
                              "padding": "2px 6px",
                              "text-align": " center",
                              "border-radius": "14px",
                              "margin": "2px 2px 0 0 ",
                              "cursor": "pointer",
                              "heigth": "1.4em"
                            },
                            "attributes": {
                              "class": "='ms-fontSize-14  ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 1, 'themeTertiary', 'neutralLight')"
                            },
                            "customRowAction": {
                              "action": "setValue",
                              "actionInput": {
                                "Progress": "100"
                              }
                            }
                          }
                        ]
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "24px",
                          "display": "=if( ( ([$TaskType] == 'Task' || [$TaskType] == '') && [$TaskDue]< @now && [$Progress] < 1 ) || ([$TaskType] == 'Milestone' && [$TaskStart]< @now && [$Progress] < 1 ) , 'block', 'none')",
                          "padding": "6px 0 7px 0",
                          "text-align": " center",
                          "heigth": "1.4em",
                          "margin": "2px 0"
                        },
                        "attributes": {
                          "iconName": "EventDateMissed12",
                          "class": "sp-field-severity--blocked30 ms-fontSize-14 ms-fontColor-sharedRed20"
                        }
                      },
                      {
                        "elmType": "div",
                        "txtContent": "This task is running late!",
                        "style": {
                          "width": "254px",
                          "display": "=if( ( ([$TaskType] == 'Task' || [$TaskType] == '') && [$TaskDue]< @now && [$Progress] < 1 ) || ([$TaskType] == 'Milestone' && [$TaskStart]< @now && [$Progress] < 1 ) , 'block', 'none')",
                          "padding": "4px 0 4px 4px",
                          "text-align": " Left",
                          "heigth": "1.4em",
                          "margin": "2px 0"
                        },
                        "attributes": {
                          "class": "sp-field-severity--blocked30 ms-fontSize-14 ms-fontColor-sharedRed20"
                        }
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "24px",
                          "padding": "6px 0",
                          "text-align": " center",
                          "heigth": "1.4em"
                        },
                        "attributes": {
                          "iconName": "Calendar"
                        }
                      },
                      {
                        "elmType": "div",
                        "txtContent": "=toLocaleDateString([$TaskStart])",
                        "style": {
                          "width": "127px",
                          "padding": "2px 0",
                          "text-align": " center",
                          "border-radius": "14px",
                          "margin": "2px 2px 0 0 ",
                          "height": "1.4em"
                        },
                        "attributes": {
                          "class": "ms-fontSize-14 ms-bgColor-neutralLight"
                        }
                      },
                      {
                        "elmType": "div",
                        "txtContent": "=toLocaleDateString([$TaskDue])",
                        "style": {
                          "width": "127px",
                          "padding": "2px 0",
                          "text-align": " center",
                          "border-radius": "14px",
                          "margin": "2px 2px 0 0 ",
                          "height": "1.4em"
                        },
                        "attributes": {
                          "class": "ms-fontSize-14 ms-bgColor-neutralLight"
                        }
                      },
                      {
                        "elmType": "div",
                        "style": {
                          "width": "24px",
                          "padding": "6px 0",
                          "text-align": " center",
                          "heigth": "1.4em"
                        },
                        "attributes": {
                          "iconName": "Contact",
                          "title": "='Assigned to : ' + [$AssignedToUser.title]"
                        }
                      },
                      {
                        "elmType": "div",
                        "txtContent": "[$AssignedToUser.title]",
                        "style": {
                          "width": "254px",
                          "padding": "4px 0 4px 4px"
                        },
                        "defaultHoverField": "[$AssignedToUser]"
                      },
                      {
                        "elmType": "div",
                        "txtContent": "[$TaskDescription]",
                        "style": {
                          "font-style": "italic",
                          "width": "254px",
                          "padding": "4px 0 4px 4px"
                        }
                      }
                    ]
                  }
                }
              },
              {
                "elmType": "div",
                "txtContent": "",
                "style": {
                  "position": "relative",
                  "box-sizing": "border-box",
                  "display": "=if([$TaskType] == 'Milestone', 'flex', 'none')",
                  "z-index": "10",
                  "top": "0.3em",
                  "height": "3em",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) * 100  + '%'",
                  "margin-left": "-14px",
                  "width": "28px"
                },
                "attributes": {
                  "iconName": "=if([$TaskStart]< @now && [$Progress] < 1, 'EventDateMissed12', 'EventDate'",
                  "title": "=[$Title] + ' - ' + toLocaleDateString([$TaskStart]) ",
                  "class": "='ms-fontSize-24 ' + if([$TaskStart]< @now && [$Progress] < 1, 'ms-fontColor-sharedRed20', 'ms-fontColor-themePrimary') "
                }
              },
              {
                "elmType": "div",
                "txtContent": "=getDate([$TaskStart]) + '-' +  if(getMonth([$TaskStart])==0,'Jan',if(getMonth([$TaskStart])==1,'Feb',if(getMonth([$TaskStart])==2,'Mar',if(getMonth([$TaskStart])==3,'Apr',if(getMonth([$TaskStart])==4,'May',if(getMonth([$TaskStart])==5,'Jun',if(getMonth([$TaskStart])==6,'Jul',if(getMonth([$TaskStart])==7,'Aug',if(getMonth([$TaskStart])==8,'Sep',if(getMonth([$TaskStart])==9,'Oct',if(getMonth([$TaskStart])==10,'Nov',if(getMonth([$TaskStart])==11,'Dec',''))))))))))))",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "display": "=if([$TaskType] == 'Milestone'  , 'flex', 'none')",
                  "z-index": "3",
                  "top": "10px",
                  "height": "24px",
                  "margin-left": "-60px",
                  "left": "=  (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) * 100  + '%'",
                  "width": "60px",
                  "text-align": "right"
                },
                "attributes": {
                  "class": "sp-field-bold ms-fontSize-14"
                }
              },
              {
                "elmType": "div",
                "txtContent": "=(Number[$Progress]) * 100 + '%'",
                "style": {
                  "position": "absolute",
                  "box-sizing": "border-box",
                  "display": "=if([$TaskType] == 'Task' || [$TaskType] == '' , 'flex', 'none')",
                  "z-index": "3",
                  "top": "10px",
                  "height": "24px",
                  "margin-left": "=if((Number([$TaskDue])-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) <= 0.9  , '10px' , '-40px')",
                  "left": "=if((Number([$TaskDue])-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) <= 0.9 , (Number([$TaskDue])-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) * 100  + '%' , (Number([$TaskStart])-Number([$ProjectStart])) / (Number([$ProjectEnd])-Number([$ProjectStart])) * 100  + '%' ) ",
                  "width": "40px"
                },
                "attributes": {
                  "class": "sp-field-bold ms-fontSize-14"
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
tecchan1107 commented 6 months ago

Hi @gowebUSA ! Happy New Year!

The only issue now is the date on the top and the "Now" date does not show. I also paste the current JSON below.

Thanks for the screenshot!

After trying, it seems that if ProjectEnd is not set for the first line of data, it will be out of position and the Now line will not be displayed.

gantt^chart

Perhaps the "ProjectStart" and "ProjectEnd" values for the data in the red box in the following image are not set.

image

Please try to set values for "ProjectStart" and "ProjectEnd" for all data!

gowebUSA commented 5 months ago

Hi @tecchan1107,

It worked. It was the first row that messed with the code. Thank you for your help. But, can you give me the new code with the two rows or two sets of tasks? Thank you.

tecchan1107 commented 5 months ago

Sorry for the delay @gowebUSA 🙇‍♂

I tried to create a code that displays two Gantt charts. image

The following is the code.

Sample Code (Click to open/close) ``` json { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "children": [ { "elmType": "div", "style": { "display": "flex", "flex-direction": "row", "width": "100%", "align-items": "center", "margin-top": "2px", "margin-bottom": "2px" }, "children": [ { "elmType": "div", "style": { "display": "flex", "flex-direction": "column", "width": "100%", "margin-bottom": "3px" }, "children": [ { "elmType": "div", "style": { "display": "flex", "justify-content": "space-between", "width": "100%", "white-space": "nowrap" }, "attributes": { "class": "ms-fontSize-xs" }, "children": [ { "elmType": "div", "txtContent": "=replaceAll(substring(@currentField,indexOf(@currentField,'(')+1,indexOf(@currentField,'_')),'-','/')" }, { "elmType": "div", "txtContent": "=replaceAll(substring(@currentField,indexOf(@currentField,'_')+1,indexOf(@currentField,')')),'-','/')" } ] }, { "elmType": "div", "forEach": "_period in split(substring(@currentField,0,indexOf(@currentField,'(')),',')", "style": { "width": "100%", "height": "13px", "position": "relative", "overflow": "hidden", "border-left": "1px solid", "border-right": "1px solid", "border-bottom": "=if(loopIndex('_period')==0,'','1px solid')", "border-top": "1px solid" }, "children": [ { "elmType": "div", "style": { "position": "absolute", "height": "100%", "width": "=((Number(Date(substring([$_period],indexOf([$_period],'^')+1,indexOf([$_period]+'@','@'))))-Number(Date(substring([$_period],0,indexOf([$_period],'^'))))+86400000)/(Number(Date(substring(@currentField,indexOf(@currentField,'_')+1,indexOf(@currentField,')'))))-Number(Date(substring(@currentField,indexOf(@currentField,'(')+1,indexOf(@currentField,'_'))))+86400000))*100+'%'", "left": "=((Number(Date(substring([$_period],0,indexOf([$_period],'^'))))-Number(Date(substring(@currentField,indexOf(@currentField,'(')+1,indexOf(@currentField,'_')))))/(Number(Date(substring(@currentField,indexOf(@currentField,'_')+1,indexOf(@currentField,')'))))-Number(Date(substring(@currentField,indexOf(@currentField,'(')+1,indexOf(@currentField,'_'))))+86400000))*100+'%'" }, "attributes": { "class": "ms-bgColor-themePrimary", "title": "=replaceAll(substring([$_period],0,indexOf([$_period],'^')),'-','/')+' ~ '+replaceAll(substring([$_period],indexOf([$_period],'^')+1,indexOf([$_period]+'@','@')),'-','/')" } }, { "elmType": "div", "style": { "position": "absolute", "height": "100%", "width": "=(86400000/(Number(Date(substring(@currentField,indexOf(@currentField,'_')+1,indexOf(@currentField,')'))))-Number(Date(substring(@currentField,indexOf(@currentField,'(')+1,indexOf(@currentField,'_'))))+86400000))*100+'%'", "left": "=((Number(@now)-(60*60*1000*12)-Number(Date(substring(@currentField,indexOf(@currentField,'(')+1,indexOf(@currentField,'_')))))/(Number(Date(substring(@currentField,indexOf(@currentField,'_')+1,indexOf(@currentField,')'))))-Number(Date(substring(@currentField,indexOf(@currentField,'(')+1,indexOf(@currentField,'_'))))+86400000))*100+'%'", "display": "flex", "justify-content": "center", "align-items": "center" }, "children": [ { "elmType": "div", "style": { "width": "100%", "min-width": "5px", "height": "100%" }, "attributes": { "class": "ms-bgColor-themeLight", "title": "Now" } } ] } ] } ] }, { "elmType": "div", "style": { "padding": "10px", "margin-left": "5px", "cursor": "pointer", "border-radius": "50%" }, "attributes": { "iconName": "Edit", "class": "ms-bgColor-themeLighter--hover" }, "customCardProps": { "openOnEvent": "click", "directionalHint": "topCenter", "isBeakVisible": true, "formatter": { "elmType": "div", "style": { "display": "flex", "flex-direction": "column", "padding": "10px 15px" }, "children": [ { "elmType": "div", "style": { "display": "flex", "flex-direction": "row", "align-items": "center" }, "children": [ { "elmType": "div", "style": { "margin": "5px" }, "children": [ { "elmType": "div", "style": { "display": "flex", "flex-direction": "column" }, "children": [ { "elmType": "div", "txtContent": "[!Start.DisplayName]", "attributes": { "class": "ms-fontSize-s" } }, { "elmType": "div", "inlineEditField": "[$Start]", "style": { "border": "1px solid", "padding": "5px 10px", "border-radius": "3px", "display": "flex", "align-items": "center" }, "children": [ { "elmType": "span", "txtContent": "[$Start.displayValue]" }, { "elmType": "span", "style": { "margin-left": "8px" }, "attributes": { "iconName": "Edit" } } ] } ] } ] }, { "elmType": "div", "txtContent": "~", "style": { "margin": "5px" } }, { "elmType": "div", "style": { "margin": "5px" }, "children": [ { "elmType": "div", "style": { "display": "flex", "flex-direction": "column" }, "children": [ { "elmType": "div", "txtContent": "[!End.DisplayName]", "attributes": { "class": "ms-fontSize-s" } }, { "elmType": "div", "inlineEditField": "[$End]", "style": { "border": "1px solid", "padding": "5px 10px", "border-radius": "3px", "display": "flex", "align-items": "center" }, "children": [ { "elmType": "span", "txtContent": "[$End.displayValue]" }, { "elmType": "span", "style": { "margin-left": "8px" }, "attributes": { "iconName": "Edit" } } ] } ] } ] } ] }, { "elmType": "div", "style": { "display": "flex", "flex-direction": "row", "align-items": "center" }, "children": [ { "elmType": "div", "style": { "margin": "5px" }, "children": [ { "elmType": "div", "style": { "display": "flex", "flex-direction": "column" }, "children": [ { "elmType": "div", "txtContent": "[!Start1.DisplayName]", "attributes": { "class": "ms-fontSize-s" } }, { "elmType": "div", "inlineEditField": "[$Start1]", "style": { "border": "1px solid", "padding": "5px 10px", "border-radius": "3px", "display": "flex", "align-items": "center" }, "children": [ { "elmType": "span", "txtContent": "[$Start1.displayValue]" }, { "elmType": "span", "style": { "margin-left": "8px" }, "attributes": { "iconName": "Edit" } } ] } ] } ] }, { "elmType": "div", "txtContent": "~", "style": { "margin": "5px" } }, { "elmType": "div", "style": { "margin": "5px" }, "children": [ { "elmType": "div", "style": { "display": "flex", "flex-direction": "column" }, "children": [ { "elmType": "div", "txtContent": "[!_x0045_nd1.DisplayName]", "attributes": { "class": "ms-fontSize-s" } }, { "elmType": "div", "inlineEditField": "[$_x0045_nd1]", "style": { "border": "1px solid", "padding": "5px 10px", "border-radius": "3px", "display": "flex", "align-items": "center" }, "children": [ { "elmType": "span", "txtContent": "[$_x0045_nd1.displayValue]" }, { "elmType": "span", "style": { "margin-left": "8px" }, "attributes": { "iconName": "Edit" } } ] } ] } ] } ] }, { "elmType": "div", "txtContent": "If you changed the date manually instead of using the calendar, press [Enter] after changing the date.", "style": { "max-width": "300px", "text-align": "center" }, "attributes": { "class": "ms-fontSize-s" } } ] } } } ] } ] } ```

View requirements are as follows.

Type Internal Name Required Values
Single line of text Title Yes
Date ProjectStart Yes
Date ProjectDue Yes
Date TaskStart Yes
Date TaskDue Yes
Number Progress Yes
Choice TaskType No Task, Milestone
People (single select) AssignedToUser Yes
Multilines of text (no format) TaskDescription Yes
Date Start1 Yes
Date _x0045_nd1 Yes
gowebUSA commented 5 months ago

Thank you tecchan1107. I'll try it out.

JLNMetsFan commented 4 months ago

Made some edits that Geert asked me to share. I'm still working on refining this version, but will share futures enhancements and/or updates.

View Sample ![Gantt Chart](https://github.com/pnp/List-Formatting/assets/58057103/a90e196b-d6e5-47eb-a276-4b6434342e97) ![Gantt Chart 2](https://github.com/pnp/List-Formatting/assets/58057103/2ce8f5b7-c44e-4209-ad26-a426f9d14d8a)
Column Settings ![image](https://github.com/pnp/List-Formatting/assets/58057103/ed55e5aa-15b4-4e9e-a55e-8fe7ee4722c5) ### Expected Column Calculated Formula =IF(TaskStartTODAY(),(TODAY()-TaskStart)/((TaskDue-TaskStart)+1),1),0) ### Must group items by the column "Group". **_Very Important!_** ![image](https://github.com/pnp/List-Formatting/assets/58057103/8767ac56-b5d7-437f-b8d7-fa1f381c798b)
JSON Sample Code ```JSON { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json", "hideSelection": true, "hideColumnHeader": true, "groupProps": { "headerFormatter": { "elmType": "div", "style": { "height": "50px", "padding-left": "0px", "min-width": "500px", "padding-top": "10px", "border-radius": "10px" }, "attributes": { "class": "" }, "children": [ { "elmType": "div", "attributes": { "class": "ms-bgColor-themePrimary" }, "style": { "max-width": "100%", "position": "absolute", "box-shadow": "5px 5px 10px #888", "z-index": "", "left": "45px", "right": "0px", "display": "flex", "height": "36px", "padding": "0", "font-weight": "bold", "border-radius": "6px" }, "children": [ { "elmType": "div", "txtContent": "@group.fieldData", "style": { "width": "181px", "align-self": "center", "text-align": "left", "padding-left": "0.4em", "box-sizing": "border-box" }, "attributes": { "class": "ms-fontSize-16 ms-fontColor-white" } }, { "elmType": "div", "style": { "flex-grow": "1", "height": "100%", "position": "" }, "children": [ { "elmType": "div", "style": { "display": "block", "max-width": "100%", "right": "0", "left": "240px", "height": "36px", "border-radius": "6px", "position": "absolute", "background-color": "#ddd" }, "attributes": { "title": "", "class": "ms-bgColor-themeDarker ms-fontSize-14 ms-fontColor-white" }, "children": [ { "elmType": "span", "txtContent": "=toLocaleDateString(addDays(Date(@now), -30))", "style": { "position": "absolute", "padding": "14px 4px 0 4px", "left": "0px", "height": "22px", "border-radius": "6px 6px 0 0" }, "attributes": { "title": "='Project Start: ' + toLocaleDateString([$ProjectStart])", "class": "ms-bgColor-themeDarker ms-fontSize-14 ms-fontColor-white" } }, { "elmType": "div", "txtContent": "=toLocaleDateString(addDays(@now,60))", "style": { "position": "absolute", "right": "0px", "padding": "14px 4px 0 4px", "height": "22px", "border-radius": "6px 6px 0 0" }, "attributes": { "title": "='Project Finish: ' + toLocaleDateString([$ProjectDue])", "class": "ms-bgColor-themeDarker ms-fontSize-14 ms-fontColor-white" } }, { "elmType": "span", "txtContent": "Today", "attributes": { "title": "=toLocaleDateString( @now)" }, "style": { "position": "relative", "width": "90px", "z-index": "999", "display": "=if(@rowIndex == 0, 'flex', 'none')", "left": "=( (Number(@now)-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'", "background-color": "", "font-size": "14px", "text-align": "center", "top": "5px", "padding": "0 3px", "margin": "0 0 0 -25px", "color": "#555" } }, { "elmType": "span", "txtContent": "+30 Days", "attributes": { "title": "=toLocaleDateString( addDays(@now,30))" }, "style": { "position": "relative", "font-size": "12px", "z-index": "100", "display": "=if(@rowIndex == 0, 'flex', 'none')", "left": "=( (Number(addDays(@now,30))-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'", "background-color": "", "text-align": "center", "top": "-15px", "padding": "0 0px", "margin": "0 0 0 -30px", "color": "#999" } } ] } ] } ] } ] } }, "rowFormatter": { "elmType": "div", "style": { "height": "65px", "padding-top": "=if(@rowIndex == 0,'0px','')", "display": "=if([$Progress] == 1 && [$TaskDue] < addDays(@now,-30),'none','block')", "max-width": "100%", "margin-left": "65px", "position": "sticky" }, "attributes": { "class": "", "title": "" }, "children": [ { "elmType": "div", "style": { "width": "100%", "display": "flex" }, "children": [ { "elmType": "div", "style": { "width": "220px", "position": "relative", "display": "flex", "flex-wrap": "wrap", "background-color": "transparent", "overflow": "hidden", "z-index": "109" }, "attributes": { "class": "" }, "children": [ { "elmType": "span", "style": { "width": "24px", "padding": "6px 0", "color": "=if([$Progress] == 1 ,'green',if([$TaskDue]> addDays(@now,-1), if([$Expected] > [$Progress], 'orange',if([$Progress] == 0 && [$TaskDue]> addDays(@now,-1),'#777','#0078db')),'red'))", "text-align": "center", "cursor": "pointer" }, "attributes": { "iconName": "=if([$Progress] >= 1, 'CompletedSolid', if([$Progress] > 0 , 'CortanaLogoReadyOuter', 'SkypeCircleMinus'))", "title": "='Progress: ' + Number([$Progress] * 100) + '%'", "class": "= 'ms-fontSize-14 ms-fontColor-' + if([$Progress] >= 1, 'green', 'neutralSecondaryAlt')" }, "customRowAction": { "action": "setValue", "actionInput": { "Progress": "=if([$Progress] == 0, if([$TaskType] == 'Task' || [$TaskType] == '', 25 , 100) , if([$Progress] == 0.25 , 50, if([$Progress] == 0.50, 75, if([$Progress] == 0.75, 100, 0))))" } } }, { "elmType": "button", "txtContent": "[$Title]", "customRowAction": { "action": "editProps" }, "style": { "width": "196px", "height": "1.6em", "padding": "0.3em 0 0 0", "border": "none", "background-color": "transparent", "cursor": "pointer", "text-decoration": "none", "text-align": "left", "outline": "none", "display": "inline-block", "overflow": "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" }, "attributes": { "title": "[$Title]", "class": "ms-fontSize-14 ms-fontWeight-semibold ms-fontColor-gray140 ms-fontColor-black--hover" } }, { "elmType": "span", "style": { "width": "24px", "position": "inherit", "top": "-10px", "padding": "1px 0 0 0", "text-align": "center" }, "attributes": { "iconName": "=if([$Progress] < 1 && [$TaskDue]< addDays(@now,-1), 'EventDateMissed12', if([$Expected] > [$Progress],'Warning',''))", "title": "=if([$TaskDue] < addDays(@now, -1),'This item is running late!',if([$Expected] > [$Progress],'This Item is below target progress!',''))", "class": "='ms-fontSize-14 ms-fontColor-' + if([$TaskDue]< @now && [$Progress] < 1, 'sharedRed20', if([$Expected] > [$Progress],'orange','themePrimary')" } }, { "elmType": "div", "txtContent": "=toLocaleDateString([$TaskStart])", "style": { "display": "=if([$TaskType] == 'Task' || [$TaskType] == '' , 'block', 'none')", "position": "inherit", "top": "-10px", "width": "86px", "height": "16px", "padding": "0.1em 0", "text-align": " center", "border-radius": "12px", "border": "1px solid black", "margin": "0 2px 0 0 " }, "attributes": { "class": "ms-fontSize-12" } }, { "elmType": "div", "txtContent": "=if([$TaskType] == 'Task' || [$TaskType] == '', toLocaleDateString([$TaskDue]), 'Target Date: '+toLocaleDateString([$TaskDue])", "style": { "width": "=if([$TaskType] == 'Task' || [$TaskType] == '', '86px', '172px')", "position": "inherit", "top": "-10px", "height": "16px", "padding": "0.1em 0", "text-align": " center", "border-radius": "12px", "border": "1px solid black", "margin": "0 2px 0 0 " }, "attributes": { "class": "ms-fontSize-12" } } ] }, { "elmType": "div", "style": { "position": "relative", "height": "70px", "z-index": "0" } }, { "elmType": "div", "style": { "flex-grow": "1", "position": "relative", "height": "", "z-index": "99", "border-left": "1px solid #555", "overflow": "hidden", "background-color": "" }, "attributes": { "class": "" }, "children": [ { "elmType": "span", "attributes": { "class": "ms-fontColor-gray40" }, "style": { "position": "absolute", "display": "", "top": "0px", "z-index": "100", "border-left": "1px dashed #999", "margin-left": "-2px", "height": "100%", "bottom": "0px", "left": "=floor( (Number(addDays(@now,0))-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'" } }, { "elmType": "span", "attributes": { "class": "ms-fontColor-gray40" }, "style": { "position": "absolute", "display": "", "top": "0px", "z-index": "5", "border-left": "1px dotted #bbb", "margin-left": "-1px", "height": "100vh", "bottom": "0px", "width": "1px", "left": "=floor( (Number(addDays(@now,30))-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'" } }, { "elmType": "div", "txtContent": "", "style": { "position": "absolute", "display": "=if([$TaskType] == 'Task' || [$TaskType] == '' , 'flex', 'none')", "border-radius": "6px", "z-index": "1", "top": "10px", "height": "25px", "overflow": "hidden", "margin-left": "0px", "box-shadow": "2px 2px 4px #888", "border": "1px solid", "border-color": "=if([$Progress] == 1 ,'#7FC158',if([$TaskDue]> addDays(@now,-1), if([$Expected] > [$Progress], 'orange',if([$Progress] == 0 && [$TaskDue]> addDays(@now,-1),'#555','#0078db')),'#FF8484'))", "background-color": "=if([$Progress] == 1 ,'#7FC158',if([$TaskDue]> addDays(@now,-1), if([$Expected] > [$Progress], '#FFE4A2',if([$Progress] == 0 && [$TaskDue]> addDays(@now,-1),'#bbb','#cfe6f7')),'#FFD5D5'))", "left": "=((Number([$TaskStart])-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'", "width": "=( (Number([$TaskDue])-Number([$TaskStart])) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'" }, "attributes": { "class": "" }, "children": [ { "elmType": "div", "style": { "background-color": "=if([$Progress] == 1 ,'#7FC158',if([$TaskDue]> addDays(@now,-1), if([$Expected] > [$Progress], 'orange','#0078db'),'#FF8484'))", "width": "= [$Progress]*100 +'%'" } } ] }, { "elmType": "div", "txtContent": "", "style": { "position": "relative", "box-sizing": "border-box", "display": "=if([$TaskType] == 'Milestone', 'flex', 'none')", "z-index": "10", "top": "0.3em", "height": "3em", "color": "=if([$Progress] == 1 ,'green','')", "left": "=( (Number([$TaskDue])-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'", "margin-left": "-14px", "width": "28px" }, "attributes": { "iconName": "=if([$Progress] == 1 ,'Bullseye',if([$TaskDue]< addDays(@now,-1) && [$Progress] < 1, 'BullseyeTargetDelete', 'BullseyeTarget'))", "title": "=[$Title] + ' - ' + toLocaleDateString([$TaskDue]) ", "class": "='ms-fontSize-24 ' + if([$TaskDue]< addDays(@now,-1) && [$Progress] < 1, 'ms-fontColor-sharedRed20', 'ms-fontColor-themePrimary') " } }, { "elmType": "div", "txtContent": "[$Title]", "style": { "position": "absolute", "box-sizing": "border-box", "display": "=if([$TaskType] == 'Milestone' , 'flex', 'none')", "z-index": "3", "top": "10px", "line-height": "17px", "margin-left": "20px", "left": "=( (Number([$TaskDue])-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'", "min-width": "60px", "text-align": "right" }, "attributes": { "class": "sp-field-bold ms-fontSize-14" } }, { "elmType": "div", "txtContent": "", "style": { "position": "absolute", "display": "flex", "padding": "0px 0px 0px 0px", "border-radius": "6px", "z-index": "100", "top": "10px", "height": "2.4em", "overflow": "hidden", "margin": "-1px 0px", "min-width": "=if([$TaskType] == 'Milestone' , '125px', '')", "margin-left": "=if([$TaskType] == 'Milestone' , '-12px', '')", "background-color": "transparent", "left": "=if([$TaskType] == 'Task', (Number([$TaskStart])-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))),(Number([$TaskDue])-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30)))) * 100 + '%'", "width": "=( (Number([$TaskDue])-Number([$TaskStart])) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'" }, "attributes": { "class": "", "title": "" }, "customRowAction": { "action": "editProps" }, "customCardProps": { "openOnEvent": "hover", "directionalHint": "bottomCenter", "isBeakVisible": true, "beakStyle": { "backgroundColor": "white" }, "formatter": { "elmType": "div", "style": { "max-height": "350px", "width": "425px", "display": "flex", "flex-wrap": "wrap", "align-items": "flex-start", "margin": "20px", "border-radius": "5px" }, "attributes": { "class": "ms-ContextualMenu-list is-open list-436 " }, "children": [ { "elmType": "div", "style": { "width": "100%", "display": "flex", "height": "35px" }, "attributes": { "class": "ms-fontSize-16 ms-bgColor-themeLight ms-fontWeight-semibold ms-fontColor-gray160" }, "children": [ { "elmType": "div", "inlineEditField": "[$Title]", "txtContent": "[$Title]", "style": { "width": "90%", "align-self": "center", "margin-left": "10px", "overflow": "hidden", "text-overflow": "ellipsis" }, "attributes": { "class": "" } }, { "elmType": "div", "style": { "display": "", "width": "10%", "align-self": "center", "margin-right": "5px", "text-align": "center", "cursor": "pointer" }, "attributes": { "iconName": "Delete", "title": "Delete Item", "class": "" }, "customRowAction": { "action": "delete" } } ] }, { "elmType": "div", "style": { "width": "100%", "display": "inline-flex", "margin": "5px 0px" }, "children": [ { "elmType": "div", "style": { "width": "25px", "padding": "6px 0", "text-align": " center", "heigth": "1.4em" }, "attributes": { "iconName": "taskGroup" } }, { "elmType": "div", "inlineEditField": "[$Group]", "txtContent": "[$Group]", "style": { "width": "100%", "padding": "2px 0", "text-align": "left", "border-radius": "14px", "margin": "2px 2px 0 0 ", "height": "1.4em" }, "attributes": { "class": "ms-fontSize-14" } } ] }, { "elmType": "div", "style": { "width": "100%", "display": "flex", "flex-wrap": "wrap", "align-items": "flex-start", "margin": "2px 0" }, "children": [ { "elmType": "div", "style": { "width": "24px", "padding": "6px 0", "text-align": " center", "heigth": "1.4em" }, "attributes": { "iconName": "Timeline" } }, { "elmType": "div", "txtContent": "0%", "style": { "padding": "2px 6px", "text-align": " center", "border-radius": "14px", "margin": "2px 2px 0 0 ", "cursor": "pointer", "heigth": "1.4em" }, "attributes": { "class": "='ms-fontSize-14 ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0, 'themeTertiary', 'neutralLight')" }, "customRowAction": { "action": "setValue", "actionInput": { "Progress": "0" } } }, { "elmType": "div", "txtContent": "25%", "style": { "padding": "2px 6px", "text-align": " center", "border-radius": "14px", "margin": "2px 2px 0 0 ", "cursor": "pointer", "heigth": "1.4em" }, "attributes": { "class": "='ms-fontSize-14 ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0.25, 'themeTertiary', 'neutralLight')" }, "customRowAction": { "action": "setValue", "actionInput": { "Progress": "25" } } }, { "elmType": "div", "txtContent": "50%", "style": { "padding": "2px 6px", "text-align": " center", "border-radius": "14px", "margin": "2px 2px 0 0 ", "cursor": "pointer", "heigth": "1.4em" }, "attributes": { "class": "='ms-fontSize-14 ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0.5, 'themeTertiary', 'neutralLight')" }, "customRowAction": { "action": "setValue", "actionInput": { "Progress": "50" } } }, { "elmType": "div", "txtContent": "75%", "style": { "padding": "2px 6px", "text-align": " center", "border-radius": "14px", "margin": "2px 2px 0 0 ", "cursor": "pointer", "heigth": "1.4em" }, "attributes": { "class": "='ms-fontSize-14 ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 0.75, 'themeTertiary', 'neutralLight')" }, "customRowAction": { "action": "setValue", "actionInput": { "Progress": "75" } } }, { "elmType": "div", "txtContent": "100%", "style": { "padding": "2px 6px", "text-align": " center", "border-radius": "14px", "margin": "2px 2px 0 0 ", "cursor": "pointer", "heigth": "1.4em" }, "attributes": { "class": "='ms-fontSize-14 ms-bgColor-themeLight--hover ms-fontColor-themeDarker--hover ms-bgColor-' + if([$Progress] == 1, 'themeTertiary', 'neutralLight')" }, "customRowAction": { "action": "setValue", "actionInput": { "Progress": "100" } } } ] }, { "elmType": "div", "attributes": { "class": "sp-field-severity--blocked30 ms-fontSize-14 ms-fontColor-sharedRed20" }, "style": { "display": "=if([$Progress] < 1 && [$TaskDue] < addDays(@now,-1) , 'inline-flex', 'none')", "width": "100%", "height": "20px", "margin": "3px 0px", "align-self": "center", "margin-left": "0px", "overflow": "hidden" }, "children": [ { "elmType": "span", "style": { "width": "10%", "align-self": "center", "text-align": " center", "heigth": "1.4em" }, "attributes": { "iconName": "EventDateMissed12", "class": "" } }, { "elmType": "span", "txtContent": "This item is running late!", "style": { "width": "85%", "align-self": "center", "text-align": " Left", "heigth": "1.4em" }, "attributes": { "class": "" } } ] }, { "elmType": "div", "style": { "width": "100%", "display": "inline-flex", "margin": "5px 0px" }, "children": [ { "elmType": "div", "style": { "width": "25px", "padding": "6px 0", "text-align": " center", "heigth": "1.4em" }, "attributes": { "iconName": "Calendar" } }, { "elmType": "div", "inlineEditField": "[$TaskStart]", "txtContent": "=toLocaleDateString([$TaskStart])", "style": { "width": "127px", "padding": "2px 0", "text-align": " center", "border-radius": "14px", "margin": "2px 2px 0 0 ", "height": "1.4em" }, "attributes": { "class": "ms-fontSize-14 ms-bgColor-neutralLight" } }, { "elmType": "div", "inlineEditField": "[$TaskDue]", "txtContent": "=toLocaleDateString([$TaskDue])", "style": { "width": "127px", "padding": "2px 0", "text-align": " center", "border-radius": "14px", "margin": "2px 2px 0 0 ", "height": "1.4em" }, "attributes": { "class": "ms-fontSize-14 ms-bgColor-neutralLight" } } ] }, { "elmType": "div", "style": { "width": "100%", "display": "inline-flex", "margin": "5px 0px", "align-items": "center" }, "children": [ { "elmType": "div", "style": { "width": "24px", "padding": "6px 0", "text-align": " center", "heigth": "1.4em" }, "attributes": { "iconName": "Contact", "title": "='Assigned to : ' + [$AssignedToUser.title]" } }, { "elmType": "div", "inlineEditField": "[$AssignedToUser]", "style": { "height": "40px", "width": "100%" }, "attributes": { "class": "" }, "children": [ { "elmType": "div", "style": { "display": "flex", "align-items": "center" }, "children": [ { "elmType": "p", "attributes": { "class": "" }, "txtContent": "=if(length([$AssignedToUser]) == 0, '–', '')" }, { "forEach": "personIterator in [$AssignedToUser]", "elmType": "a", "attributes": { "class": "" }, "style": { "display": "=if(loopIndex('personIterator') >= 10, 'none', '')" }, "children": [ { "elmType": "img", "attributes": { "src": "=getUserImage([$personIterator.email], 'L')", "title": "[$personIterator.title]", "class": "" }, "style": { "display": "relative", "width": "35px", "height": "35px", "padding": "4px 1px", "border-radius": "50%" } } ] }, { "elmType": "div", "attributes": { "class": "" }, "style": { "display": "=if(length([$AssignedToUser]) == 1, '', 'none')", "align-self": "center", "margin-left": "5px" }, "defaultHoverField": "", "txtContent": "[$AssignedToUser.title]" }, { "elmType": "div", "txtContent": "='+' + toString(length([$AssignedToUser]) - (10))", "attributes": { "class": "" }, "style": { "display": "=if(length([$AssignedToUser]) > 10, '', 'none')", "align-self": "center" } } ] } ] } ] }, { "elmType": "div", "inlineEditField": "[$TaskDescription]", "txtContent": "[$TaskDescription]", "style": { "font-style": "italic", "width": "100%", "border": "1px solid #aaa", "padding": "4px 0 4px 4px", "height": "100px", "overflow-y": "scroll" } } ] } } }, { "elmType": "div", "txtContent": "=(Number[$Progress]) * 100 + '%'", "style": { "position": "absolute", "box-sizing": "border-box", "display": "=if([$TaskType] == 'Task' || [$TaskType] == '' , 'flex', 'none')", "z-index": "999999", "top": "10px", "line-height": "25px", "height": "30px", "margin-left": "5px", "left": "=( (Number([$TaskDue])-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'", "width": "40px" }, "attributes": { "class": "sp-field-bold ms-fontSize-14", "title": "=((Number([$TaskStart])-Number(addDays(@now,-30))) / (Number(addDays(@now,60))-Number(addDays(@now,-30))) * 100 ) + '%'" } } ] } ] } ] } } ```