4

I have a question regarding highlighting severals values in (column of) a dataset. Here a simple example:

names = StringJoin["name", #] & /@ ToString /@ Range[9];

values = RandomInteger[100, 9];

and then

ds = Dataset[AssociationThread[{"name", "value"} -> #] & /@ ({names, 
 values}\[Transpose])]

Now we have something like:

enter image description here

I now can highlight values in the Dataset with:

    highLight1[x_] := Which[x < 0.9*50, Style[x, Blue],
   x > 1.1*50, Style[x, Red],
   True, x];

Now the following does what I desire, it applies a function to a column of the dataset:

ds[All, {"value" -> highLight1}]

enter image description here

What I could not manage to do is to make the highlighting work with a parameter, something like

    Clear highLight;
highLight[x_, limit_] := Which[x < 0.9*limit, Style[x, Blue],
   x > 1.1*limit, Style[x, Red],
   True, x];

This does not work, even when I use a modified version which accepts a list as x_ in the highlight1 function.

enter image description here

So the question is, whether there is a clean and simple way to get the values highlighted in this "parametrized" way? (Maybe it is just simple and I do not see it...)

mgamer
  • 5,593
  • 18
  • 26

0 Answers0