I got this working for anyone interested, using a spinner to change the bin size on the fly

[code]#Script to create a histogram

#This script looks at an array of data and counts how many cells are between specific numbers (called “bins”) to use for plotting a histogram on a bar chart.

#----Change these values according to your needs-----

#data = system.db.runQuery(“select t_weld from laserweld where station = 3 and substation = 0 and datetime > DateAdd(HOUR,-12,getdate())”) #load a dataset. Have the column of interest be labeled “Data”

dropDownValue = event.source.parent.getComponent(‘Dropdown’).selectedStringValue

start_date = event.source.parent.getComponent(‘Date Range’).startDate

end_date = event.source.parent.getComponent(‘Date Range’).endDate

input = system.db.runPrepQuery(“select %s as data from laserweld where station = 3 and substation = 0 and datetime between ? and ?” %dropDownValue, [start_date, end_date])

dat = system.dataset.toDataSet(input)

mx= 0.4 #the maximum value of the data

mn= 0.1 #the minimum value of the data

bins=event.source.intValue #should this be dynamic based on the row count? is 10 bins enough granularity? Change to adapt to your dataset!

#----histogram code-----

import math

rng=float(mx-mn) #the range of the dataset

binSize=float(rng/bins) #the size of the bins

mn1=mn-(2*binSize)#include some extra bins on the low end

bin_ar=[] #initalize the bin array

for x in range(bins+4): #Iterate through the bin array. include some bins on the high end.

bin_val=round(mn1+(x*binSize),1)

bin_ar.append([bin_val])

hd=[“Bins”]

bins_array= system.dataset.toDataSet(hd,bin_ar) #the complete array of the bins

resar=[]

for i in range(len(bin_ar)-1): #iterate through each bin.

cnt=0

for x in range(dat.rowCount): #iterate on each datapoint, for a specific bin, then count if it is in range.

val=dat.getValueAt(x,“Data”)

if val>= bins_array.getValueAt(i,“Bins”) and val< bins_array.getValueAt(i+1,“Bins”): #if the value is within between the current bin and the next bin, count it.

cnt+=1

if x==(dat.rowCount-1):

resar.append([str(bins_array.getValueAt(i,“Bins”)),cnt]) #append to an array with the count results for the specific bin

hd1=[“Bin”,“Count”]

histdata=system.dataset.toDataSet(hd1,resar) #the output dataset

event.source.parent.getComponent(‘Bar Chart’).data = histdata

[/code]