# Problem with XY Chart and script transform

**URL:** <https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 24, 2022, 2:23pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599 "2022-10-24T14:23:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michal\_Goralczyk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michal_goralczyk/32/55564_2.png) [@Michal\_Goralczyk](https://forum.inductiveautomation.com/u/Michal_Goralczyk)\
**Post date:** [October 24, 2022, 2:23pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/1 "2022-10-24T14:23:34Z")

</div>

Hi, I have a problem loading my chart on the perspective screen. I use the script to adjust what the XY chart shows depending on the situation. Script generates .json format for dataSources.

When I load the window as a refresh or switch from another tab everything looks ok but when I try to use navigate sript doesn't generate. What it depends on how it can be prevented?

View after navigate:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/55d8722c8c821c7959c5a45c38f4de636772c034.png)

View after refresh:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/5/f5993ae0065b72ed2598bfed3784b4bad718493d.png)

Best Regards  
MG

---

<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:** [October 24, 2022, 2:25pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/2 "2022-10-24T14:25:30Z")

</div>

Going to be difficult to troubleshoot a script transform without the script.

Please post it using the preformatted text `</>` option.

---

<div class="post-metadata">

**Author:** ![Michal\_Goralczyk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michal_goralczyk/32/55564_2.png) [@Michal\_Goralczyk](https://forum.inductiveautomation.com/u/Michal_Goralczyk)\
**Post date:** [October 24, 2022, 2:29pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/3 "2022-10-24T14:29:06Z")

</div>

Code works fine but i dont know why script doesnt ganerate when i use navigate window in perspective. when I do a refresh everything works fine.

```auto
def transform(self, value, quality, timestamp):

	#Color palete
	ColorHEX =[	"#9AFEFF", #0
				"#4EE2EC", #1
				"#81D8D0", #2
				"#7BCCB5", #3
				"#48D1CC", #4
				"#43BFC7", #5
				"#3B9C9C", #6
				"#008080", #7
				"#438D80", #8
				"#50C878"] #9
	
	IndexFor = len(value.keys())
	ListDictionary = []
	TempValue = value
	
	if IndexFor <= 10:
		for i in range(IndexFor):
			SubDictionary = {}
			SubDictionary["Color"] = ColorHEX[i]
			Temp = str(i+1)
			SubDictionary["nr"] = "Inv. " + Temp
			Temp = "Power_Inverter_" + str(i+1)
			SubDictionary["value"] = round(value[Temp], 2)
			ListDictionary.append(SubDictionary)
			
		dictionaries={"ActivePower": ListDictionary}
	
	return dictionaries

```

---

<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, 2:32pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/4 "2022-10-24T14:32:35Z")

</div>

Where does the value come from ?

---

<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:** [October 24, 2022, 2:35pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/5 "2022-10-24T14:35:48Z")

</div>

How are you using `system.perspective.navigate()` (i.e. are you navigating to a Page, URL, or View)

---

<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:** [October 24, 2022, 2:36pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/6 "2022-10-24T14:36:44Z")

</div>

I think binding update problems with XY Chart have been fixed in 8.1.22.  
See the changelog.

**[4429](https://forum.inductiveautomation.com/t/nightly-8-1-changelogs-2022/54636/148): XY Chart Expression Tag History binding with dynamic path causes Component Error**  
Fixed an issue with the XY Chart where the chart would not load when using a dynamic expression tag history bindings and switching views.

This had been a big puzzle for me and as a workaround I was refreshing the page on load. The upgrade fixed it.

---

<div class="post-metadata">

**Author:** ![Michal\_Goralczyk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michal_goralczyk/32/55564_2.png) [@Michal\_Goralczyk](https://forum.inductiveautomation.com/u/Michal_Goralczyk)\
**Post date:** [October 24, 2022, 2:36pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/7 "2022-10-24T14:36:50Z")

</div>

It's simply the readout of device values from the tag provider.  
Everything works fine but if I use navigate window script does not start. If I use refresh script it executes correctly.

---

<div class="post-metadata">

**Author:** ![Michal\_Goralczyk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michal_goralczyk/32/55564_2.png) [@Michal\_Goralczyk](https://forum.inductiveautomation.com/u/Michal_Goralczyk)\
**Post date:** [October 24, 2022, 2:38pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/8 "2022-10-24T14:38:22Z")

</div>

> [@Transistor](#):
>
> I think binding update problems with XY Chart have been fixed in 8.1.22.  
> See the changelog.
> 
> **[4429](https://forum.inductiveautomation.com/t/nightly-8-1-changelogs-2022/54636/148): XY Chart Expression Tag History binding with dynamic path causes Component Error**  
> Fixed an issue with the XY Chart where the chart would not load when using a dynamic expression tag history bindings and switching views.
> 
> This had been a big puzzle for me. The upgrade fixed it.

So you recomend upgrade?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2daac846d1a8e45f8fe6dac5501c25454a09218e.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, 2:41pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/9 "2022-10-24T14:41:23Z")

</div>

Well that script is not complete and might run into a runtime error: it returns `dictionnaries` which is declared in an if statement. If the if is not entered, `dictionnaries` will not exist and can't be returned.

What should happen if `IndexFor` is above 10 ?

---

<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:** [October 24, 2022, 2:43pm UTC](https://forum.inductiveautomation.com/t/problem-with-xy-chart-and-script-transform/65599/10 "2022-10-24T14:43:30Z")

</div>

> [@Michal\_Goralczyk](#):
>
> So you recomend upgrade?

Try it on a test server / PC and see if it solves the problem.
