Public
Edited
Nov 23
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
spec = { return ({
"$schema": "https://vega.github.io/schema/vega-lite/v4.17.0.json",
"config": {
"view": {
"continuousHeight": 300,
"continuousWidth": 400
}
},
"data": {
"name": "data-c2a3e89ba9d5d1687d5e8c28d630a033"
},
"datasets": {
"data-c2a3e89ba9d5d1687d5e8c28d630a033": [
{
"a": "A",
"b": 28
},
{
"a": "B",
"b": 55
},
{
"a": "C",
"b": 43
},
{
"a": "D",
"b": 91
},
{
"a": "E",
"b": 81
},
{
"a": "F",
"b": 53
},
{
"a": "G",
"b": 19
},
{
"a": "H",
"b": 87
},
{
"a": "I",
"b": 52
}
]
},
"encoding": {
"x": {
"field": "a",
"type": "nominal"
},
"y": {
"field": "b",
"type": "quantitative"
}
},
"mark": "bar"
})}
Insert cell
Insert cell
embed = require("vega-embed@6")
Insert cell
viewof chart1 = embed(spec)
Insert cell
Insert cell
data = [
{
"a": "A",
"b": 28
},
{
"a": "B",
"b": 55
},
{
"a": "C",
"b": 43
},
{
"a": "D",
"b": 91
},
{
"a": "E",
"b": 81
},
{
"a": "F",
"b": 53
},
{
"a": "G",
"b": 19
},
{
"a": "H",
"b": 87
},
{
"a": "I",
"b": 52
}
]
Insert cell
Insert cell
filtered_spec = {
return ({
"$schema": "https://vega.github.io/schema/vega-lite/v4.17.0.json",
"config": {
"view": {
"continuousHeight": 300,
"continuousWidth": 400
}
},
"data": {
"name": "data-c2a3e89ba9d5d1687d5e8c28d630a033"
},
"datasets": {
"data-c2a3e89ba9d5d1687d5e8c28d630a033": data
},
"encoding": {
"x": {
"field": "a",
"type": "nominal"
},
"y": {
"field": "b",
"type": "quantitative"
}
},
"mark": "bar"
})}
Insert cell
Insert cell
viewof chart2 = embed(filtered_spec)
Insert cell
Insert cell
viewof min_value = Inputs.range([d3.min(data, d => d.b)-1, d3.max(data, d => d.b)-1], {value: d3.max(data, d => d.b), step: 1, label: "Min Value"})
Insert cell
Insert cell
filtered_data = data.filter(d => d.b > min_value)
Insert cell
Insert cell
viewof chart = embed(filtered_spec_dynamic_data)
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more