8
$\begingroup$

When I try to create a tooltip for a Dataset item, I get ... instead of the item value. See the toy code example below:

tooltipValue =  Plot[Sinc[x], {x, 0, 10}];

Dataset[{
    <|"colA" -> 1, "colB" -> Tooltip[1, tooltipValue]|>
  , <|"colA" -> 2, "colB" -> Tooltip[2, tooltipValue]|>
  }]

Dataset

How can I force the value in column B to be 1 and 2 instead of ... ?

$\endgroup$
1
  • 4
    $\begingroup$ Use option ItemDisplayFunction -> (# &) in Dataset. $\endgroup$
    – Domen
    Oct 3 at 20:25
9
$\begingroup$

From the version 12.1 on, you can use option ItemDisplayOption -> (# &). By default, it is set to Automatic, which does some preprocessing and converts large items to ellipsis.

tooltipValue = Plot[Sinc[x], {x, 0, 10}];

Dataset[{<|"colA" -> 1, "colB" -> Tooltip[1, tooltipValue]|>, <|
   "colA" -> 2, "colB" -> Tooltip[2, tooltipValue]|>}, 
 ItemDisplayFunction -> (# &)]

Dataset

$\endgroup$
5
  • $\begingroup$ Also see Identity for the ItemDisplayFunction. $\endgroup$
    – Edmund
    Oct 3 at 22:23
  • 1
    $\begingroup$ @Edmund, I did try that but ItemDisplayFunction -> Identity did not work. $\endgroup$
    – Domen
    Oct 3 at 22:48
  • $\begingroup$ ItemDisplayFunction -> (Identity[#] &) works but this is less elegant than your solution. $\endgroup$
    – Bob Hanlon
    Oct 3 at 23:07
  • $\begingroup$ Read ItemDisplayFunction's documentation. The function takes 3 parameters. ({i, p, d} |-> i) for example. $\endgroup$
    – Edmund
    Oct 4 at 23:43
  • $\begingroup$ @Edmund, yes, I know. But I don't see any advantage (or difference) in using Identity instead of a shorthand pure function. $\endgroup$
    – Domen
    Oct 5 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.