Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Model Driven MES 7​.0

Update Data Segments

  • Last UpdatedOct 10, 2025
  • 2 minute read

The updateDataSegments property is used to support updating a specific Gantt Chart bar data in a multi-line scenario during runtime. This property is ignored when there is an active selection on the data segments. You can use this together with the onTimerRefresh or onRefresh event.

This property consists of datasets, where you can update the dataset of a particular bar. If you don't want to update, you can specify a null value for that bar, just like in the following script:

control.findByXmlNode("Widget1").widgetProperties.updateDataSegments =

JSON.stringify({

barsData:

[

[{}, {}, {}], // 1st bar - data segments

[{}, {}, {}], // 2nd bar - data segments

null, // 3rd bar - data segments (no update in third dataset)

],

});

Example 1

The following script updates the dataset. If you have multiple Gantt Chart, it updates the initial bar data segments.

control.findByXmlNode("Widget1").widgetProperties.updateDataSegments = JSON.stringify(

{

barsData:

[

[

{"id":1,"start":"2022/9/9 1:00:00","end":"2022/9/9 2:00:00","name":"Running","state":"Running","color":"red"},

{"id":2,"start":"2022/9/9 2:00:00","end":"2022/9/9 3:00:00","name":"Run","state":"Run","color":"yellow"},

{"id":3,"start":"2022/9/9 3:00:00","end":"2022/9/9 4:00:00","name":"Stopping","state":"Stopping","color":"lightgreen"},

{"id":4,"start":"2022/9/9 4:00:00","end":"2022/9/9 5:00:00","name":"Stop","state":"Stop","color":"green"},

{"id":5,"start":"2022/9/9 5:00:00","end":"2022/9/9 6:00:00","name":"Down","state":"Down","color":"blue"},

{"id":6,"start":"2022/9/9 6:00:00","end":"2022/9/9 7:00:00","name":"Error","state":"Error","color":"violet"},

{"id":7,"start":"2022/9/9 7:00:00","end":"2022/9/9 8:00:00","name":"Unknown","state":"Unknown","color":"purple"},

{"id":8,"start":"2022/9/9 8:00:00","end":"2022/9/9 9:00:00","name":"Running","state":"Running","color":"black"}

]

]

});

Example 2

The following script updates the dataset of a single bar. This uses a lookup data.

// update only entity 13

try {

var entities = [12, 13, 14];

var ganttLookup = [];

//for (var i = 0; i < entities.length; i++) {

var parameterCollection = [

{

Name: "1",

Value: entities[1],

},

{

Name: "2",

Value: 100,

},

];

ganttLookup.push(

SFU.getLookupSchemaAndData("789Api", parameterCollection, true)

);

if (

ganttLookup[1].DisplayColumn === "" &&

ganttLookup[1].ValueColumn === "" &&

ganttLookup[1].Data.length === 0

) {

throw new Error("gantt lookup #1 not found !");

}

//} // end of for loops - entities

var allData =

{

barsData:

[

null, // no change for entity 12

ganttLookup[1].Data, // update entity 13

null // no change for entity 14

],

};

control.findByXmlNode("Widget1").widgetProperties.updateDataSegments =

JSON.stringify(allData);

}

catch (error)

{

SFU.showError("Gantt Lookup Fail !");

}

Example 3

The following script updates all the dataset in a multiple Gantt Chart scenario. The lookup data includes those data within the first 100 hours. This uses two parameters for the API lookup.

// fetch and update data segments for entities 12, 13 and 14

try

{

var entities = [12, 13, 14];

var ganttLookup = [];

for (var i = 0; i < entities.length; i++)

{

var parameterCollection = [

{

Name: "1",

Value: entities[i],

},

{

Name: "2",

Value: 100,

},

];

ganttLookup.push(

SFU.getLookupSchemaAndData("789Api", parameterCollection, true)

);

if (

ganttLookup[i].DisplayColumn === "" &&

ganttLookup[i].ValueColumn === "" &&

ganttLookup[i].Data.length === 0

)

{

throw new Error("gantt lookup #" + i + " not found !");

}

} // end of for loops - entities

var allData =

{

barsData:

[

ganttLookup[0].Data, // update for entity 12

ganttLookup[1].Data, // update for entity 13

ganttLookup[2].Data, // update for entity 14

],

};

control.findByXmlNode("Widget1").widgetProperties.updateDataSegments =

JSON.stringify(allData);

}

catch (error)

{

SFU.showError("Gantt Lookup Fail !");

}

TitleResults for “How to create a CRG?”Also Available in