# Make a bar chart with array (perspective)

**URL:** <https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 17, 2024, 2:10pm UTC](https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925 "2024-12-17T14:10:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rodrigo\_Bernardes](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@Rodrigo\_Bernardes](https://forum.inductiveautomation.com/u/Rodrigo_Bernardes)\
**Post date:** [December 17, 2024, 2:10pm UTC](https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925/1 "2024-12-17T14:10:05Z")

</div>

Hi,

I have an integer array with N elements, and want to make a bar chart (could be a line) showing the values in each array index. I´d like the index to be the X axis and the corresponding value to be the Y axis.

Which element and how ?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Ha99](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Ha99](https://forum.inductiveautomation.com/u/Ha99)\
**Post date:** [December 17, 2024, 2:50pm UTC](https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925/2 "2024-12-17T14:50:39Z")

</div>

Hi,  
You can use Time Series Chart Bar

---

<div class="post-metadata">

**Author:** ![Rodrigo\_Bernardes](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@Rodrigo\_Bernardes](https://forum.inductiveautomation.com/u/Rodrigo_Bernardes)\
**Post date:** [December 17, 2024, 2:53pm UTC](https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925/3 "2024-12-17T14:53:20Z")

</div>

I tried, but when I bind the array as data source, it doesn´t work

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

---

<div class="post-metadata">

**Author:** ![Ha99](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Ha99](https://forum.inductiveautomation.com/u/Ha99)\
**Post date:** [December 17, 2024, 3:01pm UTC](https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925/4 "2024-12-17T15:01:44Z")

</div>

you need to add a second data which is time and build a data with a list which takes the value of time and pressure for example

```python

[
  {
    "time": 1560469431423,
    "Pressure": 12
  },
  {
    "time": 1560469432423,
    "Pressure": 42
  },
  {
    "time": 1560469433423,
    "Pressure": 81
  },
  {
    "time": 1560469434423,
    "Pressure": 11
  }
]

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 17, 2024, 3:22pm UTC](https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925/5 "2024-12-17T15:22:09Z")

</div>

The OP has categories and values, not timestamps and values. The Time Series Chart is the wrong component for the job.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 17, 2024, 3:24pm UTC](https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925/6 "2024-12-17T15:24:34Z")

</div>

Rodrigo, can you show the binding on the data property?  
If it is an SQL query please show that as well [formatted as code](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![Rodrigo\_Bernardes](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@Rodrigo\_Bernardes](https://forum.inductiveautomation.com/u/Rodrigo_Bernardes)\
**Post date:** [December 17, 2024, 4:22pm UTC](https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925/7 "2024-12-17T16:22:50Z")

</div>

Hi,

The binding is just a tag. An array of 24+1 integers. I want to show the production of something by hour. Each index will be an hour of the day, and its values will be the total produced. It´s Edge, I don´t have databases, that´s why I'm using tags.

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

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 17, 2024, 5:45pm UTC](https://forum.inductiveautomation.com/t/make-a-bar-chart-with-array-perspective/99925/8 "2024-12-17T17:45:27Z")

</div>

Add a script transform to your tag binding:

```python
def transform(self, value, quality, timestamp):
	newData = []
	for i in range(len(value)):
		newData.append({"hour": i, "produced": value[i]})
	return newData

```

Set  
`xAxes.0.name : hour`  
`xAxes.0.render : category`  
`yAxes.0.name : produced`  
`xAxes.0.render : value`  
and do the usual good stuff in `series.0...`.
