Dynamic table background colour mapping

Is there any way of linking the numeric value in a table’s background colour mapping to the value of another object? We would like the user to be able to set the value dynamically (maybe via a numeric text field) above which the rows are highlighted, rather than hard-coding it at design time.

Great question - spot on as usual! I’m beginning to suspect that you’re an undercover IA employee running a secret squirrel QA branch.

The single most significant feature of 2.2.0 is called styles. It’s an elegant feature that I have to give our programmers kudos for. It can be used as a more powerful generalization of color binding. You define a driving property (like the number in the number->color mapper). You then define states that control object properties. You can even define multiple animation states with times for given values of the driving property. My description here is more complicated than the feature - it’s simple to use and ridiculously powerful. The only notable things that you can’t control with styles are component size/position, which can be controlled now with Jython gui functions.

Now, to answer your question about controlling mapped color properties externally. You can’t bind color states to objects directly - but I think you can do better. Styles are stored as an expert property dataset on all components. You can bind that property to an SQL query that populates the style from the database. This allows you to do things like centrally manage things like warning or alarm states for all objects configured that way. You can change colors, text labels, blink rates, etc. You could also keep track of different settings for different users or groups of users in the database. That allows you to make these properties user configurable. So the “other object” isn’t controlling your settings, but all objects may be based on the same (potentially user configurable) settings.


I’m beginning to suspect you never sleep!!

Try as I might, I can’t find any styles property for a table. In case I’ve not explained things well enough, I’ll go over again what we are trying to achieve.

We have a table which colours some of the rows depending on whether one of the row values is above a limit. Rather than hard-code this limit at design time, we want to allow the user to enter the limit into a numeric text field.

For example, the table may display a log of hourly temperature readings. The default condition may be to highlight rows in red where the temperature is above 40°C. By typing 50 into a numeric text field, the table will change to highlight all rows with a temperature of above 50°C.

I have looked at the new styles feature and can see how powerful it will be. One thing concerns me slightly in storing information in a table in the SQL database - the more tables you have in a flat structure, the harder it can be to maintain the system. Do you know of any way of displaying the tables in a database in a hierarchical fashion? I use MySQL and therefore Query Browser, but I can’t see anything to help with this.

Wow - you threw some heat on that one. I’ll offer the insight that I can then someone else will do it better.

  1. You won’t be able to make the table background color mapping dynamic without a feature request or serious Jythonin’. You can make your query dynamically change data colors within the table using HTML. You could do cell level background colors, but not entire rows.
    You may need to use Jython or a SUB SELECT in your query to modify this example to your dynamic setpoint.

  2. Hierarchical structure can be equivalently stored in a relational database format. here’s MySQL info. A different useful approach is to add columns as dimensions, which isn’t really creating a true tree structure. This works well for a defined number of levels. We typically represent this in an HMI with multiple connected tables and a “drill down” approach. You might select: site, section, equipment, downtime event as a 4 level “hierarchy”. I would display this with your database frontend using grouping in your queries. I’m not sure of a SQL frontend with a GUI representation of this. Getting back to a true hierarchy, we’ve deferred this for now. We’ll have to come up with some sort of data structure that works well across SQL database types and come up with a good supporting tree component - stay tuned.

  3. I should have considered your question more closely. You cannot modify the table’s background color mapping externally, except with Jython. The “customizer” used to strictly be a custom interface for properties that both weren’t flat and that we couldn’t generalize. The data populating the component was always flexible, but configuration was static - or dynamic in a pre-canned way. Styles only help with components standard properties. The table is an “old” complex (requires customizer) component, like the Chart. We’ve since shifted to storing multi-dimensional settings as dataSet(s) of the object. The customizer helps the user with a GUI that modifies those settings, but the dataSets can be dynamic based on the FPMI binding system. We might consider more flexible background colors as a table feature, but there are 16 other column properties that should also be more dynamic. The bottom line is that we’re overdue for more powerful table components written with the new paradigm - like the Easy Chart. More notable than flexible dynamic properties is the ability to accept input in a variety of ways - the table that can work like a db frontend with little configuration.

I’ve been trying to keep my responses shorter, but ended up throwing you an essay, tech talk, and some history. We can get more specific with solving your problem. I still think we can make it happen with existing tools.

There is an elegant way to do this, you just have to think about it a little differently. If your description is accurate, and you simply have two states (highlighted or not) based on a user-editable box, simply drive your Table with a query like this:

SELECT col1, col2, col3, CASE WHEN temp > {Root Container.tempSelector.value} THEN 1 ELSE 0 END AS "Highlight" FROM MyTable

The key here is that you’ve added a column whose value will be based on whether or not that row matches the highlight criteria or not. Now simply base your table’s background color mapping off that column, and hide the column from view. Ta-da: user-customized row highlighting.

Hope this helps,

Fantastic Carl, worked perfectly :smiley: Elegant indeed!