# X and Y values linked to a tag + refresh XY Chart automatically

**URL:** <https://forum.inductiveautomation.com/t/x-and-y-values-linked-to-a-tag-refresh-xy-chart-automatically/99755>\
**Category:** Ignition\
**Created:** [December 12, 2024, 4:17pm UTC](https://forum.inductiveautomation.com/t/x-and-y-values-linked-to-a-tag-refresh-xy-chart-automatically/99755 "2024-12-12T16:17:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephanie\_Aguiar](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@Stephanie\_Aguiar](https://forum.inductiveautomation.com/u/Stephanie_Aguiar)\
**Post date:** [December 12, 2024, 4:17pm UTC](https://forum.inductiveautomation.com/t/x-and-y-values-linked-to-a-tag-refresh-xy-chart-automatically/99755/1 "2024-12-12T16:17:43Z")

</div>

I need some assistance with linking my x and y values to some tags. I tried to use a script in the project library named 'test'. I then used a binding property to run the script I had created that produces the data from a tag. The only issue is that my graph looks empty, it is not populating a line. I'm not sure if its because I may need to use some sort of tag history or what should I do? also, has anyone figured out how to make a XY graph refresh automatically, I don't want to have to refresh the page to be able to see the new data.

```python
def myFunc():
	
	path = ["[default]counter"]
	
	qualifiedValues = system.tag.readBlocking(path)
	value = qualifiedValues[0].value
	
	path2 = ["[default]y-axis"]
	
	qualifiedValues2 = system.tag.readBlocking(path2)
	value2 = qualifiedValues2[0].value
	
	data = { "example": [{"x":value, "y":value2}]}
	
	return data

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/3/735d67ff09880a0be54a7f807a7a6050c501a962.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Wilson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nick_wilson/32/80663_2.png) [@Nick\_Wilson](https://forum.inductiveautomation.com/u/Nick_Wilson)\
**Post date:** [December 12, 2024, 9:45pm UTC](https://forum.inductiveautomation.com/t/x-and-y-values-linked-to-a-tag-refresh-xy-chart-automatically/99755/2 "2024-12-12T21:45:18Z")

</div>

> [@Stephanie\_Aguiar](#):
>
> e assistance with linking my x and y values to some tags. I tried to use a script in the project library named 'test'. I then used a binding property to run the script I had created that produces the data from a tag. The only issue is that my graph looks empty, it is not populating a line. I'm not sure if its because I may need to use some sort of tag history or what should I do? also, has anyone figured out how to make a XY graph refresh automatically, I don't want to have to refresh the page to be ab

Have you considered using the PowerChart component?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/9/7931a0e35bfebb2c78ff77e94354064b41c3e93b.png)

It can be set to realtime (automatically updates in real-time according to selected tag values) or historical.

---

<div class="post-metadata">

**Author:** ![Stephanie\_Aguiar](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@Stephanie\_Aguiar](https://forum.inductiveautomation.com/u/Stephanie_Aguiar)\
**Post date:** [December 12, 2024, 10:00pm UTC](https://forum.inductiveautomation.com/t/x-and-y-values-linked-to-a-tag-refresh-xy-chart-automatically/99755/3 "2024-12-12T22:00:08Z")

</div>

I have considered it, however, my X axis would not be time and the Power Chart is time-based. My x axis would be based on a OPC tag that is counting the number of parts being made in production.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 13, 2024, 12:16pm UTC](https://forum.inductiveautomation.com/t/x-and-y-values-linked-to-a-tag-refresh-xy-chart-automatically/99755/4 "2024-12-13T12:16:51Z")

</div>

> [@Nick\_Wilson](#):
>
> It can be set to realtime (automatically updates in real-time according to selected tag values) or historical.

This is true, but it will only work with historical tags, and real time is based on how the history is configured, so that’s questionable as to if it’s truly realtime.

It can not be made to work with generated datasets.

@Stephanie_Aguiar

You need more than one point in order for the chart to draw a line, so you would need a way to keep track of the previous points location. Perhaps a top level variable in the script library if you don’t want to use history for whatever reason.

Also, in your script you should consolidate your tag reads.

```python

def myFunc():
	
	paths = ["[default]counter", "[default]y-axis"]
	
	qualifiedValues = system.tag.readBlocking(paths)
	value, value2 = (qv.value for qv in qualifiedValues)
	
	data = { "example": [{"x":value, "y":value2}]}
	
	return data

```

---

<div class="post-metadata">

**Author:** ![Stephanie\_Aguiar](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@Stephanie\_Aguiar](https://forum.inductiveautomation.com/u/Stephanie_Aguiar)\
**Post date:** [December 17, 2024, 3:13pm UTC](https://forum.inductiveautomation.com/t/x-and-y-values-linked-to-a-tag-refresh-xy-chart-automatically/99755/5 "2024-12-17T15:13:08Z")

</div>

How would I track the previous points?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 17, 2024, 3:14pm UTC](https://forum.inductiveautomation.com/t/x-and-y-values-linked-to-a-tag-refresh-xy-chart-automatically/99755/6 "2024-12-17T15:14:32Z")

</div>

That depends on your requirements. How long do you need to keep the data?

---

<div class="post-metadata">

**Author:** ![Stephanie\_Aguiar](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@Stephanie\_Aguiar](https://forum.inductiveautomation.com/u/Stephanie_Aguiar)\
**Post date:** [December 17, 2024, 3:38pm UTC](https://forum.inductiveautomation.com/t/x-and-y-values-linked-to-a-tag-refresh-xy-chart-automatically/99755/7 "2024-12-17T15:38:48Z")

</div>

I would need my data to go back at least 24 hrs
