-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow custom tooltip formatting (#8883)
Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com> Co-authored-by: Kanit Wongsuphasawat <kanitw@gmail.com>
- Loading branch information
1 parent
b29fa64
commit e7b45b8
Showing
9 changed files
with
294 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 126 additions & 0 deletions
126
examples/compiled/config_numberFormatType_tooltip.vg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega/v5.json", | ||
"description": "Testing global number formatting config", | ||
"background": "white", | ||
"padding": 5, | ||
"width": 150, | ||
"height": 150, | ||
"style": "cell", | ||
"data": [ | ||
{ | ||
"name": "source_0", | ||
"url": "data/cars.json", | ||
"format": {"type": "json", "parse": {"Year": "date"}}, | ||
"transform": [ | ||
{ | ||
"type": "aggregate", | ||
"groupby": ["Year"], | ||
"ops": ["average"], | ||
"fields": ["Miles_per_Gallon"], | ||
"as": ["average_Miles_per_Gallon"] | ||
}, | ||
{ | ||
"type": "filter", | ||
"expr": "(isDate(datum[\"Year\"]) || (isValid(datum[\"Year\"]) && isFinite(+datum[\"Year\"]))) && isValid(datum[\"average_Miles_per_Gallon\"]) && isFinite(+datum[\"average_Miles_per_Gallon\"])" | ||
} | ||
] | ||
} | ||
], | ||
"marks": [ | ||
{ | ||
"name": "marks", | ||
"type": "rect", | ||
"style": ["bar"], | ||
"from": {"data": "source_0"}, | ||
"encode": { | ||
"update": { | ||
"tooltip": { | ||
"signal": "{\"Year\": timeFormat(datum[\"Year\"], '%b %d, %Y'), \"Average of Miles_per_Gallon\": format(datum[\"average_Miles_per_Gallon\"], \".8f\")}" | ||
}, | ||
"fill": {"value": "#4c78a8"}, | ||
"ariaRoleDescription": {"value": "bar"}, | ||
"description": { | ||
"signal": "\"Year: \" + (timeFormat(datum[\"Year\"], '%b %d, %Y')) + \"; Average of Miles_per_Gallon: \" + (format(datum[\"average_Miles_per_Gallon\"], \".8f\"))" | ||
}, | ||
"xc": {"scale": "x", "field": "Year"}, | ||
"width": {"value": 5}, | ||
"y": {"scale": "y", "field": "average_Miles_per_Gallon"}, | ||
"y2": {"scale": "y", "value": 0} | ||
} | ||
} | ||
} | ||
], | ||
"scales": [ | ||
{ | ||
"name": "x", | ||
"type": "time", | ||
"domain": {"data": "source_0", "field": "Year"}, | ||
"range": [0, {"signal": "width"}], | ||
"padding": 5 | ||
}, | ||
{ | ||
"name": "y", | ||
"type": "linear", | ||
"domain": {"data": "source_0", "field": "average_Miles_per_Gallon"}, | ||
"range": [{"signal": "height"}, 0], | ||
"nice": true, | ||
"zero": true | ||
} | ||
], | ||
"axes": [ | ||
{ | ||
"scale": "x", | ||
"orient": "bottom", | ||
"gridScale": "y", | ||
"grid": true, | ||
"tickCount": {"signal": "ceil(width/40)"}, | ||
"domain": false, | ||
"labels": false, | ||
"aria": false, | ||
"maxExtent": 0, | ||
"minExtent": 0, | ||
"ticks": false, | ||
"zindex": 0 | ||
}, | ||
{ | ||
"scale": "y", | ||
"orient": "left", | ||
"gridScale": "x", | ||
"grid": true, | ||
"tickCount": {"signal": "ceil(height/40)"}, | ||
"tickMinStep": 1, | ||
"domain": false, | ||
"labels": false, | ||
"aria": false, | ||
"maxExtent": 0, | ||
"minExtent": 0, | ||
"ticks": false, | ||
"zindex": 0 | ||
}, | ||
{ | ||
"scale": "x", | ||
"orient": "bottom", | ||
"grid": false, | ||
"title": "Year", | ||
"labelFlush": true, | ||
"labelOverlap": true, | ||
"tickCount": {"signal": "ceil(width/40)"}, | ||
"zindex": 0 | ||
}, | ||
{ | ||
"scale": "y", | ||
"orient": "left", | ||
"grid": false, | ||
"title": "Average of Miles_per_Gallon", | ||
"format": "d", | ||
"labelOverlap": true, | ||
"tickCount": {"signal": "ceil(height/40)"}, | ||
"tickMinStep": 1, | ||
"zindex": 0 | ||
} | ||
], | ||
"config": { | ||
"tooltipFormat": {"numberFormat": ".8f"}, | ||
"customFormatTypes": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json", | ||
"description": "Testing global number formatting config", | ||
"width": 150, | ||
"height": 150, | ||
"data": {"url": "data/cars.json"}, | ||
"mark": {"type": "bar", "tooltip": true}, | ||
"encoding": { | ||
"x": {"field": "Year", "type": "temporal"}, | ||
"y": {"field": "Miles_per_Gallon", "type": "quantitative", "aggregate": "average"} | ||
}, | ||
"config": { | ||
"tooltipFormat": { | ||
"numberFormat": ".8f" | ||
}, | ||
"numberFormat": "d", | ||
"customFormatTypes": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.