Download a PNG from URL LookIntoBitcoin - image

There is a page with URL:
https://www.lookintobitcoin.com/charts/1-year-hodl-wave/
I'm designing a page and I just want to reference the "image" of this URL.
It has a download PNG file, how can i just get the path/url to this png image file?
Here is the image icon, but i cant figure out how to get the url path to just the png file.
Can anyone show me how to get it?

This image is dynamically generated at client side (browser), so here is two ways to solve your problem:
Use Selenium or PhantomJS (both using headless browser technology) to emulate browser behaviour and automatically "press" download button at background.
Fetch JSON data and create graph by yourself (for example how to create PNG image based on txt file in python)
I recommend second way because it more flexible and you will be able to widely customize result image. But it may be more complicated than headless browser way.
If you want to use second way, you can fetch JSON data using python (for example):
import requests
import json
url = 'https://www.lookintobitcoin.com/django_plotly_dash/app/hodl_wave/_dash-update-component'
request_data = {
"output":"chart.figure",
"changedPropIds":["url.pathname"],
"inputs":[
{
"id":"url",
"property":"pathname",
"value":"/charts/1-year-hodl-wave/"
}
]
}
response = requests.post(url, json=request_data)
print(json.dumps(response.json(), indent=2))
And output will be:
{
"response": {
"props": {
"figure": {
"data": [
{
"line": {
"color": "#003366",
"width": 1.2
},
"name": "BTC Price",
"x": [
"2010-08-17",
"2020-09-13",
"2020-09-14",
...
"2021-09-07",
"2021-09-08"
],
"y": [
0.07,
0.07,
...
46215.0
],
"yaxis": "y2",
"type": "scatter"
},
{
"connectgaps": true,
"line": {
"color": "#ffa500",
"width": 0.8
},
"name": "1Yr+ HODL Wave",
"x": [
"2010-08-17",
...
"2021-12-16T00:00:00",
"2021-12-17T00:00:00"
],
"y": [
0.28032062150000003,
0.2807032645,
...
0.5101534705064048,
0.5090896880670537
],
"yaxis": "y",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(255, 207, 209, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Peak",
"showlegend": true,
"x": [
"2011-06-13"
],
"y": [
20.11
],
"yaxis": "y2",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(255, 207, 209, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Peak",
"showlegend": false,
"x": [
"2011-06-13"
],
"y": [
0.2979442568
],
"yaxis": "y",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(255, 207, 209, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Peak",
"showlegend": false,
"x": [
"2013-12-02"
],
"y": [
1047.9
],
"yaxis": "y2",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(255, 207, 209, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Peak",
"showlegend": false,
"x": [
"2013-12-02"
],
"y": [
0.3877138953
],
"yaxis": "y",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(255, 207, 209, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Peak",
"showlegend": false,
"x": [
"2017-12-20"
],
"y": [
16811.3
],
"yaxis": "y2",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(255, 207, 209, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Peak",
"showlegend": false,
"x": [
"2017-12-20"
],
"y": [
0.43133634880000005
],
"yaxis": "y",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(211, 245, 231, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Bottom",
"showlegend": false,
"x": [
"2011-11-22"
],
"y": [
2.31
],
"yaxis": "y2",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(211, 245, 231, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Bottom",
"showlegend": false,
"x": [
"2011-11-22"
],
"y": [
0.3073864328
],
"yaxis": "y",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(211, 245, 231, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Bottom",
"showlegend": false,
"x": [
"2015-01-17"
],
"y": [
201.75
],
"yaxis": "y2",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(211, 245, 231, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Bottom",
"showlegend": false,
"x": [
"2015-01-17"
],
"y": [
0.5363931366
],
"yaxis": "y",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(211, 245, 231, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Bottom",
"showlegend": true,
"x": [
"2018-12-20"
],
"y": [
3983.01
],
"yaxis": "y2",
"type": "scatter"
},
{
"hoverinfo": "skip",
"marker": {
"color": "rgba(211, 245, 231, 0.75)",
"size": 15
},
"mode": "markers",
"name": "Price Bottom",
"showlegend": false,
"x": [
"2018-12-20"
],
"y": [
0.5097358173
],
"yaxis": "y",
"type": "scatter"
}
],
"layout": {
"hovermode": "closest",
"images": [
{
"layer": "below",
"opacity": 0.1,
"sizex": 0.4,
"sizey": 0.4,
"source": "https://www.lookintobitcoin.com/static/img/logo/logo-stacked.png",
"x": 0.4,
"xref": "paper",
"y": 0.75,
"yref": "paper"
}
],
"legend": {
"font": {
"color": "#696969"
},
"orientation": "h",
"x": 0.1
},
"margin": {
"t": 10
},
"uirevision": "False",
"xaxis": {
"color": "#696969",
"gridcolor": "#d3d3d3",
"hoverformat": "%d-%b-%y",
"range": [
"2010-08-17",
"2021-12-17T00:00:00"
],
"showline": true,
"showspikes": true,
"spikecolor": "#696969",
"spikedash": "solid",
"spikemode": "toaxis+across",
"spikethickness": 1
},
"yaxis": {
"color": "#696969",
"hoverformat": "%",
"range": [
0,
1
],
"showgrid": false,
"showspikes": true,
...
"spikethickness": 1,
"tickformat": "%",
"title": {
"text": "1Yr+ HODL Wave"
}
},
"yaxis2": {
"color": "#696969",
"dtick": 1,
...
"spikethickness": 1,
"ticktext": [
"$0.001",
...
"$10,000",
"$100,000"
],
"tickvals": [
0.001,
...
100000
],
"title": {
"text": "BTC Price (USD)"
},
"type": "log",
"zeroline": true
}
}
}
}
}
}

Related

Add legend to Bullet Chart in vega-lite

I have been trying to add a legend to the following example in Vega-lite. The visualization has a facet and each bar has independent axis. Each bar has different segments with different colors. When I tried to add a legend, it changes the color defined in each mark to the first mark and the legend overlap.
This is the example without changes:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"title":"Revenue", "subtitle":"US$, in thousands", "ranges":[150,225,300],"measures":[220,270],"markers":[250]},
{"title":"Profit", "subtitle":"%", "ranges":[20,25,30],"measures":[21,23],"markers":[26]},
{"title":"Order Size", "subtitle":"US$, average", "ranges":[350,500,600],"measures":[100,320],"markers":[550]},
{"title":"New Customers", "subtitle":"count", "ranges":[1400,2000,2500],"measures":[1000,1650],"markers":[2100]},
{"title":"Satisfaction", "subtitle":"out of 5", "ranges":[3.5,4.25,5],"measures":[3.2,4.7],"markers":[4.4]}
]
},
"facet": {
"row": {
"field": "title", "type": "ordinal",
"header": {"labelAngle": 0, "title": ""}
}
},
"spacing": 10,
"spec": {
"encoding": {
"x": {
"type": "quantitative",
"scale": {"nice": false},
"title": null
}
},
"layer": [{
"mark": {"type": "bar", "color": "#eee"},
"encoding": {"x": {"field": "ranges[2]"}}
},{
"mark": {"type": "bar", "color": "#ddd"},
"encoding": {"x": {"field": "ranges[1]"}}
},{
"mark": {"type": "bar", "color": "#ccc"},
"encoding": {"x": {"field": "ranges[0]"}}
},{
"mark": {"type": "bar", "color": "lightsteelblue", "size": 10},
"encoding": {"x": {"field": "measures[1]"}}
},{
"mark": {"type": "bar", "color": "steelblue", "size": 10},
"encoding": {"x": {"field": "measures[0]"}}
},{
"mark": {"type": "tick", "color": "black"},
"encoding": {"x": {"field": "markers[0]"}}
}]
},
"resolve": {"scale": {"x": "independent"}},
"config": {"tick": {"thickness": 2}}
}
Here the changes I did without success because it change the color defined in the first 2 mark rather than having two separate scales for each mark
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"title":"Revenue", "subtitle":"US$, in thousands", "ranges":[150,225,300],"measures":[220,270],"markers":[250]},
{"title":"Profit", "subtitle":"%", "ranges":[20,25,30],"measures":[21,23],"markers":[26]},
{"title":"Order Size", "subtitle":"US$, average", "ranges":[350,500,600],"measures":[100,320],"markers":[550]},
{"title":"New Customers", "subtitle":"count", "ranges":[1400,2000,2500],"measures":[1000,1650],"markers":[2100]},
{"title":"Satisfaction", "subtitle":"out of 5", "ranges":[3.5,4.25,5],"measures":[3.2,4.7],"markers":[4.4]}
]
},
"facet": {
"row": {
"field": "title", "type": "ordinal",
"header": {"labelAngle": 0, "title": ""}
}
},
"spacing": 10,
"spec": {
"encoding": {
"x": {
"type": "quantitative",
"scale": {"nice": false},
"title": null
}
},
"layer": [{
"mark": {"type": "bar", "color": "#eee"},
"encoding": {
"x": {"field": "ranges[2]"},
"color":{
"field":"ranges[2]",
"type":"quantitative",
"legend":{
"orient": "right"
}
}
}
},{
"mark": {"type": "bar", "color": "#ddd"},
"encoding": {
"x": {"field": "ranges[1]"},
"color":{
"field":"ranges[1]",
"type":"quantitative",
"legend":{
"orient": "right"
}
}
}
},{
"mark": {"type": "bar", "color": "#ccc"},
"encoding": {"x": {"field": "ranges[0]"}}
},{
"mark": {"type": "bar", "color": "lightsteelblue", "size": 10},
"encoding": {"x": {"field": "measures[1]"}}
},{
"mark": {"type": "bar", "color": "steelblue", "size": 10},
"encoding": {"x": {"field": "measures[0]"}}
},{
"mark": {"type": "tick", "color": "black"},
"encoding": {"x": {"field": "markers[0]"}}
}]
},
"resolve": {"scale": {"x": "independent"}},
"config": {"tick": {"thickness": 2}}
}
Anyone has experience creating this type of legend
Thanks
I have added a color and legend to each mark to make the point that the gradient displayed is not related to the marks defined in the visualization
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{
"title": "Revenue",
"subtitle": "US$, in thousands",
"ranges": [150, 225, 300],
"measures": [220, 270],
"markers": [250]
},
{
"title": "Profit",
"subtitle": "%",
"ranges": [20, 25, 30],
"measures": [21, 23],
"markers": [26]
},
{
"title": "Order Size",
"subtitle": "US$, average",
"ranges": [350, 500, 600],
"measures": [100, 320],
"markers": [550]
},
{
"title": "New Customers",
"subtitle": "count",
"ranges": [1400, 2000, 2500],
"measures": [1000, 1650],
"markers": [2100]
},
{
"title": "Satisfaction",
"subtitle": "out of 5",
"ranges": [3.5, 4.25, 5],
"measures": [3.2, 4.7],
"markers": [4.4]
}
]
},
"facet": {
"row": {
"field": "title",
"type": "ordinal",
"header": {"labelAngle": 0, "title": ""}
}
},
"spacing": 10,
"spec": {
"encoding": {
"x": {"type": "quantitative", "scale": {"nice": false}, "title": null}
},
"layer": [
{
"mark": {"type": "bar", "fill": "red"},
"encoding": {
"x": {"field": "ranges[2]"},
"color": {
"field": "ranges[2]",
"type": "quantitative",
"legend": {"orient": "right"}
}
}
},
{
"mark": {"type": "bar", "fill": "green"},
"encoding": {
"x": {"field": "ranges[1]"},
"color": {
"field": "ranges[1]",
"type": "quantitative",
"legend": {"orient": "right"}
}
}
},
{
"mark": {"type": "bar", "fill": "yellow"},
"encoding": {
"x": {"field": "ranges[0]"},
"color": {
"field": "ranges[0]",
"type": "quantitative",
"legend": {"orient": "right"}
}
}
},
{
"mark": {"type": "bar", "fill": "blue", "size": 10},
"encoding": {
"x": {"field": "measures[1]"},
"color": {
"field": "measures[1]",
"type": "quantitative",
"legend": {"orient": "right"}
}
}
},
{
"mark": {"type": "bar", "fill": "violet", "size": 10},
"encoding": {
"x": {"field": "measures[0]"},
"color": {
"field": "measures[0]",
"type": "quantitative",
"legend": {"orient": "right"}
}
}
},
{
"mark": {"type": "tick", "fill": "black"},
"encoding": {"x": {"field": "markers[0]"}}
}
]
},
"resolve": {"scale": {"x": "independent"}},
"config": {"tick": {"thickness": 2}}
}
I have changed the color given in mark to fill which seemed to resolve the issue.
Below is the config or refer editor:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{
"title": "Revenue",
"subtitle": "US$, in thousands",
"ranges": [150, 225, 300],
"measures": [220, 270],
"markers": [250]
},
{
"title": "Profit",
"subtitle": "%",
"ranges": [20, 25, 30],
"measures": [21, 23],
"markers": [26]
},
{
"title": "Order Size",
"subtitle": "US$, average",
"ranges": [350, 500, 600],
"measures": [100, 320],
"markers": [550]
},
{
"title": "New Customers",
"subtitle": "count",
"ranges": [1400, 2000, 2500],
"measures": [1000, 1650],
"markers": [2100]
},
{
"title": "Satisfaction",
"subtitle": "out of 5",
"ranges": [3.5, 4.25, 5],
"measures": [3.2, 4.7],
"markers": [4.4]
}
]
},
"facet": {
"row": {
"field": "title",
"type": "ordinal",
"header": {"labelAngle": 0, "title": ""}
}
},
"spacing": 10,
"spec": {
"encoding": {
"x": {"type": "quantitative", "scale": {"nice": false}, "title": null}
},
"layer": [
{
"mark": {"type": "bar", "fill": "#eee"},
"encoding": {
"x": {"field": "ranges[2]"},
"color": {
"field": "ranges[2]",
"type": "quantitative",
"legend": {"orient": "right"}
}
}
},
{
"mark": {"type": "bar", "fill": "#ddd"},
"encoding": {
"x": {"field": "ranges[1]"},
"color": {
"field": "ranges[1]",
"type": "quantitative",
"legend": {"orient": "right"}
}
}
},
{
"mark": {"type": "bar", "fill": "#ccc"},
"encoding": {"x": {"field": "ranges[0]"}}
},
{
"mark": {"type": "bar", "fill": "lightsteelblue", "size": 10},
"encoding": {"x": {"field": "measures[1]"}}
},
{
"mark": {"type": "bar", "fill": "steelblue", "size": 10},
"encoding": {"x": {"field": "measures[0]"}}
},
{
"mark": {"type": "tick", "fill": "black"},
"encoding": {"x": {"field": "markers[0]"}}
}
]
},
"resolve": {"scale": {"x": "independent"}},
"config": {"tick": {"thickness": 2}}
}
I managed to create a legend as I was expecting. I create another visualization mark bar and create a fake legend there, and using hcol, I concatenate this to the existing graph
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{
"title": "Revenue",
"subtitle": "US$, in thousands",
"ranges": [150, 225, 300],
"measures": [220, 270],
"markers": [250]
},
{
"title": "Profit",
"subtitle": "%",
"ranges": [20, 25, 30],
"measures": [21, 23],
"markers": [26]
},
{
"title": "Order Size",
"subtitle": "US$, average",
"ranges": [350, 500, 600],
"measures": [100, 320],
"markers": [550]
},
{
"title": "New Customers",
"subtitle": "count",
"ranges": [1400, 2000, 2500],
"measures": [1000, 1650],
"markers": [2100]
},
{
"title": "Satisfaction",
"subtitle": "out of 5",
"ranges": [3.5, 4.25, 5],
"measures": [3.2, 4.7],
"markers": [4.4]
}
]
},
"hconcat": [{
"data": {
"values": [
{
"color": "green",
"phase": 1,
"name": "Green"
},
{
"color": "silver",
"phase": 1,
"name": "Silver"
},
{
"color": "violet",
"phase": 1,
"name": "Violet"
},
{
"color": "yellow",
"phase": 1,
"name": "Yellow"
},
{
"color": "red",
"phase": 1,
"name": "Red"
}
]
},
"mark": "bar",
"width": 50,
"encoding": {
"y": {
"field": "name",
"type": "nominal",
"axis": {"title": null}
},
"x": {
"field": "phase",
"type": "quantitative",
"axis": null
},
"color": {
"field": "color",
"type": "nominal",
"scale": null,
"legend": null
}
}
},{
"facet": {
"row": {
"field": "title",
"type": "ordinal",
"header": {"labelAngle": 0, "title": ""}
}
},
"spacing": 10,
"spec": {
"encoding": {
"x": {"type": "quantitative", "scale": {"nice": false}, "title": null}
},
"layer": [
{
"mark": {"type": "bar", "fill": "red"},
"encoding": {
"x": {"field": "ranges[2]"}
}
},
{
"mark": {"type": "bar", "fill": "yellow"},
"encoding": {
"x": {"field": "ranges[1]"}
}
},
{
"mark": {"type": "bar", "fill": "violet"},
"encoding": {"x": {"field": "ranges[0]"}}
},
{
"mark": {"type": "bar", "fill": "silver", "size": 10},
"encoding": {"x": {"field": "measures[1]"}}
},
{
"mark": {"type": "bar", "fill": "green", "size": 10},
"encoding": {"x": {"field": "measures[0]"}}
},
{
"mark": {"type": "tick", "fill": "black"},
"encoding": {"x": {"field": "markers[0]"}}
}
]
},
"resolve": {"scale": {"x": "independent"}}
}],
"config": {"tick": {"thickness": 2}}
}

How do I make the charts c two type: normal and stacked?

I want to have two typecharts in one visual.
Desired example
Current example, Editor
You can use 2 layers having bar chart instead of column. First layer will be a stacked layer in which filter is applied for used and free fields. Second layer can have the total field. Using xOffset you can position both the bar charts. Refer the code below or editor:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"config": {"view": {"stroke": "transparent"}, "axis": {"domainWidth": 1}},
"width": 300,
"data": {
"values": [
{"branch": "V", "free": 300, "used": 800, "total": 1000},
{"branch": "K", "free": 100, "used": 400, "total": 500},
{"branch": "D", "free": 100, "used": 200, "total": 300}
]
},
"transform": [
{"calculate": "[ datum.used, datum.free, datum.total]", "as": "table"},
{"calculate": "['used', 'free', 'total']", "as": "headline"},
{"flatten": ["table", "headline"]},
{
"calculate": "datum.headline +':'+ datum.table + ' ('+round(datum.table *100/ datum.total)+'%)'",
"as": "tooltip"
}
],
"encoding": {
"y": {"aggregate": "sum", "field": "table", "axis": {"grid": false}},
"x": {
"field": "branch",
"axis": {"grid": false, "domain": false, "labelAngle": 0, "ticks": false},
"sort": {"op": "sum", "field": "table", "order": "descending"}
},
"tooltip": {"field": "tooltip", "type": "nominal"},
"color": {
"field": "headline",
"type": "nominal",
"scale": {"range": ["#409b66", "#878787", "#1b5c9e"]}
}
},
"layer": [
{
"transform": [
{"filter": {"field": "headline", "oneOf": ["used", "free"]}}
],
"mark": {"type": "bar", "width": 15, "xOffset": -10}
},
{
"mark": {"type": "bar", "width": 15, "xOffset": 8},
"encoding": {
"y": {"field": "total", "axis": {"grid": false}, "stack": false}
}
}
]
}

Vega-lite heat map change the color, location, test

Good time of day!
formerly = Vega-lite heat map text properties
1)How to build a new X2-axis in this scheme, which takes into account the original X-axis
{"window": [{"op": "count", "field": "x", "as": "x2"}], "groupby": ["y"]}
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.4.3.json",
"config": {"view": {"height": 300, "width": 400}},
"data": {
"values": [
{"x": "X1", "y": "Y1", "z": 1,"Name":"Name3"}
{"x": "X3", "y": "Y1", "z": 9,"Name":"Name2"}
{"x": "X3", "y": "Y1", "z": 25,"Name":"Name1"}
{"x": "X0", "y": "Y2", "z": 1,"Name":"Name1"}
{"x": "X1", "y": "Y2", "z": 2,"Name":"Name1"}
{"x": "X4", "y": "Y2", "z": 20,"Name":"Name1"}
{"x": "X5", "y": "Y2", "z": 40,"Name":"Name1"}
]
},
"transform": [
{"window": [{"op": "count", "field": "x", "as": "x2"}], "groupby": ["y"]}
{"window": [{"op": "count", "field": "Name", "as": "x7"}], "groupby": ["x","y"]}
{
"calculate": "'https://google.com/search?q='+datum.y",
"as": "web"
}
],
"encoding": {
"x": {"field": "x2", "type": "ordinal", "title": "X"},
"y": {"field": "y", "type": "ordinal", "title": "Y"}
},
"layer": [
{
"mark": "rect",
"encoding": {
"color": {
"field": "z",
"scale": {"scheme": "redyellowgreen"},
"type": "quantitative"
}
"tooltip": [
{"field": "x", "type": "ordinal", title: "text"}
{"field": "y", "type": "ordinal", title: "text1"}
{"field": "z", "type": "ordinal", title: "text2"}
]
"href": {"field": "web"}
}
},
{
"mark": {"type": "text", "fontSize": 10, "dy": -20},
"encoding": {
"text": {"field": "x"},
"color": {"value": "black"}
}
},
{
"mark": {"type": "text", "fontSize": 20, "dy": 40},
"encoding": {
"text": {"field": "x7"},
"color": {"value": "black"}
}
},
{
"mark": {"type": "text", "fontSize": 20, "dy": 20},
"encoding": {
"text": {"field": "z", "type": "quantitative"},
"color": {"value": "black"}
}
}
]
}
2)how to make clear color boundaries? like here:
I use it:
"color": {"aggregate": "average","field": "z", "type": "quantitative","format": ".0f", "scale": { "domain": [0,20,25,35],"range": ["#6ce165", "#E0ED15", "#ED9715", "#CE4334"]}}
3) how to add text here:
{
"mark": {"type": "text", "fontSize": 20, "dy": 40},
"encoding": {
"text": {"field": "x7"},+ Text????
"color": {"value": "black"}
}
},
Please only ask one question per post. I do not understand what you are asking in the first or third part of your question, so I will answer the second.
You can make the color scale discrete using a binned encoding:
"encoding": {
"color": {
"field": "z",
"scale": {"scheme": "redyellowgreen"},
"type": "ordinal",
"bin": true
}
}
Here is the result (Vega Editor):

Vega: Use filter as input and dynamically change data URL

I am trying to create a Vega visualisation using an external URL and I want to construct the URL dynamically using some filters as input to the visualisation. My current Vega code is this:
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 400,
"height": 200,
"padding": 5,
"data": {
"name": "table",
"url":"https://raw.githubusercontent.com/aryak93/vega/master/data.json"
},
"signals": [
{
"name": "tooltip",
"value": {},
"on": [
{"events": "rect:mouseover", "update": "datum"},
{"events": "rect:mouseout", "update": "{}"}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "category"},
"range": "width",
"padding": 0.05,
"round": true
},
{
"name": "yscale",
"domain": {"data": "table", "field": "amount"},
"nice": true,
"range": "height"
}
],
"axes": [
{ "orient": "bottom", "scale": "xscale" },
{ "orient": "left", "scale": "yscale" }
],
"marks": [
{
"type": "rect",
"from": {"data":"table"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "category"},
"width": {"scale": "xscale", "band": 1},
"y": {"scale": "yscale", "field": "amount"},
"y2": {"scale": "yscale", "value": 0}
},
"update": {
"fill": {"value": "steelblue"}
},
"hover": {
"fill": {"value": "red"}
}
}
},
{
"type": "text",
"encode": {
"enter": {
"align": {"value": "center"},
"baseline": {"value": "bottom"},
"fill": {"value": "#333"}
},
"update": {
"x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},
"y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},
"text": {"signal": "tooltip.amount"},
"fillOpacity": [
{"test": "isNaN(tooltip.amount)", "value": 0},
{"value": 1}
]
}
}
}
]
}
What I'm trying is to change the URL from "url":"https://raw.githubusercontent.com/aryak93/vega/master/data.json" to something like "url":"https://raw.githubusercontent.com/aryak93/vega/master/data.json?projectName={projectName}" and I am expecting the project name to be populated when a user sets the filter.
So far, I have struggled to find something relevant from the Vega and Vega lite documentations. Please let me know whether this'll be possible.

Google Place by Id call returns all fields even though 'fields' param specified in the request

Google added the option to request specific fields in their 'Place Details' api.
I've added the fields that I want to the request params and I'm still getting all the fields even though I didn't request some of them.
my request URL :
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ022Et4sG5xQRtB0kHxBfakc&key=*****&fileds=address_component,adr_address,alt_id,formatted_address,geometry,icon,id,name,permanently_closed,photo,place_id,plus_code,scope,type,url,utc_offset,vicinity
and this is the response :
{
"html_attributions": [],
"result": {
"address_components": [
{
"long_name": "8021",
"short_name": "8021",
"types": [
"street_number"
]
},
{
"long_name": "Ελευθέριου Βενιζέλου",
"short_name": "Ελευθέριου Βενιζέλου",
"types": [
"route"
]
},
{
"long_name": "Baf",
"short_name": "Baf",
"types": [
"locality",
"political"
]
},
{
"long_name": "Baf",
"short_name": "Baf",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "Cyprus",
"short_name": "CY",
"types": [
"country",
"political"
]
}
],
"adr_address": "56, <span class=\"street-address\">Ελευθέριου Βενιζέλου 8021</span>, <span class=\"locality\">Baf</span>, <span class=\"country-name\">Cyprus</span>",
"formatted_address": "56, Ελευθέριου Βενιζέλου 8021, Baf, Cyprus",
"formatted_phone_number": "26 944855",
"geometry": {
"location": {
"lat": 34.7810935,
"lng": 32.4350841
},
"viewport": {
"northeast": {
"lat": 34.7824810802915,
"lng": 32.43649373029149
},
"southwest": {
"lat": 34.7797831197085,
"lng": 32.4337957697085
}
}
},
"icon": "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id": "108c7a1119ccc7ecfff72825a5df8bbd6a025192",
"international_phone_number": "+357 26 944855",
"name": "New York Sweets",
"opening_hours": {
"open_now": true,
"periods": [
{
"close": {
"day": 0,
"time": "2100"
},
"open": {
"day": 0,
"time": "0900"
}
},
{
"close": {
"day": 1,
"time": "2100"
},
"open": {
"day": 1,
"time": "0900"
}
},
{
"close": {
"day": 2,
"time": "2100"
},
"open": {
"day": 2,
"time": "0900"
}
},
{
"close": {
"day": 3,
"time": "2100"
},
"open": {
"day": 3,
"time": "0900"
}
},
{
"close": {
"day": 4,
"time": "2100"
},
"open": {
"day": 4,
"time": "0900"
}
},
{
"close": {
"day": 5,
"time": "2100"
},
"open": {
"day": 5,
"time": "0900"
}
},
{
"close": {
"day": 6,
"time": "2100"
},
"open": {
"day": 6,
"time": "0900"
}
}
],
"weekday_text": [
"Monday: 9:00 AM – 9:00 PM",
"Tuesday: 9:00 AM – 9:00 PM",
"Wednesday: 9:00 AM – 9:00 PM",
"Thursday: 9:00 AM – 9:00 PM",
"Friday: 9:00 AM – 9:00 PM",
"Saturday: 9:00 AM – 9:00 PM",
"Sunday: 9:00 AM – 9:00 PM"
]
},
"photos": [
{
"height": 854,
"html_attributions": [
"Michalis Christofi"
],
"photo_reference": "CmRZAAAAlKTZ5eOmQlupJ-rP71RW8djD8EDVCjb4xWGwpBH0fwBVtZwnnuYxitbabXV_aYTID0clGnlDR0SibQGsOW6i79-tEe-b69qZQ2Y_2k3lW1zpLcP_wrgXANvyKSzbW23XEhB8gIuRI2uYOsmDMpF_L4CsGhR0PpCS20QRffwv3q6MS6HKg4sbdA",
"width": 640
},
{
"height": 960,
"html_attributions": [
"Michalis Christofi"
],
"photo_reference": "CmRZAAAA715GtCYdgW4fChR9bsEdKJCyqspxFxNaw-wARuswoT4Vi_NC88Cg7LFQIfGAvWUSuKOhmDXBFzGZgOgRdGVjLWmuPUiIV1dMo2BJU2AJH5hpimiDVA2k0CtNwbTAmra1EhBhNKEDAVnd7RJtfkTEvO5NGhS3a9G8XQG16NVHdUGIpgtqv9ZlZw",
"width": 899
},
{
"height": 720,
"html_attributions": [
"Андрей Тихонов"
],
"photo_reference": "CmRaAAAA1VB5gyNfgeKnHRd_3hEPtcn-ddhHAQFZndcEeLu_w3N1IvtbDtViJfQ-Gjcu_ptCPigLsc3yFUl8cxRruT6ZJpFrMKSbLh544NQqAD72iQmpkpUNm9gy-2J6uAz4g0y2EhBlOHhkFM2RyQbHp8ut9gW7GhSnI2JrjLRNQ7TrZojJebjVLuqUtg",
"width": 1280
},
{
"height": 1463,
"html_attributions": [
"Michalis Christofi"
],
"photo_reference": "CmRZAAAAJjNiiWBeg0Q4HaqSBg_ndJ7XFugVSKj8_PYkUvWgcwVQaVc3RTTIoShDokWLrEPOS7GV-vilqjTXgmSlQdN_Ju3kXLXWNHkEsnZA3d_EdxieXb4q2KbsWiTVYYmoqK2TEhAyOm3gfdARi6Gz96oaQhr2GhTZK9cSie3dHNUr_GyR3dNCLk8x9g",
"width": 2000
},
{
"height": 854,
"html_attributions": [
"Michalis Christofi"
],
"photo_reference": "CmRZAAAAPJ3QX0KjX4QFr1NP9H8uyvONNmo95dlbLN5sj6r_65-dzlHfS0_G5wLf3BISu7lIIe8Zzg0DtYcq8l6E1vl-x7vuwsJAGp4Oixn6OoO3BXNKrsJPFc9A5dyxoLqXnjkeEhDS3ZN3V2LMgKB5HTQx4Oq4GhTyuViljWaU_wvEADhvdaoviV05pw",
"width": 640
},
{
"height": 960,
"html_attributions": [
"Michalis Christofi"
],
"photo_reference": "CmRZAAAA62cqSZn29xr9xtwS2-V2Mgpkxr_uv95zrQbJiQf4D185roywoZhnJMgn4l8UfVdE_DNlBd_OfEJNmt63Ul36G9McPVFh22-k67BSsa6G_GdYl4wOFuAI0hwnp_B0P7dXEhAvKR890R42YW0OJ_CSAFijGhTlkOOdJttXHGLcHXDRQtJb8Cyeuw",
"width": 720
},
{
"height": 921,
"html_attributions": [
"Michalis Christofi"
],
"photo_reference": "CmRZAAAAB9UnZE_v6khkk1Kdp7vb9V6kK1xw-_H-b5JaASutS-8VNvM8Fk9WkNrpH4NbDkq6rjfBdRJsRE3EX5_31AqU0rWpNL18kvAvNsVafPhuDk5qtxECnTnR0P31NZV5Mv2OEhCTV1AQFseaaV-SWnMNHDa9GhR5cywSvCIs9OFAB-OmZJSdp8ZoUQ",
"width": 960
},
{
"height": 1152,
"html_attributions": [
"Michalis Christofi"
],
"photo_reference": "CmRZAAAABY8bl7qB-3mI7Q5JUsco0xHp8vJLMyCf8SINMu8TDpIq9pUq1w3jHKXzTbJgVMOb-jzan8lhmxQGSs_BAyCwMEk1MdRJ9XVVXQXjye80vqIYWVQJkHtBj0nYTSCzTe5jEhBdlGpwfMdGcBLrxUEVzD0RGhSeXt6CqHuREAKQllZ2h2_jfA6ehg",
"width": 2048
},
{
"height": 754,
"html_attributions": [
"Michalis Christofi"
],
"photo_reference": "CmRZAAAAYkuexUvSiG_tVssjPVw3BGsvDjobwD0gjkJKkUOXXEXXlKYi5nSzAjHO3xS7KRd8ZaB3UUj6RUI0IE30ZAecFxMBd-qmORQb5M6Zgt7UrXzpBh2hMlhjGhQdS7WaOQFYEhAhFE8dunrSxpP-jJggmQzDGhSVHHz583G50lFjnX6J0d00u3O6Nw",
"width": 639
},
{
"height": 1536,
"html_attributions": [
"Michalis Christofi"
],
"photo_reference": "CmRZAAAAEoDqdNive69uJD2elhZAs50tPQUbBVGJDwULsyEsiHK85pMrwvzjy26SZqXLj4NRB-8lyDxyoFn2oqp6KFlqOyWgwimzv-W3LJDEdlLuUq1-hfU-MgR3PuptbeVf56BYEhAP_3GFlHnFEPijFPt5vNCvGhSEMexeFrcqgLcegYYynFFw3XpytA",
"width": 2048
}
],
"place_id": "ChIJ022Et4sG5xQRtB0kHxBfakc",
"plus_code": {
"compound_code": "QCJP+C2 Paphos, Cyprus",
"global_code": "8G6JQCJP+C2"
},
"rating": 4.8,
"reference": "ChIJ022Et4sG5xQRtB0kHxBfakc",
"reviews": [
{
"author_name": "Bill Hax",
"author_url": "https://www.google.com/maps/contrib/100332769349142525953/reviews",
"language": "en",
"profile_photo_url": "https://lh5.googleusercontent.com/-7NYsnw_M3pY/AAAAAAAAAAI/AAAAAAAACLI/iCl3xCE-hyc/s128-c0x00000000-cc-rp-mo-ba3/photo.jpg",
"rating": 5,
"relative_time_description": "9 months ago",
"text": "Best cheesecake brownies u will have! ! We ship them to lebanon 😂",
"time": 1522390670
},
{
"author_name": "G. Nad.",
"author_url": "https://www.google.com/maps/contrib/110675617871447677660/reviews",
"profile_photo_url": "https://lh3.googleusercontent.com/-W3LviwY-xTM/AAAAAAAAAAI/AAAAAAAAAAA/AKxrwcahlmVGmqRH2R49tcb4WwwxWnIDgw/s128-c0x00000000-cc-rp-mo/photo.jpg",
"rating": 5,
"relative_time_description": "3 months ago",
"text": "",
"time": 1539151080
},
{
"author_name": "Christina Christofi",
"author_url": "https://www.google.com/maps/contrib/116812443860721124624/reviews",
"profile_photo_url": "https://lh5.googleusercontent.com/-DOM0y22sX7Q/AAAAAAAAAAI/AAAAAAAAAAA/AKxrwcYrhk3mTztA81u06_SSqr8YtmTsCg/s128-c0x00000000-cc-rp-mo/photo.jpg",
"rating": 5,
"relative_time_description": "5 months ago",
"text": "",
"time": 1532377587
},
{
"author_name": "Michalis Christofi",
"author_url": "https://www.google.com/maps/contrib/109749370461397405510/reviews",
"profile_photo_url": "https://lh4.googleusercontent.com/-llt-lt53Y4o/AAAAAAAAAAI/AAAAAAAAAAA/AKxrwcbc-3ZahfOATYxC7u8OAOBoo8EINQ/s128-c0x00000000-cc-rp-mo/photo.jpg",
"rating": 5,
"relative_time_description": "5 months ago",
"text": "",
"time": 1532359074
},
{
"author_name": "Nick F",
"author_url": "https://www.google.com/maps/contrib/107808115662805818674/reviews",
"profile_photo_url": "https://lh5.googleusercontent.com/-cuA4HtKIgZA/AAAAAAAAAAI/AAAAAAAAAAk/VqVcEUa9pYQ/s128-c0x00000000-cc-rp-mo-ba4/photo.jpg",
"rating": 4,
"relative_time_description": "a month ago",
"text": "",
"time": 1542667692
}
],
"scope": "GOOGLE",
"types": [
"bakery",
"store",
"point_of_interest",
"food",
"establishment"
],
"url": "https://maps.google.com/?cid=5146030047070789044",
"user_ratings_total": 6,
"utc_offset": 120,
"vicinity": "56, Ελευθέριου Βενιζέλου 8021, Πάφος",
"website": "http://www.newyorksweets.com.cy"
},
"status": "OK"
}
try
fields=address_component,adr_address,alt_id,formatted_address,geometry,icon,id,name,permanently_closed,photo,place_id,plus_code,scope,type,url,utc_offset,vicinity
If you spell a paramter wrong it gets ignored fileds != fields

Resources