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:
-
Added expression toColor("255,0,0")
But color changed to black from default green color. Though it returned â#FF0000â in property editor.
-
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.
-
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:

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.

Any help is appreciated!