# Possible to Pick and Choose X/Y data for chart from dataset?

**URL:** <https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492>\
**Category:** Ignition\
**Created:** [May 17, 2012, 6:06pm UTC](https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492 "2012-05-17T18:06:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cswett](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@cswett](https://forum.inductiveautomation.com/u/cswett)\
**Post date:** [May 17, 2012, 6:06pm UTC](https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492/1 "2012-05-17T18:06:45Z")

</div>

Is it possible to pick and choose the x and y data sources for a chart from a dataset that is already retrieved without creating a new sql query or stored procedure that formats the returned data in the correct order to be displayed in a chart?

I have a stored procedure that returns a large dataset every few minutes, from which I want to make about 8 different charts from.

Thoughts?

Thanks,  
Casey

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/aeb12a316449460316521bd06dc095390c4341b2.PNG)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 17, 2012, 6:25pm UTC](https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492/2 "2012-05-17T18:25:12Z")

</div>

You can create datasets out of a single dataset in scripting. For example, do the following:

1. Add a custom property to the root container of the window called “origData” that is a dataset.

2. Bind it to the stored procedure you talked about that returns the large dataset.

3. When the property changes we can run code that can create new datasets. So add a propertyChange event to the root container like this:[code]if event.propertyName == “origData”:  
origData = system.dataset.toPyDataSet(event.newValue)  
newData1 = []  
newData2 = []  
newData3 = []

Enjoy!

---

<div class="post-metadata">

**Author:** ![cswett](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@cswett](https://forum.inductiveautomation.com/u/cswett)\
**Post date:** [May 17, 2012, 6:28pm UTC](https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492/3 "2012-05-17T18:28:25Z")

</div>

Awesome! That really helps!

Thanks

---

<div class="post-metadata">

**Author:** ![cswett](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@cswett](https://forum.inductiveautomation.com/u/cswett)\
**Post date:** [May 17, 2012, 7:56pm UTC](https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492/4 "2012-05-17T19:56:50Z")

</div>

Travis,

I have come up with an error when attempting to run the script. Any thoughts as to what I may have to change? Is it expecting an integer?

Thanks  
Casey Swett

* * *

Error executing script for event property change on component: Root Container

Traceback (most recent call last):

File “event:propertyChange”, line 12, in

TypeError: getComponent(): 1st arg can’t be coerced to int

## Ignition v7.4.2 (b953) Java: Sun Microsystems Inc. 1.6.0\_31

Line 12 being: event.source.parent.getComponent(“Chart 1”).Data = system.dataset.toDataSet([“Col Name 1”, “Col Name 2”, “Col Name 3”], newData1)

---

<div class="post-metadata">

**Author:** ![cswett](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@cswett](https://forum.inductiveautomation.com/u/cswett)\
**Post date:** [May 18, 2012, 1:42pm UTC](https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492/5 "2012-05-18T13:42:42Z")

</div>

I did some more experimenting last night “learning”. I tried adding another custom property to the Root Container of the window named newData1 which already has origData. I also tried adding the Charts such as Chart 1, Chart 2, Chart 3.

I still end up with the error:

File “event:propertyChange”, line 12, in

TypeError: getComponent(): 1st arg can’t be coerced to int

For example, All columns with numbers such as METRICID, GOAL, and PREYEAR are all doubles if that makes a difference.

I trying to get a better understanding of how the rows and columns from within the script.

Thanks  
Casey

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c720892f051ffb84e902089088bff8680a21bd2b.PNG)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/71b7aca5793679a9dd1f320e4ffd7b7f3c471590.PNG)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/ae20a36c8e95513ea796da2c56f02a453e0373fe.PNG)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3dce7bad76b4d53e5fd9ea2360bdc42c39bfd996.PNG)

---

<div class="post-metadata">

**Author:** ![Michael.Stofan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.stofan/32/3342_2.png) [@Michael.Stofan](https://forum.inductiveautomation.com/u/Michael.Stofan)\
**Post date:** [May 18, 2012, 6:22pm UTC](https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492/6 "2012-05-18T18:22:55Z")

</div>

Unless you’re in category mode, the Classic Chart requires the first column in that new data set to be a timestamp. I can’t see if your master dataset has any timestamps you can use but I’d start there.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 18, 2012, 6:38pm UTC](https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492/7 "2012-05-18T18:38:03Z")

</div>

Well, if your datasets exists on the root container called newData1, newData2, etc… you should have something like:`event.source.newData1 = system.dataset.toDataSet(....)`My code was trying to set datasets on the chart itself. It requires the name of your chart to be “Chart 1”.

---

<div class="post-metadata">

**Author:** ![cswett](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@cswett](https://forum.inductiveautomation.com/u/cswett)\
**Post date:** [May 18, 2012, 6:45pm UTC](https://forum.inductiveautomation.com/t/possible-to-pick-and-choose-x-y-data-for-chart-from-dataset/4492/8 "2012-05-18T18:45:55Z")

</div>

Alright, thanks for the help. I was able to get data into the datasets now, so I believe I can make it display in a chart now once I pick the correct columns.

Thanks  
Casey
