# Perspective XY Chart onClick Scripting

**URL:** <https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240>\
**Category:** Ignition Early Access\
**Tags:** ignition80\
**Created:** [February 13, 2020, 7:06pm UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240 "2020-02-13T19:06:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phil\_B](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@Phil\_B](https://forum.inductiveautomation.com/u/Phil_B)\
**Post date:** [February 13, 2020, 7:06pm UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/1 "2020-02-13T19:06:51Z")

</div>

Hello all. I am trying to write a script on an XY chart in perspective to display text in the label underneath it based on the bar and/or section of the bar clicked on.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c3652f92bfd93d25789259872fe3bd3bc747ad58.png)

I tried linking to the tooltip text as seen in the picture but that just gave me the tooltip formatting. What i am wondering is if the string formatting variables ({valueY},{CatergoryX} etc.) are reachable in the onClick event? “self” is a passed in parameter but i am not sure how to get to those values. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![pascal](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pascal](https://forum.inductiveautomation.com/u/pascal)\
**Post date:** [June 8, 2020, 8:09am UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/2 "2020-06-08T08:09:08Z")

</div>

Hey Phil\_B, did you manage to do what you wanted ?  
I’d be interested in such a functionality.

---

<div class="post-metadata">

**Author:** ![Phil\_B](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@Phil\_B](https://forum.inductiveautomation.com/u/Phil_B)\
**Post date:** [June 8, 2020, 1:09pm UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/3 "2020-06-08T13:09:16Z")

</div>

No i havent but i pivoted away from that for the time being. i will try again someday though

---

<div class="post-metadata">

**Author:** ![pascal](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pascal](https://forum.inductiveautomation.com/u/pascal)\
**Post date:** [June 8, 2020, 1:13pm UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/4 "2020-06-08T13:13:24Z")

</div>

OK thanks, it’s driving my crazy but I hope to find a solution soon enough.

---

<div class="post-metadata">

**Author:** ![Phil\_B](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@Phil\_B](https://forum.inductiveautomation.com/u/Phil_B)\
**Post date:** [June 8, 2020, 1:34pm UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/5 "2020-06-08T13:34:30Z")

</div>

One thought we had but didnt get a chance to try is to make a flex repeater under the chart and when we populate the chart data also make instances of a view in the flex repeater that are buttons which contain custom properties of the data for the bar on the chart right above it. and then on click you can do what ever you want.

---

<div class="post-metadata">

**Author:** ![pascal](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pascal](https://forum.inductiveautomation.com/u/pascal)\
**Post date:** [June 8, 2020, 1:36pm UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/6 "2020-06-08T13:36:22Z")

</div>

That could be a lead.  
I’m trying to replicate this functionality :  
[https://www.amcharts.com/docs/v4/tutorials/zoom-to-month-by-clicking-on-a-dateaxis-label/](https://www.amcharts.com/docs/v4/tutorials/zoom-to-month-by-clicking-on-a-dateaxis-label/)

---

<div class="post-metadata">

**Author:** ![Phil\_B](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@Phil\_B](https://forum.inductiveautomation.com/u/Phil_B)\
**Post date:** [June 8, 2020, 1:41pm UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/7 "2020-06-08T13:41:59Z")

</div>

when i was last looking into this (which was a while ago) i was finding something called “Listeners” in the amCharts which is what would be used to fire an event and from what i could see, that functionality wasnt in yet.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [June 8, 2020, 2:32pm UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/8 "2020-06-08T14:32:32Z")

</div>

Yeah at the moment there isnt any “onActionPerformed” events on the XY Chart, Pie Chart, and a few others that could definitely use it for exactly what you guys have talked about here.

I made an ideas post about it a while back that you could update if you want  
[https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/xy-chart-and-pie-chart-onactionperformed](https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/xy-chart-and-pie-chart-onactionperformed)

---

<div class="post-metadata">

**Author:** ![renzoc](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@renzoc](https://forum.inductiveautomation.com/u/renzoc)\
**Post date:** [May 5, 2021, 1:21am UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/9 "2021-05-05T01:21:06Z")

</div>

Hi @Phil_B , any luck on this?

---

<div class="post-metadata">

**Author:** ![Toobor](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@Toobor](https://forum.inductiveautomation.com/u/Toobor)\
**Post date:** [May 5, 2021, 6:00am UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/10 "2021-05-05T06:00:34Z")

</div>

I manage to get this functionality. Like Phil\_B suggested I used a flex repeater that are buttons which contain custom properties of the data for the bar on the chart right above it.

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

---

<div class="post-metadata">

**Author:** ![Phil\_B](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@Phil\_B](https://forum.inductiveautomation.com/u/Phil_B)\
**Post date:** [May 5, 2021, 1:35pm UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/11 "2021-05-05T13:35:34Z")

</div>

I havent revisited this lately. sorry

---

<div class="post-metadata">

**Author:** ![michal.such](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@michal.such](https://forum.inductiveautomation.com/u/michal.such)\
**Post date:** [September 14, 2021, 11:12am UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/12 "2021-09-14T11:12:39Z")

</div>

Hi all.  
Maybe my solution will help you.  
Based on the selected bar I open a popup and pass selected data as a parameter to the popup.

1. Enable selection on XY chart.

 ![pic 1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cfed8b3ac3762ce6a78a1e2a6a380ce8d08089e8.png)

1. Click on a bar to get the data

 ![pic 3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/b/6bfdda033d59e2def97060fe256be1b675606c1e.png)

1. Using OnClick even for XY Chart access the data. ( it is important to use Try - Except, otherwise Ignition crashes)

 ![pic 2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/a/1ab884c200bc8e81bec48ec5f2c3214c62fd095c.png)

Hope this helps

---

<div class="post-metadata">

**Author:** ![roland.scheuer](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@roland.scheuer](https://forum.inductiveautomation.com/u/roland.scheuer)\
**Post date:** [September 29, 2021, 7:01am UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/13 "2021-09-29T07:01:25Z")

</div>

@michal.such what is the Ignition version you are using? I tried same with 8.1.7 but i dont have the selection property. So i guess its only available in newer versions.

EDIT: nvm. i see its available with 8.1.10

---

<div class="post-metadata">

**Author:** ![michal.such](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@michal.such](https://forum.inductiveautomation.com/u/michal.such)\
**Post date:** [September 29, 2021, 8:05am UTC](https://forum.inductiveautomation.com/t/perspective-xy-chart-onclick-scripting/32240/14 "2021-09-29T08:05:55Z")

</div>

@roland.scheuer you are right, the selection property was released in 8.1.10 and that is the version I am running.
