2
<Chart
              chartType="Gantt"
              data={dt}
              height={1600}
              chartEvents={[
                {
                  eventName: "ready",
                  callback: async e => {
                    let container = document.getElementById("chart_div");
                    let chart = e.chartWrapper.getChart();
                    window.google.visualization.events.addListener(chart, "ready", () => {
                      let svg = container.getElementsByTagName("svg")[0];
                      console.log("::: ::: svg ::: :: ", svg);
                      let ganttGroups = svg.getElementsByTagName("g")[7]?.getElementsByTagName("text");
                      let rectGroups = svg.getElementsByTagName("g")[5]?.getElementsByTagName("rect");
                      for (let i = 0; i < ganttGroups.length; i++) {
                        let x = rectGroups[i].getAttribute("x") - rectGroups[i].getAttribute("width") / 2;

                        if (x < 100) {
                          x = x + 900;
                        } else if (x > 1200) {
                          x = x - 300;
                        }

                        ganttGroups[i].setAttribute("fill", "#211BF1");
                        ganttGroups[i].setAttribute("transform", "translate(" + x + ")");
                      }
                    });
                  }
                },
                {
                  eventName: "select",
                  callback: e => {
                    if (email !== "oneweb@umich.edu") return;
                    console.log(":: :: e.chartWrapper.getChart().getSelection() :: :: ", e.chartWrapper.getChart());
                    handleClickOpen(dt[e.chartWrapper.getChart().getSelection()[0].row + 1]);
                  }
                }
              ]}
            />

i added the event ready so that when the chart is drawn it will change the position of the labels .but the problem is it the labels return to the initial position just moment after the event got triggered .how can i fix that in a way to keep the labels in the new position fixed

WhiteHat
  • 59,912
  • 7
  • 51
  • 133
nodisplayname
  • 71
  • 1
  • 5
  • you can use a `MutationObserver` -- check [this answer](https://stackoverflow.com/a/46285361/5090771)... – WhiteHat Mar 15 '23 at 23:49

0 Answers0