Skip to content

Commit

Permalink
docs: Use vega_datasets instead of url
Browse files Browse the repository at this point in the history
  • Loading branch information
dangotbanned committed Oct 3, 2024
1 parent 2d07630 commit 5052f4c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions tests/examples_arguments_syntax/calculate_residuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,25 @@
# category: advanced calculations

import altair as alt
from vega_datasets import data

imdb_rating = alt.datum["IMDB Rating"]
imdb_rating = alt.datum["IMDB_Rating"]
source = data.movies.url

chart = (
alt.Chart("https://vega.github.io/vega-lite/data/movies.json")
alt.Chart(source)
.mark_point()
.transform_filter(imdb_rating != None)
.transform_filter(
alt.FieldRangePredicate("Release Date", [None, 2019], timeUnit="year")
alt.FieldRangePredicate("Release_Date", [None, 2019], timeUnit="year")
)
.transform_joinaggregate(AverageRating="mean(IMDB Rating)")
.transform_calculate(RatingDelta=imdb_rating - alt.datum.AverageRating)
.transform_joinaggregate(Average_Rating="mean(IMDB_Rating)")
.transform_calculate(Rating_Delta=imdb_rating - alt.datum.Average_Rating)
.encode(
x="Release Date:T",
y=alt.Y("RatingDelta:Q", title="Rating Delta"),
x=alt.X("Release_Date:T", title="Release Date"),
y=alt.Y("Rating_Delta:Q", title="Rating Delta"),
color=alt.Color(
"RatingDelta:Q",
"Rating_Delta:Q",
title="Rating Delta",
scale=alt.Scale(domainMid=0),
),
Expand Down
18 changes: 10 additions & 8 deletions tests/examples_methods_syntax/calculate_residuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@
# category: advanced calculations

import altair as alt
from vega_datasets import data

imdb_rating = alt.datum["IMDB Rating"]
imdb_rating = alt.datum["IMDB_Rating"]
source = data.movies.url

chart = (
alt.Chart("https://vega.github.io/vega-lite/data/movies.json")
alt.Chart(source)
.mark_point()
.transform_filter(imdb_rating != None)
.transform_filter(
alt.FieldRangePredicate("Release Date", [None, 2019], timeUnit="year")
alt.FieldRangePredicate("Release_Date", [None, 2019], timeUnit="year")
)
.transform_joinaggregate(AverageRating="mean(IMDB Rating)")
.transform_calculate(RatingDelta=imdb_rating - alt.datum.AverageRating)
.transform_joinaggregate(Average_Rating="mean(IMDB_Rating)")
.transform_calculate(Rating_Delta=imdb_rating - alt.datum.Average_Rating)
.encode(
x="Release Date:T",
y=alt.Y("RatingDelta:Q").title("Rating Delta"),
color=alt.Color("RatingDelta:Q").title("Rating Delta").scale(domainMid=0),
x=alt.X("Release_Date:T").title("Release Date"),
y=alt.Y("Rating_Delta:Q").title("Rating Delta"),
color=alt.Color("Rating_Delta:Q").title("Rating Delta").scale(domainMid=0),
)
)
chart

0 comments on commit 5052f4c

Please sign in to comment.