reactjs - How to Optimize GanttComponent Performance for Large Data Sets (200+ Rows)? - Stack Overflow

I'm using the GanttComponent (shown in the code below) to display a dataset of around 200 rows. Ho

I'm using the GanttComponent (shown in the code below) to display a dataset of around 200 rows. However, it's taking approximately 15 seconds to load. While I understand that enabling enableVirtualization could improve performance, I'm exploring if there are other optimizations I can implement to reduce the loading time further.

Key Points:

  • I'm rendering a Gantt chart with custom column templates.
  • There are 11 additional columns (not included in the example).
  • Tooltip and header customization are in use, as seen in the code.
  • The dataset is provided via ref.current.dataSource.

Here’s the relevant code snippet:

const Gantt = forwardRef((props, ref) => {
  const headerTemplate = useCallback((args) => {
    switch (args.field) {
      case "name": {
        return (
          <Box
            sx={{
              alignItems: "flex-start",
              display: "flex",
              flexDirection: "row",
              gap: "10px",
              justifyContent: "space-between",
              overflow: "hidden",
            }}
          >
            <Box
              sx={{
                flex: 1,
                textOverflow: "ellipsis",
                overflow: "hidden",
              }}
            >
              {tTest("Names")}
              <br />
              &nbsp;
            </Box>
          </Box>
        );
      }
      // 11 more columns
      default:
        break;
    }
    return null;
  }, []);

  const template = useCallback((field) => (args) => {
    switch (field) {
      case "name":
        return (
          <Box
            sx={{
              alignItems: "center",
              display: "flex",
              flexDirection: "row",
              gap: "10px",
              justifyContent: "space-between",
              overflow: "hidden",
            }}
          >
            <Tooltip name={args.taskData.name}>{args.taskData.name}</Tooltip>
          </Box>
        );
      // 11 more columns
      default:
        break;
    }
    return null;
  }, []);

  const settings = useMemo(() => {
    return {
      allowSelection: false,
      columns: [
        {
          autoFit: true,
          field: "name",
          headerTemplate,
          isPrimaryKey: true,
          template: template("name"),
          visible: true,
          width: "500px",
        },
      ],
      taskFields: {
        id: "id",
        name: "name",
        startDate: "startDate",
        duration: "duration",
        progress: "progress",
        child: "child",
      },
      width: "100%",
      gridLines: "Both",
      tooltipSettings: {
        showTooltip: true,
      },
    };
  }, []);

  return (
    <Box sx={{ display: "flex", flexDirection: "row", flexGrow: 1, overflow: "hidden" }}>
      <GanttComponent {...settings}>
        <Inject services={[DayMarkers]} />
      </GanttComponent>
    </Box>
  );
});

Questions:

  1. Besides enabling enableVirtualization, are there other ways to optimize the initial load performance?
  2. Could the issue be related to how custom templates (header or row) are implemented?
  3. Is there a more efficient way to manage such customizations or handle large datasets in GanttComponent?

Any help or suggestions from experienced users of GanttComponent would be greatly appreciated.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742343019a4426003.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信