# Refreshing Classic Chart

**URL:** <https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421>\
**Category:** Ignition\
**Created:** [March 19, 2018, 7:46pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421 "2018-03-19T19:46:48Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian.kehn](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@brian.kehn](https://forum.inductiveautomation.com/u/brian.kehn)\
**Post date:** [March 19, 2018, 7:46pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/1 "2018-03-19T19:46:48Z")

</div>

How do we refresh the classic chart? I need to re-execute the “configureChart” extension function, or delay the first time that script is run.

---

<div class="post-metadata">

**Author:** ![brian.kehn](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@brian.kehn](https://forum.inductiveautomation.com/u/brian.kehn)\
**Post date:** [March 19, 2018, 7:51pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/2 "2018-03-19T19:51:02Z")

</div>

Also, the chart’s dataset is not bound to a db query so “system.db.refresh()” doesn’t work.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 19, 2018, 10:34pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/3 "2018-03-19T22:34:03Z")

</div>

Play around with the various appearance properties – those trigger regeneration of the JFreeChart IIRC.

---

<div class="post-metadata">

**Author:** ![mrogers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mrogers/32/4110_2.png) [@mrogers](https://forum.inductiveautomation.com/u/mrogers)\
**Post date:** [March 19, 2018, 10:53pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/4 "2018-03-19T22:53:53Z")

</div>

I can’t find it here but I could have sworn I read somewhere that sometimes (usually?) that system.db.refresh will work whether or not its a SQL query so it might be worth a shot anyway if you haven’t already.

---

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [March 19, 2018, 11:16pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/5 "2018-03-19T23:16:54Z")

</div>

I have a classic chart that I’m building 3 different data sets for through scripting. To force the chart to redraw after a dataset update, I do the following:

```auto
	chart = event.source.parent.getComponent("Chart")
	chart.setDatasetEnabled("Flags", False)
	chart.setDatasetEnabled("Flags", True)

```

“Flags” is the name of one of the data sets inside the chart. It doesn’t seem to matter which data set you toggle, it redraws them all.

---

<div class="post-metadata">

**Author:** ![brian.kehn](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@brian.kehn](https://forum.inductiveautomation.com/u/brian.kehn)\
**Post date:** [March 20, 2018, 10:36pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/6 "2018-03-20T22:36:02Z")

</div>

Thanks for your input guys. I was able to refresh my chart configuration, specifically the Y Axis range, after my custom properties updated by running this script in another custom method on the root container.

```auto
	#Update Y Axis
	Chart = self.getComponent('Chart')
	axes = Chart.getYAxes()
	axis = axes.get('Default Y Axis')
	maxRange = max(self.max,self.setpointHigh)
	minRange = min(self.min,self.setpointLow)
	range = maxRange - minRange
	axis.setLowerBound(minRange - 0.1*range)
	axis.setUpperBound(maxRange + 0.1*range)
	Chart.setYAxes(axes)
	
	#Refresh Chart
	Chart.createChart()
	print "Chart has been updated after Std Dev value changed

```

This getter and setter for the Chart object was in my Chart’s “configureChart” extension function and because I’m not very familiar with python/object oriented programming I didn’t think I could just paste that code into another script. But you can, and that’s what I did. Works great. I also tried the script that Brian proposed above:

```auto
	chart = self.getComponent('Chart')
	chart.setDatasetEnabled("Data", False)
	chart.setDatasetEnabled("Data", True)

```

But for some reason that only reset my Y-axis about 50% of the time.  
Thanks again!

---

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [March 20, 2018, 10:49pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/7 "2018-03-20T22:49:56Z")

</div>

Interesting! My Y-axis (several) were never changing, only the pens and X-axis, so I guess I never would have noticed that bug.

Thanks for posting the solution! I don’t remember seeing a createChart() reference in the docs. I’ll keep it in mind if my charts start acting squirrely .

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 21, 2018, 2:42pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/8 "2018-03-21T14:42:50Z")

</div>

> [@mrogers](#):
>
> I can't find it here but I could have sworn I read somewhere that sometimes (usually?) that system.db.refresh will work whether or not its a SQL query so it might be worth a shot anyway if you haven't already.

For posterity: `System.db.refresh()` will cause _any_ binding to re-run, not just database bindings (as the path to the function would imply)

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [November 12, 2019, 10:03pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/9 "2019-11-12T22:03:45Z")

</div>

Where do you get documentation on all these chart methods? I am trying to find out if i can individually show/hide series plots inside a dataset, instead of showing / hiding the entire dataset.

And i’m sure there would be many other customization i’d like to do if i knew what was possible…  
Ignition documentation just takes you in circles describing the obvious GUI elements and their configuration. Something super helpful like your ‘setDatasetEnabled()’ was only found here on the forums.  
Thanks

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 12, 2019, 10:33pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/10 "2019-11-12T22:33:38Z")

</div>

[http://www.jfree.org/jfreechart/api/javadoc/](http://www.jfree.org/jfreechart/api/javadoc/)

The classic chart is an instance of [ChartPanel](http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/ChartPanel.html). The EasyChart contains an instance of ChartPanel surrounded by pen control and time control gingerbread.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 12, 2019, 10:37pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/11 "2019-11-12T22:37:17Z")

</div>

This old thread may help you, too:

> [@Finding all available methods from a component](http://forum.inductiveautomation.com/t/finding-all-available-methods-from-a-component/9670):
>
> Hello, I was wondering if there is a way to fetch all methods available from a component. In this topic, I can see a setVerticalScrollBarPolicy() function but I have absolutely no idea about where it ccomes from. [Subject: Check for vertical scroll bar](https://www.inductiveautomation.com:443/forum/viewtopic.php?p=48364#p48364) I’ve looked a little further and with the following code, i managed to get some of a component methods, but obviously not all as I can not find the setVerticalScrollBarPolicy() function in the returned array. powerTable = event.source.parent.ge…

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [November 12, 2019, 11:07pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/12 "2019-11-12T23:07:13Z")

</div>

Thanks Phil, can’t seem to find any reference to the “setDatasetEnabled” method there, i have been spending some time looking through the JFreeChart documentation but it is a bit overwhelming. Is the classic chart also a JFreeChart ChartPanel component? I am assuming it is?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 13, 2019, 1:57am UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/14 "2019-11-13T01:57:12Z")

</div>

So the [Classic Chart](http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/com/inductiveautomation/factorypmi/application/components/PMIChart.html) is a subclass of the JFreeChart’s ChartPanel (note the hierarchy). It adds methods and fields specific to Ignition data management, like [setDatasetEnabled()](http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/com/inductiveautomation/factorypmi/application/components/PMIChart.html#setDatasetEnabled-java.lang.String-boolean-).

The topic I linked will help you get started finding what Ignition-supplied classes and properties are involved in any particular case, and the JavaDocs will fill in the blanks (mostly).

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [November 14, 2019, 7:41pm UTC](https://forum.inductiveautomation.com/t/refreshing-classic-chart/17421/15 "2019-11-14T19:41:09Z")

</div>

Thanks a lot for the explanation Phil, Java still feels like a foreign language to me. I will have to work on a bit of upskilling in that area i think!  
And i did find what i wanted in that second link thank you:

```auto
public void setSeriesEnabled(java.lang.String dataSetName,
                             java.lang.String seriesName,
                             boolean vis)

```
