Progress bar IGNITION 8.1

Hello, I need to know how to add a progress bar in a power table in each cell of one column as animation or something changing color each percent, can anyone help me ?

This may work for you. Open the power table script and put this on configureCell.

if colIndex == 0:
		from javax.swing import JProgressBar
		from java.awt import Color
		minValue = 0.0
		maxValue = 100.0
		colora = Color.RED
		colorb = Color.GREEN
		reda = colora.getRed()
		greena = colora.getGreen()
		bluea = colora.getBlue()		
		redb = colorb.getRed()
		greenb = colorb.getGreen()
		blueb = colorb.getBlue()		
		ratio = float(value)/(maxValue+minValue) if float(maxValue+minValue) != 0.0 else 0.0
		def pcolormix(pa,pb):
			return int(pb*ratio+pa*(1.0-ratio))		
		mixcolor = Color(pcolormix(reda, redb), pcolormix(greena, greenb), pcolormix(bluea, blueb))
		jbar = JProgressBar(int(minValue), int(maxValue))
		return {"renderer": jbar}

this is how it looks


Hi, thanks, I tried that but nothing happened, I check the code that I wrote but I think everything is ok

You should modify the code based on the column Index you want to apply the render. Also modify the min and max that apply to you case.

Yes, I change de number that my column has also do I need to change the min and max in the next sentence before and after the else? : ratio = float(value)/maxValue+minValue if float(maxValue+minValue) != 0.0 else 0.0

In my example I did

minValue = 0.0
maxValue = 100.0

You should only change those

minValue = yourminvalue
maxValue = yourmaxvalue

put () between max and min addition, like:

ratio = float(value)/(maxValue+minValue) if float(maxValue+minValue) != 0.0 else 0.0

thanks, I did it, let me try changing the value

OK, but you just really need to copy the code, maybe fix de indent and adjust some variables. Everything should work. Do you see any errors?

Thanks, It worked, the problema was that my columnwas an String and should be INT

If that was a solution to the problem, please mark this post as solved.

Hi, if I want to change to other colors, can this work ?
I tried with other colors but don’t let me do it