# More graph types -- spc charts

**URL:** <https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94>\
**Category:** Archived Topics\
**Created:** [August 17, 2006, 11:04pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94 "2006-08-17T23:04:07Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![David](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@David](https://forum.inductiveautomation.com/u/David)\
**Post date:** [August 17, 2006, 11:04pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/1 "2006-08-17T23:04:07Z")

</div>

Hi gang:

Any chance of getting some spc charts in factory pmi. Histograms, Pareto charts, x-bar and range charts, individuals and moving averages, ewma, cusum, etc.?

Regards, D. Lewis

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [August 18, 2006, 3:50pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/2 "2006-08-18T15:50:20Z")

</div>

Yes, a statistical package has been in our sights for a while now. This will probably be in the form of a plugin for FactoryPMI that provides many statistical chart types.

Our development schedule is full for a while, so I’d look for something like this around the first quarter of 2007.

Note that some of these charts can be approximated or achieved using the existing charts. For example, a histogram is simply a bar chart that shows frequencies of items. Something like a “SELECT COUNT(\*) FROM MyTable GROUP BY MyCategory” query would work well for this.

Also, you can implement any arbitrary statistical calculations you’d like in Jython, and then push your derived statistical dataset into a chart. Not the easiest of tasks, but it is possible.

---

<div class="post-metadata">

**Author:** ![David](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@David](https://forum.inductiveautomation.com/u/David)\
**Post date:** [February 7, 2008, 6:50pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/3 "2008-02-07T18:50:28Z")

</div>

Hi Carl:

Quick question (I hope): I have a data set I’m going to plot as an histogram, and I would like to superimpose on that a cumulative line. So, imagine a chart with 12 bars, then a line on top of that whose first data point = 16%, 2nd= 16% + 14% (30%), 3rd = 16% + 14% + 13% (43%), etc. The final datapoint for the line = 100%. You’ve likely seen them.

How do I go about generating a line like that? Should I hop through all the hoops on the db side to calculate all the values for the line and return two distinct datasets? or can factorypmi help me out.

Thx a bunch. David

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 7, 2008, 7:11pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/4 "2008-02-07T19:11:00Z")

</div>

David,

Yes, you’re describing a Pareto chart, it seems. You can either: write a stored procedure in the database to give you these lines,

OR

Write a jython script that takes calculates this for you. Here is the general approach for the latter:

We’re going to be using the classic chart for this so that we can manipulate the data directly. We’ll have a classic chart with two datasets on it (one called “Data”, and add another one called “Cumulative”). Bind the “Data” dataset to a SQL query that brings in our raw data - first column is the X value, second column is the Y value.

Now, we add a script on the chart’s propertyChange event to generate the cumulative line for the second dataset. Here is such a script:

[code]if event.propertyName == ‘Data’:  
data = fpmi.db.toPyDataSet(event.newValue)  
headers = [“x”,“Cumulative”]

```
# First, calculate the total
total = 0
for row in data:
	total += row[1]

# Now, generate the new dataset
rows = []
pct = 0
for row in data:
	if total > 0:
		pct += (row[1]/total)*100
	rows.append([row[0], pct])

event.source.Cumulative = fpmi.db.toDataSet(headers,rows)[/code]

```

Now just map the Cumulative dataset to its own (0-100) axis, and set the Data dataset’s renderer to a “Bar Renderer”, and you should be all set.

Hope this helps,

---

<div class="post-metadata">

**Author:** ![David](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@David](https://forum.inductiveautomation.com/u/David)\
**Post date:** [February 7, 2008, 7:13pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/5 "2008-02-07T19:13:36Z")

</div>

Cool. The python route is the way to go. Thanks!

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 7, 2008, 7:37pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/6 "2008-02-07T19:37:54Z")

</div>

Thats for sure - I’d much rather code something in beautiful Python than nasty Transact-SQL!

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [March 4, 2010, 6:41pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/7 "2010-03-04T18:41:13Z")

</div>

FYI, the Easy Chart in Ignition supports automatic calculation of some statistical pens, such as:

Average, Moving average, LCL, LWL, UWL, and UCL.

---

<div class="post-metadata">

**Author:** ![TCATech](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@TCATech](https://forum.inductiveautomation.com/u/TCATech)\
**Post date:** [April 5, 2012, 3:38pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/8 "2012-04-05T15:38:03Z")

</div>

I sucessfully implemented the pareto chart using a Classic Chart in Ignition 7.3.1. One data set plots as bars, another data set plots as a line. However, I can’t get the line to draw in front of the bars. It always draws behind the bars, no matter what I do, so the bars hide the line.

Is there any way to change the draw order of different data sets?

---

<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:** [April 5, 2012, 4:13pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/9 "2012-04-05T16:13:27Z")

</div>

Yes, it is the order of the custom (dynamic properties). So if you have two datasets the second one will be on top of the first one. So make your line chart data be on the second dataset.

---

<div class="post-metadata">

**Author:** ![TCATech](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@TCATech](https://forum.inductiveautomation.com/u/TCATech)\
**Post date:** [April 6, 2012, 12:00am UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/10 "2012-04-06T00:00:15Z")

</div>

So here are my datasets. The first is plotted as bars:

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

The second is plotted as lines:

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

And this is what I get:

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/862a43ad37cb691509a85124fc79cdca4c30e230.png)

In this example the data from the first dataset is plotted over the second dataset.

---

<div class="post-metadata">

**Author:** ![TCATech](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@TCATech](https://forum.inductiveautomation.com/u/TCATech)\
**Post date:** [April 6, 2012, 12:05am UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/11 "2012-04-06T00:05:39Z")

</div>

Success!

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/999fc11f2fbb7b3a46d33b29ad4e619887009a15.png)

I made the line chart to be the first dataset (by renaming the datasets) and it all turned out beautifully. Thanks!

---

<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:** [April 6, 2012, 12:07am UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/12 "2012-04-06T00:07:13Z")

</div>

What if you swap the two datasets? Does that work?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [April 6, 2012, 12:17am UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/13 "2012-04-06T00:17:08Z")

</div>

Just swap your dataset names. The line renderer should be first, bar renderer second.

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [July 24, 2014, 7:03pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/14 "2014-07-24T19:03:29Z")

</div>

I am very close to having this working but my line chart is vertical all in one column, i thought i checked every setting but clearly I’m missing one.

Any recommendations?

Thx

---

<div class="post-metadata">

**Author:** ![tailfire](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@tailfire](https://forum.inductiveautomation.com/u/tailfire)\
**Post date:** [July 24, 2014, 8:07pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/15 "2014-07-24T20:07:36Z")

</div>

Built in components. Not a $2000 chart.

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [October 25, 2016, 6:07pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/16 "2016-10-25T18:07:29Z")

</div>

[quote=“drewdin”]I am very close to having this working but my line chart is vertical all in one column, i thought i checked every setting but clearly I’m missing one.

Any recommendations?

Thx[/quote]

On the chart Change the Extract Order from Col to Row 😉

---

<div class="post-metadata">

**Author:** ![patrick.kelly1](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@patrick.kelly1](https://forum.inductiveautomation.com/u/patrick.kelly1)\
**Post date:** [January 10, 2018, 4:00pm UTC](https://forum.inductiveautomation.com/t/more-graph-types-spc-charts/94/17 "2018-01-10T16:00:51Z")

</div>

This worked great! Just found one issue because of two integers the pct was not calculating.

Original code:  
pct += (row[1]/total)\*100

Corrected Code:  
pct += (float(row[1])/total)\*100

And make sure your chart is set to ‘Category Type’

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/d783424551e177f116625c56086b98795012768e.png)
