 # More graph types -- spc charts

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

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.

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

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)

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

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

``````

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,

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

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

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

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

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?

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.

So here are my datasets. The first is plotted as bars: The second is plotted as lines: And this is what I get: In this example the data from the first dataset is plotted over the second dataset.

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

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

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

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

Built in components. Not a \$2000 chart.

[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 This worked great! Just found one issue because of two integers the pct was not calculating.

Original code:
pct += (row/total)*100

Corrected Code:
pct += (float(row)/total)*100

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