Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make text formatting preserve invalid values by coercing them to string by default #9353

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 9 additions & 9 deletions build/vega-lite-schema.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/compiled/airport_connections.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"opacity": {"value": 0.35},
"stroke": {"value": "#000"},
"description": {
"signal": "\"longitude: \" + (format(datum[\"longitude\"], \"\")) + \"; lon2: \" + (format(datum[\"lon2\"], \"\")) + \"; latitude: \" + (format(datum[\"latitude\"], \"\")) + \"; lat2: \" + (format(datum[\"lat2\"], \"\"))"
"signal": "\"longitude: \" + (!isValid(datum[\"longitude\"]) || !isFinite(+datum[\"longitude\"]) ? \"\" + datum[\"longitude\"] : format(datum[\"longitude\"], \"\")) + \"; lon2: \" + (!isValid(datum[\"lon2\"]) || !isFinite(+datum[\"lon2\"]) ? \"\" + datum[\"lon2\"] : format(datum[\"lon2\"], \"\")) + \"; latitude: \" + (!isValid(datum[\"latitude\"]) || !isFinite(+datum[\"latitude\"]) ? \"\" + datum[\"latitude\"] : format(datum[\"latitude\"], \"\")) + \"; lat2: \" + (!isValid(datum[\"lat2\"]) || !isFinite(+datum[\"lat2\"]) ? \"\" + datum[\"lat2\"] : format(datum[\"lat2\"], \"\"))"
},
"x": {"field": "layer_1_x"},
"x2": {"field": "layer_1_x2"},
Expand All @@ -223,7 +223,7 @@
"fill": {"value": "#4c78a8"},
"ariaRoleDescription": {"value": "circle"},
"description": {
"signal": "\"longitude: \" + (format(datum[\"longitude\"], \"\")) + \"; latitude: \" + (format(datum[\"latitude\"], \"\")) + \"; routes: \" + (format(datum[\"routes\"], \"\"))"
"signal": "\"longitude: \" + (!isValid(datum[\"longitude\"]) || !isFinite(+datum[\"longitude\"]) ? \"\" + datum[\"longitude\"] : format(datum[\"longitude\"], \"\")) + \"; latitude: \" + (!isValid(datum[\"latitude\"]) || !isFinite(+datum[\"latitude\"]) ? \"\" + datum[\"latitude\"] : format(datum[\"latitude\"], \"\")) + \"; routes: \" + (!isValid(datum[\"routes\"]) || !isFinite(+datum[\"routes\"]) ? \"\" + datum[\"routes\"] : format(datum[\"routes\"], \"\"))"
},
"x": {"field": "layer_2_x"},
"y": {"field": "layer_2_y"},
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/arc_color_mappings.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"update": {
"fill": {"scale": "color", "field": "category"},
"description": {
"signal": "\"value: \" + (format(datum[\"value\"], \"\")) + \"; category: \" + (isValid(datum[\"category\"]) ? datum[\"category\"] : \"\"+datum[\"category\"])"
"signal": "\"value: \" + (!isValid(datum[\"value\"]) || !isFinite(+datum[\"value\"]) ? \"\" + datum[\"value\"] : format(datum[\"value\"], \"\")) + \"; category: \" + (\"\" + datum[\"category\"])"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/arc_donut.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"innerRadius": {"value": 50},
"fill": {"scale": "color", "field": "category"},
"description": {
"signal": "\"value: \" + (format(datum[\"value\"], \"\")) + \"; category: \" + (isValid(datum[\"category\"]) ? datum[\"category\"] : \"\"+datum[\"category\"])"
"signal": "\"value: \" + (!isValid(datum[\"value\"]) || !isFinite(+datum[\"value\"]) ? \"\" + datum[\"value\"] : format(datum[\"value\"], \"\")) + \"; category: \" + (\"\" + datum[\"category\"])"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
Expand Down
6 changes: 2 additions & 4 deletions examples/compiled/arc_facet.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@
"from": {"data": "column_domain"},
"sort": {"field": "datum[\"year\"]", "order": "ascending"},
"title": {
"text": {
"signal": "isValid(parent[\"year\"]) ? parent[\"year\"] : \"\"+parent[\"year\"]"
},
"text": {"signal": "\"\" + parent[\"year\"]"},
"style": "guide-label",
"frame": "group",
"offset": 10
Expand Down Expand Up @@ -93,7 +91,7 @@
"update": {
"fill": {"scale": "color", "field": "site"},
"description": {
"signal": "\"Sum of yield: \" + (format(datum[\"sum_yield\"], \"\")) + \"; site: \" + (isValid(datum[\"site\"]) ? datum[\"site\"] : \"\"+datum[\"site\"])"
"signal": "\"Sum of yield: \" + (!isValid(datum[\"sum_yield\"]) || !isFinite(+datum[\"sum_yield\"]) ? \"\" + datum[\"sum_yield\"] : format(datum[\"sum_yield\"], \"\")) + \"; site: \" + (\"\" + datum[\"site\"])"
},
"x": {"signal": "child_width", "mult": 0.5},
"y": {"signal": "child_height", "mult": 0.5},
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/arc_ordinal_theta.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"update": {
"fill": {"scale": "color", "field": "dir"},
"description": {
"signal": "\"dir: \" + (isValid(datum[\"dir\"]) ? datum[\"dir\"] : \"\"+datum[\"dir\"]) + \"; strength: \" + (format(datum[\"strength\"], \"\"))"
"signal": "\"dir: \" + (\"\" + datum[\"dir\"]) + \"; strength: \" + (!isValid(datum[\"strength\"]) || !isFinite(+datum[\"strength\"]) ? \"\" + datum[\"strength\"] : format(datum[\"strength\"], \"\"))"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/arc_params.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"cornerRadius": {"signal": "cornerRadius"},
"fill": {"scale": "color", "field": "category"},
"description": {
"signal": "\"value: \" + (format(datum[\"value\"], \"\")) + \"; category: \" + (isValid(datum[\"category\"]) ? datum[\"category\"] : \"\"+datum[\"category\"])"
"signal": "\"value: \" + (!isValid(datum[\"value\"]) || !isFinite(+datum[\"value\"]) ? \"\" + datum[\"value\"] : format(datum[\"value\"], \"\")) + \"; category: \" + (\"\" + datum[\"category\"])"
},
"x": {"signal": "childWidth", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/arc_pie.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"update": {
"fill": {"scale": "color", "field": "category"},
"description": {
"signal": "\"value: \" + (format(datum[\"value\"], \"\")) + \"; category: \" + (isValid(datum[\"category\"]) ? datum[\"category\"] : \"\"+datum[\"category\"])"
"signal": "\"value: \" + (!isValid(datum[\"value\"]) || !isFinite(+datum[\"value\"]) ? \"\" + datum[\"value\"] : format(datum[\"value\"], \"\")) + \"; category: \" + (\"\" + datum[\"category\"])"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
Expand Down
4 changes: 2 additions & 2 deletions examples/compiled/arc_pie_normalize_tooltip.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"encode": {
"update": {
"tooltip": {
"signal": "{\"value\": format(datum[\"value_end\"]-datum[\"value_start\"], \".0%\"), \"category\": isValid(datum[\"category\"]) ? datum[\"category\"] : \"\"+datum[\"category\"]}"
"signal": "{\"value\": !isValid(datum[\"value_end\"]-datum[\"value_start\"]) || !isFinite(+datum[\"value_end\"]-datum[\"value_start\"]) ? \"\" + datum[\"value_end\"]-datum[\"value_start\"] : format(datum[\"value_end\"]-datum[\"value_start\"], \".0%\"), \"category\": \"\" + datum[\"category\"]}"
},
"fill": {"scale": "color", "field": "category"},
"description": {
"signal": "\"value: \" + (format(datum[\"value_end\"]-datum[\"value_start\"], \".0%\")) + \"; category: \" + (isValid(datum[\"category\"]) ? datum[\"category\"] : \"\"+datum[\"category\"])"
"signal": "\"value: \" + (!isValid(datum[\"value_end\"]-datum[\"value_start\"]) || !isFinite(+datum[\"value_end\"]-datum[\"value_start\"]) ? \"\" + datum[\"value_end\"]-datum[\"value_start\"] : format(datum[\"value_end\"]-datum[\"value_start\"], \".0%\")) + \"; category: \" + (\"\" + datum[\"category\"])"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/arc_pie_pyramid.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"outerRadius": {"value": 80},
"fill": {"scale": "color", "field": "category"},
"description": {
"signal": "\"value: \" + (format(datum[\"value\"], \"\")) + \"; category: \" + (isValid(datum[\"category\"]) ? datum[\"category\"] : \"\"+datum[\"category\"]) + \"; order: \" + (isValid(datum[\"order\"]) ? datum[\"order\"] : \"\"+datum[\"order\"])"
"signal": "\"value: \" + (!isValid(datum[\"value\"]) || !isFinite(+datum[\"value\"]) ? \"\" + datum[\"value\"] : format(datum[\"value\"], \"\")) + \"; category: \" + (\"\" + datum[\"category\"]) + \"; order: \" + (\"\" + datum[\"order\"])"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
Expand Down
8 changes: 5 additions & 3 deletions examples/compiled/arc_radial.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"innerRadius": {"value": 20},
"fill": {"scale": "color", "field": "data"},
"description": {
"signal": "\"data: \" + (format(datum[\"data\"], \"\"))"
"signal": "\"data: \" + (!isValid(datum[\"data\"]) || !isFinite(+datum[\"data\"]) ? \"\" + datum[\"data\"] : format(datum[\"data\"], \"\"))"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
Expand All @@ -76,11 +76,13 @@
"update": {
"fill": {"scale": "color", "field": "data"},
"description": {
"signal": "\"data: \" + (format(datum[\"data\"], \"\"))"
"signal": "\"data: \" + (!isValid(datum[\"data\"]) || !isFinite(+datum[\"data\"]) ? \"\" + datum[\"data\"] : format(datum[\"data\"], \"\"))"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
"text": {"signal": "format(datum[\"data\"], \"\")"},
"text": {
"signal": "!isValid(datum[\"data\"]) || !isFinite(+datum[\"data\"]) ? \"\" + datum[\"data\"] : format(datum[\"data\"], \"\")"
},
"align": {"value": "center"},
"baseline": {"value": "middle"},
"radius": {"scale": "radius", "field": "data", "offset": 10},
Expand Down
8 changes: 4 additions & 4 deletions examples/compiled/arc_radial_histogram.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
"update": {
"stroke": {"value": "white"},
"tooltip": {
"signal": "{\"IMDB Rating (binned)\": !isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"null\" : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\"), \"Count of Records\": format(datum[\"__count\"], \"\")}"
"signal": "{\"IMDB Rating (binned)\": !isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"\" + datum[\"bin_maxbins_10_IMDB Rating\"] : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\"), \"Count of Records\": !isValid(datum[\"__count\"]) || !isFinite(+datum[\"__count\"]) ? \"\" + datum[\"__count\"] : format(datum[\"__count\"], \"\")}"
},
"fill": {"value": "#4c78a8"},
"description": {
"signal": "\"IMDB Rating (binned): \" + (!isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"null\" : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\")) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\"))"
"signal": "\"IMDB Rating (binned): \" + (!isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"\" + datum[\"bin_maxbins_10_IMDB Rating\"] : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\")) + \"; Count of Records: \" + (!isValid(datum[\"__count\"]) || !isFinite(+datum[\"__count\"]) ? \"\" + datum[\"__count\"] : format(datum[\"__count\"], \"\"))"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
Expand All @@ -98,12 +98,12 @@
"align": {"value": "right"},
"fill": {"value": "black"},
"description": {
"signal": "\"IMDB Rating (binned): \" + (!isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"null\" : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\")) + \"; Count of Records: \" + (format(datum[\"__count\"], \"\"))"
"signal": "\"IMDB Rating (binned): \" + (!isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"\" + datum[\"bin_maxbins_10_IMDB Rating\"] : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\")) + \"; Count of Records: \" + (!isValid(datum[\"__count\"]) || !isFinite(+datum[\"__count\"]) ? \"\" + datum[\"__count\"] : format(datum[\"__count\"], \"\"))"
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
"text": {
"signal": "!isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"null\" : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\")"
"signal": "!isValid(datum[\"bin_maxbins_10_IMDB Rating\"]) || !isFinite(+datum[\"bin_maxbins_10_IMDB Rating\"]) ? \"\" + datum[\"bin_maxbins_10_IMDB Rating\"] : format(datum[\"bin_maxbins_10_IMDB Rating\"], \"\") + \" – \" + format(datum[\"bin_maxbins_10_IMDB Rating_end\"], \"\")"
},
"angle": {
"signal": "scale(\"angle\", 0.5 * datum[\"bin_maxbins_10_IMDB Rating\"] + 0.5 * datum[\"bin_maxbins_10_IMDB Rating_end\"])"
Expand Down
2 changes: 1 addition & 1 deletion examples/compiled/area.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"orient": {"value": "vertical"},
"fill": {"value": "#4c78a8"},
"description": {
"signal": "\"date (year-month): \" + (timeFormat(datum[\"yearmonth_date\"], '%Y')) + \"; count: \" + (format(datum[\"sum_count\"], \"\"))"
"signal": "\"date (year-month): \" + (!isValid(datum[\"yearmonth_date\"]) || !isFinite(+datum[\"yearmonth_date\"]) ? \"\" + datum[\"yearmonth_date\"] : timeFormat(datum[\"yearmonth_date\"], '%Y')) + \"; count: \" + (!isValid(datum[\"sum_count\"]) || !isFinite(+datum[\"sum_count\"]) ? \"\" + datum[\"sum_count\"] : format(datum[\"sum_count\"], \"\"))"
},
"x": {"scale": "x", "field": "yearmonth_date"},
"y": {"scale": "y", "field": "sum_count"},
Expand Down
Loading
Loading