You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could you please implement an easy way to add arbitrary text (e.g. units) to tooltips or text marks, because the existing possibilities (proposed in #5122 (comment)) have several disadvantages:
Derive a new field (in addition to the value) for the display text using the calculate transform and use that field in the tooltip or text mark
Disadvantage: Duplication
Extension of the existing formatTypenumber to use the same implementation as in the previous alternative, when the format specification contains braces:
Since { and } do not occur as tokens in the d3-number specification (see https://github.com/d3/d3-format), this should not cause problems with d3-number specifications and has the advantage that "formatType": "number" can be emitted, if it is inferred by vega-lite (which should normally be the case).
Usage:
"tooltip": [{
"field": "Mean of energy",
"format": "{.2f} kWh",
}]
Being able to add a custom text to express units (like Watt, Watt hour, Meter, Ampere, Liter, etc) to text marks, tooltips and axis labels would be a great addition!
I +1 this enhancement request. Thank you for raising this
Could you please implement an easy way to add arbitrary text (e.g. units) to tooltips or text marks, because the existing possibilities (proposed in #5122 (comment)) have several disadvantages:
calculate
transform and use that field in the tooltip or text markDisadvantage: Duplication
Disadvantages: Complex usage (needs JavaScript code) and no support in e.g.
vl2svg
(see Support expression for formatting axis #5122 (comment)) and VS CodePossible enhancement alternatives come to my mind:
numberAndText
:With this
formatType
the d3-number format is specified in braces and all other text is just copied:Usage:
Implementation:
formatType
number
to use the same implementation as in the previous alternative, when theformat
specification contains braces:Since
{
and}
do not occur as tokens in the d3-number specification (see https://github.com/d3/d3-format), this should not cause problems with d3-number specifications and has the advantage that"formatType": "number"
can be emitted, if it is inferred by vega-lite (which should normally be the case).Usage:
formatExpr
for tooltips and text marks/encodings.usage see https://vega.github.io/vega-lite/docs/axis.html#example-using-axis-labelexpr-to-display-initial-letters-of-month-name
The text was updated successfully, but these errors were encountered: