How to find and set y-axis value


#1

how do I find out y-axis value from the key [{key:‘abc’, label:‘test1’},{key:‘xyz’, label:‘test2’}] and change the value of label or some other attribute from that key. e.g key: abc I want to change value of label


#2

Hello @ash0602 ,

You can get find the section label by key, using the find method of the Array, after that you will be able to update the label of the found section, and call the updateCollection method:

var sections=[
  {key:1, label:"Apartment 1"},
  {key:2, label:"Apartment 2"},
  {key:3, label:"Apartment 3"},
  {key:4, label:"Apartment 4"}
];

scheduler.createTimelineView({
  name:	"timeline",
  x_unit:	"day",
  x_date:	"%H:%i", 
  x_step:	1,
  x_size: 7,
  x_start: 0,
  x_length: 7,
  y_unit:	scheduler.serverList("sec", sections),
  y_property:	"section_id",
  render:"bar",
  second_scale:{
    x_unit: "day", 
    x_date: "%F %d" 
  }
});
sections.find(x => x.key === 1).label = "apt Foo";
scheduler.updateCollection()

Here is a demo:
https://snippet.dhtmlx.com/5/16da513a4
(click on the empty space on a section to change its label)

Kind regards,


#3

that’s great, so simple, thanks a ton! :blush::+1: