Power Table Column Size

I have a power table with 480 columns and 1 row with 0s and 1s as a status.

I add script on the power table under Extension Funcions > configureCell, to change the background and foreground color base on the status 0 or 1.

I set the font size to 1 since I am not interest on the value but the color it is displaying. Also uncheck all the behavior checkbox from the power table (Column resize menu, Column resizable, etc…)

this part is working, but when I try to resize the columns, it looks like the column will not resize smaller than ~10 px, and base on my screen size the columns will be around 2-3 px.

I try on the Extension Funcions > initialize, to resize the columns but it will not go into a 2-3px

	from javax.swing.border import BevelBorder
	from javax.swing import BorderFactory
	from javax.swing import JTable
	from java.awt import Dimension
	
	# remove outside border
	self.putClientProperty("BevelBorder", BevelBorder)
	self.putClientProperty("BorderFactory", BorderFactory)
	
	self.border = None
	self.viewport.background = system.gui.color(67,60,69)
	
	# ajust the rows height base on the component height
	tableHeight = self.getHeight()
	self.setRowHeight(tableHeight)
	# set column width
	for x in range(480):
		self.setColumnWidth(x,2)

So is there a hidden padding, or do I need to applied this somewhere else? or is there a key combination on what is true in the behavior options on the power table?

any guidance will help, thanks

It sounds like you’ll have an easier time using the paintable canvas to get the rendering you want, honestly.

1 Like

Yeah, it’s actually pretty easy with a paintable canvas given the stated conditions.
I put a 480 column dataset full of random booleans onto the component, then used this script to draw it:

from java.awt import Color

g = event.graphics
ds = event.source.data
dX = (event.width-1)/ds.columnCount
dY = event.height
g.scale(dX,dY)

for column in xrange(ds.columnCount):
	val = ds.getValueAt(0, column)
	g.setColor(Color.GREEN if val else Color.RED)
	g.fillRect(column, 0, 1, 1)

I wired it up to a power table to quickly make changes:

Kapture 2022-06-14 at 14.28.27

paintable canvas.zip (17.0 KB)

2 Likes

Hello PGriffith,
This is a complete different way of doing this and I really like it, thanks for the example. I already implemented and it is working great.

thanks again.