How we setup color formatting in particular column's value in table

we need to setup color formatting in particular 1 columns value like if columnname<35% - red,columnname>35% and columnname<60% -yellow and columnname>60%-green

What do you want to color, the whole row or just a particular cell ?
What's the data format/source ? You'll need to format the whole thing to json I believe.

Taking the example table (except changing Folsom's format to have consistent formatting) and making its rows red/green depending on population:

color = lambda row: "red" if row['population'] > 1000000 else "green"
return [
	{
		k: {
			'value': v,
			'style': {'background-color': color(row)}
		} for k, v in row.iteritems()
	} for row in value
]

If you're pulling data from a query, you can just change its return format to json then add this script as a transform. And obviously change the color lambda to match your conditions and colors.

Note: I pulled the color selection logic out to make it easier to separate the logic that builds the data structure and the one that selects a color, but it would probably be a good idea to inline it once you understand how it works:

return [
	{
		k: {
			'value': v,
			'style': {'background-color': "red" if row['population'] > 1000000 else "green"}
		} for k, v in row.iteritems()
	} for row in value
]
1 Like

the whole row for particular column value and from where we need to add this script under which section and script is in python.

In the data binding, add a script transform. That's where you can script things.

can you give proper script ?

There are examples in the documentation.

Perspective - Table - Ignition User Manual 8.1 - Ignition Documentation.

Work through those, testing them in Designer so that you understand them fully before attempting to write your own. Then come back here if you can't get Pascal's code to work.

What do you mean, proper script ? You find the ones above "improper" ?

1 Like

ok

I have done with the scripting.

Good.
Don't forget to mark one of the answers as "Solution".