Reporting Module Dynamic Key for Font Color

In the new reporting module how do you use a dynamic key to change the font color?

I have tried making a key in my dataset with string of just the number. e.g. 0,255,255,255

I have also tried making a key with the expression color function color(0,255,255,255) with no luck

I have easily used dynamic keys when they are just regular data types like integers, but i am not sure how to get a data type of a color and the color will be user selectable so i cannot just make labels visible/invisible based on a boolean.

Here’s one way to do it:

I made a parameter of type string (sorry, I know that’s not intuitive), with a default value of toColor("0,255,255")

Then in my design tab, I selected the item I wanted to have a dynamic color. In the property inspector, I right-clicked on ‘fill color’ and chose ‘use dynamic data key’. Then I dragged my parameter onto the word ‘data_key’ that replaced the previous color that had been there.

To let users select a color, override this parameter with a new one, using the toColor("x,y,z") format.

1 Like

i have changed it to toColor and I also added the double quotes around the numbers, but it is still not working.

I am not using a parameter i am trying to use a key from a data source. I only want the color of the font to change on certain rows of the table.

my data source looks something like this

Label FontColor
Tag1 toColor(“0,0,0,255”)
Tag2 toColor(“0,0,0,255”)
Tag3 toColor(“102,255,102,255”)

then in my table I have the Text bound to the Label key of the datasource and the Text Color bound to the FontColor key from the datasource

I suspect that if you want the color to change only for certain rows, you will need to use row versioning. If you’re not familiar with it, the IU video may help.

Row Versioning will not solve my problem because i am trying to us a color stored in the database. For row versioning to work i would have to create a version of row for ever possible color that could be stored in the database.

i setup a little test in my table. you can see in the picture on the left side i am displaying the key from the datasource. On the right side i am displaying the parameter that i have the toColor function as a string. it looks like for some reason the report is converting the parameter to a java color and the string that is in my datasource is being left as a string.

[attachment=0]row text color.png[/attachment]

String parameters are evaluated as expressions first, and if the expression fails, then as a string. Datasources are not evaluated as expressions.

I am using parameter(“textColor”) to dynamically change the ‘Text Color’ on report.
I added parameter with default value as mentioned above and dragged that parameter to ‘Text Color’. I can see color changed to green in Preview tab. But I can’t find a way to change the color dynamically on Report Viewer.

I tried following things on “textColor” parameter of the report viewer:

  1. Added expression toColor("255,0,0") But color changed to black from default green color. Though it returned “#FF0000” in property editor.

  2. Created a string tag and bound it to “textColor” parameter. Changed values of the tag to “255,0,0” (it returned “#FF0000”) and then toColor(“255,0,0”). In both cases color changed to black instead of red.

  3. Added expression "toColor({tagPath}) It also returned hex value but got same result.

Where could I be going wrong?
Thanks.

I was able to do this through a little indirection.

In the report, I made two parameters. One I called “ColorString”, with a default value of “255,0,0”. The other I called “TextColor”, with a default value of “toColor({ColorString})” (except no quotes). The TextColor tag was bound to my text color in the report, and shows as red in the preview tab.

In a Vision window, I dropped a report viewer component. I made a string memory tag with a value of “0,255,0”, and dropped it onto the ColorString parameter, overriding the default value. In my report viewer, the text shows as green.

Yes. That is indeed the right way.

Thanks a lot!

Sorry for bringing an old thread but I kind of can’t get that working.

I have the following situation - I got a report in 7.9.6 where I have a table that is being fed from a report script.

I am trying to get a table’s cell to turn red if the value in it is > 0. So I select the cell in “Design” tab and then go to “Fill color” and select “Use dynamic data key” and finally select the parameter which I will be using as my key.

I got 2 x parameters as above. One called “accidentColor” of type string and it has a value:

“255,255,255”
Then have another parameter called “accidentFlag” of type string with the following expression:

toColor({accidentColor})

Up to this point is all good. But I can’t make my script to do anything. It seems to compile okay but it won’t turn the cell red.

if accidentSum > 0:
data[‘accidentColor’] = “255,0,0”

“”“I can’t the indentation correct in here but it is properly indented”""""

I have created some new text boxes and assigned in the Design tab and binded both my parameters to them and this is what I get:

image

So it seems that the If statement is executed, the value “255,0,0” is transferred to accidentColor but somehow it is not used in accidentFlag . As the bottom line is still showing the default color.

I made sure that the positions of the 2 parameters is appropriate but I think the order of execution of the parameters and the script is somehow messing it up for me.

image

Any help is appreciated!