How to pass empty dataset to chart?

below is my code is written on the dropdown value property change script…
if rows>0 then dataset from method should be passed to bar chart
if not then it should pass 0rows but it’s passing null value due to which not even showing x n y axis on graph …added screenshots below plz help anyone…

Designer end…

if types arent important, you could just create one with no rows

dsWithNoRows= system.dataset.toDataSet(headerChart,[])

else you can use one the base ignition java classes:

1 Like

I’m thinking you should be binding the dataSources property to your dropdown value instead.
It makes things easier to follow, as populating it with a script is “invisible” when looking at the chart component, and figuring out where the data comes from can be a pain.

self.parent.parent.getChild("cntr_DowntimeReasons").getChild("DowntimeReasonsChart").props.dataSources.example= None

self.parent.parent.getChild("cntr_DowntimeReasons").getChild("DowntimeReasonsChart").props.dataSources = {}

And it should show you this:

I’m not sure what the dropdown role is as I don’t see any of the self, previousValue, currentValue, origin, missedEvents parameters in your script… But, binding dataSources to dropdown.props.value instead of using a value change script and adding a transform, you could do something like this:

ds_down = system.optebiz.getdowntimeDataSetNew(vDataPoints,vWhereClause,vGroupBy,vOrderBy,vNoofRows,vNoofRowsOf,vLineAutoId,vProcessAutoId,vEquipAutoId,str(vStartDate),str(vEndDate),vArea,vDataSource,vUser)

headerChart = ['Process', 'down Time']
rowsProcess = []
if ds_down:
	for row in range(ds_Down.rowCount):
		vProcess = ds_Down.getValueAt(row,'Description')
		vDownTime = round(ds_Down.getValueAt(row,'TotalDowntimeM'),2)
return {
	'data': system.dataset.toDataSet(headerChart, rowsProcess)

This one worked out. Thanks for your help :slight_smile: :slight_smile:

The output which I was expecting …returns 0rows of dataset :+1:

Thanks for your reply and explanation… :+1: :+1:
Actually, the multiple charts data changes based on dropdown value and 2 more methods called on dropdown value property change script so it’s quite long script but I shared only one method here …Now no rows returned from method so need to pass 0rows dataset to the chart but it was passing null(datasource expecting array/dataset but null passed …below img shared)

as I don’t know how to pass Dataset[0x2]…shown as image below…

Now, it has been solved by using below code shared by @victordcq

dsWithNoRows= system.dataset.toDataSet(headerChart,[])
		self.parent.parent.getChild("cntr_OEE").getChild("DowntimeReasonsChart").props.dataSources.example= dsWithNoRows

Thanks a lot to both of you :+1: :+1: :+1: :slightly_smiling_face: :slightly_smiling_face:

Plz help me on below …
I want to change the individual bar chart based on custom property values…
earlier in array datasource> example>I just added value in the name of color( expression binding done to change the color based on custom property values ) and given value “color” for the below prop that worked out but in this case, it is dataset in datasource>example then how to change individual bar chart in dataset case?

Doesnt it work the same way? Idk about this particular chart, but it should get converted