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

Update to Vega-Lite 4.17.0 #2513

Merged
merged 48 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
cc2f9ec
Include datum in channel wrappers
ChristopherDavisUCI Oct 23, 2021
ede3c68
Correct names like NameDatumValue
ChristopherDavisUCI Oct 23, 2021
fcf005b
Update altair/utils/core.py with Datum
ChristopherDavisUCI Oct 23, 2021
5485c23
Update DatumChannelMixin
ChristopherDavisUCI Oct 23, 2021
5ae3399
Replace [] with Array in get_valid_identifier
ChristopherDavisUCI Oct 25, 2021
f45e75b
Allow "week" as time unit
ChristopherDavisUCI Oct 26, 2021
6411078
Update allowable time units
ChristopherDavisUCI Oct 26, 2021
2c78afa
Update TopLevelRepeatSpec
ChristopherDavisUCI Oct 26, 2021
0ba0c79
include layer for repeat
mattijn Oct 27, 2021
3251337
removed TopLevelRepeatSpec, its the schema
mattijn Oct 27, 2021
aeea9f3
auto-generated files
mattijn Oct 27, 2021
8b41830
Merge pull request #1 from mattijn/sample417
ChristopherDavisUCI Oct 27, 2021
8305ac3
Dealing with TopLevelRepeatSpec
ChristopherDavisUCI Oct 28, 2021
105c924
Formatting updates
ChristopherDavisUCI Oct 28, 2021
0a15c5d
Update "Encoding Channel Options" part of docs
ChristopherDavisUCI Oct 31, 2021
cec423e
Examples of Datum and mark_arc
ChristopherDavisUCI Oct 31, 2021
ab9ad94
Remove old ad hoc code for TopLevelRepeatSpec
ChristopherDavisUCI Oct 31, 2021
7b76665
add linked vegalite issue
mattijn Oct 31, 2021
6fafc33
remove None values in compiled vega so test pass
mattijn Oct 31, 2021
dfcbc2f
add linked vl-issue
mattijn Oct 31, 2021
9a365d4
add more documentation on new arc mark
mattijn Oct 31, 2021
07fe2c3
Merge branch 'sample417' into patchtoplevelrepeat
ChristopherDavisUCI Oct 31, 2021
2ed2814
Update generate_schema_wrapper.py
ChristopherDavisUCI Oct 31, 2021
08d4b3d
Update to allow the correct spec options in TopLevelRepeatSpec
ChristopherDavisUCI Nov 1, 2021
771e036
Replace spaces with underscores in IMDB column names
ChristopherDavisUCI Nov 1, 2021
1eef3de
Update build.yml
mattijn Nov 2, 2021
d594587
Update docbuild.yml
mattijn Nov 2, 2021
b3e30da
New method for dealing with TopLevelRepeatSpec
ChristopherDavisUCI Nov 2, 2021
df162de
Explicit schema for RepeatChart
ChristopherDavisUCI Nov 2, 2021
444dbb8
apply black format
mattijn Nov 2, 2021
33e0c90
remove trailing white space
mattijn Nov 2, 2021
f348cd7
Add an optional default_class argument to _FromDict.from_dict
ChristopherDavisUCI Nov 3, 2021
a23a8ff
Add an optional default_class argument to _FromDict.from_dict
ChristopherDavisUCI Nov 3, 2021
6899722
Allow alt.datum syntax similar to alt.value
ChristopherDavisUCI Nov 3, 2021
18d0c12
Simplify _FromDict.from_dict logic
ChristopherDavisUCI Nov 3, 2021
7ebe289
Update Change Log
ChristopherDavisUCI Nov 3, 2021
38727fd
include cicurlar plots
mattijn Nov 4, 2021
33fb849
plots in category circular plots
mattijn Nov 4, 2021
73de4cd
change examples to use alt.datum()
mattijn Nov 4, 2021
b4f0f91
add example using angle encoding
mattijn Nov 4, 2021
aab8017
add example compact trellis grid bar chart
mattijn Nov 4, 2021
225c9f3
extend change log to include angle encoding
mattijn Nov 4, 2021
158d2ff
Fix typo in link
ChristopherDavisUCI Nov 4, 2021
98293e9
simplify from_dict
mattijn Nov 4, 2021
25baa86
Update schemapi.py
ChristopherDavisUCI Nov 4, 2021
c10c57e
serialize values InlineDataset within InlineData
mattijn Nov 5, 2021
93e8467
improve robustness
mattijn Nov 5, 2021
464b203
remove link to master of altair_viewer
mattijn Nov 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
python -m pip install --upgrade pip
pip install .[dev]
pip install altair_saver
pip install git+git://github.com/altair-viz/altair_viewer.git
- name: Test with pytest
run: |
pytest --doctest-modules altair
3 changes: 2 additions & 1 deletion .github/workflows/docbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ jobs:
pip install .[dev]
pip install altair_saver
pip install -r doc/requirements.txt
pip install git+git://github.com/altair-viz/altair_viewer.git
- name: Run docbuild
run: |
cd doc && make ${{ matrix.build-type }}



2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ Untitled*.ipynb
*.DS_Store

# VSCode
.vscode
.vscode
50 changes: 50 additions & 0 deletions altair/examples/bar_chart_trellis_compact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
Compact Trellis Grid of Bar Charts
==================================
This example shows a simple grid of bar charts to compare performance data..
"""
# category: bar charts
import altair as alt
import pandas as pd

source = pd.DataFrame(
[
{"a": "a1", "b": "b1", "c": "x", "p": "0.14"},
{"a": "a1", "b": "b1", "c": "y", "p": "0.60"},
{"a": "a1", "b": "b1", "c": "z", "p": "0.03"},
{"a": "a1", "b": "b2", "c": "x", "p": "0.80"},
{"a": "a1", "b": "b2", "c": "y", "p": "0.38"},
{"a": "a1", "b": "b2", "c": "z", "p": "0.55"},
{"a": "a1", "b": "b3", "c": "x", "p": "0.11"},
{"a": "a1", "b": "b3", "c": "y", "p": "0.58"},
{"a": "a1", "b": "b3", "c": "z", "p": "0.79"},
{"a": "a2", "b": "b1", "c": "x", "p": "0.83"},
{"a": "a2", "b": "b1", "c": "y", "p": "0.87"},
{"a": "a2", "b": "b1", "c": "z", "p": "0.67"},
{"a": "a2", "b": "b2", "c": "x", "p": "0.97"},
{"a": "a2", "b": "b2", "c": "y", "p": "0.84"},
{"a": "a2", "b": "b2", "c": "z", "p": "0.90"},
{"a": "a2", "b": "b3", "c": "x", "p": "0.74"},
{"a": "a2", "b": "b3", "c": "y", "p": "0.64"},
{"a": "a2", "b": "b3", "c": "z", "p": "0.19"},
{"a": "a3", "b": "b1", "c": "x", "p": "0.57"},
{"a": "a3", "b": "b1", "c": "y", "p": "0.35"},
{"a": "a3", "b": "b1", "c": "z", "p": "0.49"},
{"a": "a3", "b": "b2", "c": "x", "p": "0.91"},
{"a": "a3", "b": "b2", "c": "y", "p": "0.38"},
{"a": "a3", "b": "b2", "c": "z", "p": "0.91"},
{"a": "a3", "b": "b3", "c": "x", "p": "0.99"},
{"a": "a3", "b": "b3", "c": "y", "p": "0.80"},
{"a": "a3", "b": "b3", "c": "z", "p": "0.37"},
]
)

alt.Chart(source, width=60, height=alt.Step(8)).mark_bar().encode(
y=alt.Y("c:N", axis=None),
x=alt.X("p:Q", title=None, axis=alt.Axis(format="%")),
color=alt.Color(
"c:N", title="settings", legend=alt.Legend(orient="bottom", titleOrient="left")
),
row=alt.Row("a:N", title="Factor A", header=alt.Header(labelAngle=0)),
column=alt.Column("b:N", title="Factor B"),
)
18 changes: 18 additions & 0 deletions altair/examples/donut_chart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Donut Chart
-----------
This example shows how to make a Donut Chart using ``mark_arc``.
This is adapted from a corresponding Vega-Lite Example:
`Donut Chart <https://vega.github.io/vega-lite/examples/arc_donut.html>`_.
"""
# category: circular plots

import pandas as pd
import altair as alt

source = pd.DataFrame({"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]})

alt.Chart(source).mark_arc(innerRadius=50).encode(
theta=alt.Theta(field="value", type="quantitative"),
color=alt.Color(field="category", type="nominal"),
)
21 changes: 21 additions & 0 deletions altair/examples/line_chart_with_color_datum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Line Chart with datum for color
-------------------------------
An example of using ``datum`` and ``repeat`` to color a multi-series line chart.
This is adapted from this corresponding Vega-Lite Example:
`Repeat and Layer to Show Different Movie Measures <https://vega.github.io/vega-lite/examples/repeat_layer.html>`_.
"""
# category: line charts

import altair as alt
from vega_datasets import data

source = data.movies()

alt.Chart(source).mark_line().encode(
x=alt.X("IMDB_Rating", bin=True),
y=alt.Y(
alt.repeat("layer"), aggregate="mean", title="Mean of US and Worldwide Gross"
),
color=alt.datum(alt.repeat("layer")),
).repeat(layer=["US_Gross", "Worldwide_Gross"])
33 changes: 33 additions & 0 deletions altair/examples/line_chart_with_datum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Line Chart with datum
---------------------------------
An example of using ``datum`` to highlight certain values, including a ``DateTime`` value.
This is adapted from two corresponding Vega-Lite Examples:
`Highlight a Specific Value <https://vega.github.io/vega-lite/docs/datum.html#highlight-a-specific-data-value>`_.
"""
# category: line charts

import altair as alt
from vega_datasets import data

source = data.stocks()
no_source = alt.Data(values=[{}])

lines = (
alt.Chart(source)
.mark_line()
.encode(x=alt.X("date"), y=alt.Y("price"), color="symbol")
)

xrule = (
alt.Chart(no_source)
.mark_rule(color="cyan", strokeWidth=2)
.encode(x=alt.datum(alt.DateTime(year=2006, month="November")))
)

yrule = (
alt.Chart(no_source).mark_rule(strokeDash=[12, 6], size=2).encode(y=alt.datum(350))
)


lines + yrule + xrule
19 changes: 19 additions & 0 deletions altair/examples/pacman_chart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Pacman Chart
------------
Chart made using ``mark_arc`` and constant values.
This could also be made using
``alt.Chart(source).mark_arc(color = "gold", theta = (5/8)*np.pi, theta2 = (19/8)*np.pi,radius=100)``.
"""
# category: circular plots

import numpy as np
import altair as alt

no_source = alt.Data(values=[{}])

alt.Chart(no_source).mark_arc(color="gold").encode(
theta=alt.datum((5 / 8) * np.pi, scale=None),
theta2=alt.datum((19 / 8) * np.pi),
radius=alt.datum(100, scale=None),
)
18 changes: 18 additions & 0 deletions altair/examples/pie_chart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Pie Chart
---------
This example shows how to make a Pie Chart using ``mark_arc``.
This is adapted from a corresponding Vega-Lite Example:
`Pie Chart <https://vega.github.io/vega-lite/examples/arc_pie.html>`_.
"""
# category: circular plots

import pandas as pd
import altair as alt

source = pd.DataFrame({"category": [1, 2, 3, 4, 5, 6], "value": [4, 6, 10, 3, 7, 8]})

alt.Chart(source).mark_arc().encode(
theta=alt.Theta(field="value", type="quantitative"),
color=alt.Color(field="category", type="nominal"),
)
24 changes: 24 additions & 0 deletions altair/examples/pie_chart_with_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Pie Chart with Labels
---------------------
This example shows how to layer text over arc marks (``mark_arc``) to label pie charts.
This is adapted from a corresponding Vega-Lite Example:
`Pie Chart with Labels <https://vega.github.io/vega-lite/examples/layer_arc_label.html>`_.
"""
# category: circular plots

import pandas as pd
import altair as alt

source = pd.DataFrame(
{"category": ["a", "b", "c", "d", "e", "f"], "value": [4, 6, 10, 3, 7, 8]}
)

base = alt.Chart(source).encode(
theta=alt.Theta("value:Q", stack=True), color=alt.Color("category:N", legend=None)
)

pie = base.mark_arc(outerRadius=120)
text = base.mark_text(radius=140, size=20).encode(text="category:N")

pie + text
25 changes: 25 additions & 0 deletions altair/examples/radial_chart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Radial Chart
------------
This radial plot uses both angular and radial extent to convey multiple dimensions of data.
This is adapted from a corresponding Vega-Lite Example:
`Radial Plot <https://vega.github.io/vega-lite/examples/arc_radial.html>`_.
"""
# category: circular plots

import pandas as pd
import altair as alt

source = pd.DataFrame({"values": [12, 23, 47, 6, 52, 19]})

base = alt.Chart(source).encode(
theta=alt.Theta("values:Q", stack=True),
radius=alt.Radius("values", scale=alt.Scale(type="sqrt", zero=True, rangeMin=20)),
color="values:N",
)

c1 = base.mark_arc(innerRadius=20, stroke="#fff")

c2 = base.mark_text(radiusOffset=10).encode(text="values:Q")

c1 + c2
24 changes: 24 additions & 0 deletions altair/examples/wind_vector_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Wind Vector Map
---------------
An example showing a vector array map showing wind speed and direction using ``wedge``
as shape for ``mark_point`` and ``angle`` encoding for the wind direction.
This is adapted from this corresponding Vega-Lite Example:
`Wind Vector Map <https://vega.github.io/vega-lite/examples/point_angle_windvector.html>`_.
"""
# category: scatter plots

import altair as alt
from vega_datasets import data

source = data.windvectors()

alt.Chart(source).mark_point(shape="wedge", filled=True).encode(
latitude="latitude",
longitude="longitude",
color=alt.Color(
"dir", scale=alt.Scale(domain=[0, 360], scheme="rainbow"), legend=None
),
angle=alt.Angle("dir", scale=alt.Scale(domain=[0, 360], range=[180, 540])),
size=alt.Size("speed", scale=alt.Scale(rangeMax=500)),
).project("equalEarth")
4 changes: 4 additions & 0 deletions altair/expr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def __getattr__(self, attr):
def __getitem__(self, attr):
return GetItemExpression("datum", attr)

def __call__(self, datum, **kwargs):
"""Specify a datum for use in an encoding"""
return dict(datum=datum, **kwargs)


datum = DatumType()

Expand Down
1 change: 1 addition & 0 deletions altair/sphinxext/altairgallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def main(app):
"Bar Charts": [],
"Line Charts": [],
"Area Charts": [],
"Circular Plots": [],
"Scatter Plots": [],
"Histograms": [],
"Maps": [],
Expand Down
Loading