Search code examples
javascriptgantt-chartanychart

Is it possible to select programatically a row in AnyGantt charts?


Let's say we have a simple Gantt chart, implemented in JavaScript, using AnyChart library:

Simple Gantt chart

If the user clicks on Tuesday row, it's automatically highlighted:

Highlighted row

Is it possible to do it programatically? I mean, I don't want the user to click on a row, I want to do it with code.

AnyChart provides a wonderful playground to test the library. I created one to have a starting point: Select a row programatically. In the JavaScript code, search for the selectRow function, and do your magic.

function selectRow() {
  const idToSelect = "3";
  const selected = treeData.search("id", idToSelect);
  // highlight selected item
}

Solution

  • To achieve that you should apply true to the selected field of the item meta. For details, check the sample.