You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "guan404ming (via GitHub)" <gi...@apache.org> on 2025/06/12 18:02:07 UTC

[PR] Add Gantt chart view [airflow]

guan404ming opened a new pull request, #51667:
URL: https://github.com/apache/airflow/pull/51667

   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ## Related Issue
   
   #44672
   
   cc @bbovenzi 
   
   ## Why
   
   Our ui currently lack of gantt chart compared with AF2
   
   ## How
   
   Reimplement the gantt chart in AF2 with chart.js
   
   - add `chartjs-adapter-dayjs-4` to use dayjs to format time in chart.js
   - use grid data hook to fetch data and sync layout with grid view
   - add gantt tab in `Run`, `TI` and `GroupTI` page
   
   https://github.com/user-attachments/assets/f970b6d4-29fe-43fa-a13d-7d14e6b0639e
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3189678486

   ## Fixed
   
   - the grid axes lines in dark mode should be fixed
   - selected color also should be the same as the grid view
   - we need a minimum width for tasks
   - We should only allow the grid view toggle button to show when the user has a dag run or task instance
   - The translation seems broken from my end
   - With one task the row height is not the same as the grid view
   
   <img width="810" height="353" alt="image" src="https://github.com/user-attachments/assets/28f3493f-c5b5-4b5f-a5f5-f4ed2c911781" />
   
   <img width="815" height="307" alt="image" src="https://github.com/user-attachments/assets/836e814b-a5fb-48cd-bf2d-69f5ea62bbfe" />
   
   <img width="847" height="510" alt="image" src="https://github.com/user-attachments/assets/c21ccdf0-bdb2-4a99-8bb7-6984eb477b55" />
   
   
   ## Need Confirmed
   
   - We should try to prevent the graph from completely rerendering when changing selection between tasks on the same dag run → I have updated the component to use `useMemo`, but switching the selection from a group task to an individual task still triggers a re-render, as these are treated as two different pages.
   
   - The spacing between the task name, the grid, and the gap between the grid and the graph views appears inconsistent → I am not sure if the update shown in the screenshot has resolved this issue. Please let me know if I have misunderstood or overlooked anything.
   
   - We are missing the “crosshairs” hover effect → Since the Gantt chart is rendered in a `Canvas`, I have not yet found an effective way to synchronize the hover state between the Grid and the Gantt. I would keep investigate about this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2286366387


##########
airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx:
##########
@@ -0,0 +1,291 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box, useToken } from "@chakra-ui/react";
+import {
+  Chart as ChartJS,
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  LineElement,
+  BarElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  TimeScale,
+  type TooltipItem,
+} from "chart.js";
+import "chart.js/auto";
+import "chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm";
+import annotationPlugin from "chartjs-plugin-annotation";
+import { useMemo, useRef } from "react";
+import { Bar } from "react-chartjs-2";
+import { useTranslation } from "react-i18next";
+import { useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import { useColorMode } from "src/context/colorMode";
+import { useOpenGroups } from "src/context/openGroups";
+import { useTimezone } from "src/context/timezone";
+import { flattenNodes } from "src/layouts/Details/Grid/utils";
+import { useGridRuns } from "src/queries/useGridRuns";
+import { useGridStructure } from "src/queries/useGridStructure";
+import { useGridTiSummaries } from "src/queries/useGridTISummaries";
+import { system } from "src/theme";
+import { getDuration, isStatePending, useAutoRefresh } from "src/utils";
+import { formatDate } from "src/utils/datetimeUtils";
+
+ChartJS.register(
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  BarElement,
+  LineElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  annotationPlugin,
+  TimeScale,
+);
+
+type Props = {
+  readonly limit: number;
+};
+
+const CHART_PADDING = 36;
+const CHART_ROW_HEIGHT = 20;
+const MIN_BAR_WIDTH = 10;
+
+export const Gantt = ({ limit }: Props) => {
+  const { dagId = "", groupId: selectedGroupId, runId, taskId: selectedTaskId } = useParams();
+  const { openGroupIds } = useOpenGroups();
+  const { t: translate } = useTranslation("common");
+  const { selectedTimezone } = useTimezone();
+  const { colorMode } = useColorMode();
+  const ref = useRef();
+
+  const [lightGridColor, darkGridColor, lightSelectedColor, darkSelectedColor] = useToken("colors", [
+    "gray.200",
+    "gray.800",
+    "blue.200",
+    "blue.800",
+  ]);
+  const gridColor = colorMode === "light" ? lightGridColor : darkGridColor;
+  const selectedItemColor = colorMode === "light" ? lightSelectedColor : darkSelectedColor;
+
+  const { data: gridRuns, isLoading: runsLoading } = useGridRuns({ limit });
+  const { data: dagStructure, isLoading: structureLoading } = useGridStructure({ limit });
+  const selectedRun = gridRuns?.find((run) => run.run_id === runId);
+  const refetchInterval = useAutoRefresh({ dagId });
+
+  // Get grid summaries for groups (which have min/max times)
+  const { data: gridTiSummaries, isLoading: summariesLoading } = useGridTiSummaries({
+    dagId,
+    runId: runId ?? "",
+    state: selectedRun?.state,
+  });
+
+  // Get individual task instances for tasks (which have start/end times)
+  const { data: taskInstancesData, isLoading: tiLoading } = useTaskInstanceServiceGetTaskInstances(
+    {
+      dagId,
+      dagRunId: runId ?? "~",
+    },
+    undefined,
+    {
+      enabled: Boolean(dagId),
+      refetchInterval: (query) =>
+        query.state.data?.task_instances.some((ti) => isStatePending(ti.state)) ? refetchInterval : false,
+    },
+  );
+
+  const { flatNodes } = useMemo(() => flattenNodes(dagStructure, openGroupIds), [dagStructure, openGroupIds]);
+
+  const isLoading = runsLoading || structureLoading || summariesLoading || tiLoading;
+
+  const data = useMemo(() => {
+    if (isLoading || runId === undefined) {
+      return [];
+    }
+
+    const gridSummaries = gridTiSummaries?.task_instances ?? [];
+    const taskInstances = taskInstancesData?.task_instances ?? [];
+
+    return flatNodes
+      .map((node) => {
+        const gridSummary = gridSummaries.find((ti) => ti.task_id === node.id);
+
+        if (node.isGroup && gridSummary) {
+          // Group node - use min/max times from grid summary
+          return {
+            isGroup: true,
+            state: gridSummary.state,
+            x: [
+              formatDate(gridSummary.min_start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              formatDate(gridSummary.max_end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+            ],
+            y: gridSummary.task_id,
+          };
+        } else if (!node.isGroup) {
+          // Individual task - use individual task instance data
+          const taskInstance = taskInstances.find((ti) => ti.task_id === node.id);
+
+          if (taskInstance) {
+            return {
+              isGroup: false,
+              state: taskInstance.state,
+              x: [
+                formatDate(taskInstance.start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+                formatDate(taskInstance.end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              ],
+              y: taskInstance.task_id,
+            };
+          }
+        }
+
+        return undefined;
+      })
+      .filter((item) => item !== undefined);
+  }, [flatNodes, gridTiSummaries, taskInstancesData, selectedTimezone, isLoading, runId]);
+
+  const chartData = useMemo(
+    () => ({
+      datasets: [
+        {
+          backgroundColor: data.map(
+            (dataItem) =>
+              system.tokens.categoryMap.get("colors")?.get(`${dataItem.state}.600`)?.value as string,
+          ),
+          data,
+          maxBarThickness: CHART_ROW_HEIGHT,
+          minBarLength: MIN_BAR_WIDTH,
+        },
+      ],
+      labels: [],
+    }),
+    [data],
+  );
+
+  const fixedHeight = flatNodes.length * CHART_ROW_HEIGHT + CHART_PADDING;
+  const selectedId = selectedTaskId ?? selectedGroupId;
+
+  const chartOptions = useMemo(
+    () => ({
+      animation: {
+        duration: 100,
+      },
+      indexAxis: "y" as const,
+      maintainAspectRatio: false,
+      plugins: {
+        annotation: {
+          annotations:
+            selectedId === undefined
+              ? []
+              : [
+                  {
+                    backgroundColor: selectedItemColor,
+                    borderWidth: 0,
+                    drawTime: "beforeDatasetsDraw" as const,
+                    type: "box" as const,
+                    xMax: "max" as const,
+                    xMin: "min" as const,
+                    yMax: data.findIndex((dataItem) => dataItem.y === selectedId) + 0.5,
+                    yMin: data.findIndex((dataItem) => dataItem.y === selectedId) - 0.5,
+                  },
+                ],
+        },
+        legend: {
+          display: false,
+        },
+        tooltip: {
+          callbacks: {
+            afterBody(tooltipItems: Array<TooltipItem<"bar">>) {
+              const taskInstance = data.find((dataItem) => dataItem.y === tooltipItems[0]?.label);
+              const startDate = formatDate(taskInstance?.x[0], selectedTimezone);
+              const endDate = formatDate(taskInstance?.x[1], selectedTimezone);
+
+              return [
+                `${translate("startDate")}: ${startDate}`,
+                `${translate("endDate")}: ${endDate}`,
+                `${translate("duration")}: ${getDuration(taskInstance?.x[0], taskInstance?.x[1])}`,
+              ];
+            },
+            label(tooltipItem: TooltipItem<"bar">) {
+              const { label } = tooltipItem;
+              const taskInstance = data.find((dataItem) => dataItem.y === label);
+
+              return `${translate("state")}: ${translate(`states.${taskInstance?.state}`)}`;
+            },
+          },
+        },
+      },
+      resizeDelay: 100,
+      responsive: true,
+      scales: {
+        x: {
+          grid: {
+            color: gridColor,
+            display: true,
+          },
+          max: formatDate(selectedRun?.end_date, selectedTimezone),
+          min: formatDate(selectedRun?.start_date, selectedTimezone),
+          position: "top" as const,
+          stacked: true,
+          ticks: {
+            align: "start" as const,
+            callback: (value: number | string) => formatDate(value, selectedTimezone, "HH:mm:ss"),
+            maxRotation: 8,
+            maxTicksLimit: 8,
+            minRotation: 8,
+          },
+          type: "time" as const,
+        },
+        y: {
+          grid: {
+            color: gridColor,
+            display: true,
+          },
+          stacked: true,
+          ticks: {
+            display: false,
+          },
+        },
+      },
+    }),
+    [data, selectedId, selectedItemColor, gridColor, selectedRun, selectedTimezone, translate],
+  );
+
+  if (runId === undefined) {
+    return undefined;
+  }
+
+  return (
+    <Box height={`${fixedHeight}px`} minW="500px" ml={-2} mt={36} w="100%">

Review Comment:
   ```suggestion
       <Box height={`${fixedHeight}px`} minW="200px" ml={-2} mt={36} w="100%">
   ```
   
   Looking great let's just change the minW and looks good to me



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3198310354

   Looking really good! Let's fix some spacing issues and merge this. Then we can work on the tooltips and clicking on a gantt bar to select the task


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2968037139

   Very cool!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2278293877


##########
airflow-core/src/airflow/ui/src/layouts/Details/PanelButtons.tsx:
##########
@@ -72,10 +78,19 @@ const deps = ["all", "immediate", "tasks"];
 
 type Dependency = (typeof deps)[number];
 
-export const PanelButtons = ({ dagView, limit, panelGroupRef, setDagView, setLimit }: Props) => {
+export const PanelButtons = ({
+  dagView,
+  limit,
+  panelGroupRef,
+  setDagView,
+  setLimit,
+  setShowGantt,
+  showGantt,
+}: Props) => {
   const { t: translate } = useTranslation(["components", "dag"]);
-  const { dagId = "" } = useParams();
+  const { dagId = "", runId, taskId } = useParams();
   const { fitView } = useReactFlow();
+  const shouldShowToggleButtons = Boolean(runId ?? taskId);

Review Comment:
   Yes, it should be `Boolean(runId)`. Let me update it.
   
   > In the future we can make a custom /gantt endpoint to generate a box-whisker plot to show trends across runs.
   
   That is a cool idea, with box-whister plot we could get more useful info at first glance. But I'm not sure if there is still place to show box-whisker plot. I think we could try and iterate the chart in the future!
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3206883725

   Indeed #protm


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3128379774

   Apologies for the delay. I have been a bit busy recently. I will be getting back to this and address the comments soon. If I encounter any issues, I will bring them up for discussion. Thank you very much for your patience and understanding.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2283338921


##########
airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx:
##########
@@ -110,16 +113,30 @@ export const DetailsLayout = ({ children, error, isLoading, tabs }: Props) => {
           key={`${dagView}-${direction}`}
           ref={panelGroupRef}
         >
-          <Panel defaultSize={dagView === "graph" ? 70 : 20} id="main-panel" minSize={6} order={1}>
+          <Panel
+            defaultSize={dagView === "graph" ? 70 : 20}
+            id="main-panel"
+            minSize={showGantt && dagView === "grid" ? 60 : 20}

Review Comment:
   We also need a runId check here. The min size doesn't make sense if you dont have a runId selected.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi merged PR #51667:
URL: https://github.com/apache/airflow/pull/51667


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2990429414

   Modification:
   - move gantt to grid and revert all changes about HeaderCard
   - add checkbox to determine whether to show the gantt chart
   - expand minWidth when gantt chart is enabled
   - extract time format func to utils
   
   
   https://github.com/user-attachments/assets/5946eb07-2919-4ec0-902f-fe786df0a564
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2143355278


##########
airflow-core/src/airflow/ui/src/router.tsx:
##########
@@ -60,7 +61,8 @@ import { AssetEvents as TaskInstanceAssetEvents } from "./pages/TaskInstance/Ass
 import { client } from "./queryClient";
 
 const taskInstanceRoutes = [
-  { element: <Logs />, index: true },
+  { element: <Gantt />, index: true },
+  { element: <Logs />, path: "logs" },

Review Comment:
   Logs should still be the primary view. We can put the gantt after Logs or Task Instances



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3005820668

   - the grid axes lines in dark mode should be fixed
   - selected color also should be the same as the grid view
   - we need a minimum width for tasks
   - We should only allow the grid view toggle button to show when the user has a dag run or task instance
   - We should try to prevent the graph from completely rerendering when changing selection between tasks on the same dag run
   - The spacing is off between task name, the grid and then the gap between the grid and graph views.
   - The translation seems broken from my end
   - With one task the row height is not the same as the grid view
   <img width="590" alt="Screenshot 2025-06-25 at 2 36 35 PM" src="https://github.com/user-attachments/assets/f6bdd286-e086-416b-90c8-3caf9c5932ae" />
   <img width="1172" alt="Screenshot 2025-06-25 at 2 44 07 PM" src="https://github.com/user-attachments/assets/82f3d779-51b7-4437-be2c-8be38ec43d86" />
   
   
   We're close but I want to spend more time looking into the code to see if we can integrate the charting library into our view or if we'll need to go back to building our own gantt chart like in 2.x
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2285513364


##########
airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx:
##########
@@ -110,16 +113,30 @@ export const DetailsLayout = ({ children, error, isLoading, tabs }: Props) => {
           key={`${dagView}-${direction}`}
           ref={panelGroupRef}
         >
-          <Panel defaultSize={dagView === "graph" ? 70 : 20} id="main-panel" minSize={6} order={1}>
+          <Panel
+            defaultSize={dagView === "graph" ? 70 : 20}
+            id="main-panel"
+            minSize={showGantt && dagView === "grid" ? 60 : 20}
+            order={1}
+          >
             <Box height="100%" marginInlineEnd={2} overflowY="auto" position="relative">
               <PanelButtons
                 dagView={dagView}
                 limit={limit}
                 panelGroupRef={panelGroupRef}
                 setDagView={setDagView}
                 setLimit={setLimit}
+                setShowGantt={setShowGantt}
+                showGantt={showGantt}
               />
-              {dagView === "graph" ? <Graph /> : <Grid limit={limit} />}
+              {dagView === "graph" ? (
+                <Graph />
+              ) : (
+                <HStack gap={0}>
+                  <Grid limit={limit} />

Review Comment:
   Make sense and tested on large screen. Passing the condition did fix the issue!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2286366387


##########
airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx:
##########
@@ -0,0 +1,291 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box, useToken } from "@chakra-ui/react";
+import {
+  Chart as ChartJS,
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  LineElement,
+  BarElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  TimeScale,
+  type TooltipItem,
+} from "chart.js";
+import "chart.js/auto";
+import "chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm";
+import annotationPlugin from "chartjs-plugin-annotation";
+import { useMemo, useRef } from "react";
+import { Bar } from "react-chartjs-2";
+import { useTranslation } from "react-i18next";
+import { useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import { useColorMode } from "src/context/colorMode";
+import { useOpenGroups } from "src/context/openGroups";
+import { useTimezone } from "src/context/timezone";
+import { flattenNodes } from "src/layouts/Details/Grid/utils";
+import { useGridRuns } from "src/queries/useGridRuns";
+import { useGridStructure } from "src/queries/useGridStructure";
+import { useGridTiSummaries } from "src/queries/useGridTISummaries";
+import { system } from "src/theme";
+import { getDuration, isStatePending, useAutoRefresh } from "src/utils";
+import { formatDate } from "src/utils/datetimeUtils";
+
+ChartJS.register(
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  BarElement,
+  LineElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  annotationPlugin,
+  TimeScale,
+);
+
+type Props = {
+  readonly limit: number;
+};
+
+const CHART_PADDING = 36;
+const CHART_ROW_HEIGHT = 20;
+const MIN_BAR_WIDTH = 10;
+
+export const Gantt = ({ limit }: Props) => {
+  const { dagId = "", groupId: selectedGroupId, runId, taskId: selectedTaskId } = useParams();
+  const { openGroupIds } = useOpenGroups();
+  const { t: translate } = useTranslation("common");
+  const { selectedTimezone } = useTimezone();
+  const { colorMode } = useColorMode();
+  const ref = useRef();
+
+  const [lightGridColor, darkGridColor, lightSelectedColor, darkSelectedColor] = useToken("colors", [
+    "gray.200",
+    "gray.800",
+    "blue.200",
+    "blue.800",
+  ]);
+  const gridColor = colorMode === "light" ? lightGridColor : darkGridColor;
+  const selectedItemColor = colorMode === "light" ? lightSelectedColor : darkSelectedColor;
+
+  const { data: gridRuns, isLoading: runsLoading } = useGridRuns({ limit });
+  const { data: dagStructure, isLoading: structureLoading } = useGridStructure({ limit });
+  const selectedRun = gridRuns?.find((run) => run.run_id === runId);
+  const refetchInterval = useAutoRefresh({ dagId });
+
+  // Get grid summaries for groups (which have min/max times)
+  const { data: gridTiSummaries, isLoading: summariesLoading } = useGridTiSummaries({
+    dagId,
+    runId: runId ?? "",
+    state: selectedRun?.state,
+  });
+
+  // Get individual task instances for tasks (which have start/end times)
+  const { data: taskInstancesData, isLoading: tiLoading } = useTaskInstanceServiceGetTaskInstances(
+    {
+      dagId,
+      dagRunId: runId ?? "~",
+    },
+    undefined,
+    {
+      enabled: Boolean(dagId),
+      refetchInterval: (query) =>
+        query.state.data?.task_instances.some((ti) => isStatePending(ti.state)) ? refetchInterval : false,
+    },
+  );
+
+  const { flatNodes } = useMemo(() => flattenNodes(dagStructure, openGroupIds), [dagStructure, openGroupIds]);
+
+  const isLoading = runsLoading || structureLoading || summariesLoading || tiLoading;
+
+  const data = useMemo(() => {
+    if (isLoading || runId === undefined) {
+      return [];
+    }
+
+    const gridSummaries = gridTiSummaries?.task_instances ?? [];
+    const taskInstances = taskInstancesData?.task_instances ?? [];
+
+    return flatNodes
+      .map((node) => {
+        const gridSummary = gridSummaries.find((ti) => ti.task_id === node.id);
+
+        if (node.isGroup && gridSummary) {
+          // Group node - use min/max times from grid summary
+          return {
+            isGroup: true,
+            state: gridSummary.state,
+            x: [
+              formatDate(gridSummary.min_start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              formatDate(gridSummary.max_end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+            ],
+            y: gridSummary.task_id,
+          };
+        } else if (!node.isGroup) {
+          // Individual task - use individual task instance data
+          const taskInstance = taskInstances.find((ti) => ti.task_id === node.id);
+
+          if (taskInstance) {
+            return {
+              isGroup: false,
+              state: taskInstance.state,
+              x: [
+                formatDate(taskInstance.start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+                formatDate(taskInstance.end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              ],
+              y: taskInstance.task_id,
+            };
+          }
+        }
+
+        return undefined;
+      })
+      .filter((item) => item !== undefined);
+  }, [flatNodes, gridTiSummaries, taskInstancesData, selectedTimezone, isLoading, runId]);
+
+  const chartData = useMemo(
+    () => ({
+      datasets: [
+        {
+          backgroundColor: data.map(
+            (dataItem) =>
+              system.tokens.categoryMap.get("colors")?.get(`${dataItem.state}.600`)?.value as string,
+          ),
+          data,
+          maxBarThickness: CHART_ROW_HEIGHT,
+          minBarLength: MIN_BAR_WIDTH,
+        },
+      ],
+      labels: [],
+    }),
+    [data],
+  );
+
+  const fixedHeight = flatNodes.length * CHART_ROW_HEIGHT + CHART_PADDING;
+  const selectedId = selectedTaskId ?? selectedGroupId;
+
+  const chartOptions = useMemo(
+    () => ({
+      animation: {
+        duration: 100,
+      },
+      indexAxis: "y" as const,
+      maintainAspectRatio: false,
+      plugins: {
+        annotation: {
+          annotations:
+            selectedId === undefined
+              ? []
+              : [
+                  {
+                    backgroundColor: selectedItemColor,
+                    borderWidth: 0,
+                    drawTime: "beforeDatasetsDraw" as const,
+                    type: "box" as const,
+                    xMax: "max" as const,
+                    xMin: "min" as const,
+                    yMax: data.findIndex((dataItem) => dataItem.y === selectedId) + 0.5,
+                    yMin: data.findIndex((dataItem) => dataItem.y === selectedId) - 0.5,
+                  },
+                ],
+        },
+        legend: {
+          display: false,
+        },
+        tooltip: {
+          callbacks: {
+            afterBody(tooltipItems: Array<TooltipItem<"bar">>) {
+              const taskInstance = data.find((dataItem) => dataItem.y === tooltipItems[0]?.label);
+              const startDate = formatDate(taskInstance?.x[0], selectedTimezone);
+              const endDate = formatDate(taskInstance?.x[1], selectedTimezone);
+
+              return [
+                `${translate("startDate")}: ${startDate}`,
+                `${translate("endDate")}: ${endDate}`,
+                `${translate("duration")}: ${getDuration(taskInstance?.x[0], taskInstance?.x[1])}`,
+              ];
+            },
+            label(tooltipItem: TooltipItem<"bar">) {
+              const { label } = tooltipItem;
+              const taskInstance = data.find((dataItem) => dataItem.y === label);
+
+              return `${translate("state")}: ${translate(`states.${taskInstance?.state}`)}`;
+            },
+          },
+        },
+      },
+      resizeDelay: 100,
+      responsive: true,
+      scales: {
+        x: {
+          grid: {
+            color: gridColor,
+            display: true,
+          },
+          max: formatDate(selectedRun?.end_date, selectedTimezone),
+          min: formatDate(selectedRun?.start_date, selectedTimezone),
+          position: "top" as const,
+          stacked: true,
+          ticks: {
+            align: "start" as const,
+            callback: (value: number | string) => formatDate(value, selectedTimezone, "HH:mm:ss"),
+            maxRotation: 8,
+            maxTicksLimit: 8,
+            minRotation: 8,
+          },
+          type: "time" as const,
+        },
+        y: {
+          grid: {
+            color: gridColor,
+            display: true,
+          },
+          stacked: true,
+          ticks: {
+            display: false,
+          },
+        },
+      },
+    }),
+    [data, selectedId, selectedItemColor, gridColor, selectedRun, selectedTimezone, translate],
+  );
+
+  if (runId === undefined) {
+    return undefined;
+  }
+
+  return (
+    <Box height={`${fixedHeight}px`} minW="500px" ml={-2} mt={36} w="100%">

Review Comment:
   ```suggestion
       <Box height={`${fixedHeight}px`} minW="200px" ml={-2} mt={36} w="100%">
   ```
   
   Looking great! Let's just change the minW and looks good to me



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2286695314


##########
airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx:
##########
@@ -0,0 +1,291 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box, useToken } from "@chakra-ui/react";
+import {
+  Chart as ChartJS,
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  LineElement,
+  BarElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  TimeScale,
+  type TooltipItem,
+} from "chart.js";
+import "chart.js/auto";
+import "chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm";
+import annotationPlugin from "chartjs-plugin-annotation";
+import { useMemo, useRef } from "react";
+import { Bar } from "react-chartjs-2";
+import { useTranslation } from "react-i18next";
+import { useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import { useColorMode } from "src/context/colorMode";
+import { useOpenGroups } from "src/context/openGroups";
+import { useTimezone } from "src/context/timezone";
+import { flattenNodes } from "src/layouts/Details/Grid/utils";
+import { useGridRuns } from "src/queries/useGridRuns";
+import { useGridStructure } from "src/queries/useGridStructure";
+import { useGridTiSummaries } from "src/queries/useGridTISummaries";
+import { system } from "src/theme";
+import { getDuration, isStatePending, useAutoRefresh } from "src/utils";
+import { formatDate } from "src/utils/datetimeUtils";
+
+ChartJS.register(
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  BarElement,
+  LineElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  annotationPlugin,
+  TimeScale,
+);
+
+type Props = {
+  readonly limit: number;
+};
+
+const CHART_PADDING = 36;
+const CHART_ROW_HEIGHT = 20;
+const MIN_BAR_WIDTH = 10;
+
+export const Gantt = ({ limit }: Props) => {
+  const { dagId = "", groupId: selectedGroupId, runId, taskId: selectedTaskId } = useParams();
+  const { openGroupIds } = useOpenGroups();
+  const { t: translate } = useTranslation("common");
+  const { selectedTimezone } = useTimezone();
+  const { colorMode } = useColorMode();
+  const ref = useRef();
+
+  const [lightGridColor, darkGridColor, lightSelectedColor, darkSelectedColor] = useToken("colors", [
+    "gray.200",
+    "gray.800",
+    "blue.200",
+    "blue.800",
+  ]);
+  const gridColor = colorMode === "light" ? lightGridColor : darkGridColor;
+  const selectedItemColor = colorMode === "light" ? lightSelectedColor : darkSelectedColor;
+
+  const { data: gridRuns, isLoading: runsLoading } = useGridRuns({ limit });
+  const { data: dagStructure, isLoading: structureLoading } = useGridStructure({ limit });
+  const selectedRun = gridRuns?.find((run) => run.run_id === runId);
+  const refetchInterval = useAutoRefresh({ dagId });
+
+  // Get grid summaries for groups (which have min/max times)
+  const { data: gridTiSummaries, isLoading: summariesLoading } = useGridTiSummaries({
+    dagId,
+    runId: runId ?? "",
+    state: selectedRun?.state,
+  });
+
+  // Get individual task instances for tasks (which have start/end times)
+  const { data: taskInstancesData, isLoading: tiLoading } = useTaskInstanceServiceGetTaskInstances(
+    {
+      dagId,
+      dagRunId: runId ?? "~",
+    },
+    undefined,
+    {
+      enabled: Boolean(dagId),
+      refetchInterval: (query) =>
+        query.state.data?.task_instances.some((ti) => isStatePending(ti.state)) ? refetchInterval : false,
+    },
+  );
+
+  const { flatNodes } = useMemo(() => flattenNodes(dagStructure, openGroupIds), [dagStructure, openGroupIds]);
+
+  const isLoading = runsLoading || structureLoading || summariesLoading || tiLoading;
+
+  const data = useMemo(() => {
+    if (isLoading || runId === undefined) {
+      return [];
+    }
+
+    const gridSummaries = gridTiSummaries?.task_instances ?? [];
+    const taskInstances = taskInstancesData?.task_instances ?? [];
+
+    return flatNodes
+      .map((node) => {
+        const gridSummary = gridSummaries.find((ti) => ti.task_id === node.id);
+
+        if (node.isGroup && gridSummary) {
+          // Group node - use min/max times from grid summary
+          return {
+            isGroup: true,
+            state: gridSummary.state,
+            x: [
+              formatDate(gridSummary.min_start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              formatDate(gridSummary.max_end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+            ],
+            y: gridSummary.task_id,
+          };
+        } else if (!node.isGroup) {
+          // Individual task - use individual task instance data
+          const taskInstance = taskInstances.find((ti) => ti.task_id === node.id);
+
+          if (taskInstance) {
+            return {
+              isGroup: false,
+              state: taskInstance.state,
+              x: [
+                formatDate(taskInstance.start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+                formatDate(taskInstance.end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              ],
+              y: taskInstance.task_id,
+            };
+          }
+        }
+
+        return undefined;
+      })
+      .filter((item) => item !== undefined);
+  }, [flatNodes, gridTiSummaries, taskInstancesData, selectedTimezone, isLoading, runId]);
+
+  const chartData = useMemo(
+    () => ({
+      datasets: [
+        {
+          backgroundColor: data.map(
+            (dataItem) =>
+              system.tokens.categoryMap.get("colors")?.get(`${dataItem.state}.600`)?.value as string,
+          ),
+          data,
+          maxBarThickness: CHART_ROW_HEIGHT,
+          minBarLength: MIN_BAR_WIDTH,
+        },
+      ],
+      labels: [],
+    }),
+    [data],
+  );
+
+  const fixedHeight = flatNodes.length * CHART_ROW_HEIGHT + CHART_PADDING;
+  const selectedId = selectedTaskId ?? selectedGroupId;
+
+  const chartOptions = useMemo(
+    () => ({
+      animation: {
+        duration: 100,
+      },
+      indexAxis: "y" as const,
+      maintainAspectRatio: false,
+      plugins: {
+        annotation: {
+          annotations:
+            selectedId === undefined
+              ? []
+              : [
+                  {
+                    backgroundColor: selectedItemColor,
+                    borderWidth: 0,
+                    drawTime: "beforeDatasetsDraw" as const,
+                    type: "box" as const,
+                    xMax: "max" as const,
+                    xMin: "min" as const,
+                    yMax: data.findIndex((dataItem) => dataItem.y === selectedId) + 0.5,
+                    yMin: data.findIndex((dataItem) => dataItem.y === selectedId) - 0.5,
+                  },
+                ],
+        },
+        legend: {
+          display: false,
+        },
+        tooltip: {
+          callbacks: {
+            afterBody(tooltipItems: Array<TooltipItem<"bar">>) {
+              const taskInstance = data.find((dataItem) => dataItem.y === tooltipItems[0]?.label);
+              const startDate = formatDate(taskInstance?.x[0], selectedTimezone);
+              const endDate = formatDate(taskInstance?.x[1], selectedTimezone);
+
+              return [
+                `${translate("startDate")}: ${startDate}`,
+                `${translate("endDate")}: ${endDate}`,
+                `${translate("duration")}: ${getDuration(taskInstance?.x[0], taskInstance?.x[1])}`,
+              ];
+            },
+            label(tooltipItem: TooltipItem<"bar">) {
+              const { label } = tooltipItem;
+              const taskInstance = data.find((dataItem) => dataItem.y === label);
+
+              return `${translate("state")}: ${translate(`states.${taskInstance?.state}`)}`;
+            },
+          },
+        },
+      },
+      resizeDelay: 100,
+      responsive: true,
+      scales: {
+        x: {
+          grid: {
+            color: gridColor,
+            display: true,
+          },
+          max: formatDate(selectedRun?.end_date, selectedTimezone),
+          min: formatDate(selectedRun?.start_date, selectedTimezone),
+          position: "top" as const,
+          stacked: true,
+          ticks: {
+            align: "start" as const,
+            callback: (value: number | string) => formatDate(value, selectedTimezone, "HH:mm:ss"),
+            maxRotation: 8,
+            maxTicksLimit: 8,
+            minRotation: 8,
+          },
+          type: "time" as const,
+        },
+        y: {
+          grid: {
+            color: gridColor,
+            display: true,
+          },
+          stacked: true,
+          ticks: {
+            display: false,
+          },
+        },
+      },
+    }),
+    [data, selectedId, selectedItemColor, gridColor, selectedRun, selectedTimezone, translate],
+  );
+
+  if (runId === undefined) {
+    return undefined;
+  }
+
+  return (
+    <Box height={`${fixedHeight}px`} minW="500px" ml={-2} mt={36} w="100%">

Review Comment:
   Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2972480728

   I've fixed the HeaderCard height for Gantt page and do some rwd implementation for `Stat`. Also, I've followed the official docs to optimize our `Gantt`. Current ui may looks like 
   
   
   https://github.com/user-attachments/assets/74681065-f6f2-4688-8929-d712c664e52c
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2283379395


##########
airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx:
##########
@@ -110,16 +113,30 @@ export const DetailsLayout = ({ children, error, isLoading, tabs }: Props) => {
           key={`${dagView}-${direction}`}
           ref={panelGroupRef}
         >
-          <Panel defaultSize={dagView === "graph" ? 70 : 20} id="main-panel" minSize={6} order={1}>
+          <Panel
+            defaultSize={dagView === "graph" ? 70 : 20}
+            id="main-panel"
+            minSize={showGantt && dagView === "grid" ? 60 : 20}

Review Comment:
   Also, I think its ok if these values are `? 30 : 6` instead. The gantt chart looks like it can work with a minW of 150px instead of 500px



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2278293877


##########
airflow-core/src/airflow/ui/src/layouts/Details/PanelButtons.tsx:
##########
@@ -72,10 +78,19 @@ const deps = ["all", "immediate", "tasks"];
 
 type Dependency = (typeof deps)[number];
 
-export const PanelButtons = ({ dagView, limit, panelGroupRef, setDagView, setLimit }: Props) => {
+export const PanelButtons = ({
+  dagView,
+  limit,
+  panelGroupRef,
+  setDagView,
+  setLimit,
+  setShowGantt,
+  showGantt,
+}: Props) => {
   const { t: translate } = useTranslation(["components", "dag"]);
-  const { dagId = "" } = useParams();
+  const { dagId = "", runId, taskId } = useParams();
   const { fitView } = useReactFlow();
+  const shouldShowToggleButtons = Boolean(runId ?? taskId);

Review Comment:
   Yes, it should be `Boolean(runId)`. Let me update it.
   
   > In the future we can make a custom /gantt endpoint to generate a box-whisker plot to show trends across runs.
   That is a cool idea, but I'm not sure if there is still place to show box-whisker. We could try and iterate the chart in the future!
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2978332089

   I was thinking about the UX of this after https://github.com/apache/airflow/pull/51764
   
   Perhaps instead of putting the gantt in a tab on the right-hand panel, it should be an option to add onto the grid view on the left panel. Let's discuss first before you refactor everything though.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2994137716

   Thanks for pulling it down and testing! I'm also getting used to the new UI, but it's starting to make sense, having the Gantt on the left definitely feels more logical in terms of layout and usability.
   
   1. That bar rendering issue should be fixed now, it turns out `formatDate` needed a fallback to work properly in all cases.
   <img width="942" alt="image" src="https://github.com/user-attachments/assets/3c8cb896-1874-455f-814d-ab84ee027d1e" />
   
   2. As for the tooltips, Chart.js automatically calculates the best position to avoid them being cut off or hidden. Fixing them to a static position can sometimes create problems. For example, if a tooltip is pinned to always appear above the bar, it might get clipped if the bar is already close to the top edge of the container.
   
   I'm currently increasing the `minWidth` of the tooltip to help with the visual overlap issue. It seems to help a bit, but if there are any better ideas or suggestions, I’m definitely open to them!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2981410127

   I think the second idea is great and aligns better with the UX, especially since users will likely want to use both the grid and Gantt views at the same time. I’ll try implementing it first and see how it feels. My only concern is that it might get a bit cramped, so I might increase the min-width of the left pane to help with that. Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2967754149

   Known issue: the row alignment would break when the HeaderCard height change. I would like to know that should we fix the height of `HeaderCard` to some constant or is there any better to solve this issue?
   
   Thanks in advance!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2143421132


##########
airflow-core/src/airflow/ui/src/router.tsx:
##########
@@ -60,7 +61,8 @@ import { AssetEvents as TaskInstanceAssetEvents } from "./pages/TaskInstance/Ass
 import { client } from "./queryClient";
 
 const taskInstanceRoutes = [
-  { element: <Logs />, index: true },
+  { element: <Gantt />, index: true },
+  { element: <Logs />, path: "logs" },

Review Comment:
   Sure, let me fix it tomorrow. Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2981276672

   > I’m back! I've noticed the change to the right panel. It seems like fixing the height of HeaderCard might not be ideal now. I agree with your idea of moving the Gantt chart to the left panel, similar to how we handle the grid and graph. That might be a better way to manage the Gantt chart UX without messing up the layout.
   > 
   > The only trade-off I see is that we might lose the shared scroll between the grid and the Gantt. What are your thoughts on that?
   
   Either, the gantt chart can be a separate view on the left panel (easier)
   Show/Hide Gantt , is an option on the grid view and they can live inside of the same container so the scrolling is easier to handle.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2981431567

   Yeah, when the gantt is shown we can change the minWidth!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2146971124


##########
airflow-core/src/airflow/ui/src/components/StatsDisplay.tsx:
##########
@@ -0,0 +1,79 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box, GridItem, Heading, HStack, VStack } from "@chakra-ui/react";
+import { useState } from "react";
+import { MdInfoOutline } from "react-icons/md";
+
+import { Stat } from "src/components/Stat";
+import { Dialog } from "src/components/ui";
+
+import ActionButton from "./ui/ActionButton";
+
+const StatsDisplay = ({
+  isCompact = false,
+  stats,
+  title,
+}: {
+  readonly isCompact?: boolean;
+  readonly stats: Array<{ label: string; value: React.ReactNode | string }>;
+  readonly title?: string;
+}) => {
+  const [isOpen, setIsOpen] = useState(false);
+
+  if (isCompact) {
+    return (
+      <Box>
+        <ActionButton
+          actionName="Show stats"
+          icon={<MdInfoOutline />}
+          onClick={() => setIsOpen(true)}
+          text="Stats"
+          withText={false}
+        />
+        <Dialog.Root lazyMount onOpenChange={() => setIsOpen(false)} open={isOpen} size="md">
+          <Dialog.Content backdrop>
+            <Dialog.Header bg="blue.muted">
+              <Heading size="xl">{title ?? "Statistics"}</Heading>

Review Comment:
   Translation needed here as well



##########
airflow-core/src/airflow/ui/src/components/HeaderCard.tsx:
##########
@@ -33,24 +37,39 @@ type Props = {
   readonly title: ReactNode | string;
 };
 
-export const HeaderCard = ({ actions, icon, isRefreshing, state, stats, subTitle, title }: Props) => (
-  <Box borderColor="border" borderRadius={8} borderWidth={1} ml={2} p={2}>
-    <Flex alignItems="center" flexWrap="wrap" justifyContent="space-between" mb={2}>
-      <Flex alignItems="center" flexWrap="wrap" gap={2}>
-        <Heading size="xl">{icon}</Heading>
-        <Heading size="lg">{title}</Heading>
-        <Heading size="lg">{subTitle}</Heading>
-        {state === undefined ? undefined : <StateBadge state={state}>{state}</StateBadge>}
-        {isRefreshing ? <Spinner /> : <div />}
+export const HeaderCard = ({ actions, icon, isRefreshing, state, stats, subTitle, title }: Props) => {
+  const containerRef = useRef<HTMLDivElement>();
+  const containerWidth = useContainerWidth(containerRef);
+  const isGanttPage = useLocation().pathname.includes("/gantt");
+
+  return (
+    <Box
+      borderColor="border"
+      borderRadius={8}
+      borderWidth={1}
+      h={isGanttPage ? 52 : undefined}
+      ml={2}
+      overflow="auto"
+      p={2}
+      ref={containerRef}
+    >
+      <Flex alignItems="center" flexWrap="wrap" justifyContent="space-between" mb={2}>
+        <Flex alignItems="center" flexWrap="wrap" gap={2}>
+          <Heading size="xl">{icon}</Heading>
+          <Heading size="lg">{title}</Heading>
+          <Heading size="lg">{subTitle}</Heading>
+          {state === undefined ? undefined : <StateBadge state={state}>{state}</StateBadge>}
+          {isRefreshing ? <Spinner /> : <div />}
+        </Flex>
+        <Stack direction={isGanttPage && containerWidth <= 380 ? "row" : "column"} mt={2} w="100%">
+          <HStack gap={1}>{actions}</HStack>
+          <StatsDisplay

Review Comment:
   Nice call on moving it to an Info tooltip on small sizes.



##########
airflow-core/src/airflow/ui/src/components/StatsDisplay.tsx:
##########
@@ -0,0 +1,79 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box, GridItem, Heading, HStack, VStack } from "@chakra-ui/react";
+import { useState } from "react";
+import { MdInfoOutline } from "react-icons/md";
+
+import { Stat } from "src/components/Stat";
+import { Dialog } from "src/components/ui";
+
+import ActionButton from "./ui/ActionButton";
+
+const StatsDisplay = ({
+  isCompact = false,
+  stats,
+  title,
+}: {
+  readonly isCompact?: boolean;
+  readonly stats: Array<{ label: string; value: React.ReactNode | string }>;
+  readonly title?: string;
+}) => {
+  const [isOpen, setIsOpen] = useState(false);
+
+  if (isCompact) {
+    return (
+      <Box>
+        <ActionButton
+          actionName="Show stats"
+          icon={<MdInfoOutline />}
+          onClick={() => setIsOpen(true)}
+          text="Stats"

Review Comment:
   Here too



##########
airflow-core/src/airflow/ui/src/components/StatsDisplay.tsx:
##########
@@ -0,0 +1,79 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box, GridItem, Heading, HStack, VStack } from "@chakra-ui/react";
+import { useState } from "react";
+import { MdInfoOutline } from "react-icons/md";
+
+import { Stat } from "src/components/Stat";
+import { Dialog } from "src/components/ui";
+
+import ActionButton from "./ui/ActionButton";
+
+const StatsDisplay = ({
+  isCompact = false,
+  stats,
+  title,
+}: {
+  readonly isCompact?: boolean;
+  readonly stats: Array<{ label: string; value: React.ReactNode | string }>;
+  readonly title?: string;
+}) => {
+  const [isOpen, setIsOpen] = useState(false);
+
+  if (isCompact) {
+    return (
+      <Box>
+        <ActionButton
+          actionName="Show stats"

Review Comment:
   Translation needed



##########
airflow-core/src/airflow/ui/src/components/StatsDisplay.tsx:
##########
@@ -0,0 +1,79 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box, GridItem, Heading, HStack, VStack } from "@chakra-ui/react";
+import { useState } from "react";
+import { MdInfoOutline } from "react-icons/md";
+
+import { Stat } from "src/components/Stat";
+import { Dialog } from "src/components/ui";
+
+import ActionButton from "./ui/ActionButton";
+
+const StatsDisplay = ({
+  isCompact = false,
+  stats,
+  title,
+}: {
+  readonly isCompact?: boolean;
+  readonly stats: Array<{ label: string; value: React.ReactNode | string }>;
+  readonly title?: string;
+}) => {
+  const [isOpen, setIsOpen] = useState(false);
+
+  if (isCompact) {
+    return (
+      <Box>
+        <ActionButton
+          actionName="Show stats"
+          icon={<MdInfoOutline />}
+          onClick={() => setIsOpen(true)}
+          text="Stats"
+          withText={false}
+        />
+        <Dialog.Root lazyMount onOpenChange={() => setIsOpen(false)} open={isOpen} size="md">

Review Comment:
   Do we need a full dialog? I feel like a [Popover](https://www.chakra-ui.com/docs/components/popover) is sufficient



##########
airflow-core/src/airflow/ui/src/components/HeaderCard.tsx:
##########
@@ -33,24 +37,39 @@ type Props = {
   readonly title: ReactNode | string;
 };
 
-export const HeaderCard = ({ actions, icon, isRefreshing, state, stats, subTitle, title }: Props) => (
-  <Box borderColor="border" borderRadius={8} borderWidth={1} ml={2} p={2}>
-    <Flex alignItems="center" flexWrap="wrap" justifyContent="space-between" mb={2}>
-      <Flex alignItems="center" flexWrap="wrap" gap={2}>
-        <Heading size="xl">{icon}</Heading>
-        <Heading size="lg">{title}</Heading>
-        <Heading size="lg">{subTitle}</Heading>
-        {state === undefined ? undefined : <StateBadge state={state}>{state}</StateBadge>}
-        {isRefreshing ? <Spinner /> : <div />}
+export const HeaderCard = ({ actions, icon, isRefreshing, state, stats, subTitle, title }: Props) => {
+  const containerRef = useRef<HTMLDivElement>();
+  const containerWidth = useContainerWidth(containerRef);
+  const isGanttPage = useLocation().pathname.includes("/gantt");

Review Comment:
   How does this look when switching tabs? It might be better to stay consistent and always change the header based on containerWidth



##########
airflow-core/src/airflow/ui/src/layouts/Details/Grid/GridTI.tsx:
##########
@@ -72,7 +72,7 @@ const Instance = ({ dagId, isGroup, isMapped, runId, search, state, taskId }: Pr
       <Link
         replace
         to={{
-          pathname: `/dags/${dagId}/runs/${runId}/tasks/${isGroup ? "group/" : ""}${taskId}${isMapped ? "/mapped" : ""}`,
+          pathname: `/dags/${dagId}/runs/${runId}/tasks/${isGroup ? "group/" : ""}${taskId}${isMapped ? "/mapped" : ""}/gantt`,

Review Comment:
   Let's drop `gantt` from here or let's make sure we persist whatever the selected tab is



##########
airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx:
##########
@@ -0,0 +1,210 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box } from "@chakra-ui/react";
+import {
+  Chart as ChartJS,
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  LineElement,
+  BarElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  TimeScale,
+} from "chart.js";
+import "chart.js/auto";
+import "chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm";
+import annotationPlugin from "chartjs-plugin-annotation";
+import dayjs from "dayjs";
+import { useMemo, useRef } from "react";
+import { Bar } from "react-chartjs-2";
+import { useTranslation } from "react-i18next";
+import { useParams } from "react-router-dom";
+
+import { useOpenGroups } from "src/context/openGroups";
+import { useTimezone } from "src/context/timezone";
+import { flattenNodes } from "src/layouts/Details/Grid/utils";
+import { useGrid } from "src/queries/useGrid";
+import { system } from "src/theme";
+import { getDuration } from "src/utils";
+
+ChartJS.register(
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  BarElement,
+  LineElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  annotationPlugin,
+  TimeScale,
+);
+
+const CHART_PADDING = 38;
+const CHART_ROW_HEIGHT = 20;
+
+export const Gantt = () => {
+  const { groupId: selectedGroupId, runId, taskId: selectedTaskId } = useParams();
+  const { openGroupIds } = useOpenGroups();
+  const { t: translate } = useTranslation("common");
+  const { selectedTimezone } = useTimezone();
+  const ref = useRef();
+
+  const { data: gridData, isLoading } = useGrid();
+
+  const { flatNodes } = useMemo(
+    () => flattenNodes(gridData === undefined ? [] : gridData.structure.nodes, openGroupIds),
+    [gridData, openGroupIds],
+  );
+
+  const runs = gridData?.dag_runs ?? [];
+
+  const taskInstances = runs.find((run) => run.dag_run_id === runId)?.task_instances;
+
+  if (isLoading || taskInstances === undefined || runId === undefined) {
+    return undefined;
+  }
+
+  const validTaskInstances = flatNodes
+    .map((node) => taskInstances.find((ti) => ti.task_id === node.id))
+    .filter((ti) => ti !== undefined);
+
+  const data = validTaskInstances.map((taskInstance) => ({
+    state: taskInstance.state,
+    x: [
+      dayjs(taskInstance.start_date).tz(selectedTimezone).format("YYYY-MM-DD HH:mm:ss.SSS"),

Review Comment:
   Want to put the format as a const string at the top of the file or in datetimeUtils.ts? We repeat it a lot



##########
airflow-core/src/airflow/ui/src/pages/GroupTaskInstance/GroupTaskInstance.tsx:
##########
@@ -72,7 +73,10 @@ export const GroupTaskInstance = () => {
     .find((dr) => dr.dag_run_id === runId)
     ?.task_instances.find((ti) => ti.task_id === groupId);
 
-  const tabs = [{ icon: <MdOutlineTask />, label: "Task Instances", value: "" }];
+  const tabs = [
+    { icon: <MdOutlineTask />, label: "Task Instances", value: "" },
+    { icon: <LuChartGantt />, label: "Gantt", value: "gantt" },

Review Comment:
   Looks like we forgot to include translations here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2278301139


##########
airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx:
##########
@@ -0,0 +1,291 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box, useToken } from "@chakra-ui/react";
+import {
+  Chart as ChartJS,
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  LineElement,
+  BarElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  TimeScale,
+  type TooltipItem,
+} from "chart.js";
+import "chart.js/auto";
+import "chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm";
+import annotationPlugin from "chartjs-plugin-annotation";
+import { useMemo, useRef } from "react";
+import { Bar } from "react-chartjs-2";
+import { useTranslation } from "react-i18next";
+import { useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import { useColorMode } from "src/context/colorMode";
+import { useOpenGroups } from "src/context/openGroups";
+import { useTimezone } from "src/context/timezone";
+import { flattenNodes } from "src/layouts/Details/Grid/utils";
+import { useGridRuns } from "src/queries/useGridRuns";
+import { useGridStructure } from "src/queries/useGridStructure";
+import { useGridTiSummaries } from "src/queries/useGridTISummaries";
+import { system } from "src/theme";
+import { getDuration, isStatePending, useAutoRefresh } from "src/utils";
+import { formatDate } from "src/utils/datetimeUtils";
+
+ChartJS.register(
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  BarElement,
+  LineElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  annotationPlugin,
+  TimeScale,
+);
+
+type Props = {
+  readonly limit: number;
+};
+
+const CHART_PADDING = 36;
+const CHART_ROW_HEIGHT = 20;
+const MIN_BAR_WIDTH = 10;
+
+export const Gantt = ({ limit }: Props) => {
+  const { dagId = "", groupId: selectedGroupId, runId, taskId: selectedTaskId } = useParams();
+  const { openGroupIds } = useOpenGroups();
+  const { t: translate } = useTranslation("common");
+  const { selectedTimezone } = useTimezone();
+  const { colorMode } = useColorMode();
+  const ref = useRef();
+
+  const [lightGridColor, darkGridColor, lightSelectedColor, darkSelectedColor] = useToken("colors", [
+    "gray.200",
+    "gray.800",
+    "blue.200",
+    "blue.800",
+  ]);
+  const gridColor = colorMode === "light" ? lightGridColor : darkGridColor;
+  const selectedItemColor = colorMode === "light" ? lightSelectedColor : darkSelectedColor;
+
+  const { data: gridRuns, isLoading: runsLoading } = useGridRuns({ limit });
+  const { data: dagStructure, isLoading: structureLoading } = useGridStructure({ limit });
+  const selectedRun = gridRuns?.find((run) => run.run_id === runId);
+  const refetchInterval = useAutoRefresh({ dagId });
+
+  // Get grid summaries for groups (which have min/max times)
+  const { data: gridTiSummaries, isLoading: summariesLoading } = useGridTiSummaries({
+    dagId,
+    runId: runId ?? "",
+    state: selectedRun?.state,
+  });
+
+  // Get individual task instances for tasks (which have start/end times)
+  const { data: taskInstancesData, isLoading: tiLoading } = useTaskInstanceServiceGetTaskInstances(
+    {
+      dagId,
+      dagRunId: runId ?? "~",
+    },
+    undefined,
+    {
+      enabled: Boolean(dagId),
+      refetchInterval: (query) =>
+        query.state.data?.task_instances.some((ti) => isStatePending(ti.state)) ? refetchInterval : false,
+    },
+  );
+
+  const { flatNodes } = useMemo(() => flattenNodes(dagStructure, openGroupIds), [dagStructure, openGroupIds]);
+
+  const isLoading = runsLoading || structureLoading || summariesLoading || tiLoading;
+
+  const data = useMemo(() => {
+    if (isLoading || runId === undefined) {
+      return [];
+    }
+
+    const gridSummaries = gridTiSummaries?.task_instances ?? [];
+    const taskInstances = taskInstancesData?.task_instances ?? [];
+
+    return flatNodes
+      .map((node) => {
+        const gridSummary = gridSummaries.find((ti) => ti.task_id === node.id);
+
+        if (node.isGroup && gridSummary) {
+          // Group node - use min/max times from grid summary
+          return {
+            isGroup: true,
+            state: gridSummary.state,
+            x: [
+              formatDate(gridSummary.min_start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              formatDate(gridSummary.max_end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+            ],
+            y: gridSummary.task_id,
+          };
+        } else if (!node.isGroup) {
+          // Individual task - use individual task instance data
+          const taskInstance = taskInstances.find((ti) => ti.task_id === node.id);
+
+          if (taskInstance) {
+            return {
+              isGroup: false,
+              state: taskInstance.state,
+              x: [
+                formatDate(taskInstance.start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+                formatDate(taskInstance.end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              ],
+              y: taskInstance.task_id,
+            };
+          }
+        }
+
+        return undefined;
+      })
+      .filter((item) => item !== undefined);
+  }, [flatNodes, gridTiSummaries, taskInstancesData, selectedTimezone, isLoading, runId]);
+
+  const chartData = useMemo(
+    () => ({
+      datasets: [
+        {
+          backgroundColor: data.map(
+            (dataItem) =>
+              system.tokens.categoryMap.get("colors")?.get(`${dataItem.state}.600`)?.value as string,
+          ),
+          data,
+          maxBarThickness: CHART_ROW_HEIGHT,
+          minBarLength: MIN_BAR_WIDTH,
+        },
+      ],
+      labels: [],
+    }),
+    [data],
+  );
+
+  const fixedHeight = data.length * CHART_ROW_HEIGHT + CHART_PADDING;
+  const selectedId = selectedTaskId ?? selectedGroupId;
+
+  const chartOptions = useMemo(
+    () => ({
+      animation: {
+        duration: 100,
+      },
+      indexAxis: "y" as const,
+      maintainAspectRatio: false,
+      plugins: {
+        annotation: {
+          annotations:
+            selectedId === undefined
+              ? []
+              : [
+                  {
+                    backgroundColor: selectedItemColor,
+                    borderWidth: 0,
+                    drawTime: "beforeDatasetsDraw" as const,
+                    type: "box" as const,
+                    xMax: "max" as const,
+                    xMin: "min" as const,
+                    yMax: data.findIndex((dataItem) => dataItem.y === selectedId) + 0.5,
+                    yMin: data.findIndex((dataItem) => dataItem.y === selectedId) - 0.5,
+                  },
+                ],
+        },
+        legend: {
+          display: false,
+        },
+        tooltip: {

Review Comment:
   Sure, I agree with you. To keep consistent in ui is quite important. I could try add it in in follow-up pr.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3206489603

   #protm


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2967764780

   Very cool! I'll pull thsi down and play with it some more. But my quick thoughts:
   
   - Yes, let's make the header a fixed height. Ideally by using <Skeleton /> as a placeholder
   - I think we need to remove or at least speed up the animations in the gantt chart
   - Let's test this against a dag with 100+ tasks and see how the scrolling holds up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2980683594

   I’m back!
   I've noticed the change to the right panel. It seems like fixing the height of HeaderCard might not be ideal now. I agree with your idea of moving the Gantt chart to the left panel, similar to how we handle the grid and graph. That might be a better way to manage the Gantt chart UX without messing up the layout.
   
   The only trade-off I see is that we might lose the shared scroll between the grid and the Gantt. What are your thoughts on that?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-2992256786

   Looks cool! Need to get used to have the Gantt on the left but from perspective of layout and usage this really makes sense! I slightly worry about conflict of space/pixels but maybe the amount of runs just need to be reduced.
   
   Two small nits/glitches:
   (1) It seems the calculation of the bar is not correct, I used the "integration test" DAG (Which I usually use for testing all sorts) and it seems while a task was running the start position was not correct:
   ![image](https://github.com/user-attachments/assets/1a7e184b-b85a-42a0-a7ed-afafde508452)
   ("long running" is started after "my setup" as dependecy but bar starts before)
   
   (2) The tooltips of execution duration is sometimes overlapping with the mouse, hiding the actualy bars it should provide more details to. Can these be positioned somewhere else (above/below)?
   ![image](https://github.com/user-attachments/assets/2b6920cf-90fa-45ad-9edb-3620de470177)
   
   Otherwise I'd have said LGTM but these two glitches should be ironed-out.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2277659346


##########
airflow-core/src/airflow/ui/src/layouts/Details/PanelButtons.tsx:
##########
@@ -72,10 +78,19 @@ const deps = ["all", "immediate", "tasks"];
 
 type Dependency = (typeof deps)[number];
 
-export const PanelButtons = ({ dagView, limit, panelGroupRef, setDagView, setLimit }: Props) => {
+export const PanelButtons = ({
+  dagView,
+  limit,
+  panelGroupRef,
+  setDagView,
+  setLimit,
+  setShowGantt,
+  showGantt,
+}: Props) => {
   const { t: translate } = useTranslation(["components", "dag"]);
-  const { dagId = "" } = useParams();
+  const { dagId = "", runId, taskId } = useParams();
   const { fitView } = useReactFlow();
+  const shouldShowToggleButtons = Boolean(runId ?? taskId);

Review Comment:
   Shouldn't this just be `Boolean(runId)`?
   
   In the future we can make a custom /gantt endpoint to generate a box-whisker plot to show trends across runs.



##########
airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx:
##########
@@ -0,0 +1,291 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Box, useToken } from "@chakra-ui/react";
+import {
+  Chart as ChartJS,
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  LineElement,
+  BarElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  TimeScale,
+  type TooltipItem,
+} from "chart.js";
+import "chart.js/auto";
+import "chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm";
+import annotationPlugin from "chartjs-plugin-annotation";
+import { useMemo, useRef } from "react";
+import { Bar } from "react-chartjs-2";
+import { useTranslation } from "react-i18next";
+import { useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import { useColorMode } from "src/context/colorMode";
+import { useOpenGroups } from "src/context/openGroups";
+import { useTimezone } from "src/context/timezone";
+import { flattenNodes } from "src/layouts/Details/Grid/utils";
+import { useGridRuns } from "src/queries/useGridRuns";
+import { useGridStructure } from "src/queries/useGridStructure";
+import { useGridTiSummaries } from "src/queries/useGridTISummaries";
+import { system } from "src/theme";
+import { getDuration, isStatePending, useAutoRefresh } from "src/utils";
+import { formatDate } from "src/utils/datetimeUtils";
+
+ChartJS.register(
+  CategoryScale,
+  LinearScale,
+  PointElement,
+  BarElement,
+  LineElement,
+  Filler,
+  Title,
+  Tooltip,
+  Legend,
+  annotationPlugin,
+  TimeScale,
+);
+
+type Props = {
+  readonly limit: number;
+};
+
+const CHART_PADDING = 36;
+const CHART_ROW_HEIGHT = 20;
+const MIN_BAR_WIDTH = 10;
+
+export const Gantt = ({ limit }: Props) => {
+  const { dagId = "", groupId: selectedGroupId, runId, taskId: selectedTaskId } = useParams();
+  const { openGroupIds } = useOpenGroups();
+  const { t: translate } = useTranslation("common");
+  const { selectedTimezone } = useTimezone();
+  const { colorMode } = useColorMode();
+  const ref = useRef();
+
+  const [lightGridColor, darkGridColor, lightSelectedColor, darkSelectedColor] = useToken("colors", [
+    "gray.200",
+    "gray.800",
+    "blue.200",
+    "blue.800",
+  ]);
+  const gridColor = colorMode === "light" ? lightGridColor : darkGridColor;
+  const selectedItemColor = colorMode === "light" ? lightSelectedColor : darkSelectedColor;
+
+  const { data: gridRuns, isLoading: runsLoading } = useGridRuns({ limit });
+  const { data: dagStructure, isLoading: structureLoading } = useGridStructure({ limit });
+  const selectedRun = gridRuns?.find((run) => run.run_id === runId);
+  const refetchInterval = useAutoRefresh({ dagId });
+
+  // Get grid summaries for groups (which have min/max times)
+  const { data: gridTiSummaries, isLoading: summariesLoading } = useGridTiSummaries({
+    dagId,
+    runId: runId ?? "",
+    state: selectedRun?.state,
+  });
+
+  // Get individual task instances for tasks (which have start/end times)
+  const { data: taskInstancesData, isLoading: tiLoading } = useTaskInstanceServiceGetTaskInstances(
+    {
+      dagId,
+      dagRunId: runId ?? "~",
+    },
+    undefined,
+    {
+      enabled: Boolean(dagId),
+      refetchInterval: (query) =>
+        query.state.data?.task_instances.some((ti) => isStatePending(ti.state)) ? refetchInterval : false,
+    },
+  );
+
+  const { flatNodes } = useMemo(() => flattenNodes(dagStructure, openGroupIds), [dagStructure, openGroupIds]);
+
+  const isLoading = runsLoading || structureLoading || summariesLoading || tiLoading;
+
+  const data = useMemo(() => {
+    if (isLoading || runId === undefined) {
+      return [];
+    }
+
+    const gridSummaries = gridTiSummaries?.task_instances ?? [];
+    const taskInstances = taskInstancesData?.task_instances ?? [];
+
+    return flatNodes
+      .map((node) => {
+        const gridSummary = gridSummaries.find((ti) => ti.task_id === node.id);
+
+        if (node.isGroup && gridSummary) {
+          // Group node - use min/max times from grid summary
+          return {
+            isGroup: true,
+            state: gridSummary.state,
+            x: [
+              formatDate(gridSummary.min_start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              formatDate(gridSummary.max_end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+            ],
+            y: gridSummary.task_id,
+          };
+        } else if (!node.isGroup) {
+          // Individual task - use individual task instance data
+          const taskInstance = taskInstances.find((ti) => ti.task_id === node.id);
+
+          if (taskInstance) {
+            return {
+              isGroup: false,
+              state: taskInstance.state,
+              x: [
+                formatDate(taskInstance.start_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+                formatDate(taskInstance.end_date, selectedTimezone, "YYYY-MM-DD HH:mm:ss.SSS"),
+              ],
+              y: taskInstance.task_id,
+            };
+          }
+        }
+
+        return undefined;
+      })
+      .filter((item) => item !== undefined);
+  }, [flatNodes, gridTiSummaries, taskInstancesData, selectedTimezone, isLoading, runId]);
+
+  const chartData = useMemo(
+    () => ({
+      datasets: [
+        {
+          backgroundColor: data.map(
+            (dataItem) =>
+              system.tokens.categoryMap.get("colors")?.get(`${dataItem.state}.600`)?.value as string,
+          ),
+          data,
+          maxBarThickness: CHART_ROW_HEIGHT,
+          minBarLength: MIN_BAR_WIDTH,
+        },
+      ],
+      labels: [],
+    }),
+    [data],
+  );
+
+  const fixedHeight = data.length * CHART_ROW_HEIGHT + CHART_PADDING;
+  const selectedId = selectedTaskId ?? selectedGroupId;
+
+  const chartOptions = useMemo(
+    () => ({
+      animation: {
+        duration: 100,
+      },
+      indexAxis: "y" as const,
+      maintainAspectRatio: false,
+      plugins: {
+        annotation: {
+          annotations:
+            selectedId === undefined
+              ? []
+              : [
+                  {
+                    backgroundColor: selectedItemColor,
+                    borderWidth: 0,
+                    drawTime: "beforeDatasetsDraw" as const,
+                    type: "box" as const,
+                    xMax: "max" as const,
+                    xMin: "min" as const,
+                    yMax: data.findIndex((dataItem) => dataItem.y === selectedId) + 0.5,
+                    yMin: data.findIndex((dataItem) => dataItem.y === selectedId) - 0.5,
+                  },
+                ],
+        },
+        legend: {
+          display: false,
+        },
+        tooltip: {

Review Comment:
   Not a blocker, this can be a later PR. but it would be nice to try to use the custom tooltip option to pass chakra jsx components and have it match tooltips in the rest of the UI



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3190843567

   > Switching between dag runs is really jarring. I wonder if we can fetch the data in advanced or have the data size set so we're not rerendering everything.
   
   The prefetch solution works well in action, but it can be quite slow when running multiple runs with multiple tasks.
   I improved it by fixing the data size (the height) using `flattenNodes`. The updated version, as shown in the demo below, still takes some time to fetch the data, but I think the delay is much less jarring compared to the previous version.
   
   https://github.com/user-attachments/assets/a12749d7-30ea-4013-9d49-0027fd15a732
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2285510004


##########
airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx:
##########
@@ -110,16 +113,30 @@ export const DetailsLayout = ({ children, error, isLoading, tabs }: Props) => {
           key={`${dagView}-${direction}`}
           ref={panelGroupRef}
         >
-          <Panel defaultSize={dagView === "graph" ? 70 : 20} id="main-panel" minSize={6} order={1}>
+          <Panel
+            defaultSize={dagView === "graph" ? 70 : 20}
+            id="main-panel"
+            minSize={showGantt && dagView === "grid" ? 60 : 20}

Review Comment:
   > We also need a runId check here. The min size doesn't make sense if you dont have a runId selected.
   
   Thanks for catching this.
   
   > Also, I think its ok if these values are ? 30 : 6 instead. The gantt chart looks like it can work with a minW of 150px instead of 500px
   
   Updated as well. It will feel a little crowded visually on laptop, but I think that’s acceptable for not taking lots of horizontal space.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3001599421

   > Also that leaves a big scroll. I don't know maybe a separate page at first would be much easier to handle all cases, and prevent enormous horizontal scroll. No strong opinion on this, you guys seemed all aligned on the "Gantt next to the Grid" so if you want to keep it like this it's fine
   
   I acknowledge that it is hard to use the Gantt in case you display ~50 or 100 runs. Maybe we should disable the Gantt by default if you pick more than 10 runs.
   
   Separate page makes the usage harder I believe. And we had challenges aligning it on the right panel... but I like having it then you can directly select tasks that are long-runners and check logs or details.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3207576970

   Thanks for all reviews! I would keep working on improving the chart.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #51667:
URL: https://github.com/apache/airflow/pull/51667#discussion_r2283377490


##########
airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx:
##########
@@ -110,16 +113,30 @@ export const DetailsLayout = ({ children, error, isLoading, tabs }: Props) => {
           key={`${dagView}-${direction}`}
           ref={panelGroupRef}
         >
-          <Panel defaultSize={dagView === "graph" ? 70 : 20} id="main-panel" minSize={6} order={1}>
+          <Panel
+            defaultSize={dagView === "graph" ? 70 : 20}
+            id="main-panel"
+            minSize={showGantt && dagView === "grid" ? 60 : 20}
+            order={1}
+          >
             <Box height="100%" marginInlineEnd={2} overflowY="auto" position="relative">
               <PanelButtons
                 dagView={dagView}
                 limit={limit}
                 panelGroupRef={panelGroupRef}
                 setDagView={setDagView}
                 setLimit={setLimit}
+                setShowGantt={setShowGantt}
+                showGantt={showGantt}
               />
-              {dagView === "graph" ? <Graph /> : <Grid limit={limit} />}
+              {dagView === "graph" ? (
+                <Graph />
+              ) : (
+                <HStack gap={0}>
+                  <Grid limit={limit} />

Review Comment:
   After testing on large screen sizes I think we need to pass `showGantt && runId` to <Grid /> and replace `width="100%"` in a few spots to `width={showGantt ? undefined : "100%"}`. This will create cut down on whitespace between the task name and grid cells and give more room for the gantt chart.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add Gantt chart view [airflow]

Posted by "simi (via GitHub)" <gi...@apache.org>.
simi commented on PR #51667:
URL: https://github.com/apache/airflow/pull/51667#issuecomment-3312807304

   I'm facing this issue on Linux/Chrome. Number time rotated is not simple to read, since it is cut at the top and tooltip is streched to fit inside. 
   
   <img width="942" height="320" alt="image" src="https://github.com/user-attachments/assets/182f31b2-d200-45fa-a021-a4b45d41e529" />
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org