Platform
Solutions
Resources
Pricing
Sign in
Sign up
Mahesh Abnave
Workspace
Fork
Published unlisted
By
Mahesh Abnave
Edited
Apr 16, 2022
1 fork
Insert cell
import
{
vl
}
from
'@vega/vega-lite-api-v5'
Insert cell
df2
=
data
[
'movies.json'
]
(
)
// get hold of movies dataset
Insert cell
data
=
require
(
'vega-datasets@1'
)
// import vega_datasets
Insert cell
df2
[
0
]
[
'IMDB_Rating'
]
Insert cell
plot
=
vl
.
markBar
(
)
.
data
(
df2
)
.
encode
(
vl
.
x
(
)
.
fieldQ
(
'IMDB_Rating'
)
.
bin
(
true
)
,
vl
.
y
(
)
.
count
(
)
)
Insert cell
plot
.
render
(
)
Insert cell
vl
.
markBar
(
)
.
data
(
df2
)
.
encode
(
vl
.
x
(
)
.
fieldQ
(
'IMDB_Rating'
)
.
bin
(
false
)
,
vl
.
y
(
)
.
count
(
)
)
.
render
(
)
Insert cell
{
const
plot
=
vl
.
markCircle
(
)
.
encode
(
{
x
:
{
field
:
'precip'
,
type
:
'quantitative'
,
aggregate
:
'average'
}
,
y
:
{
field
:
'city'
,
type
:
'nominal'
}
}
)
;
return
html
`<pre>${
JSON
.
stringify
(
plot
.
toObject
(
)
,
0
,
2
)
}</pre>`
;
// format JSON data
}
Insert cell
vl
.
markBar
(
)
.
data
(
df2
)
.
render
(
)
Insert cell
Insert cell
// html`<pre>${JSON.stringify(plot.toObject(), 0, 2)}</pre>`;
Insert cell
Insert cell
vegalite
=
require
(
"@observablehq/vega-lite@0.2"
)
Insert cell
vegalite
.
compile
(
plot
.
toObject
(
)
)
.
spec
;
Insert cell
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.
Try it for free
Learn more
Fork
View
Export
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
df2
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
plot
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
vegalite
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML