# How to pass empty dataset to chart?

**URL:** <https://forum.inductiveautomation.com/t/how-to-pass-empty-dataset-to-chart/53874>\
**Category:** Ignition\
**Created:** [December 8, 2021, 10:34am UTC](https://forum.inductiveautomation.com/t/how-to-pass-empty-dataset-to-chart/53874 "2021-12-08T10:34:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 8, 2021, 10:34am UTC](https://forum.inductiveautomation.com/t/how-to-pass-empty-dataset-to-chart/53874/1 "2021-12-08T10:34:39Z")

</div>

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…

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/4/84d8141e0233bc4167265efc8bcb5a23b8f92f95.png)

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 8, 2021, 10:44am UTC](https://forum.inductiveautomation.com/t/how-to-pass-empty-dataset-to-chart/53874/2 "2021-12-08T10:44:39Z")

</div>

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:  
[https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.0/com/inductiveautomation/ignition/common/BasicDataset.html](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.0/com/inductiveautomation/ignition/common/BasicDataset.html)  
or  
[http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/com/inductiveautomation/ignition/common/util/DatasetBuilder.html](http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/com/inductiveautomation/ignition/common/util/DatasetBuilder.html)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 8, 2021, 12:54pm UTC](https://forum.inductiveautomation.com/t/how-to-pass-empty-dataset-to-chart/53874/3 "2021-12-08T12:54:26Z")

</div>

> [@manjuyadav95.m](#):
>
> my code is written on the dropdown value property change script…

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`

-\>

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

```

And it should show you this:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/2/a29a86f332fc4724fd7c3d130615ec0ff87b58b6.png)

edit:  
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:

```python
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)
		rowsProcess.append([vProcess,vDownTime])
return {
	'data': system.dataset.toDataSet(headerChart, rowsProcess)
}

```

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 9, 2021, 5:36am UTC](https://forum.inductiveautomation.com/t/how-to-pass-empty-dataset-to-chart/53874/4 "2021-12-09T05:36:07Z")

</div>

This one worked out. Thanks for your help 🙂 🙂

The output which I was expecting …returns 0rows of dataset 👍

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 9, 2021, 5:48am UTC](https://forum.inductiveautomation.com/t/how-to-pass-empty-dataset-to-chart/53874/5 "2021-12-09T05:48:05Z")

</div>

Thanks for your reply and explanation… 👍 👍  
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)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/f/bf5d5dd1ccf7e457eb5e7470710d40290b85ea70.png)  
as I don’t know how to pass Dataset[0x2]…shown as image below…  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/3/e395c938ee327e0822fbbd29034726e4e2b1231c.png)

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

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

```

Thanks a lot to both of you 👍 👍 👍 🙂 🙂

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?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/0/70c353e28c24064f930cbe13ea235ac4e19afb4c.png)

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 9, 2021, 8:11am UTC](https://forum.inductiveautomation.com/t/how-to-pass-empty-dataset-to-chart/53874/6 "2021-12-09T08:11:30Z")

</div>

> [@manjuyadav95.m](#):
>
> 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
