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
    Commented Oct 3, 2021 at 20:25

1 Answer 1

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
    Commented Oct 3, 2021 at 22:23
  • 1
    $\begingroup$ @Edmund, I did try that but ItemDisplayFunction -> Identity did not work. $\endgroup$
    – Domen
    Commented Oct 3, 2021 at 22:48
  • $\begingroup$ ItemDisplayFunction -> (Identity[#] &) works but this is less elegant than your solution. $\endgroup$
    – Bob Hanlon
    Commented Oct 3, 2021 at 23:07
  • $\begingroup$ Read ItemDisplayFunction's documentation. The function takes 3 parameters. ({i, p, d} |-> i) for example. $\endgroup$
    – Edmund
    Commented Oct 4, 2021 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
    Commented Oct 5, 2021 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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