# Query binding to piechart

**URL:** <https://forum.inductiveautomation.com/t/query-binding-to-piechart/65592>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [October 24, 2022, 12:04pm UTC](https://forum.inductiveautomation.com/t/query-binding-to-piechart/65592 "2022-10-24T12:04:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Massiris](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Miguel\_Massiris](https://forum.inductiveautomation.com/u/Miguel_Massiris)\
**Post date:** [October 24, 2022, 12:04pm UTC](https://forum.inductiveautomation.com/t/query-binding-to-piechart/65592/1 "2022-10-24T12:04:18Z")

</div>

Hello good morning to all,

I am having a problem with displaying the data of my query in the pie chart, I am passing the information I think properly but when I go to the screen I get "data invalid".

Thank you very much for your help, I attach a couple of screenshots that I hope will facilitate the understanding of the problem.  
 ![Query](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/8/d8e49474dd6f5b36ad34b166de6e200bf26d082f.png)  
 ![data invalid](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/8/48418ba35d3bb798717dcca2beb5d7b15778d9ee.png)  
 ![script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/8/f885a29f1ecb6319ea94741d63c3cd04152fe256.png)

---

<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:** [October 24, 2022, 12:36pm UTC](https://forum.inductiveautomation.com/t/query-binding-to-piechart/65592/2 "2022-10-24T12:36:02Z")

</div>

What do the logs say ? Can you show us the piechart config ?

Also, let's 'fix' that script transform:

```python
for i in range(value.getRowCount()):
    labelList.append(str(system.dataset.toPyDataSet(value)[i][0]))

```

ew !  
You're converting the same dataset to a pydataset once per row !  
You could use `dataset.getValueAt()` instead:

```python
for i in range(value.getRowCount()):
    labelList.append(value.getValueAt(i, 0))

```

Or first convert to a pydataset, then loop through it:

```python
ds = system.dataset.toPyDataSet(value)
for row in ds:
    labelList.append(row[0])

```

But there's actually a better, built-in way to do this:

```python
labelList = value.getColumnAsList(0)

```

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [October 24, 2022, 12:36pm UTC](https://forum.inductiveautomation.com/t/query-binding-to-piechart/65592/3 "2022-10-24T12:36:21Z")

</div>

Your piechart doesn't work because your first label don't have a value in it:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/a/cab6719b468c65e736b46a5977072b72617825c5.png)

Your query result shows the same issue:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/0524c3f000869adedd4e55c6d1b32537b0c174d8.png)

---

<div class="post-metadata">

**Author:** ![Miguel\_Massiris](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Miguel\_Massiris](https://forum.inductiveautomation.com/u/Miguel_Massiris)\
**Post date:** [October 24, 2022, 1:24pm UTC](https://forum.inductiveautomation.com/t/query-binding-to-piechart/65592/4 "2022-10-24T13:24:28Z")

</div>

Thanks!!!!
