Skip to main content

api.getState()

Description

Gets the state object that stores current values of most Gantt properties

You can apply the method to get the state of tasks, links, columns, scales, etc. See the parameters of the returned object below.

Usage

api.getState(): object;

Returns

The method returns an object with the following parameters:

{
tasks,
links,
start,
columns,
end,
lengthUnit,
cellWidth,
cellHeight,
scaleHeight,
scales,
taskTypes,
zoom,
selected,
activeTask,
baselines,
}

Example

<script>
import { getData } from "./common/data";
import { Gantt } from "@wx/svelte-gantt";

const data = getData();

let api;

$: if (api) {
const { tasks, links } = api.getState();
console.log(tasks);//output the state of tasks
console.log(links);//output the state of links
}
</script>

<Gantt bind:api tasks={data.tasks} links={data.links} />

Related articles: