# SPC Control Capability chart in report

**URL:** <https://forum.inductiveautomation.com/t/spc-control-capability-chart-in-report/15180>\
**Category:** Ignition\
**Created:** [August 28, 2017, 2:48pm UTC](https://forum.inductiveautomation.com/t/spc-control-capability-chart-in-report/15180 "2017-08-28T14:48:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [August 28, 2017, 2:48pm UTC](https://forum.inductiveautomation.com/t/spc-control-capability-chart-in-report/15180/1 "2017-08-28T14:48:08Z")

</div>

I am using the SPC module to collect samples of this tag. I would like to make 2 graphs in the reporting module. The first would be like this script and I am looking to show upper set limits and lower set limits too.  
The second graph is a histogram, and I am looking for some code to display the count of samples that were in each bin where I can set the bin to be to the nearest degree and show the standard deviation bell curve too. How can I accomplish this?  
Thanks.

```auto
    definition = "SQLTag-Solder Pot Temperature"
	attribute = "DegreesF"
	filters = "Location=Luvata Waterbury\Wire In Channel\Solder\Solder Line 1,FromDate=2017-08-14 07:00:00 -0800,ToDate=2017-08-14 8:00:00 -0800"
	controlLimits = "Individual LCL,Individual UCL"
	signals = "Individual Outside"
	dataformat = "Individual"
	spcSettings = system.quality.spc.settings.createSettings(definition, attribute, filters, controlLimits, signals, dataformat)
	spcSettings.setOptionalParams('RowLimit=100') # limit the dataset while testing
		
	# get the analysis results
	spcResults = system.quality.spc.getSPCResults(spcSettings)
	# get the table data
	spcData = spcResults.getTableResults()
	
	# Create a new column that will hold any value that is out of range
	# cycle through the rows in the dataset and determine the new column values
	# if the value is outside the limits then it will have a value and can be plotted as a point
	# if it is not outside then we must set it to be Not A Number
	colCount=spcData.getColumnCount()
	columnName="isOutside"
	columnData=[]
	for row in range(spcData.getRowCount()):
		isOut = spcData.getValueAt(row, 'Individual Outside')
		#uclVal = spcData.getValueAt(row, 'Individual UCL') # this value will plot
		if isOut==True:
			measVal = spcData.getValueAt(row, 'Measurement 1') # this value will plot
			#uclVal = float('NaN') # this value will plot
			#system.quality.spc.controllimit.calcControlLimitValue
		else:
			measVal = float('NaN') # this value will not plot
			#uclVal = spcData.getValueAt(row, 'Individual UCL') # this value will plot
		columnData.append(measVal)
		#columnData.append(clVal)
		#uclVal = spcData.getValueAt(row, 'Individual UCL') # this value will plot
		#columnData.append(uclVal)
	# create a new dataset with the new column added
	newData = system.dataset.addColumn(spcData, colCount, columnData, columnName, float)
	data['myKey']=newData

```

---

<div class="post-metadata">

**Author:** ![PeteLow](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@PeteLow](https://forum.inductiveautomation.com/u/PeteLow)\
**Post date:** [September 7, 2017, 4:46pm UTC](https://forum.inductiveautomation.com/t/spc-control-capability-chart-in-report/15180/2 "2017-09-07T16:46:30Z")

</div>

Hi,  
You can get the dataset by using the Hisogram dataFormat, but, the report chart does not support the generation of a bell curve or creating the bars from the data as far as I know. The Histogram Chart component does that natively.

You can save off the chart image to a file and then place it on a report:  
comp = event.source.parent.getComponent(‘Histogram Chart’)  
system.print.printToImage(comp,“c:\Temp\img.png”)  
But, this may not be a good solution for automatic reports.

This is a feature for reporting that we need to do more investigating.

Pete Low  
Tech Support  
Sepasoft
