# Perspective Pie chart data not showing from query

**URL:** <https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254>\
**Category:** Ignition\
**Tags:** ignition81, database, python, scripting, perspective\
**Created:** [February 1, 2023, 6:16am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254 "2023-02-01T06:16:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adarsh\_Shelar](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Adarsh\_Shelar](https://forum.inductiveautomation.com/u/Adarsh_Shelar)\
**Post date:** [February 1, 2023, 6:16am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/1 "2023-02-01T06:16:32Z")

</div>

Hi connections,

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/f/0f9b56c83fd2ca46c6d0573e50c42581aebb5043.png)  
Need to pass the Value form the data base to the pie chart.Bindied the Named query at the Data. But the color is not visible at the Pie chart. I am passing the data through the named query.

Named query.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/e/deefa877261172f94afc81fdf699564d01aae40c.png)

But not able to get the Data at the Pie chart.

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [February 1, 2023, 6:25am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/2 "2023-02-01T06:25:20Z")

</div>

Your data and bindings don't seem valid. Look at the example here:

[Perspective - Pie Chart - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Pie+Chart)

I see you have a binding on `data`, and another on `data[1]["quality"]`. Those will fight each other.

Refactor your binding on data to return something like this:

```auto
[
   {"quality":"Good", "count":88},
   {"quality":"Bad", "count":12}
]

```

---

<div class="post-metadata">

**Author:** ![Adarsh\_Shelar](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Adarsh\_Shelar](https://forum.inductiveautomation.com/u/Adarsh_Shelar)\
**Post date:** [February 1, 2023, 6:30am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/3 "2023-02-01T06:30:14Z")

</div>

[  
{"quality":"Good", "count":88},  
{"quality":"Bad", "count":12}  
]

This script exactly where needs to Execute.

---

<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:** [February 1, 2023, 7:45am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/4 "2023-02-01T07:45:36Z")

</div>

post your query here using the formated text `</>`  
so we can help

---

<div class="post-metadata">

**Author:** ![Adarsh\_Shelar](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Adarsh\_Shelar](https://forum.inductiveautomation.com/u/Adarsh_Shelar)\
**Post date:** [February 1, 2023, 7:47am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/5 "2023-02-01T07:47:46Z")

</div>

DECLARE @ET Datetime  
DECLARE @ST Datetime

SET @ET = (select convert(DATETIME, :EndDate, 121))  
SET @ST = (select convert(DATETIME, :StartDate, 121))

SELECT AVG([Performance]) as performance  
FROM [OKUMA].[dbo].[OEE\_DATA]  
where [TIMESTAMP] \>= @ST and [TIMESTAMP] \<= @ET

The abovementioned is the Query.

---

<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:** [February 1, 2023, 8:12am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/6 "2023-02-01T08:12:57Z")

</div>

are you sure this is the query?

Your output is quality, while your query says performance...  
anyways you need 2 selects.  
one for the type/label  
and one for the value/count

---

<div class="post-metadata">

**Author:** ![Adarsh\_Shelar](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Adarsh\_Shelar](https://forum.inductiveautomation.com/u/Adarsh_Shelar)\
**Post date:** [February 1, 2023, 8:26am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/7 "2023-02-01T08:26:27Z")

</div>

okay.  
performance and quality have same query.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 1, 2023, 10:01am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/8 "2023-02-01T10:01:18Z")

</div>

You are only returning one column. You need two.

```sql
SELECT 'performance' as key, AVG([Performance]) as value
FROM [OKUMA].[dbo].[OEE_DATA]
where [TIMESTAMP] >= @ST and [TIMESTAMP] <= @ET

```

---

<div class="post-metadata">

**Author:** ![Adarsh\_Shelar](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Adarsh\_Shelar](https://forum.inductiveautomation.com/u/Adarsh_Shelar)\
**Post date:** [February 1, 2023, 1:17pm UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/9 "2023-02-01T13:17:15Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/b/eb2e74a72fc3de2045359bc9976cf71d7249ac6d.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/4522aec6285c38db4e5a26b7bf849e347e461c08.png)

Value Getting Updated in the Designer but While Opened in the Browser Not able Update showing default 100%.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 1, 2023, 1:47pm UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/10 "2023-02-01T13:47:53Z")

</div>

Your query returns one row of data. You need two.

Also, I neglected that 'key' is a keyword in my last post, so I changed the column alias.

You can do this by calculating in your query, then doing an unpivot.

```sql
SELECT keyName, val
FROM (SELECT AVG([Performance]) as performance, 100-AVG([Performance]) as ad
      FROM [OKUMA].[dbo].[OEE_DATA]
      WHERE [TIMESTAMP] >= @ST and [TIMESTAMP] <= @ET) t
UNPIVOT
    (val for keyName in (performance, ad)) u

```

Example:

```sql
SELECT keyName, val
FROM (select 35 as performance, 65 as ad) t
UNPIVOT( val for keyName in (performance, ad)) u

```

Returns:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/1/0146ae195edacac603bf16e0ecaff52ec205394a.png)

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [February 1, 2023, 2:31pm UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/11 "2023-02-01T14:31:18Z")

</div>

Seeing these screenshots, it looks like you don't want a pie chart. Maybe a simple gauge is better suited?

[Perspective - Simple Gauge - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Simple+Gauge)

---

<div class="post-metadata">

**Author:** ![Adarsh\_Shelar](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Adarsh\_Shelar](https://forum.inductiveautomation.com/u/Adarsh_Shelar)\
**Post date:** [February 2, 2023, 6:00am UTC](https://forum.inductiveautomation.com/t/perspective-pie-chart-data-not-showing-from-query/69254/12 "2023-02-02T06:00:33Z")

</div>

> [@JordanCClark](#):
>
> ```python
> SELECT 'performance' as key, AVG([Performance]) as value
> FROM [OKUMA].[dbo].[OEE_DATA]
> where [TIMESTAMP] >= @ST and [TIMESTAMP] <= @ET
> 
> ```

Thank you JordanC Clark its working fine.
