Skip to main content

load()

Description​

Loads data from an external file

Usage​

load(
url: string | object,
driver?: object | string
): promise;

Parameters​

  • url - (required) the URL of an external file or DataProxy with the URL configured
  • driver - (optional) DataDriver or type of data ("json", "csv", "xml"), "json" by default

Returns​

The method returns a promise of data loading

Example​

const diagram = new dhx.Diagram("diagram_container", {
type: "default"
});
diagram.data.parse(data);

diagram.data.load("../common/data.json");

Details​

The component will make an AJAX call and expect the remote URL to provide valid JSON data.

Data loading is asynchronous, so you need to wrap any after-loading code into a promise:

diagram.data.load("../some/data").then(() => {
diagram.selection.add(123);
});

Related article: Loading and storing data

Related sample: Diagram. Data. Data loading