More graph types -- spc charts

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,