How to set dataset to a chart


I am trying to set a list of datasets to a chart. Is there a way to iterate through each dataset in the chart? I’m looking for something like this:

chart = event.source.parent.getComponent(‘Chart’)
for i, name in enumerate(tankName, start = 1):
headers = [“Time”, name]
chart.setDataset(“Data” + str(i), [headers, data[i]])

chart.setDataset isn’t a real function

You may find this of interest.