vg.tooltip(vgView[, options])
Parameter | Type | Description |
---|---|---|
vgView |
Vega View | The visualization view. |
options |
Object | Options to customize the tooltip. See options for details. |
vl.tooltip(vgView, vlSpec[, options])
Parameter | Type | Description |
---|---|---|
vgView |
Vega View | The visualization view. |
vlSpec |
Object | The Vega-Lite specification of the visualization. |
options |
Object | Options to customize the tooltip. See options for details. |
options
can customize the content and look of the tooltip. Here is a template of options
. All of its properties are optional.
var options =
{
showAllFields: true | false,
fields: [
{
field: "field1",
title: "Field One",
formatType: "time" | "number" | "string",
format: string-specifier,
aggregate: operation,
},
...
}],
colorTheme: "light" | "dark"
};
Property | Type | Description |
---|---|---|
showAllFields |
Boolean | If true , show all data fields of a visualization in the tooltip. If false , only show fields specified in the fields array in the tooltip. Default value: true |
fields |
Array | An array of fields to be displayed in the tooltip when showAllFields is false . |
colorTheme |
String | A color theme picker. Supported values: "light" and "dark" . Default value: "light" To further customize, overwrite the .vl-tooltip class in your CSS. |
Tip: You can customize the order of the fields in your tooltip by setting
showAllFields
tofalse
and providing afields
array. Your tooltip will display fields in the order they appear in thefields
array.
Each member in the fields
array can customize the format of a field. These custom formats are applied whenever applicable (no matter showAllFields
is true
or false
).
Property | Type | Description |
---|---|---|
field |
String | The unique name of the field. With Vega-Lite, this is the field you provided to each encoding channel. |
title |
String | A custom title for the field. |
formatType |
String | Tells what kind of field this is (for formatting the field value in the tooltip) Supported values: "number" , "time" , and "string" . |
format |
String | A string specifier for formatting the field value in the tooltip. If formatType is "number" , you can provide a number format string-specifier. If formatType is "time" , you can provide a time format string-specifier. If formatType is "string" , there is no need to provide a format . |
aggregate |
String | (Vega-Lite only) If your Vega-Lite visualization has multiple aggregations of the same field, you can specify the aggregation to identify the particular aggregated field. Supported values: Vega-Lite aggregate operations |