diff --git a/altair/examples/attribute_syntax/__init__.py b/altair/examples/attribute_syntax/__init__.py new file mode 100644 index 000000000..5046eda13 --- /dev/null +++ b/altair/examples/attribute_syntax/__init__.py @@ -0,0 +1,16 @@ +import os + + +def iter_attribute_syntax(): + """Iterate over the examples in this directory. + + Each item is a dict with the following keys: + - "name" : the unique name of the example + - "filename" : the full file path to the example + """ + attribute_syntax_dir = os.path.abspath(os.path.dirname(__file__)) + for filename in os.listdir(attribute_syntax_dir): + name, ext = os.path.splitext(filename) + if name.startswith("_") or ext != ".py": + continue + yield {"name": name, "filename": os.path.join(attribute_syntax_dir, filename)} diff --git a/altair/examples/attribute_syntax/airport_connections.py b/altair/examples/attribute_syntax/airport_connections.py new file mode 100644 index 000000000..0b54db495 --- /dev/null +++ b/altair/examples/attribute_syntax/airport_connections.py @@ -0,0 +1,70 @@ +""" +Connections Among U.S. Airports Interactive +------------------------------------------- +This example shows all the connections between major U.S. airports. Lookup transformations +are used to find the coordinates of each airport and connecting airports. Connections +are displayed on mouseover via a single selection. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +# Since these data are each more than 5,000 rows we'll import from the URLs +airports = data.airports.url +flights_airport = data.flights_airport.url + +states = alt.topo_feature(data.us_10m.url, feature="states") + +# Create mouseover selection +select_city = alt.selection_point( + on="mouseover", nearest=True, fields=["origin"], empty=False +) + +# Define which attributes to lookup from airports.csv +lookup_data = alt.LookupData( + airports, key="iata", fields=["state", "latitude", "longitude"] +) + +background = alt.Chart(states).mark_geoshape( + fill="lightgray", + stroke="white" +).properties( + width=750, + height=500 +).project("albersUsa") + +connections = alt.Chart(flights_airport).mark_rule(opacity=0.35).encode( + latitude="latitude:Q", + longitude="longitude:Q", + latitude2="lat2:Q", + longitude2="lon2:Q" +).transform_lookup( + lookup="origin", + from_=lookup_data +).transform_lookup( + lookup="destination", + from_=lookup_data, + as_=["state", "lat2", "lon2"] +).transform_filter( + select_city +) + +points = alt.Chart(flights_airport).mark_circle().encode( + latitude="latitude:Q", + longitude="longitude:Q", + size=alt.Size("routes:Q").legend(None).scale(range=[0, 1000]), + order=alt.Order("routes:Q").sort("descending"), + tooltip=["origin:N", "routes:Q"] +).transform_aggregate( + routes="count()", + groupby=["origin"] +).transform_lookup( + lookup="origin", + from_=lookup_data +).transform_filter( + (alt.datum.state != "PR") & (alt.datum.state != "VI") +).add_params( + select_city +) + +(background + connections + points).configure_view(stroke=None) diff --git a/altair/examples/attribute_syntax/annual_weather_heatmap.py b/altair/examples/attribute_syntax/annual_weather_heatmap.py new file mode 100644 index 000000000..d96b1e06c --- /dev/null +++ b/altair/examples/attribute_syntax/annual_weather_heatmap.py @@ -0,0 +1,24 @@ +""" +Annual Weather Heatmap +---------------------- +""" +# category: tables +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +alt.Chart(source, title="Daily Max Temperatures (C) in Seattle, WA").mark_rect().encode( + alt.X("date(date):O").title("Day").axis(format="%e", labelAngle=0), + alt.Y("month(date):O").title("Month"), + alt.Color("max(temp_max)").title(None), + tooltip=[ + alt.Tooltip("monthdate(date)", title="Date"), + alt.Tooltip("max(temp_max)", title="Max Temp"), + ], +).configure_view( + step=13, + strokeWidth=0 +).configure_axis( + domain=False +) diff --git a/altair/examples/attribute_syntax/anscombe_plot.py b/altair/examples/attribute_syntax/anscombe_plot.py new file mode 100644 index 000000000..906f15ee7 --- /dev/null +++ b/altair/examples/attribute_syntax/anscombe_plot.py @@ -0,0 +1,20 @@ +""" +Anscombe's Quartet +------------------ + +This example shows how to use the column channel to make a trellis plot. Anscombe's Quartet is a famous dataset constructed by Francis Anscombe. Common summary statistics are identical for each subset of the data, despite the subsets having vastly different characteristics. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.anscombe() + +alt.Chart(source).mark_circle().encode( + alt.X('X').scale(zero=False), + alt.Y('Y').scale(zero=False), + alt.Facet('Series', columns=2), +).properties( + width=180, + height=180, +) diff --git a/altair/examples/attribute_syntax/bar_chart_trellis_compact.py b/altair/examples/attribute_syntax/bar_chart_trellis_compact.py new file mode 100644 index 000000000..2cb0e4b7d --- /dev/null +++ b/altair/examples/attribute_syntax/bar_chart_trellis_compact.py @@ -0,0 +1,48 @@ +""" +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( + alt.Y("c:N").axis(None), + alt.X("p:Q").title(None).axis(format="%"), + alt.Color("c:N").title("settings").legend(orient="bottom", titleOrient="left"), + alt.Row("a:N").title("Factor A").header(labelAngle=0), + alt.Column("b:N").title("Factor B"), +) diff --git a/altair/examples/attribute_syntax/beckers_barley_trellis_plot.py b/altair/examples/attribute_syntax/beckers_barley_trellis_plot.py new file mode 100644 index 000000000..9f7c68867 --- /dev/null +++ b/altair/examples/attribute_syntax/beckers_barley_trellis_plot.py @@ -0,0 +1,28 @@ +""" +Becker's Barley Trellis Plot +---------------------------- +The example demonstrates the trellis charts created by Richard Becker, William Cleveland and others in the 1990s. Using the visualization technique below they identified an anomoly in a widely used agriculatural dataset, which they termed `"The Morris Mistake." `_. It became their favored way of showcasing the power of this pioneering plot. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.barley() + +alt.Chart(source, title="The Morris Mistake").mark_point().encode( + alt.X('yield:Q') + .title("Barley Yield (bushels/acre)") + .scale(zero=False) + .axis(grid=False), + alt.Y('variety:N') + .title("") + .sort('-x') + .axis(grid=True), + alt.Color('year:N') + .legend(title="Year"), + alt.Row('site:N') + .title("") + .sort(alt.EncodingSortField(field='yield', op='sum', order='descending')) +).properties( + height=alt.Step(20) +).configure_view(stroke="transparent") diff --git a/altair/examples/attribute_syntax/beckers_barley_wrapped_facet.py b/altair/examples/attribute_syntax/beckers_barley_wrapped_facet.py new file mode 100644 index 000000000..1b36dfbc0 --- /dev/null +++ b/altair/examples/attribute_syntax/beckers_barley_wrapped_facet.py @@ -0,0 +1,22 @@ +""" +Becker's Barley Trellis Plot (Wrapped Facet) +-------------------------------------------- +The example demonstrates the trellis charts created by Richard Becker, William Cleveland and others in the 1990s. +This is the Altair replicate of `the VegaLite version `_ +demonstrating the usage of `columns` argument to create wrapped facet. +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.barley.url + +alt.Chart(source).mark_point().encode( + alt.X('median(yield):Q').scale(zero=False), + y='variety:O', + color='year:N', + facet=alt.Facet('site:O', columns=2), +).properties( + width=200, + height=100, +) diff --git a/altair/examples/attribute_syntax/bump_chart.py b/altair/examples/attribute_syntax/bump_chart.py new file mode 100644 index 000000000..03f88c8ac --- /dev/null +++ b/altair/examples/attribute_syntax/bump_chart.py @@ -0,0 +1,29 @@ +""" +Bump Chart +---------- +This example shows a bump chart. The data is first grouped into six-month +intervals using pandas. The ranks are computed by Altair using a +window transform. +""" +# category: line charts + +import altair as alt +from vega_datasets import data +import pandas as pd + +stocks = data.stocks() +source = stocks.groupby([pd.Grouper(key="date", freq="6M"),"symbol"]).mean().reset_index() + +alt.Chart(source).mark_line(point=True).encode( + x=alt.X("date:O").timeUnit("yearmonth").title("date"), + y="rank:O", + color=alt.Color("symbol:N") +).transform_window( + rank="rank()", + sort=[alt.SortField("price", order="descending")], + groupby=["date"] +).properties( + title="Bump Chart for Stock Prices", + width=600, + height=150, +) diff --git a/altair/examples/attribute_syntax/candlestick_chart.py b/altair/examples/attribute_syntax/candlestick_chart.py new file mode 100644 index 000000000..47e713abb --- /dev/null +++ b/altair/examples/attribute_syntax/candlestick_chart.py @@ -0,0 +1,40 @@ +""" +Candlestick Chart +================= +A candlestick chart inspired from `Protovis `_. +This example shows the performance of the Chicago Board Options Exchange `Volatility Index `_ (VIX) +in the summer of 2009. The thick bar represents the opening and closing prices, +while the thin bar shows intraday high and low prices; if the index closed higher on a given day, the bars are colored green rather than red. +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.ohlc() + +open_close_color = alt.condition( + "datum.open <= datum.close", + alt.value("#06982d"), + alt.value("#ae1325") +) + +base = alt.Chart(source).encode( + alt.X('date:T') + .axis(format='%m/%d', labelAngle=-45) + .title('Date in 2009'), + color=open_close_color +) + +rule = base.mark_rule().encode( + alt.Y('low:Q') + .title('Price') + .scale(zero=False), + alt.Y2('high:Q') +) + +bar = base.mark_bar().encode( + alt.Y('open:Q'), + alt.Y2('close:Q') +) + +rule + bar diff --git a/altair/examples/attribute_syntax/co2_concentration.py b/altair/examples/attribute_syntax/co2_concentration.py new file mode 100644 index 000000000..e82f830d6 --- /dev/null +++ b/altair/examples/attribute_syntax/co2_concentration.py @@ -0,0 +1,64 @@ +""" +Atmospheric CO2 Concentration +----------------------------- +This example is a fully developed line chart that uses a window transformation. +It was inspired by `Gregor Aisch's work at datawrapper +`_. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.co2_concentration.url + +base = alt.Chart( + source, + title="Carbon Dioxide in the Atmosphere" +).transform_calculate( + year="year(datum.Date)" +).transform_calculate( + decade="floor(datum.year / 10)" +).transform_calculate( + scaled_date="(datum.year % 10) + (month(datum.Date)/12)" +).transform_window( + first_date='first_value(scaled_date)', + last_date='last_value(scaled_date)', + sort=[{"field": "scaled_date", "order": "ascending"}], + groupby=['decade'], + frame=[None, None] +).transform_calculate( + end=( + "datum.first_date === datum.scaled_date ? 'first'" + ": datum.last_date === datum.scaled_date ? 'last'" + ": null" + ) +).encode( + alt.X("scaled_date:Q") + .title("Year into Decade") + .axis(tickCount=11), + alt.Y("CO2:Q") + .title("CO2 concentration in ppm") + .scale(zero=False) +) + +line = base.mark_line().encode( + alt.Color("decade:O") + .scale(scheme="magma") + .legend(None) +) + +text = base.encode(text="year:N") + +start_year = text.transform_filter( + alt.datum.end == 'first' +).mark_text(baseline="top") + +end_year = text.transform_filter( + alt.datum.end == 'last' +).mark_text(baseline="bottom") + +(line + start_year + end_year).configure_text( + align="left", + dx=1, + dy=3 +).properties(width=600, height=375) diff --git a/altair/examples/attribute_syntax/comet_chart.py b/altair/examples/attribute_syntax/comet_chart.py new file mode 100644 index 000000000..b8edff751 --- /dev/null +++ b/altair/examples/attribute_syntax/comet_chart.py @@ -0,0 +1,44 @@ +""" +Comet Chart +----------- +Inspired by `Zan Armstrong's comet chart `_ +this plot uses ``mark_trail`` to visualize change of grouped data over time. +A more elaborate example and explanation of creating comet charts in Altair +is shown in `this blogpost `_. +""" +# category: advanced calculations + +import altair as alt +import vega_datasets + +alt.Chart( + vega_datasets.data.barley.url, + title='Barley Yield comparison between 1932 and 1931' +).mark_trail().encode( + alt.X('year:O').title(None), + alt.Y('variety:N').title('Variety'), + alt.Size('yield:Q') + .scale(range=[0, 12]) + .legend(values=[20, 60]) + .title('Barley Yield (bushels/acre)'), + alt.Color('delta:Q') + .scale(domainMid=0) + .title('Yield Delta (%)'), + alt.Tooltip(['year:O', 'yield:Q']), + alt.Column('site:N').title('Site') +).transform_pivot( + "year", + value="yield", + groupby=["variety", "site"] +).transform_fold( + ["1931", "1932"], + as_=["year", "yield"] +).transform_calculate( + calculate="datum['1932'] - datum['1931']", + as_="delta" +).configure_legend( + orient='bottom', + direction='horizontal' +).configure_view( + stroke=None +) diff --git a/altair/examples/attribute_syntax/connected_scatterplot.py b/altair/examples/attribute_syntax/connected_scatterplot.py new file mode 100644 index 000000000..a5902841c --- /dev/null +++ b/altair/examples/attribute_syntax/connected_scatterplot.py @@ -0,0 +1,18 @@ +""" +Connected Scatter Plot (Lines with Custom Paths) +------------------------------------------------ + +This example show how the order encoding can be used to draw a custom path. The dataset tracks miles driven per capita along with gas prices annually from 1956 to 2010. +It is based on Hannah Fairfield's article 'Driving Shifts Into Reverse'. See https://archive.nytimes.com/www.nytimes.com/imagepages/2010/05/02/business/02metrics.html for the original. +""" +# category: scatter plots +import altair as alt +from vega_datasets import data + +source = data.driving() + +alt.Chart(source).mark_line(point=True).encode( + alt.X('miles').scale(zero=False), + alt.Y('gas').scale(zero=False), + order='year' +) diff --git a/altair/examples/attribute_syntax/density_stack.py b/altair/examples/attribute_syntax/density_stack.py new file mode 100644 index 000000000..56b0161f1 --- /dev/null +++ b/altair/examples/attribute_syntax/density_stack.py @@ -0,0 +1,35 @@ +""" +Stacked Density Estimates +------------------------- +To plot a stacked graph of estimates, use a shared ``extent`` and a fixed +number of subdivision ``steps`` to ensure that the points for each area align +well. Density estimates of measurements for each iris flower feature are plot +in a stacked method. In addition, setting ``counts`` to true multiplies the +densities by the number of data points in each group, preserving proportional +differences. +""" +# category: distributions + +import altair as alt +from vega_datasets import data + +source = data.iris() + +alt.Chart(source).transform_fold( + ['petalWidth', + 'petalLength', + 'sepalWidth', + 'sepalLength'], + as_ = ['Measurement_type', 'value'] +).transform_density( + density='value', + bandwidth=0.3, + groupby=['Measurement_type'], + extent= [0, 8], + counts = True, + steps=200 +).mark_area().encode( + alt.X('value:Q'), + alt.Y('density:Q').stack('zero'), + alt.Color('Measurement_type:N') +).properties(width=400, height=100) diff --git a/altair/examples/attribute_syntax/diverging_stacked_bar_chart.py b/altair/examples/attribute_syntax/diverging_stacked_bar_chart.py new file mode 100644 index 000000000..19ddc1d13 --- /dev/null +++ b/altair/examples/attribute_syntax/diverging_stacked_bar_chart.py @@ -0,0 +1,363 @@ +""" +Diverging Stacked Bar Chart +--------------------------- +This example shows a diverging stacked bar chart for sentiments towards a set of eight questions, displayed as percentages with neutral responses straddling the 0% mark. +""" +# category: bar charts +import altair as alt + +source = alt.pd.DataFrame([ + { + "question": "Question 1", + "type": "Strongly disagree", + "value": 24, + "percentage": 0.7, + "percentage_start": -19.1, + "percentage_end": -18.4 + }, + { + "question": "Question 1", + "type": "Disagree", + "value": 294, + "percentage": 9.1, + "percentage_start": -18.4, + "percentage_end": -9.2 + }, + { + "question": "Question 1", + "type": "Neither agree nor disagree", + "value": 594, + "percentage": 18.5, + "percentage_start": -9.2, + "percentage_end": 9.2 + }, + { + "question": "Question 1", + "type": "Agree", + "value": 1927, + "percentage": 59.9, + "percentage_start": 9.2, + "percentage_end": 69.2 + }, + { + "question": "Question 1", + "type": "Strongly agree", + "value": 376, + "percentage": 11.7, + "percentage_start": 69.2, + "percentage_end": 80.9 + }, + + { + "question": "Question 2", + "type": "Strongly disagree", + "value": 2, + "percentage": 18.2, + "percentage_start": -36.4, + "percentage_end": -18.2 + }, + { + "question": "Question 2", + "type": "Disagree", + "value": 2, + "percentage": 18.2, + "percentage_start": -18.2, + "percentage_end": 0 + }, + { + "question": "Question 2", + "type": "Neither agree nor disagree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 2", + "type": "Agree", + "value": 7, + "percentage": 63.6, + "percentage_start": 0, + "percentage_end": 63.6 + }, + { + "question": "Question 2", + "type": "Strongly agree", + "value": 11, + "percentage": 0, + "percentage_start": 63.6, + "percentage_end": 63.6 + }, + + { + "question": "Question 3", + "type": "Strongly disagree", + "value": 2, + "percentage": 20, + "percentage_start": -30, + "percentage_end": -10 + }, + { + "question": "Question 3", + "type": "Disagree", + "value": 0, + "percentage": 0, + "percentage_start": -10, + "percentage_end": -10 + }, + { + "question": "Question 3", + "type": "Neither agree nor disagree", + "value": 2, + "percentage": 20, + "percentage_start": -10, + "percentage_end": 10 + }, + { + "question": "Question 3", + "type": "Agree", + "value": 4, + "percentage": 40, + "percentage_start": 10, + "percentage_end": 50 + }, + { + "question": "Question 3", + "type": "Strongly agree", + "value": 2, + "percentage": 20, + "percentage_start": 50, + "percentage_end": 70 + }, + + { + "question": "Question 4", + "type": "Strongly disagree", + "value": 0, + "percentage": 0, + "percentage_start": -15.6, + "percentage_end": -15.6 + }, + { + "question": "Question 4", + "type": "Disagree", + "value": 2, + "percentage": 12.5, + "percentage_start": -15.6, + "percentage_end": -3.1 + }, + { + "question": "Question 4", + "type": "Neither agree nor disagree", + "value": 1, + "percentage": 6.3, + "percentage_start": -3.1, + "percentage_end": 3.1 + }, + { + "question": "Question 4", + "type": "Agree", + "value": 7, + "percentage": 43.8, + "percentage_start": 3.1, + "percentage_end": 46.9 + }, + { + "question": "Question 4", + "type": "Strongly agree", + "value": 6, + "percentage": 37.5, + "percentage_start": 46.9, + "percentage_end": 84.4 + }, + + { + "question": "Question 5", + "type": "Strongly disagree", + "value": 0, + "percentage": 0, + "percentage_start": -10.4, + "percentage_end": -10.4 + }, + { + "question": "Question 5", + "type": "Disagree", + "value": 1, + "percentage": 4.2, + "percentage_start": -10.4, + "percentage_end": -6.3 + }, + { + "question": "Question 5", + "type": "Neither agree nor disagree", + "value": 3, + "percentage": 12.5, + "percentage_start": -6.3, + "percentage_end": 6.3 + }, + { + "question": "Question 5", + "type": "Agree", + "value": 16, + "percentage": 66.7, + "percentage_start": 6.3, + "percentage_end": 72.9 + }, + { + "question": "Question 5", + "type": "Strongly agree", + "value": 4, + "percentage": 16.7, + "percentage_start": 72.9, + "percentage_end": 89.6 + }, + + { + "question": "Question 6", + "type": "Strongly disagree", + "value": 1, + "percentage": 6.3, + "percentage_start": -18.8, + "percentage_end": -12.5 + }, + { + "question": "Question 6", + "type": "Disagree", + "value": 1, + "percentage": 6.3, + "percentage_start": -12.5, + "percentage_end": -6.3 + }, + { + "question": "Question 6", + "type": "Neither agree nor disagree", + "value": 2, + "percentage": 12.5, + "percentage_start": -6.3, + "percentage_end": 6.3 + }, + { + "question": "Question 6", + "type": "Agree", + "value": 9, + "percentage": 56.3, + "percentage_start": 6.3, + "percentage_end": 62.5 + }, + { + "question": "Question 6", + "type": "Strongly agree", + "value": 3, + "percentage": 18.8, + "percentage_start": 62.5, + "percentage_end": 81.3 + }, + + { + "question": "Question 7", + "type": "Strongly disagree", + "value": 0, + "percentage": 0, + "percentage_start": -10, + "percentage_end": -10 + }, + { + "question": "Question 7", + "type": "Disagree", + "value": 0, + "percentage": 0, + "percentage_start": -10, + "percentage_end": -10 + }, + { + "question": "Question 7", + "type": "Neither agree nor disagree", + "value": 1, + "percentage": 20, + "percentage_start": -10, + "percentage_end": 10 + }, + { + "question": "Question 7", + "type": "Agree", + "value": 4, + "percentage": 80, + "percentage_start": 10, + "percentage_end": 90 + }, + { + "question": "Question 7", + "type": "Strongly agree", + "value": 0, + "percentage": 0, + "percentage_start": 90, + "percentage_end": 90 + }, + + { + "question": "Question 8", + "type": "Strongly disagree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 8", + "type": "Disagree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 8", + "type": "Neither agree nor disagree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 8", + "type": "Agree", + "value": 0, + "percentage": 0, + "percentage_start": 0, + "percentage_end": 0 + }, + { + "question": "Question 8", + "type": "Strongly agree", + "value": 2, + "percentage": 100, + "percentage_start": 0, + "percentage_end": 100 + } +]) + +color_scale = alt.Scale( + domain=[ + "Strongly disagree", + "Disagree", + "Neither agree nor disagree", + "Agree", + "Strongly agree" + ], + range=["#c30d24", "#f3a583", "#cccccc", "#94c6da", "#1770ab"] +) + +y_axis = alt.Axis( + title='Question', + offset=5, + ticks=False, + minExtent=60, + domain=False +) + +alt.Chart(source).mark_bar().encode( + x='percentage_start:Q', + x2='percentage_end:Q', + y=alt.Y('question:N').axis(y_axis), + color=alt.Color('type:N').title('Response').scale(color_scale), +) diff --git a/altair/examples/attribute_syntax/donut_chart.py b/altair/examples/attribute_syntax/donut_chart.py new file mode 100644 index 000000000..a734825da --- /dev/null +++ b/altair/examples/attribute_syntax/donut_chart.py @@ -0,0 +1,21 @@ +""" +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 `_. +""" +# 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="value", + color="category:N", +) diff --git a/altair/examples/attribute_syntax/errorbars_with_ci.py b/altair/examples/attribute_syntax/errorbars_with_ci.py new file mode 100644 index 000000000..af950a45e --- /dev/null +++ b/altair/examples/attribute_syntax/errorbars_with_ci.py @@ -0,0 +1,24 @@ +""" +Error Bars with Confidence Interval +====================================== +This example shows how to show error bars using confidence intervals. +The confidence intervals are computed internally in vega by a non-parametric +`bootstrap of the mean `_. +""" +# category: uncertainties and trends +import altair as alt +from vega_datasets import data + +source = data.barley() + +error_bars = alt.Chart(source).mark_errorbar(extent='ci').encode( + alt.X('yield').scale(zero=False), + alt.Y('variety') +) + +points = alt.Chart(source).mark_point(filled=True, color='black').encode( + x=alt.X('mean(yield)'), + y=alt.Y('variety'), +) + +error_bars + points diff --git a/altair/examples/attribute_syntax/errorbars_with_std.py b/altair/examples/attribute_syntax/errorbars_with_std.py new file mode 100644 index 000000000..d20c154b9 --- /dev/null +++ b/altair/examples/attribute_syntax/errorbars_with_std.py @@ -0,0 +1,23 @@ +""" +Error Bars with Standard Deviation +---------------------------------- +This example shows how to show error bars with standard deviation using crop yields data of different +in the years of 1930s. +""" +# category: uncertainties and trends +import altair as alt +from vega_datasets import data + +source = data.barley() + +error_bars = alt.Chart(source).mark_errorbar(extent='stdev').encode( + x=alt.X('yield').scale(zero=False), + y=alt.Y('variety') +) + +points = alt.Chart(source).mark_point(filled=True, color='black').encode( + x=alt.X('mean(yield)'), + y=alt.Y('variety'), +) + +error_bars + points diff --git a/altair/examples/attribute_syntax/falkensee.py b/altair/examples/attribute_syntax/falkensee.py new file mode 100644 index 000000000..b5d01b86e --- /dev/null +++ b/altair/examples/attribute_syntax/falkensee.py @@ -0,0 +1,77 @@ +""" +Population of Falkensee from 1875 to 2014 +----------------------------------------- +This example is a reproduction of the Falkensee plot found in the Vega-Lite examples. +""" +# category: case studies +import altair as alt + +source = [ + {"year": "1875", "population": 1309}, + {"year": "1890", "population": 1558}, + {"year": "1910", "population": 4512}, + {"year": "1925", "population": 8180}, + {"year": "1933", "population": 15915}, + {"year": "1939", "population": 24824}, + {"year": "1946", "population": 28275}, + {"year": "1950", "population": 29189}, + {"year": "1964", "population": 29881}, + {"year": "1971", "population": 26007}, + {"year": "1981", "population": 24029}, + {"year": "1985", "population": 23340}, + {"year": "1989", "population": 22307}, + {"year": "1990", "population": 22087}, + {"year": "1991", "population": 22139}, + {"year": "1992", "population": 22105}, + {"year": "1993", "population": 22242}, + {"year": "1994", "population": 22801}, + {"year": "1995", "population": 24273}, + {"year": "1996", "population": 25640}, + {"year": "1997", "population": 27393}, + {"year": "1998", "population": 29505}, + {"year": "1999", "population": 32124}, + {"year": "2000", "population": 33791}, + {"year": "2001", "population": 35297}, + {"year": "2002", "population": 36179}, + {"year": "2003", "population": 36829}, + {"year": "2004", "population": 37493}, + {"year": "2005", "population": 38376}, + {"year": "2006", "population": 39008}, + {"year": "2007", "population": 39366}, + {"year": "2008", "population": 39821}, + {"year": "2009", "population": 40179}, + {"year": "2010", "population": 40511}, + {"year": "2011", "population": 40465}, + {"year": "2012", "population": 40905}, + {"year": "2013", "population": 41258}, + {"year": "2014", "population": 41777}, +] + +source2 = [ + {"start": "1933", "end": "1945", "event": "Nazi Rule"}, + {"start": "1948", "end": "1989", "event": "GDR (East Germany)"}, +] + + +source = alt.pd.DataFrame(source) +source2 = alt.pd.DataFrame(source2) + + +line = alt.Chart(source).mark_line(color="#333").encode( + alt.X("year:T").axis(format="%Y").title("Year"), + alt.Y("population").title("Population"), +) + +point = line.mark_point(color="#333") + +rect = alt.Chart(source2).mark_rect().encode( + x="start:T", + x2="end:T", + color=alt.Color("event:N").title("Event") +) + +(rect + line + point).properties( + title="Population of Falkensee from 1875 to 2014", + width=500, + height=300 +) diff --git a/altair/examples/attribute_syntax/gapminder_bubble_plot.py b/altair/examples/attribute_syntax/gapminder_bubble_plot.py new file mode 100644 index 000000000..839212885 --- /dev/null +++ b/altair/examples/attribute_syntax/gapminder_bubble_plot.py @@ -0,0 +1,18 @@ +""" +Gapminder Bubble Plot +===================== +This example shows how to make a bubble plot showing the correlation between +health and income for 187 countries in the world (modified from an example +in Lisa Charlotte Rost's blog post `'One Chart, Twelve Charting Libraries' `_. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.gapminder_health_income.url + +alt.Chart(source).mark_circle().encode( + alt.X('income:Q').scale(type='log'), + alt.Y('health:Q').scale(zero=False), + size='population:Q' +) diff --git a/altair/examples/attribute_syntax/groupby-map.py b/altair/examples/attribute_syntax/groupby-map.py new file mode 100644 index 000000000..20f0817e6 --- /dev/null +++ b/altair/examples/attribute_syntax/groupby-map.py @@ -0,0 +1,36 @@ +""" +Grouped Points with Proportional Symbols Map +============================================ +This is a layered geographic visualization that groups points by state. +""" +# category: maps +import altair as alt +from vega_datasets import data + +airports = data.airports.url +states = alt.topo_feature(data.us_10m.url, feature='states') + +# US states background +background = alt.Chart(states).mark_geoshape( + fill='lightgray', + stroke='white' +).properties( + width=500, + height=300 +).project('albersUsa') + +# Airports grouped by state +points = alt.Chart(airports, title='Number of airports in US').transform_aggregate( + latitude='mean(latitude)', + longitude='mean(longitude)', + count='count()', + groupby=['state'] +).mark_circle().encode( + longitude='longitude:Q', + latitude='latitude:Q', + size=alt.Size('count:Q').title('Number of Airports'), + color=alt.value('steelblue'), + tooltip=['state:N','count:Q'] +) + +background + points diff --git a/altair/examples/attribute_syntax/grouped_bar_chart2.py b/altair/examples/attribute_syntax/grouped_bar_chart2.py new file mode 100644 index 000000000..671f83e44 --- /dev/null +++ b/altair/examples/attribute_syntax/grouped_bar_chart2.py @@ -0,0 +1,22 @@ +""" +Grouped Bar Chart with xOffset +------------------------------ +Like :ref:`gallery_grouped_bar_chart`, this example shows a grouped bar chart. Whereas :ref:`gallery_grouped_bar_chart` used the ``column`` encoding channel, this example uses the ``xOffset`` encoding channel. This is adapted from a corresponding Vega-Lite Example: +`Grouped Bar Chart `_. +""" +# category: bar charts +import altair as alt +import pandas as pd + +source = pd.DataFrame({ + "Category":list("AAABBBCCC"), + "Group":list("xyzxyzxyz"), + "Value":[0.1, 0.6, 0.9, 0.7, 0.2, 1.1, 0.6, 0.1, 0.2] +}) + +alt.Chart(source).mark_bar().encode( + x="Category:N", + y="Value:Q", + xOffset="Group:N", + color="Group:N" +) diff --git a/altair/examples/attribute_syntax/grouped_bar_chart_with_error_bars.py b/altair/examples/attribute_syntax/grouped_bar_chart_with_error_bars.py new file mode 100644 index 000000000..4ef796f12 --- /dev/null +++ b/altair/examples/attribute_syntax/grouped_bar_chart_with_error_bars.py @@ -0,0 +1,25 @@ +""" +Grouped Bar Chart with Error Bars +--------------------------------- +This example shows a grouped bar chart with error bars. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source = data.barley() + +bars = alt.Chart().mark_bar().encode( + x='year:O', + y=alt.Y('mean(yield):Q').title('Mean Yield'), + color='year:N', +) + +error_bars = alt.Chart().mark_errorbar(extent='ci').encode( + x='year:O', + y='yield:Q' +) + +alt.layer(bars, error_bars, data=source).facet( + column='site:N' +) diff --git a/altair/examples/attribute_syntax/hexbins.py b/altair/examples/attribute_syntax/hexbins.py new file mode 100644 index 000000000..26f3890a0 --- /dev/null +++ b/altair/examples/attribute_syntax/hexbins.py @@ -0,0 +1,46 @@ +""" +Hexbin Chart +------------ +This example shows a hexbin chart. +""" +# category: tables +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +# Size of the hexbins +size = 15 +# Count of distinct x features +xFeaturesCount = 12 +# Count of distinct y features +yFeaturesCount = 7 +# Name of the x field +xField = 'date' +# Name of the y field +yField = 'date' + +# the shape of a hexagon +hexagon = "M0,-2.3094010768L2,-1.1547005384 2,1.1547005384 0,2.3094010768 -2,1.1547005384 -2,-1.1547005384Z" + +alt.Chart(source).mark_point(size=size**2, shape=hexagon).encode( + alt.X('xFeaturePos:Q') + .title('Month') + .axis(grid=False, tickOpacity=0, domainOpacity=0), + alt.Y('day(' + yField + '):O') + .title('Weekday') + .axis(labelPadding=20, tickOpacity=0, domainOpacity=0), + stroke=alt.value('black'), + strokeWidth=alt.value(0.2), + fill=alt.Color('mean(temp_max):Q').scale(scheme='darkblue'), + tooltip=['month(' + xField + '):O', 'day(' + yField + '):O', 'mean(temp_max):Q'] +).transform_calculate( + # This field is required for the hexagonal X-Offset + xFeaturePos='(day(datum.' + yField + ') % 2) / 2 + month(datum.' + xField + ')' +).properties( + # Exact scaling factors to make the hexbins fit + width=size * xFeaturesCount * 2, + height=size * yFeaturesCount * 1.7320508076, # 1.7320508076 is approx. sin(60°)*2 +).configure_view( + strokeWidth=0 +) diff --git a/altair/examples/attribute_syntax/histogram_heatmap.py b/altair/examples/attribute_syntax/histogram_heatmap.py new file mode 100644 index 000000000..c697d1dd7 --- /dev/null +++ b/altair/examples/attribute_syntax/histogram_heatmap.py @@ -0,0 +1,16 @@ +""" +2D Histogram Heatmap +-------------------- +This example shows how to make a heatmap from binned quantitative data. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +alt.Chart(source).mark_rect().encode( + alt.X('IMDB_Rating:Q').bin(maxbins=60), + alt.Y('Rotten_Tomatoes_Rating:Q').bin(maxbins=40), + alt.Color('count():Q').scale(scheme='greenblue') +) diff --git a/altair/examples/attribute_syntax/histogram_responsive.py b/altair/examples/attribute_syntax/histogram_responsive.py new file mode 100644 index 000000000..e8ce16cb6 --- /dev/null +++ b/altair/examples/attribute_syntax/histogram_responsive.py @@ -0,0 +1,34 @@ +""" +Histogram with Responsive Bins +------------------------------ +This shows an example of a histogram with bins that are responsive to a +selection domain. Click and drag on the bottom panel to see the bins +change on the top panel. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.flights_5k.url + +brush = alt.selection_interval(encodings=['x']) + +base = alt.Chart(source).transform_calculate( + time="hours(datum.date) + minutes(datum.date) / 60" +).mark_bar().encode( + y='count():Q' +).properties( + width=600, + height=100 +) + +alt.vconcat( + base.encode( + alt.X('time:Q') + .bin(maxbins=30, extent=brush) + .scale(domain=brush) + ), + base.encode( + alt.X('time:Q').bin(maxbins=30), + ).add_params(brush) +) diff --git a/altair/examples/attribute_syntax/histogram_scatterplot.py b/altair/examples/attribute_syntax/histogram_scatterplot.py new file mode 100644 index 000000000..6286b615e --- /dev/null +++ b/altair/examples/attribute_syntax/histogram_scatterplot.py @@ -0,0 +1,16 @@ +""" +2D Histogram Scatter Plot +------------------------- +This example shows how to make a 2d histogram scatter plot. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +alt.Chart(source).mark_circle().encode( + alt.X('IMDB_Rating:Q').bin(), + alt.Y('Rotten_Tomatoes_Rating:Q').bin(), + size='count()' +) diff --git a/altair/examples/attribute_syntax/histogram_with_a_global_mean_overlay.py b/altair/examples/attribute_syntax/histogram_with_a_global_mean_overlay.py new file mode 100644 index 000000000..bcb91a216 --- /dev/null +++ b/altair/examples/attribute_syntax/histogram_with_a_global_mean_overlay.py @@ -0,0 +1,24 @@ +""" +Histogram with a Global Mean Overlay +------------------------------------ +This example shows a histogram with a global mean overlay. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +base = alt.Chart(source) + +bar = base.mark_bar().encode( + alt.X('IMDB_Rating:Q').bin().axis(None), + y='count()' +) + +rule = base.mark_rule(color='red').encode( + x='mean(IMDB_Rating):Q', + size=alt.value(5) +) + +bar + rule diff --git a/altair/examples/attribute_syntax/horizon_graph.py b/altair/examples/attribute_syntax/horizon_graph.py new file mode 100644 index 000000000..d2f534a73 --- /dev/null +++ b/altair/examples/attribute_syntax/horizon_graph.py @@ -0,0 +1,41 @@ +""" +Horizon Graph +------------- +This example shows how to make a Horizon Graph with 2 layers. (See https://idl.cs.washington.edu/papers/horizon/ for more details on Horizon Graphs.) +""" +# category: area charts +import altair as alt +import pandas as pd + +source = pd.DataFrame([ + {"x": 1, "y": 28}, {"x": 2, "y": 55}, + {"x": 3, "y": 43}, {"x": 4, "y": 91}, + {"x": 5, "y": 81}, {"x": 6, "y": 53}, + {"x": 7, "y": 19}, {"x": 8, "y": 87}, + {"x": 9, "y": 52}, {"x": 10, "y": 48}, + {"x": 11, "y": 24}, {"x": 12, "y": 49}, + {"x": 13, "y": 87}, {"x": 14, "y": 66}, + {"x": 15, "y": 17}, {"x": 16, "y": 27}, + {"x": 17, "y": 68}, {"x": 18, "y": 16}, + {"x": 19, "y": 49}, {"x": 20, "y": 15} +]) + +area1 = alt.Chart(source).mark_area( + clip=True, + interpolate='monotone', + opacity=0.6 +).encode( + alt.X('x').scale(zero=False, nice=False), + alt.Y('y').scale(domain=[0, 50]).title('y'), +).properties( + width=500, + height=75 +) + +area2 = area1.encode( + alt.Y('ny:Q').scale(domain=[0, 50]) +).transform_calculate( + "ny", alt.datum.y - 50 +) + +area1 + area2 diff --git a/altair/examples/attribute_syntax/interactive_cross_highlight.py b/altair/examples/attribute_syntax/interactive_cross_highlight.py new file mode 100644 index 000000000..f862cb973 --- /dev/null +++ b/altair/examples/attribute_syntax/interactive_cross_highlight.py @@ -0,0 +1,41 @@ +""" +Interactive Chart with Cross-Highlight +====================================== +This example shows an interactive chart where selections in one portion of +the chart affect what is shown in other panels. Click on the bar chart to +see a detail of the distribution in the upper panel. +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +source = data.movies.url + +pts = alt.selection(type="point", encodings=['x']) + +rect = alt.Chart(data.movies.url).mark_rect().encode( + alt.X('IMDB_Rating:Q').bin(), + alt.Y('Rotten_Tomatoes_Rating:Q').bin(), + alt.Color('count()').scale(scheme='greenblue').title('Total Records') +) + +circ = rect.mark_point().encode( + alt.ColorValue('grey'), + alt.Size('count()').title('Records in Selection') +).transform_filter( + pts +) + +bar = alt.Chart(source, width=550, height=200).mark_bar().encode( + x='Major_Genre:N', + y='count()', + color=alt.condition(pts, alt.ColorValue("steelblue"), alt.ColorValue("grey")) +).add_params(pts) + +alt.vconcat( + rect + circ, + bar +).resolve_legend( + color="independent", + size="independent" +) diff --git a/altair/examples/attribute_syntax/interactive_layered_crossfilter.py b/altair/examples/attribute_syntax/interactive_layered_crossfilter.py new file mode 100644 index 000000000..831365996 --- /dev/null +++ b/altair/examples/attribute_syntax/interactive_layered_crossfilter.py @@ -0,0 +1,42 @@ +""" +Interactive Crossfilter +======================= +This example shows a multi-panel view of the same data, where you can interactively +select a portion of the data in any of the panels to highlight that portion in any +of the other panels. +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +source = alt.UrlData( + data.flights_2k.url, + format={'parse': {'date': 'date'}} +) + +brush = alt.selection(type='interval', encodings=['x']) + +# Define the base chart, with the common parts of the +# background and highlights +base = alt.Chart(width=160, height=130).mark_bar().encode( + x=alt.X(alt.repeat('column')).bin(maxbins=20), + y='count()' +) + +# gray background with selection +background = base.encode( + color=alt.value('#ddd') +).add_params(brush) + +# blue highlights on the transformed data +highlight = base.transform_filter(brush) + +# layer the two charts & repeat +alt.layer( + background, + highlight, + data=source +).transform_calculate( + "time", + "hours(datum.date)" +).repeat(column=["distance", "delay", "time"]) diff --git a/altair/examples/attribute_syntax/interactive_legend.py b/altair/examples/attribute_syntax/interactive_legend.py new file mode 100644 index 000000000..80c47cf11 --- /dev/null +++ b/altair/examples/attribute_syntax/interactive_legend.py @@ -0,0 +1,23 @@ +""" +Interactive Legend +------------------ +The following shows how to create a chart with an interactive legend, by +binding the selection to ``"legend"``. Such a binding only works with +``selection_point`` when projected over a single field or encoding. +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +source = data.unemployment_across_industries.url + +selection = alt.selection_point(fields=['series'], bind='legend') + +alt.Chart(source).mark_area().encode( + alt.X('yearmonth(date):T').axis(domain=False, format='%Y', tickSize=0), + alt.Y('sum(count):Q').stack('center').axis(None), + alt.Color('series:N').scale(scheme='category20b'), + opacity=alt.condition(selection, alt.value(1), alt.value(0.2)) +).add_params( + selection +) diff --git a/altair/examples/attribute_syntax/interval_selection.py b/altair/examples/attribute_syntax/interval_selection.py new file mode 100644 index 000000000..f0aa303e9 --- /dev/null +++ b/altair/examples/attribute_syntax/interval_selection.py @@ -0,0 +1,29 @@ +""" +Interval Selection +================== + +This is an example of creating a stacked chart for which the domain of the +top chart can be selected by interacting with the bottom chart. +""" +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.sp500.url + +brush = alt.selection(type='interval', encodings=['x']) + +base = alt.Chart(source, width=600, height=200).mark_area().encode( + x = 'date:T', + y = 'price:Q' +) + +upper = base.encode( + alt.X('date:T').scale(domain=brush) +) + +lower = base.properties( + height=60 +).add_params(brush) + +upper & lower diff --git a/altair/examples/attribute_syntax/iowa_electricity.py b/altair/examples/attribute_syntax/iowa_electricity.py new file mode 100644 index 000000000..252cb0423 --- /dev/null +++ b/altair/examples/attribute_syntax/iowa_electricity.py @@ -0,0 +1,19 @@ +""" +Iowa's Renewable Energy Boom +---------------------------- +This example is a fully developed stacked chart using the sample dataset of Iowa's electricity sources. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.iowa_electricity() + +alt.Chart(source, title="Iowa's renewable energy boom").mark_area().encode( + alt.X("year:T").title("Year"), + alt.Y("net_generation:Q") + .title("Share of net generation") + .stack("normalize") + .axis(format=".0%"), + alt.Color("source:N").title("Electricity source") +) diff --git a/altair/examples/attribute_syntax/isotype.py b/altair/examples/attribute_syntax/isotype.py new file mode 100644 index 000000000..92850b729 --- /dev/null +++ b/altair/examples/attribute_syntax/isotype.py @@ -0,0 +1,81 @@ +''' +Isotype Visualization +===================== +Isotype Visualization shows the distribution of animals across UK and US. +Inspired by `Only An Ocean Between, 1943 `_. Population Live Stock, p.13. +This is adapted from Vega-Lite example https://vega.github.io/editor/#/examples/vega-lite/isotype_bar_chart +''' +# category: advanced calculations +import altair as alt +import pandas as pd + +source = pd.DataFrame([ + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'pigs'}, + {'country': 'Great Britain', 'animal': 'pigs'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'} + ]) + +domains = ['person', 'cattle', 'pigs', 'sheep'] + +shape_scale = alt.Scale( + domain=domains, + range=[ + 'M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 -0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7 0.6 0.9h-0.8c-0.4 0 -0.7 0.3 -0.7 0.6v1.9c0 0.3 0.3 0.6 0.6 0.6h0.2c0 0 0 0.1 0 0.1v1.9c0 0.3 0.2 0.6 0.3 0.6h1.3c0.2 0 0.3 -0.3 0.3 -0.6v-1.8c0 0 0 -0.1 0 -0.1h0.2c0.3 0 0.6 -0.3 0.6 -0.6v-2c0.2 -0.3 -0.1 -0.6 -0.4 -0.6z', + 'M4 -2c0 0 0.9 -0.7 1.1 -0.8c0.1 -0.1 -0.1 0.5 -0.3 0.7c-0.2 0.2 1.1 1.1 1.1 1.2c0 0.2 -0.2 0.8 -0.4 0.7c-0.1 0 -0.8 -0.3 -1.3 -0.2c-0.5 0.1 -1.3 1.6 -1.5 2c-0.3 0.4 -0.6 0.4 -0.6 0.4c0 0.1 0.3 1.7 0.4 1.8c0.1 0.1 -0.4 0.1 -0.5 0c0 0 -0.6 -1.9 -0.6 -1.9c-0.1 0 -0.3 -0.1 -0.3 -0.1c0 0.1 -0.5 1.4 -0.4 1.6c0.1 0.2 0.1 0.3 0.1 0.3c0 0 -0.4 0 -0.4 0c0 0 -0.2 -0.1 -0.1 -0.3c0 -0.2 0.3 -1.7 0.3 -1.7c0 0 -2.8 -0.9 -2.9 -0.8c-0.2 0.1 -0.4 0.6 -0.4 1c0 0.4 0.5 1.9 0.5 1.9l-0.5 0l-0.6 -2l0 -0.6c0 0 -1 0.8 -1 1c0 0.2 -0.2 1.3 -0.2 1.3c0 0 0.3 0.3 0.2 0.3c0 0 -0.5 0 -0.5 0c0 0 -0.2 -0.2 -0.1 -0.4c0 -0.1 0.2 -1.6 0.2 -1.6c0 0 0.5 -0.4 0.5 -0.5c0 -0.1 0 -2.7 -0.2 -2.7c-0.1 0 -0.4 2 -0.4 2c0 0 0 0.2 -0.2 0.5c-0.1 0.4 -0.2 1.1 -0.2 1.1c0 0 -0.2 -0.1 -0.2 -0.2c0 -0.1 -0.1 -0.7 0 -0.7c0.1 -0.1 0.3 -0.8 0.4 -1.4c0 -0.6 0.2 -1.3 0.4 -1.5c0.1 -0.2 0.6 -0.4 0.6 -0.4z', + 'M1.2 -2c0 0 0.7 0 1.2 0.5c0.5 0.5 0.4 0.6 0.5 0.6c0.1 0 0.7 0 0.8 0.1c0.1 0 0.2 0.2 0.2 0.2c0 0 -0.6 0.2 -0.6 0.3c0 0.1 0.4 0.9 0.6 0.9c0.1 0 0.6 0 0.6 0.1c0 0.1 0 0.7 -0.1 0.7c-0.1 0 -1.2 0.4 -1.5 0.5c-0.3 0.1 -1.1 0.5 -1.1 0.7c-0.1 0.2 0.4 1.2 0.4 1.2l-0.4 0c0 0 -0.4 -0.8 -0.4 -0.9c0 -0.1 -0.1 -0.3 -0.1 -0.3l-0.2 0l-0.5 1.3l-0.4 0c0 0 -0.1 -0.4 0 -0.6c0.1 -0.1 0.3 -0.6 0.3 -0.7c0 0 -0.8 0 -1.5 -0.1c-0.7 -0.1 -1.2 -0.3 -1.2 -0.2c0 0.1 -0.4 0.6 -0.5 0.6c0 0 0.3 0.9 0.3 0.9l-0.4 0c0 0 -0.4 -0.5 -0.4 -0.6c0 -0.1 -0.2 -0.6 -0.2 -0.5c0 0 -0.4 0.4 -0.6 0.4c-0.2 0.1 -0.4 0.1 -0.4 0.1c0 0 -0.1 0.6 -0.1 0.6l-0.5 0l0 -1c0 0 0.5 -0.4 0.5 -0.5c0 -0.1 -0.7 -1.2 -0.6 -1.4c0.1 -0.1 0.1 -1.1 0.1 -1.1c0 0 -0.2 0.1 -0.2 0.1c0 0 0 0.9 0 1c0 0.1 -0.2 0.3 -0.3 0.3c-0.1 0 0 -0.5 0 -0.9c0 -0.4 0 -0.4 0.2 -0.6c0.2 -0.2 0.6 -0.3 0.8 -0.8c0.3 -0.5 1 -0.6 1 -0.6z', + 'M-4.1 -0.5c0.2 0 0.2 0.2 0.5 0.2c0.3 0 0.3 -0.2 0.5 -0.2c0.2 0 0.2 0.2 0.4 0.2c0.2 0 0.2 -0.2 0.5 -0.2c0.2 0 0.2 0.2 0.4 0.2c0.2 0 0.2 -0.2 0.4 -0.2c0.1 0 0.2 0.2 0.4 0.1c0.2 0 0.2 -0.2 0.4 -0.3c0.1 0 0.1 -0.1 0.4 0c0.3 0 0.3 -0.4 0.6 -0.4c0.3 0 0.6 -0.3 0.7 -0.2c0.1 0.1 1.4 1 1.3 1.4c-0.1 0.4 -0.3 0.3 -0.4 0.3c-0.1 0 -0.5 -0.4 -0.7 -0.2c-0.3 0.2 -0.1 0.4 -0.2 0.6c-0.1 0.1 -0.2 0.2 -0.3 0.4c0 0.2 0.1 0.3 0 0.5c-0.1 0.2 -0.3 0.2 -0.3 0.5c0 0.3 -0.2 0.3 -0.3 0.6c-0.1 0.2 0 0.3 -0.1 0.5c-0.1 0.2 -0.1 0.2 -0.2 0.3c-0.1 0.1 0.3 1.1 0.3 1.1l-0.3 0c0 0 -0.3 -0.9 -0.3 -1c0 -0.1 -0.1 -0.2 -0.3 -0.2c-0.2 0 -0.3 0.1 -0.4 0.4c0 0.3 -0.2 0.8 -0.2 0.8l-0.3 0l0.3 -1c0 0 0.1 -0.6 -0.2 -0.5c-0.3 0.1 -0.2 -0.1 -0.4 -0.1c-0.2 -0.1 -0.3 0.1 -0.4 0c-0.2 -0.1 -0.3 0.1 -0.5 0c-0.2 -0.1 -0.1 0 -0.3 0.3c-0.2 0.3 -0.4 0.3 -0.4 0.3l0.2 1.1l-0.3 0l-0.2 -1.1c0 0 -0.4 -0.6 -0.5 -0.4c-0.1 0.3 -0.1 0.4 -0.3 0.4c-0.1 -0.1 -0.2 1.1 -0.2 1.1l-0.3 0l0.2 -1.1c0 0 -0.3 -0.1 -0.3 -0.5c0 -0.3 0.1 -0.5 0.1 -0.7c0.1 -0.2 -0.1 -1 -0.2 -1.1c-0.1 -0.2 -0.2 -0.8 -0.2 -0.8c0 0 -0.1 -0.5 0.4 -0.8z' + ] +) + +color_scale = alt.Scale( + domain=domains, + range=['rgb(162,160,152)', 'rgb(194,81,64)', 'rgb(93,93,93)', 'rgb(91,131,149)'] +) + +alt.Chart(source).mark_point(filled=True, opacity=1, size=100).encode( + alt.X('x:O').axis(None), + alt.Y('animal:O').axis(None), + alt.Row('country:N').header(title=''), + alt.Shape('animal:N').legend(None).scale(shape_scale), + alt.Color('animal:N').legend(None).scale(color_scale), +).transform_window( + x='rank()', + groupby=['country', 'animal'] +).properties( + width=550, + height=140 +) diff --git a/altair/examples/attribute_syntax/isotype_emoji.py b/altair/examples/attribute_syntax/isotype_emoji.py new file mode 100644 index 000000000..313af8e82 --- /dev/null +++ b/altair/examples/attribute_syntax/isotype_emoji.py @@ -0,0 +1,66 @@ +''' +Isotype Visualization with Emoji +================================ +Isotype Visualization shows the distribution of animals across UK and US, using unicode emoji +marks rather than custom SVG paths (see https://altair-viz.github.io/gallery/isotype.html). +This is adapted from Vega-Lite example https://vega.github.io/vega-lite/examples/isotype_bar_chart_emoji.html. +''' +# category:advanced calculations +import altair as alt +import pandas as pd + +source = pd.DataFrame([ + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'cattle'}, + {'country': 'Great Britain', 'animal': 'pigs'}, + {'country': 'Great Britain', 'animal': 'pigs'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'Great Britain', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'cattle'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'pigs'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'}, + {'country': 'United States', 'animal': 'sheep'} + ]) + + +alt.Chart(source).mark_text(size=45, baseline='middle').encode( + alt.X('x:O').axis(None), + alt.Y('animal:O').axis(None), + alt.Row('country:N').title(''), + alt.Text('emoji:N') +).transform_calculate( + emoji="{'cattle': '🐄', 'pigs': '🐖', 'sheep': '🐏'}[datum.animal]" +).transform_window( + x='rank()', + groupby=['country', 'animal'] +).properties( + width=550, + height=140 +) diff --git a/altair/examples/attribute_syntax/isotype_grid.py b/altair/examples/attribute_syntax/isotype_grid.py new file mode 100644 index 000000000..d0a9b6d4b --- /dev/null +++ b/altair/examples/attribute_syntax/isotype_grid.py @@ -0,0 +1,38 @@ +""" +Isotype Grid +------------ +This example is a grid of isotype figures. +""" +# category: advanced calculations +import altair as alt +import pandas as pd + +data = pd.DataFrame([dict(id=i) for i in range(1, 101)]) + +person = ( + "M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 " + "-0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7 0.6 " + "0.9h-0.8c-0.4 0 -0.7 0.3 -0.7 0.6v1.9c0 0.3 0.3 0.6 " + "0.6 0.6h0.2c0 0 0 0.1 0 0.1v1.9c0 0.3 0.2 0.6 0.3 " + "0.6h1.3c0.2 0 0.3 -0.3 0.3 -0.6v-1.8c0 0 0 -0.1 0 " + "-0.1h0.2c0.3 0 0.6 -0.3 0.6 -0.6v-2c0.2 -0.3 -0.1 " + "-0.6 -0.4 -0.6z" +) + +alt.Chart(data).transform_calculate( + row="ceil(datum.id/10)" +).transform_calculate( + col="datum.id - datum.row*10" +).mark_point( + filled=True, + size=50 +).encode( + alt.X("col:O").axis(None), + alt.Y("row:O").axis(None), + alt.ShapeValue(person) +).properties( + width=400, + height=400 +).configure_view( + strokeWidth=0 +) diff --git a/altair/examples/attribute_syntax/lasagna_plot.py b/altair/examples/attribute_syntax/lasagna_plot.py new file mode 100644 index 000000000..0da7c44fd --- /dev/null +++ b/altair/examples/attribute_syntax/lasagna_plot.py @@ -0,0 +1,31 @@ +""" +Lasagna Plot (Dense Time-Series Heatmap) +---------------------------------------- +""" +# category: tables +import altair as alt +from vega_datasets import data + +source = data.stocks() + +color_condition = alt.condition( + "month(datum.value) == 1 && date(datum.value) == 1", + alt.value("black"), + alt.value(None), +) + +alt.Chart(source, width=300, height=100).transform_filter( + alt.datum.symbol != "GOOG" +).mark_rect().encode( + alt.X("yearmonthdate(date):O") + .title("Time") + .axis( + format="%Y", + labelAngle=0, + labelOverlap=False, + labelColor=color_condition, + tickColor=color_condition, + ), + alt.Y("symbol:N").title(None), + alt.Color("sum(price)").title("Price") +) diff --git a/altair/examples/attribute_syntax/layered_area_chart.py b/altair/examples/attribute_syntax/layered_area_chart.py new file mode 100644 index 000000000..83eb51b75 --- /dev/null +++ b/altair/examples/attribute_syntax/layered_area_chart.py @@ -0,0 +1,16 @@ +""" +Layered Area Chart +------------------ +This example shows a layered area chart. +""" +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.iowa_electricity() + +alt.Chart(source).mark_area(opacity=0.3).encode( + x="year:T", + y=alt.Y("net_generation:Q").stack(None), + color="source:N" +) diff --git a/altair/examples/attribute_syntax/layered_bar_chart.py b/altair/examples/attribute_syntax/layered_bar_chart.py new file mode 100644 index 000000000..ba485fea7 --- /dev/null +++ b/altair/examples/attribute_syntax/layered_bar_chart.py @@ -0,0 +1,16 @@ +""" +Layered Bar Chart +----------------- +This example shows a segmented bar chart that is layered rather than stacked. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source = data.iowa_electricity() + +alt.Chart(source).mark_bar(opacity=0.7).encode( + x='year:O', + y=alt.Y('net_generation:Q').stack(None), + color="source", +) diff --git a/altair/examples/attribute_syntax/layered_chart_with_dual_axis.py b/altair/examples/attribute_syntax/layered_chart_with_dual_axis.py new file mode 100644 index 000000000..d14fbca57 --- /dev/null +++ b/altair/examples/attribute_syntax/layered_chart_with_dual_axis.py @@ -0,0 +1,28 @@ +""" +Layered chart with Dual-Axis +---------------------------- +This example shows how to create a second independent y axis. +""" +# category: advanced calculations + +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +base = alt.Chart(source).encode( + alt.X('month(date):T').axis(title=None) +) + +area = base.mark_area(opacity=0.3, color='#57A44C').encode( + alt.Y('average(temp_max)').title('Avg. Temperature (°C)', titleColor='#57A44C'), + alt.Y2('average(temp_min)') +) + +line = base.mark_line(stroke='#5276A7', interpolate='monotone').encode( + alt.Y('average(precipitation)').title('Precipitation (inches)', titleColor='#5276A7') +) + +alt.layer(area, line).resolve_scale( + y='independent' +) diff --git a/altair/examples/attribute_syntax/layered_heatmap_text.py b/altair/examples/attribute_syntax/layered_heatmap_text.py new file mode 100644 index 000000000..7a61c08cb --- /dev/null +++ b/altair/examples/attribute_syntax/layered_heatmap_text.py @@ -0,0 +1,41 @@ +""" +Text over a Heatmap +------------------- + +An example of a layered chart of text over a heatmap using the cars dataset. +""" +# category: tables +import altair as alt +from vega_datasets import data + +source = data.cars() + +# Configure common options. We specify the aggregation +# as a transform here so we can reuse it in both layers. +base = alt.Chart(source).transform_aggregate( + mean_horsepower='mean(Horsepower)', + groupby=['Origin', 'Cylinders'] +).encode( + alt.X('Cylinders:O'), + alt.Y('Origin:O'), +) + +# Configure heatmap +heatmap = base.mark_rect().encode( + alt.Color('mean_horsepower:Q') + .scale(scheme='viridis') + .title("Mean of Horsepower") +) + +# Configure text +text = base.mark_text(baseline='middle').encode( + alt.Text('mean_horsepower:Q', format=".0f"), + color=alt.condition( + alt.datum.mean_horsepower > 150, + alt.value('black'), + alt.value('white') + ) +) + +# Draw the chart +heatmap + text diff --git a/altair/examples/attribute_syntax/layered_histogram.py b/altair/examples/attribute_syntax/layered_histogram.py new file mode 100644 index 000000000..62c7dccf6 --- /dev/null +++ b/altair/examples/attribute_syntax/layered_histogram.py @@ -0,0 +1,29 @@ +""" +Layered Histogram +================= +This example shows how to use opacity to make a layered histogram in Altair. +""" +# category: distributions +import pandas as pd +import altair as alt +import numpy as np +np.random.seed(42) + +# Generating Data +source = pd.DataFrame({ + 'Trial A': np.random.normal(0, 0.8, 1000), + 'Trial B': np.random.normal(-2, 1, 1000), + 'Trial C': np.random.normal(3, 2, 1000) +}) + +alt.Chart(source).transform_fold( + ['Trial A', 'Trial B', 'Trial C'], + as_=['Experiment', 'Measurement'] +).mark_bar( + opacity=0.3, + binSpacing=0 +).encode( + alt.X('Measurement:Q').bin(maxbins=100), + alt.Y('count()').stack(None), + alt.Color('Experiment:N') +) diff --git a/altair/examples/attribute_syntax/line_chart_with_color_datum.py b/altair/examples/attribute_syntax/line_chart_with_color_datum.py new file mode 100644 index 000000000..77cad9574 --- /dev/null +++ b/altair/examples/attribute_syntax/line_chart_with_color_datum.py @@ -0,0 +1,23 @@ +""" +Line Chart with Datum for Color +------------------------------- +An example of using ``repeat`` inside ``datum`` to color a multi-series line chart. +This is adapted from this corresponding Vega-Lite Example: +`Repeat and Layer to Show Different Movie Measures `_. +""" +# category: line charts + +import altair as alt +from vega_datasets import data + +source = data.movies() + +alt.Chart(source).mark_line().encode( + alt.X("IMDB_Rating").bin(True), + 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"] +) diff --git a/altair/examples/attribute_syntax/line_chart_with_cumsum.py b/altair/examples/attribute_syntax/line_chart_with_cumsum.py new file mode 100644 index 000000000..ef3144fe1 --- /dev/null +++ b/altair/examples/attribute_syntax/line_chart_with_cumsum.py @@ -0,0 +1,24 @@ +""" +Line Chart with Cumulative Sum +------------------------------ +This chart creates a simple line chart from the cumulative sum of a fields. +""" +# category: line charts +import altair as alt +from vega_datasets import data + +source = data.wheat() + +alt.Chart(source, width=600).mark_line().transform_window( + # Sort the data chronologically + sort=[{'field': 'year'}], + # Include all previous records before the current record and none after + # (This is the default value so you could skip it and it would still work.) + frame=[None, 0], + # What to add up as you go + cumulative_wheat='sum(wheat)' +).encode( + x='year:O', + # Plot the calculated field created by the transformation + y='cumulative_wheat:Q' +) diff --git a/altair/examples/attribute_syntax/line_chart_with_custom_legend.py b/altair/examples/attribute_syntax/line_chart_with_custom_legend.py new file mode 100644 index 000000000..2ee60088e --- /dev/null +++ b/altair/examples/attribute_syntax/line_chart_with_custom_legend.py @@ -0,0 +1,40 @@ +""" +Line Chart with Custom Legend +----------------------------- +This example uses the argmax aggregation function in order to create a custom +legend for a line chart. +""" +# category: line charts +import altair as alt +from vega_datasets import data + + +source = data.stocks() + +base = alt.Chart(source).encode( + alt.Color("symbol").legend(None) +).transform_filter( + "datum.symbol !== 'IBM'" +).properties( + width=500 +) + +line = base.mark_line().encode(x="date", y="price") + + +last_price = base.mark_circle().encode( + alt.X("last_date['date']:T"), + alt.Y("last_date['price']:Q") +).transform_aggregate( + last_date="argmax(date)", + groupby=["symbol"] +) + +company_name = last_price.mark_text(align="left", dx=4).encode(text="symbol") + +chart = (line + last_price + company_name).encode( + x=alt.X().title("date"), + y=alt.Y().title("price") +) + +chart diff --git a/altair/examples/attribute_syntax/line_percent.py b/altair/examples/attribute_syntax/line_percent.py new file mode 100644 index 000000000..52e047034 --- /dev/null +++ b/altair/examples/attribute_syntax/line_percent.py @@ -0,0 +1,18 @@ +""" +Line Chart with Percent axis +---------------------------- +This example shows how to format the tick labels of the y-axis of a chart as percentages. +""" +# category: line charts +import altair as alt +from vega_datasets import data + +source = data.jobs.url + +alt.Chart(source).mark_line().encode( + alt.X('year:O'), + alt.Y('perc:Q').axis(format='%'), + alt.Color('sex:N') +).transform_filter( + alt.datum.job == 'Welder' +) diff --git a/altair/examples/attribute_syntax/line_with_ci.py b/altair/examples/attribute_syntax/line_with_ci.py new file mode 100644 index 000000000..744f453d0 --- /dev/null +++ b/altair/examples/attribute_syntax/line_with_ci.py @@ -0,0 +1,22 @@ +""" +Line Chart with Confidence Interval Band +---------------------------------------- +How to make a line chart with a bootstrapped 95% confidence interval band. +""" +# category: uncertainties and trends +import altair as alt +from vega_datasets import data + +source = data.cars() + +line = alt.Chart(source).mark_line().encode( + x='Year', + y='mean(Miles_per_Gallon)' +) + +band = alt.Chart(source).mark_errorband(extent='ci').encode( + x='Year', + y=alt.Y('Miles_per_Gallon').title('Miles/Gallon'), +) + +band + line diff --git a/altair/examples/line_with_last_value_labeled b/altair/examples/attribute_syntax/line_with_last_value_labeled.py similarity index 86% rename from altair/examples/line_with_last_value_labeled rename to altair/examples/attribute_syntax/line_with_last_value_labeled.py index 8793cab29..1bc108a08 100644 --- a/altair/examples/line_with_last_value_labeled +++ b/altair/examples/attribute_syntax/line_with_last_value_labeled.py @@ -14,7 +14,7 @@ chart = alt.Chart(source).transform_filter( alt.datum.symbol != "IBM" # A reducation of the dataset to clarify our example. Not required. ).encode( - color=alt.Color("symbol", legend=None) + alt.Color("symbol").legend(None) ) # Draw the line @@ -25,8 +25,8 @@ # Use the `argmax` aggregate to limit the dataset to the final value label = chart.encode( - x=alt.X('max(date):T'), - y=alt.Y('price:Q', aggregate=alt.ArgmaxDef(argmax='date')), + x='max(date):T', + y=alt.Y('price:Q').aggregate(argmax='date'), text='symbol' ) diff --git a/altair/examples/attribute_syntax/line_with_log_scale.py b/altair/examples/attribute_syntax/line_with_log_scale.py new file mode 100644 index 000000000..740a670cb --- /dev/null +++ b/altair/examples/attribute_syntax/line_with_log_scale.py @@ -0,0 +1,15 @@ +""" +Line Chart with Logarithmic Scale +--------------------------------- +How to make a line chart on a `Logarithmic scale `_. +""" +# category: line charts +import altair as alt +from vega_datasets import data + +source = data.population() + +alt.Chart(source).mark_line().encode( + x='year:O', + y=alt.Y('sum(people)').scale(type="log") +) diff --git a/altair/examples/attribute_syntax/london_tube.py b/altair/examples/attribute_syntax/london_tube.py new file mode 100644 index 000000000..b19ef9acc --- /dev/null +++ b/altair/examples/attribute_syntax/london_tube.py @@ -0,0 +1,51 @@ +""" +London Tube Lines +================= +This example shows the London tube lines against the background of the +borough boundaries. It is based on the vega-lite example at +https://vega.github.io/vega-lite/examples/geo_layer_line_london.html. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +boroughs = alt.topo_feature(data.londonBoroughs.url, 'boroughs') +tubelines = alt.topo_feature(data.londonTubeLines.url, 'line') +centroids = data.londonCentroids.url + +background = alt.Chart(boroughs, width=700, height=500).mark_geoshape( + stroke='white', + strokeWidth=2 +).encode( + color=alt.value('#eee'), +) + +labels = alt.Chart(centroids).mark_text().encode( + longitude='cx:Q', + latitude='cy:Q', + text='bLabel:N', + size=alt.value(8), + opacity=alt.value(0.6) +).transform_calculate( + "bLabel", "indexof (datum.name,' ') > 0 ? substring(datum.name,0,indexof(datum.name, ' ')) : datum.name" +) + +line_scale = alt.Scale(domain=["Bakerloo", "Central", "Circle", "District", "DLR", + "Hammersmith & City", "Jubilee", "Metropolitan", "Northern", + "Piccadilly", "Victoria", "Waterloo & City"], + range=["rgb(137,78,36)", "rgb(220,36,30)", "rgb(255,206,0)", + "rgb(1,114,41)", "rgb(0,175,173)", "rgb(215,153,175)", + "rgb(106,114,120)", "rgb(114,17,84)", "rgb(0,0,0)", + "rgb(0,24,168)", "rgb(0,160,226)", "rgb(106,187,170)"]) + +lines = alt.Chart(tubelines).mark_geoshape( + filled=False, + strokeWidth=2 +).encode( + alt.Color('id:N') + .title(None) + .legend(orient='bottom-right', offset=0) + .scale(line_scale) +) + +background + labels + lines diff --git a/altair/examples/attribute_syntax/mosaic_with_labels.py b/altair/examples/attribute_syntax/mosaic_with_labels.py new file mode 100644 index 000000000..d77ed05ab --- /dev/null +++ b/altair/examples/attribute_syntax/mosaic_with_labels.py @@ -0,0 +1,85 @@ +""" +Mosaic Chart with Labels +------------------------ +""" +# category: tables + +import altair as alt +from vega_datasets import data + +source = data.cars() + +base = ( + alt.Chart(source) + .transform_aggregate(count_="count()", groupby=["Origin", "Cylinders"]) + .transform_stack( + stack="count_", + as_=["stack_count_Origin1", "stack_count_Origin2"], + offset="normalize", + sort=[alt.SortField("Origin", "ascending")], + groupby=[], + ) + .transform_window( + x="min(stack_count_Origin1)", + x2="max(stack_count_Origin2)", + rank_Cylinders="dense_rank()", + distinct_Cylinders="distinct(Cylinders)", + groupby=["Origin"], + frame=[None, None], + sort=[alt.SortField("Cylinders", "ascending")], + ) + .transform_window( + rank_Origin="dense_rank()", + frame=[None, None], + sort=[alt.SortField("Origin", "ascending")], + ) + .transform_stack( + stack="count_", + groupby=["Origin"], + as_=["y", "y2"], + offset="normalize", + sort=[alt.SortField("Cylinders", "ascending")], + ) + .transform_calculate( + ny="datum.y + (datum.rank_Cylinders - 1) * datum.distinct_Cylinders * 0.01 / 3", + ny2="datum.y2 + (datum.rank_Cylinders - 1) * datum.distinct_Cylinders * 0.01 / 3", + nx="datum.x + (datum.rank_Origin - 1) * 0.01", + nx2="datum.x2 + (datum.rank_Origin - 1) * 0.01", + xc="(datum.nx+datum.nx2)/2", + yc="(datum.ny+datum.ny2)/2", + ) +) + + +rect = base.mark_rect().encode( + x=alt.X("nx:Q").axis(None), + x2="nx2", + y="ny:Q", + y2="ny2", + color=alt.Color("Origin:N").legend(None), + opacity=alt.Opacity("Cylinders:Q").legend(None), + tooltip=["Origin:N", "Cylinders:Q"], +) + + +text = base.mark_text(baseline="middle").encode( + alt.X("xc:Q").axis(None), + alt.Y("yc:Q").title("Cylinders"), + text="Cylinders:N" +) + +mosaic = rect + text + +origin_labels = base.mark_text(baseline="middle", align="center").encode( + alt.X("min(xc):Q").title("Origin").axis(orient="top"), + alt.Color("Origin").legend(None), + text="Origin", +) + +( + (origin_labels & mosaic) + .resolve_scale(x="shared") + .configure_view(stroke="") + .configure_concat(spacing=10) + .configure_axis(domain=False, ticks=False, labels=False, grid=False) +) diff --git a/altair/examples/attribute_syntax/multifeature_scatter_plot.py b/altair/examples/attribute_syntax/multifeature_scatter_plot.py new file mode 100644 index 000000000..164b647bd --- /dev/null +++ b/altair/examples/attribute_syntax/multifeature_scatter_plot.py @@ -0,0 +1,17 @@ +""" +Multifeature Scatter Plot +========================= +This example shows how to make a scatter plot with multiple feature encodings. +""" +# category: scatter plots +import altair as alt +from vega_datasets import data + +source = data.iris() + +alt.Chart(source).mark_circle().encode( + alt.X('sepalLength').scale(zero=False), + alt.Y('sepalWidth').scale(zero=False, padding=1), + color='species', + size='petalWidth' +) diff --git a/altair/examples/attribute_syntax/multiline_highlight.py b/altair/examples/attribute_syntax/multiline_highlight.py new file mode 100644 index 000000000..0e3f7781b --- /dev/null +++ b/altair/examples/attribute_syntax/multiline_highlight.py @@ -0,0 +1,38 @@ +""" +Multi-Line Highlight +==================== +This multi-line chart uses an invisible Voronoi tessellation to handle mouseover to +identify the nearest point and then highlight the line on which the point falls. +It is adapted from the Vega-Lite example found at +https://bl.ocks.org/amitkaps/fe4238e716db53930b2f1a70d3401701 +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +source = data.stocks() + +highlight = alt.selection( + type='point', on='mouseover', + fields=['symbol'], nearest=True +) + +base = alt.Chart(source).encode( + x='date:T', + y='price:Q', + color='symbol:N' +) + +points = base.mark_circle().encode( + opacity=alt.value(0) +).add_params( + highlight +).properties( + width=600 +) + +lines = base.mark_line().encode( + size=alt.condition(~highlight, alt.value(1), alt.value(3)) +) + +points + lines diff --git a/altair/examples/attribute_syntax/multiline_tooltip.py b/altair/examples/attribute_syntax/multiline_tooltip.py new file mode 100644 index 000000000..4dfa8d2c0 --- /dev/null +++ b/altair/examples/attribute_syntax/multiline_tooltip.py @@ -0,0 +1,69 @@ +""" +Multi-Line Tooltip +================== +This example shows how you can use selections and layers to create a +tooltip-like behavior tied to the x position of the cursor. +If you are looking for more standard tooltips, it is recommended to use the +tooltip encoding channel as shown in the +`Scatter Plot With Tooltips `_ +example. + +The following example employs a little trick to isolate the x-position of the +cursor: we add some transparent points with only an x encoding (no y encoding) +and tie a *nearest* selection to these, tied to the "x" field. +""" +# category: interactive charts +import altair as alt +import pandas as pd +import numpy as np + +np.random.seed(42) +source = pd.DataFrame( + np.cumsum(np.random.randn(100, 3), 0).round(2), + columns=['A', 'B', 'C'], index=pd.RangeIndex(100, name='x') +) +source = source.reset_index().melt('x', var_name='category', value_name='y') + +# Create a selection that chooses the nearest point & selects based on x-value +nearest = alt.selection(type='point', nearest=True, on='mouseover', + fields=['x'], empty=False) + +# The basic line +line = alt.Chart(source).mark_line(interpolate='basis').encode( + x='x:Q', + y='y:Q', + color='category:N' +) + +# Transparent selectors across the chart. This is what tells us +# the x-value of the cursor +selectors = alt.Chart(source).mark_point().encode( + x='x:Q', + opacity=alt.value(0), +).add_params( + nearest +) + +# Draw points on the line, and highlight based on selection +points = line.mark_point().encode( + opacity=alt.condition(nearest, alt.value(1), alt.value(0)) +) + +# Draw text labels near the points, and highlight based on selection +text = line.mark_text(align='left', dx=5, dy=-5).encode( + text=alt.condition(nearest, 'y:Q', alt.value(' ')) +) + +# Draw a rule at the location of the selection +rules = alt.Chart(source).mark_rule(color='gray').encode( + x='x:Q', +).transform_filter( + nearest +) + +# Put the five layers into a chart and bind the data +alt.layer( + line, selectors, points, rules, text +).properties( + width=600, height=300 +) diff --git a/altair/examples/attribute_syntax/multiple_interactions.py b/altair/examples/attribute_syntax/multiple_interactions.py new file mode 100644 index 000000000..3f85ab5aa --- /dev/null +++ b/altair/examples/attribute_syntax/multiple_interactions.py @@ -0,0 +1,98 @@ +""" +Multiple Interactions +===================== +This example shows how multiple user inputs can be layered onto a chart. The four inputs have functionality as follows: + +* Dropdown: Filters the movies by genre +* Radio Buttons: Highlights certain films by Worldwide Gross +* Mouse Drag and Scroll: Zooms the x and y scales to allow for panning. + + + +""" +# category: interactive charts +import altair as alt +from vega_datasets import data + +movies = alt.UrlData( + data.movies.url, + format=alt.DataFormat(parse={"Release_Date":"date"}) +) +ratings = ['G', 'NC-17', 'PG', 'PG-13', 'R'] +genres = [ + 'Action', 'Adventure', 'Black Comedy', 'Comedy', + 'Concert/Performance', 'Documentary', 'Drama', 'Horror', 'Musical', + 'Romantic Comedy', 'Thriller/Suspense', 'Western' +] + +base = alt.Chart(movies, width=200, height=200).mark_point(filled=True).transform_calculate( + Rounded_IMDB_Rating = "floor(datum.IMDB_Rating)", + Hundred_Million_Production = "datum.Production_Budget > 100000000.0 ? 100 : 10", + Release_Year = "year(datum.Release_Date)" +).transform_filter( + alt.datum.IMDB_Rating > 0 +).transform_filter( + alt.FieldOneOfPredicate(field='MPAA_Rating', oneOf=ratings) +).encode( + x=alt.X('Worldwide_Gross:Q').scale(domain=(100000,10**9), clamp=True), + y='IMDB_Rating:Q', + tooltip="Title:N" +) + +# A slider filter +year_slider = alt.binding_range(min=1969, max=2018, step=1) +slider_selection = alt.selection_point( + bind=year_slider, + fields=['Release_Year'], + name="Release Year_" +) + + +filter_year = base.add_params( + slider_selection +).transform_filter( + slider_selection +).properties(title="Slider Filtering") + +# A dropdown filter +genre_dropdown = alt.binding_select(options=genres) +genre_select = alt.selection_point(fields=['Major_Genre'], bind=genre_dropdown, name="Genre") + +filter_genres = base.add_params( + genre_select +).transform_filter( + genre_select +).properties(title="Dropdown Filtering") + +#color changing marks +rating_radio = alt.binding_radio(options=ratings) + +rating_select = alt.selection_point(fields=['MPAA_Rating'], bind=rating_radio, name="Rating") +rating_color_condition = alt.condition( + rating_select, + alt.Color('MPAA_Rating:N').legend(None), + alt.value('lightgray') +) + +highlight_ratings = base.add_params( + rating_select +).encode( + color=rating_color_condition +).properties(title="Radio Button Highlighting") + +# Boolean selection for format changes +input_checkbox = alt.binding_checkbox() +checkbox_selection = alt.selection_point(bind=input_checkbox, name="Big Budget Films") + +size_checkbox_condition = alt.condition(checkbox_selection, + alt.SizeValue(25), + alt.Size('Hundred_Million_Production:Q') + ) + +budget_sizing = base.add_params( + checkbox_selection +).encode( + size=size_checkbox_condition +).properties(title="Checkbox Formatting") + +( filter_year | filter_genres) & (highlight_ratings | budget_sizing ) diff --git a/altair/examples/attribute_syntax/natural_disasters.py b/altair/examples/attribute_syntax/natural_disasters.py new file mode 100644 index 000000000..31b50a151 --- /dev/null +++ b/altair/examples/attribute_syntax/natural_disasters.py @@ -0,0 +1,52 @@ +""" +Global Deaths from Natural Disasters +------------------------------------ +This example shows a proportional symbols visualization of deaths from natural disasters by year and type. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.disasters.url + +alt.Chart(source).transform_filter( + alt.datum.Entity != 'All natural disasters' +).mark_circle( + opacity=0.8, + stroke='black', + strokeWidth=1, + strokeOpacity=0.4 +).encode( + alt.X('Year:T') + .title(None) + .scale(domain=['1899','2018']), + alt.Y('Entity:N') + .title(None) + .sort(field="Deaths", op="sum", order='descending'), + alt.Size('Deaths:Q') + .scale(range=[0, 2500]) + .title('Deaths') + .legend(clipHeight=30, format='s'), + alt.Color('Entity:N').legend(None), + tooltip=[ + "Entity:N", + alt.Tooltip("Year:T", format='%Y'), + alt.Tooltip("Deaths:Q", format='~s') + ], +).properties( + width=450, + height=320, + title=alt.TitleParams( + text="Global Deaths from Natural Disasters (1900-2017)", + subtitle="The size of the bubble represents the total death count per year, by type of disaster", + anchor='start' + ) +).configure_axisY( + domain=False, + ticks=False, + offset=10 +).configure_axisX( + grid=False, +).configure_view( + stroke=None +) diff --git a/altair/examples/attribute_syntax/normalized_stacked_area_chart.py b/altair/examples/attribute_syntax/normalized_stacked_area_chart.py new file mode 100644 index 000000000..5973d7174 --- /dev/null +++ b/altair/examples/attribute_syntax/normalized_stacked_area_chart.py @@ -0,0 +1,16 @@ +""" +Normalized Stacked Area Chart +----------------------------- +This example shows how to make a normalized stacked area chart. +""" +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.iowa_electricity() + +alt.Chart(source).mark_area().encode( + x="year:T", + y=alt.Y("net_generation:Q").stack("normalize"), + color="source:N" +) diff --git a/altair/examples/attribute_syntax/normalized_stacked_bar_chart.py b/altair/examples/attribute_syntax/normalized_stacked_bar_chart.py new file mode 100644 index 000000000..71e48b9a1 --- /dev/null +++ b/altair/examples/attribute_syntax/normalized_stacked_bar_chart.py @@ -0,0 +1,16 @@ +""" +Normalized Stacked Bar Chart +---------------------------- +This is an example of a normalized stacked bar chart using data which contains crop yields over different regions and different years in the 1930s. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source = data.barley() + +alt.Chart(source).mark_bar().encode( + x=alt.X('sum(yield)').stack("normalize"), + y='variety', + color='site' +) diff --git a/altair/examples/attribute_syntax/pacman_chart.py b/altair/examples/attribute_syntax/pacman_chart.py new file mode 100644 index 000000000..c6c6f98c6 --- /dev/null +++ b/altair/examples/attribute_syntax/pacman_chart.py @@ -0,0 +1,17 @@ +""" +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 + +alt.Chart().mark_arc(color="gold").encode( + theta=alt.ThetaDatum((5 / 8) * np.pi).scale(None), + theta2=alt.Theta2Datum((19 / 8) * np.pi), + radius=alt.RadiusDatum(100).scale(None), +) diff --git a/altair/examples/attribute_syntax/parallel_coordinates.py b/altair/examples/attribute_syntax/parallel_coordinates.py new file mode 100644 index 000000000..f5d7cbd6e --- /dev/null +++ b/altair/examples/attribute_syntax/parallel_coordinates.py @@ -0,0 +1,28 @@ +""" +Parallel Coordinates +-------------------- +A `Parallel Coordinates `_ +chart is a chart that lets you visualize the individual data points by drawing +a single line for each of them. +Such a chart can be created in Altair by first transforming the data into a +suitable representation. +This example shows a parallel coordinates chart with the Iris dataset. +""" +# category: advanced calculations + +import altair as alt +from vega_datasets import data + +source = data.iris() + +alt.Chart(source, width=500).transform_window( + index='count()' +).transform_fold( + ['petalLength', 'petalWidth', 'sepalLength', 'sepalWidth'] +).mark_line().encode( + x='key:N', + y='value:Q', + color='species:N', + detail='index:N', + opacity=alt.value(0.5) +) diff --git a/altair/examples/attribute_syntax/percentage_of_total.py b/altair/examples/attribute_syntax/percentage_of_total.py new file mode 100644 index 000000000..addb9fd84 --- /dev/null +++ b/altair/examples/attribute_syntax/percentage_of_total.py @@ -0,0 +1,23 @@ +""" +Calculating Percentage of Total +------------------------------- +This chart demonstrates how to use a joinaggregate transform to display +data values as a percentage of total. +""" +# category: bar charts +import altair as alt +import pandas as pd + +source = pd.DataFrame({ + 'Activity': ['Sleeping', 'Eating', 'TV', 'Work', 'Exercise'], + 'Time': [8, 2, 4, 8, 2] +}) + +alt.Chart(source).transform_joinaggregate( + TotalTime='sum(Time)', +).transform_calculate( + PercentOfTotal="datum.Time / datum.TotalTime" +).mark_bar().encode( + alt.X('PercentOfTotal:Q').axis(format='.0%'), + y='Activity:N' +) diff --git a/altair/examples/attribute_syntax/pie_chart.py b/altair/examples/attribute_syntax/pie_chart.py new file mode 100644 index 000000000..afc7515cb --- /dev/null +++ b/altair/examples/attribute_syntax/pie_chart.py @@ -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 `_. +""" +# 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="value", + color="category" +) diff --git a/altair/examples/attribute_syntax/pie_chart_with_labels.py b/altair/examples/attribute_syntax/pie_chart_with_labels.py new file mode 100644 index 000000000..d82860853 --- /dev/null +++ b/altair/examples/attribute_syntax/pie_chart_with_labels.py @@ -0,0 +1,25 @@ +""" +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 `_. +""" +# 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( + alt.Theta("value:Q").stack(True), + 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 diff --git a/altair/examples/attribute_syntax/poly_fit_regression.py b/altair/examples/attribute_syntax/poly_fit_regression.py new file mode 100644 index 000000000..8842b9d98 --- /dev/null +++ b/altair/examples/attribute_syntax/poly_fit_regression.py @@ -0,0 +1,37 @@ +""" +Polynomial Fit Plot with Regression Transform +============================================= +This example shows how to overlay data with multiple fitted polynomials using +the regression transform. +""" +# category: uncertainties and trends + +import numpy as np +import pandas as pd +import altair as alt + +# Generate some random data +rng = np.random.RandomState(1) +x = rng.rand(40) ** 2 +y = 10 - 1.0 / (x + 0.1) + rng.randn(40) +source = pd.DataFrame({"x": x, "y": y}) + +# Define the degree of the polynomial fits +degree_list = [1, 3, 5] + +base = alt.Chart(source).mark_circle(color="black").encode( + alt.X("x"), + alt.Y("y") +) + +polynomial_fit = [ + base.transform_regression( + "x", "y", method="poly", order=order, as_=["x", str(order)] + ) + .mark_line() + .transform_fold([str(order)], as_=["degree", "y"]) + .encode(alt.Color("degree:N")) + for order in degree_list +] + +alt.layer(base, *polynomial_fit) diff --git a/altair/examples/attribute_syntax/pyramid.py b/altair/examples/attribute_syntax/pyramid.py new file mode 100644 index 000000000..82aa854d0 --- /dev/null +++ b/altair/examples/attribute_syntax/pyramid.py @@ -0,0 +1,23 @@ +""" +Pyramid Pie Chart +----------------- +Altair reproduction of http://robslink.com/SAS/democd91/pyramid_pie.htm +""" +# category: case studies +import altair as alt +import pandas as pd + +category = ['Sky', 'Shady side of a pyramid', 'Sunny side of a pyramid'] +color = ["#416D9D", "#674028", "#DEAC58"] +df = pd.DataFrame({'category': category, 'value': [75, 10, 15]}) + +alt.Chart(df, width=150, height=150).mark_arc(outerRadius=80).encode( + alt.Theta('value:Q').scale(range=[2.356, 8.639]), + alt.Color('category:N') + .title(None) + .scale(domain=category, range=color) + .legend(orient='none', legendX=160, legendY=50), + order='value:Q' +).configure_view( + strokeOpacity=0 +) diff --git a/altair/examples/attribute_syntax/radial_chart.py b/altair/examples/attribute_syntax/radial_chart.py new file mode 100644 index 000000000..1f844c945 --- /dev/null +++ b/altair/examples/attribute_syntax/radial_chart.py @@ -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 `_. +""" +# 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( + alt.Theta("values:Q").stack(True), + alt.Radius("values").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 diff --git a/altair/examples/attribute_syntax/ranged_dot_plot.py b/altair/examples/attribute_syntax/ranged_dot_plot.py new file mode 100644 index 000000000..340eeed32 --- /dev/null +++ b/altair/examples/attribute_syntax/ranged_dot_plot.py @@ -0,0 +1,38 @@ +""" +Ranged Dot Plot +--------------- +This example shows a ranged dot plot to convey changing life expectancy for the five most populous countries (between 1955 and 2000). +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.countries.url + +chart = alt.Chart( + data=source +).transform_filter( + filter={"field": 'country', + "oneOf": ["China", "India", "United States", "Indonesia", "Brazil"]} +).transform_filter( + filter={'field': 'year', + "oneOf": [1955, 2000]} +) + +line = chart.mark_line(color='#db646f').encode( + x='life_expect:Q', + y='country:N', + detail='country:N' +) +# Add points for life expectancy in 1955 & 2000 +points = chart.mark_point( + size=100, + opacity=1, + filled=True +).encode( + x='life_expect:Q', + y='country:N', + color=alt.Color('year:O').scale(domain=[1955, 2000], range=['#e6959c', '#911a24']) +).interactive() + +(line + points) diff --git a/altair/examples/attribute_syntax/ridgeline_plot.py b/altair/examples/attribute_syntax/ridgeline_plot.py new file mode 100644 index 000000000..a04d6c566 --- /dev/null +++ b/altair/examples/attribute_syntax/ridgeline_plot.py @@ -0,0 +1,59 @@ +""" +Ridgeline plot +-------------- +A `Ridgeline plot `_ +chart is a chart that lets you visualize distribution of a numeric value for +several groups. + +Such a chart can be created in Altair by first transforming the data into a +suitable representation. + +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.seattle_weather.url + +step = 20 +overlap = 1 + +alt.Chart(source, height=step).transform_timeunit( + Month='month(date)' +).transform_joinaggregate( + mean_temp='mean(temp_max)', groupby=['Month'] +).transform_bin( + ['bin_max', 'bin_min'], 'temp_max' +).transform_aggregate( + value='count()', groupby=['Month', 'mean_temp', 'bin_min', 'bin_max'] +).transform_impute( + impute='value', groupby=['Month', 'mean_temp'], key='bin_min', value=0 +).mark_area( + interpolate='monotone', + fillOpacity=0.8, + stroke='lightgray', + strokeWidth=0.5 +).encode( + alt.X('bin_min:Q') + .bin(True) + .title('Maximum Daily Temperature (C)'), + alt.Y('value:Q') + .axis(None) + .scale(range=[step, -step * overlap]), + alt.Fill('mean_temp:Q') + .legend(None) + .scale(domain=[30, 5], scheme='redyellowblue') +).facet( + alt.Row('Month:T') + .title(None) + .header(labelAngle=0, labelAlign='right', format='%B') +).properties( + title='Seattle Weather', + bounds='flush' +).configure_facet( + spacing=0 +).configure_view( + stroke=None +).configure_title( + anchor='end' +) diff --git a/altair/examples/attribute_syntax/scatter_linked_table.py b/altair/examples/attribute_syntax/scatter_linked_table.py new file mode 100644 index 000000000..a822d4ef3 --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_linked_table.py @@ -0,0 +1,55 @@ +""" +Brushing Scatter Plot to Show Data on a Table +--------------------------------------------- +A scatter plot of the cars dataset, with data tables for horsepower, MPG, and origin. +The tables update to reflect the selection on the scatter plot. +""" +# category: scatter plots + +import altair as alt +from vega_datasets import data + +source = data.cars() + +# Brush for selection +brush = alt.selection_interval() + +# Scatter Plot +points = alt.Chart(source).mark_point().encode( + x='Horsepower:Q', + y='Miles_per_Gallon:Q', + color=alt.condition(brush, alt.value('steelblue'), alt.value('grey')) +).add_params(brush) + +# Base chart for data tables +ranked_text = alt.Chart(source).mark_text(align='right').encode( + y=alt.Y('row_number:O').axis(None) +).transform_filter( + brush +).transform_window( + row_number='row_number()' +).transform_filter( + 'datum.row_number < 15' +) + +# Data Tables +horsepower = ranked_text.encode(text='Horsepower:N').properties( + title=alt.TitleParams(text='Horsepower', align='right') +) +mpg = ranked_text.encode(text='Miles_per_Gallon:N').properties( + title=alt.TitleParams(text='MPG', align='right') +) +origin = ranked_text.encode(text='Origin:N').properties( + title=alt.TitleParams(text='Origin', align='right') +) +text = alt.hconcat(horsepower, mpg, origin) # Combine data tables + +# Build chart +alt.hconcat( + points, + text +).resolve_legend( + color="independent" +).configure_view( + stroke=None +) diff --git a/altair/examples/attribute_syntax/scatter_marginal_hist.py b/altair/examples/attribute_syntax/scatter_marginal_hist.py new file mode 100644 index 000000000..02ddc37fe --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_marginal_hist.py @@ -0,0 +1,48 @@ +""" +Facetted Scatter Plot with Marginal Histograms +---------------------------------------------- +This example demonstrates how to generate a facetted scatter plot, +with marginal facetted histograms, and how to share their respective +- x,some y-limits. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.iris() + +base = alt.Chart(source) + +xscale = alt.Scale(domain=(4.0, 8.0)) +yscale = alt.Scale(domain=(1.9, 4.55)) + +bar_args = {'opacity': .3, 'binSpacing': 0} + +points = base.mark_circle().encode( + alt.X('sepalLength').scale(xscale), + alt.Y('sepalWidth').scale(yscale), + color='species', +) + +top_hist = base.mark_bar(**bar_args).encode( + alt.X('sepalLength:Q') + # when using bins, the axis scale is set through + # the bin extent, so we do not specify the scale here + # (which would be ignored anyway) + .bin(maxbins=20, extent=xscale.domain) + .stack(None) + .title(''), + alt.Y('count()').stack(None).title(''), + alt.Color('species:N'), +).properties(height=60) + +right_hist = base.mark_bar(**bar_args).encode( + alt.Y('sepalWidth:Q') + .bin(maxbins=20, extent=yscale.domain) + .stack(None) + .title(''), + alt.X('count()').stack(None).title(''), + alt.Color('species:N'), +).properties(width=60) + +top_hist & (points | right_hist) diff --git a/altair/examples/attribute_syntax/scatter_with_layered_histogram.py b/altair/examples/attribute_syntax/scatter_with_layered_histogram.py new file mode 100644 index 000000000..995766ead --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_with_layered_histogram.py @@ -0,0 +1,61 @@ +""" +Interactive Scatter Plot and Linked Layered Histogram +===================================================== + +This example shows how to link a scatter plot and a histogram +together such that clicking on a point in the scatter plot will +isolate the distribution corresponding to that point, and vice versa. +""" +# category: interactive charts + +import altair as alt +import pandas as pd +import numpy as np + +# generate fake data +source = pd.DataFrame({ + 'gender': ['M']*1000 + ['F']*1000, + 'height':np.concatenate(( + np.random.normal(69, 7, 1000), np.random.normal(64, 6, 1000) + )), + 'weight': np.concatenate(( + np.random.normal(195.8, 144, 1000), np.random.normal(167, 100, 1000) + )), + 'age': np.concatenate(( + np.random.normal(45, 8, 1000), np.random.normal(51, 6, 1000) + )) + }) + +selector = alt.selection_point(fields=['gender']) + +color_scale = alt.Scale(domain=['M', 'F'], + range=['#1FC3AA', '#8624F5']) + +base = alt.Chart(source).properties( + width=250, + height=250 +).add_params(selector) + +points = base.mark_point(filled=True, size=200).encode( + x=alt.X('mean(height):Q').scale(domain=[0,84]), + y=alt.Y('mean(weight):Q').scale(domain=[0,250]), + color=alt.condition( + selector, + 'gender:N', + alt.value('lightgray'), + scale=color_scale), +) + +hists = base.mark_bar(opacity=0.5, thickness=100).encode( + x=alt.X('age') + .bin(step=5) # step keeps bin size the same + .scale(domain=[0,100]), + y=alt.Y('count()') + .stack(None) + .scale(domain=[0,350]), + color=alt.Color('gender:N', scale=color_scale) +).transform_filter( + selector +) + +points | hists diff --git a/altair/examples/attribute_syntax/scatter_with_minimap.py b/altair/examples/attribute_syntax/scatter_with_minimap.py new file mode 100644 index 000000000..0ad0c634c --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_with_minimap.py @@ -0,0 +1,44 @@ +""" +Scatter Plot with Minimap +------------------------- +This example shows how to create a miniature version of a plot +such that creating a selection in the miniature version +adjusts the axis limits in another, more detailed view. +""" +# category: scatter plots + +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +zoom = alt.selection_interval(encodings=["x", "y"]) + +minimap = ( + alt.Chart(source) + .mark_point() + .add_params(zoom) + .encode( + x="date:T", + y="temp_max:Q", + color=alt.condition(zoom, "weather", alt.value("lightgray")), + ) + .properties( + width=200, + height=200, + title="Minimap -- click and drag to zoom in the detail view", + ) +) + +detail = ( + alt.Chart(source) + .mark_point() + .encode( + alt.X("date:T").scale(domain={"param": zoom.name, "encoding": "x"}), + alt.Y("temp_max:Q").scale(domain={"param": zoom.name, "encoding": "y"}), + color="weather", + ) + .properties(width=600, height=400, title="Seattle weather -- detail view") +) + +detail | minimap diff --git a/altair/examples/attribute_syntax/scatter_with_rolling_mean.py b/altair/examples/attribute_syntax/scatter_with_rolling_mean.py new file mode 100644 index 000000000..914e32e4e --- /dev/null +++ b/altair/examples/attribute_syntax/scatter_with_rolling_mean.py @@ -0,0 +1,30 @@ +""" +Scatter Plot with Rolling Mean +------------------------------ +A scatter plot with a rolling mean overlay. In this example a 30 day window +is used to calculate the mean of the maximum temperature around each date. +""" +# category: scatter plots + +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +line = alt.Chart(source).mark_line( + color='red', + size=3 +).transform_window( + rolling_mean='mean(temp_max)', + frame=[-15, 15] +).encode( + x='date:T', + y='rolling_mean:Q' +) + +points = alt.Chart(source).mark_point().encode( + x='date:T', + y=alt.Y('temp_max:Q').title('Max Temp') +) + +points + line diff --git a/altair/examples/attribute_syntax/seattle_weather_interactive.py b/altair/examples/attribute_syntax/seattle_weather_interactive.py new file mode 100644 index 000000000..46b7448e4 --- /dev/null +++ b/altair/examples/attribute_syntax/seattle_weather_interactive.py @@ -0,0 +1,61 @@ +""" +Seattle Weather Interactive +=========================== +This chart provides an interactive exploration of Seattle weather over the +course of the year. It includes a one-axis brush selection to easily +see the distribution of weather types in a particular date range. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.seattle_weather() + +scale = alt.Scale( + domain=['sun', 'fog', 'drizzle', 'rain', 'snow'], + range=['#e7ba52', '#a7a7a7', '#aec7e8', '#1f77b4', '#9467bd'] +) +color = alt.Color('weather:N', scale=scale) + +# We create two selections: +# - a brush that is active on the top panel +# - a multi-click that is active on the bottom panel +brush = alt.selection_interval(encodings=['x']) +click = alt.selection_point(encodings=['color']) + +# Top panel is scatter plot of temperature vs time +points = alt.Chart().mark_point().encode( + alt.X('monthdate(date):T').title('Date'), + alt.Y('temp_max:Q') + .title('Maximum Daily Temperature (C)') + .scale(domain=[-5, 40]), + alt.Size('precipitation:Q').scale(range=[5, 200]), + color=alt.condition(brush, color, alt.value('lightgray')), +).properties( + width=550, + height=300 +).add_params( + brush +).transform_filter( + click +) + +# Bottom panel is a bar chart of weather type +bars = alt.Chart().mark_bar().encode( + x='count()', + y='weather:N', + color=alt.condition(click, color, alt.value('lightgray')), +).transform_filter( + brush +).properties( + width=550, +).add_params( + click +) + +alt.vconcat( + points, + bars, + data=source, + title="Seattle Weather: 2012-2015" +) diff --git a/altair/examples/attribute_syntax/select_detail.py b/altair/examples/attribute_syntax/select_detail.py new file mode 100644 index 000000000..4dead24c5 --- /dev/null +++ b/altair/examples/attribute_syntax/select_detail.py @@ -0,0 +1,65 @@ +""" +Selection Detail +================ +This example shows a selection that links two views of data: the left panel +contains one point per object, and the right panel contains one line per +object. Clicking on either the points or lines will select the corresponding +objects in both views of the data. + +The challenge lies in expressing such hierarchical data in a way that Altair +can handle. We do this by merging the data into a "long form" dataframe, and +aggregating identical metadata for the final plot. +""" +# category: interactive charts +import altair as alt +import pandas as pd +import numpy as np + +np.random.seed(0) + +n_objects = 20 +n_times = 50 + +# Create one (x, y) pair of metadata per object +locations = pd.DataFrame({ + 'id': range(n_objects), + 'x': np.random.randn(n_objects), + 'y': np.random.randn(n_objects) +}) + +# Create a 50-element time-series for each object +timeseries = pd.DataFrame(np.random.randn(n_times, n_objects).cumsum(0), + columns=locations['id'], + index=pd.RangeIndex(0, n_times, name='time')) + +# Melt the wide-form timeseries into a long-form view +timeseries = timeseries.reset_index().melt('time') + +# Merge the (x, y) metadata into the long-form view +timeseries['id'] = timeseries['id'].astype(int) # make merge not complain +data = pd.merge(timeseries, locations, on='id') + +# Data is prepared, now make a chart + +selector = alt.selection_point(fields=['id']) + +base = alt.Chart(data).properties( + width=250, + height=250 +).add_params(selector) + +points = base.mark_point(filled=True, size=200).encode( + x='mean(x)', + y='mean(y)', + color=alt.condition(selector, 'id:O', alt.value('lightgray'), legend=None), +) + +timeseries = base.mark_line().encode( + x='time', + y=alt.Y('value').scale(domain=(-15, 15)), + color=alt.Color('id:O').legend(None) +).transform_filter( + selector +) + +points | timeseries diff --git a/altair/examples/attribute_syntax/simple_scatter_with_errorbars.py b/altair/examples/attribute_syntax/simple_scatter_with_errorbars.py new file mode 100644 index 000000000..434e6adca --- /dev/null +++ b/altair/examples/attribute_syntax/simple_scatter_with_errorbars.py @@ -0,0 +1,43 @@ +""" +Simple Scatter Plot with Errorbars +---------------------------------- +A simple scatter plot of a data set with errorbars. +""" +# category: uncertainties and trends +import altair as alt +import pandas as pd +import numpy as np + +# generate some data points with uncertainties +np.random.seed(0) +x = [1, 2, 3, 4, 5] +y = np.random.normal(10, 0.5, size=len(x)) +yerr = 0.2 + +# set up data frame +source = pd.DataFrame({"x": x, "y": y, "yerr": yerr}) + +# the base chart +base = alt.Chart(source).transform_calculate( + ymin="datum.y-datum.yerr", + ymax="datum.y+datum.yerr" +) + +# generate the points +points = base.mark_point( + filled=True, + size=50, + color='black' +).encode( + alt.X('x').scale(domain=(0, 6)), + alt.Y('y').scale(zero=False) +) + +# generate the error bars +errorbars = base.mark_errorbar().encode( + x="x", + y="ymin:Q", + y2="ymax:Q" +) + +points + errorbars diff --git a/altair/examples/attribute_syntax/sorted_error_bars_with_ci.py b/altair/examples/attribute_syntax/sorted_error_bars_with_ci.py new file mode 100644 index 000000000..ebda26a99 --- /dev/null +++ b/altair/examples/attribute_syntax/sorted_error_bars_with_ci.py @@ -0,0 +1,33 @@ +""" +Sorted Error Bars showing Confidence Interval +============================================= +This example shows how to show error bars using confidence intervals, while also sorting the y-axis based on x-axis values. +""" +# category: advanced calculations + +import altair as alt +from vega_datasets import data + +source = data.barley() + +points = alt.Chart(source).mark_point( + filled=True, + color='black' +).encode( + x=alt.X('mean(yield)').title('Barley Yield'), + y=alt.Y('variety').sort( + field='yield', + op='mean', + order='descending' + ) +).properties( + width=400, + height=250 +) + +error_bars = points.mark_rule().encode( + x='ci0(yield)', + x2='ci1(yield)', +) + +points + error_bars diff --git a/altair/examples/attribute_syntax/stacked_bar_chart_sorted_segments.py b/altair/examples/attribute_syntax/stacked_bar_chart_sorted_segments.py new file mode 100644 index 000000000..2a189fedd --- /dev/null +++ b/altair/examples/attribute_syntax/stacked_bar_chart_sorted_segments.py @@ -0,0 +1,21 @@ +""" +Stacked Bar Chart with Sorted Segments +-------------------------------------- +This is an example of a stacked-bar chart with the segments of each bar resorted. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source = data.barley() + +alt.Chart(source).mark_bar().encode( + x='sum(yield)', + y='variety', + color='site', + order=alt.Order( + # Sort the segments of the bars by this field + 'site', + sort='ascending' + ) +) diff --git a/altair/examples/attribute_syntax/stacked_bar_chart_with_text.py b/altair/examples/attribute_syntax/stacked_bar_chart_with_text.py new file mode 100644 index 000000000..f2641e4e2 --- /dev/null +++ b/altair/examples/attribute_syntax/stacked_bar_chart_with_text.py @@ -0,0 +1,27 @@ +""" +Stacked Bar Chart with Text Overlay +=================================== +This example shows how to overlay text on a stacked bar chart. For both the +bar and text marks, we use the ``stack`` argument in the ``x`` encoding to +cause the values to be stacked horizontally. +""" +# category: bar charts +import altair as alt +from vega_datasets import data + +source=data.barley() + +bars = alt.Chart(source).mark_bar().encode( + x=alt.X('sum(yield):Q').stack('zero'), + y=alt.Y('variety:N'), + color=alt.Color('site') +) + +text = alt.Chart(source).mark_text(dx=-15, dy=3, color='white').encode( + x=alt.X('sum(yield):Q').stack('zero'), + y=alt.Y('variety:N'), + detail='site:N', + text=alt.Text('sum(yield):Q', format='.1f') +) + +bars + text diff --git a/altair/examples/attribute_syntax/stem_and_leaf.py b/altair/examples/attribute_syntax/stem_and_leaf.py new file mode 100644 index 000000000..9436d8eb2 --- /dev/null +++ b/altair/examples/attribute_syntax/stem_and_leaf.py @@ -0,0 +1,41 @@ +""" +Stem and Leaf Plot +------------------ +This example shows how to make a stem and leaf plot. +""" +# category: advanced calculations +import altair as alt +import pandas as pd +import numpy as np +np.random.seed(42) + +# Generating random data +source = pd.DataFrame({'samples': np.random.normal(50, 15, 100).astype(int).astype(str)}) + +# Splitting stem and leaf +source['stem'] = source['samples'].str[:-1] +source['leaf'] = source['samples'].str[-1] + +source = source.sort_values(by=['stem', 'leaf']) + +# Determining leaf position +source['position'] = source.groupby('stem').cumcount().add(1) + +# Creating stem and leaf plot +alt.Chart(source).mark_text( + align='left', + baseline='middle', + dx=-5 +).encode( + alt.X('position:Q') + .title('') + .axis(ticks=False, labels=False, grid=False), + alt.Y('stem:N') + .title('') + .axis(tickSize=0), + text='leaf:N', +).configure_axis( + labelFontSize=20 +).configure_text( + fontSize=20 +) diff --git a/altair/examples/attribute_syntax/streamgraph.py b/altair/examples/attribute_syntax/streamgraph.py new file mode 100644 index 000000000..b9bdcb512 --- /dev/null +++ b/altair/examples/attribute_syntax/streamgraph.py @@ -0,0 +1,16 @@ +""" +Streamgraph +----------------- +This example shows the streamgraph from vega-lite examples. +""" +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.unemployment_across_industries.url + +alt.Chart(source).mark_area().encode( + alt.X('yearmonth(date):T').axis(format='%Y', domain=False, tickSize=0), + alt.Y('sum(count):Q').stack('center').axis(None), + alt.Color('series:N').scale(scheme='category20b') +).interactive() diff --git a/altair/examples/attribute_syntax/strip_plot_jitter.py b/altair/examples/attribute_syntax/strip_plot_jitter.py new file mode 100644 index 000000000..edf572b02 --- /dev/null +++ b/altair/examples/attribute_syntax/strip_plot_jitter.py @@ -0,0 +1,37 @@ +""" +Strip Plot with Jitter +---------------------- +In this chart, we encode the ``Major_Genre`` column from the ``movies`` dataset +in the ``y``-channel. In the default presentation of this data, it would be +difficult to gauge the relative frequencies with which different values occur +because there would be so much overlap. To address this, we use the ``yOffset`` +channel to incorporate a random offset (jittering). The example is shown twice, +on the left side using normally distributed and on the right side using +uniformally distributed jitter. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.movies.url + +gaussian_jitter = alt.Chart(source, title='Normally distributed jitter').mark_circle(size=8).encode( + y="Major_Genre:N", + x="IMDB_Rating:Q", + yOffset="jitter:Q", + color=alt.Color('Major_Genre:N').legend(None) +).transform_calculate( + # Generate Gaussian jitter with a Box-Muller transform + jitter="sqrt(-2*log(random()))*cos(2*PI*random())" +) + +uniform_jitter = gaussian_jitter.transform_calculate( + # Generate uniform jitter + jitter='random()' +).encode( + alt.Y('Major_Genre:N').axis(None) +).properties( + title='Uniformly distributed jitter' +) + +(gaussian_jitter | uniform_jitter).resolve_scale(yOffset='independent') diff --git a/altair/examples/attribute_syntax/top_k_items.py b/altair/examples/attribute_syntax/top_k_items.py new file mode 100644 index 000000000..49285670e --- /dev/null +++ b/altair/examples/attribute_syntax/top_k_items.py @@ -0,0 +1,27 @@ +""" +Top K Items +----------- +This example shows how to use the window and transformation filter to display +the Top items of a long list of items in decreasing order. +Here we sort the top 10 highest ranking movies of IMDB. +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.movies.url + +# Top 10 movies by IMBD rating +alt.Chart( + source, +).mark_bar().encode( + alt.X('Title:N').sort('-y'), + alt.Y('IMDB_Rating:Q'), + alt.Color('IMDB_Rating:Q') + +).transform_window( + rank='rank(IMDB_Rating)', + sort=[alt.SortField('IMDB_Rating', order='descending')] +).transform_filter( + (alt.datum.rank < 10) +) diff --git a/altair/examples/attribute_syntax/top_k_letters.py b/altair/examples/attribute_syntax/top_k_letters.py new file mode 100644 index 000000000..ac56b02a8 --- /dev/null +++ b/altair/examples/attribute_syntax/top_k_letters.py @@ -0,0 +1,40 @@ +""" +Top K Letters +------------- +This example shows how to use a window transform in order to display only the +top K categories by number of entries. In this case, we rank the characters in +the first paragraph of Dickens' *A Tale of Two Cities* by number of occurances. +""" +# category: advanced calculations +import altair as alt +import pandas as pd +import numpy as np + +# Excerpt from A Tale of Two Cities; public domain text +text = """ +It was the best of times, it was the worst of times, it was the age of wisdom, +it was the age of foolishness, it was the epoch of belief, it was the epoch of +incredulity, it was the season of Light, it was the season of Darkness, it was +the spring of hope, it was the winter of despair, we had everything before us, +we had nothing before us, we were all going direct to Heaven, we were all going +direct the other way - in short, the period was so far like the present period, +that some of its noisiest authorities insisted on its being received, for good +or for evil, in the superlative degree of comparison only. +""" + +source = pd.DataFrame( + {'letters': np.array([c for c in text if c.isalpha()])} +) + +alt.Chart(source).transform_aggregate( + count='count()', + groupby=['letters'] +).transform_window( + rank='rank(count)', + sort=[alt.SortField('count', order='descending')] +).transform_filter( + alt.datum.rank < 10 +).mark_bar().encode( + y=alt.Y('letters:N').sort('-x'), + x='count:Q', +) diff --git a/altair/examples/attribute_syntax/top_k_with_others.py b/altair/examples/attribute_syntax/top_k_with_others.py new file mode 100644 index 000000000..5a177e160 --- /dev/null +++ b/altair/examples/attribute_syntax/top_k_with_others.py @@ -0,0 +1,29 @@ +""" +Top-K Plot with Others +---------------------- +This example shows how to use aggregate, window, and calculate transfromations +to display the top-k directors by average worldwide gross while grouping the +remaining directors as 'All Others'. +""" +# category: advanced calculations +import altair as alt +from vega_datasets import data + +source = data.movies.url + +alt.Chart(source).mark_bar().encode( + alt.X("aggregate_gross:Q").aggregate("mean").title(None), + alt.Y("ranked_director:N") + .sort(op="mean", field="aggregate_gross", order="descending") + .title(None) +).transform_aggregate( + aggregate_gross='mean(Worldwide_Gross)', + groupby=["Director"], +).transform_window( + rank='row_number()', + sort=[alt.SortField("aggregate_gross", order="descending")], +).transform_calculate( + ranked_director="datum.rank < 10 ? datum.Director : 'All Others'" +).properties( + title="Top Directors by Average Worldwide Gross", +) diff --git a/altair/examples/attribute_syntax/trellis_area_sort_array.py b/altair/examples/attribute_syntax/trellis_area_sort_array.py new file mode 100644 index 000000000..2dab32fde --- /dev/null +++ b/altair/examples/attribute_syntax/trellis_area_sort_array.py @@ -0,0 +1,21 @@ +''' +Trellis Area Sort Chart +----------------------- +This example shows small multiples of an area chart. +Stock prices of four large companies +sorted by `['MSFT', 'AAPL', 'IBM', 'AMZN']` +''' +# category: area charts +import altair as alt +from vega_datasets import data + +source = data.stocks() + +alt.Chart(source).transform_filter( + alt.datum.symbol != 'GOOG' +).mark_area().encode( + x='date:T', + y='price:Q', + color='symbol:N', + row=alt.Row('symbol:N').sort(['MSFT', 'AAPL', 'IBM', 'AMZN']) +).properties(height=50, width=400) diff --git a/altair/examples/attribute_syntax/trellis_histogram.py b/altair/examples/attribute_syntax/trellis_histogram.py new file mode 100644 index 000000000..8c45ccf20 --- /dev/null +++ b/altair/examples/attribute_syntax/trellis_histogram.py @@ -0,0 +1,17 @@ +""" +Trellis Histogram +----------------- +This example shows how to make a basic trellis histogram. +https://vega.github.io/vega-lite/examples/trellis_bar_histogram.html +""" +# category: distributions +import altair as alt +from vega_datasets import data + +source = data.cars() + +alt.Chart(source).mark_bar().encode( + alt.X("Horsepower:Q").bin(), + y='count()', + row='Origin' +) diff --git a/altair/examples/attribute_syntax/us_employment.py b/altair/examples/attribute_syntax/us_employment.py new file mode 100644 index 000000000..2dada0833 --- /dev/null +++ b/altair/examples/attribute_syntax/us_employment.py @@ -0,0 +1,58 @@ +""" +The U.S. Employment Crash During the Great Recession +---------------------------------------------------- +This example is a fully developed bar chart with negative values using the sample dataset of U.S. employment changes during the Great Recession. +""" +# category: case studies +import altair as alt +import pandas as pd +from vega_datasets import data + +source = data.us_employment() +presidents = pd.DataFrame([ + { + "start": "2006-01-01", + "end": "2009-01-19", + "president": "Bush" + }, + { + "start": "2009-01-20", + "end": "2015-12-31", + "president": "Obama" + } +]) + +bars = alt.Chart( + source, + title="The U.S. employment crash during the Great Recession" +).mark_bar().encode( + alt.X("month:T").title(""), + alt.Y("nonfarm_change:Q").title("Change in non-farm employment (in thousands)"), + color=alt.condition( + alt.datum.nonfarm_change > 0, + alt.value("steelblue"), + alt.value("orange") + ) +) + +rule = alt.Chart(presidents).mark_rule( + color="black", + strokeWidth=2 +).encode( + x='end:T' +).transform_filter(alt.datum.president == "Bush") + +text = alt.Chart(presidents).mark_text( + align='left', + baseline='middle', + dx=7, + dy=-135, + size=11 +).encode( + x='start:T', + x2='end:T', + text='president', + color=alt.value('#000000') +) + +(bars + rule + text).properties(width=600) diff --git a/altair/examples/attribute_syntax/us_population_over_time.py b/altair/examples/attribute_syntax/us_population_over_time.py new file mode 100644 index 000000000..75c4fa01c --- /dev/null +++ b/altair/examples/attribute_syntax/us_population_over_time.py @@ -0,0 +1,39 @@ +""" +US Population by Age and Sex +============================ +This chart visualizes the age distribution of the US population over time. +It uses a slider widget that is bound to the year to visualize the age +distribution over time. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.population.url + +select_year = alt.selection_point( + name="Year", + fields=["year"], + bind=alt.binding_range(min=1900, max=2000, step=10, name="Year"), + value={"year": 2000}, +) + +alt.Chart(source).mark_bar().encode( + alt.X("sex:N").title('').axis(labels=False, ticks=False), + alt.Y("people:Q").scale(domain=(0, 12000000)).title("Population"), + alt.Color("sex:N") + .scale(domain=("Male", "Female"), range=["steelblue", "salmon"]) + .title("Sex"), + alt.Column("age:O").title("Age") +).properties( + width=20, + title="U.S. Population by Age and Sex" +).add_params( + select_year +).transform_calculate( + "sex", alt.expr.if_(alt.datum.sex == 1, "Male", "Female") +).transform_filter( + select_year +).configure_facet( + spacing=8 +) diff --git a/altair/examples/attribute_syntax/us_population_over_time_facet.py b/altair/examples/attribute_syntax/us_population_over_time_facet.py new file mode 100644 index 000000000..6444e0d80 --- /dev/null +++ b/altair/examples/attribute_syntax/us_population_over_time_facet.py @@ -0,0 +1,21 @@ +""" +US Population: Wrapped Facet +============================ +This chart visualizes the age distribution of the US population over time, +using a wrapped faceting of the data by decade. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.population.url + +alt.Chart(source).mark_area().encode( + x='age:O', + y=alt.Y('sum(people):Q').title('Population').axis(format='~s'), + facet=alt.Facet('year:O').columns(5), +).properties( + title='US Age Distribution By Year', + width=90, + height=80 +) diff --git a/altair/examples/attribute_syntax/us_population_pyramid_over_time.py b/altair/examples/attribute_syntax/us_population_pyramid_over_time.py new file mode 100644 index 000000000..f7418413d --- /dev/null +++ b/altair/examples/attribute_syntax/us_population_pyramid_over_time.py @@ -0,0 +1,57 @@ +''' +US Population Pyramid Over Time +=============================== +A population pyramid shows the distribution of age groups within a population. +It uses a slider widget that is bound to the year to visualize the age +distribution over time. +''' +# category: case studies +import altair as alt +from vega_datasets import data + +source = data.population.url + +slider = alt.binding_range(min=1850, max=2000, step=10) +select_year = alt.selection_point(name='year', fields=['year'], + bind=slider, value={'year': 2000}) + +base = alt.Chart(source).add_params( + select_year +).transform_filter( + select_year +).transform_calculate( + gender=alt.expr.if_(alt.datum.sex == 1, 'Male', 'Female') +).properties( + width=250 +) + + +color_scale = alt.Scale(domain=['Male', 'Female'], + range=['#1f77b4', '#e377c2']) + +left = base.transform_filter( + alt.datum.gender == 'Female' +).encode( + alt.Y('age:O').axis(None), + alt.X('sum(people):Q') + .title('population') + .sort('descending'), + alt.Color('gender:N') + .scale(color_scale) + .legend(None) +).mark_bar().properties(title='Female') + +middle = base.encode( + alt.Y('age:O').axis(None), + alt.Text('age:Q'), +).mark_text().properties(width=20) + +right = base.transform_filter( + alt.datum.gender == 'Male' +).encode( + alt.Y('age:O').axis(None), + alt.X('sum(people):Q').title('population'), + alt.Color('gender:N').scale(color_scale).legend(None) +).mark_bar().properties(title='Male') + +alt.concat(left, middle, right, spacing=5) diff --git a/altair/examples/attribute_syntax/us_state_capitals.py b/altair/examples/attribute_syntax/us_state_capitals.py new file mode 100644 index 000000000..00dfdaea6 --- /dev/null +++ b/altair/examples/attribute_syntax/us_state_capitals.py @@ -0,0 +1,43 @@ +""" +U.S. State Capitals Overlayed on a Map of the U.S +------------------------------------------------- +This is a layered geographic visualization that shows US capitals +overlayed on a map. +""" +# category: case studies +import altair as alt +from vega_datasets import data + +states = alt.topo_feature(data.us_10m.url, 'states') +capitals = data.us_state_capitals.url + +# US states background +background = alt.Chart(states).mark_geoshape( + fill='lightgray', + stroke='white' +).properties( + title='US State Capitols', + width=650, + height=400 +).project('albersUsa') + +# Points and text +hover = alt.selection(type='point', on='mouseover', nearest=True, + fields=['lat', 'lon']) + +base = alt.Chart(capitals).encode( + longitude='lon:Q', + latitude='lat:Q', +) + +text = base.mark_text(dy=-5, align='right').encode( + alt.Text('city:N'), + opacity=alt.condition(~hover, alt.value(0), alt.value(1)) +) + +points = base.mark_point().encode( + color=alt.value('black'), + size=alt.condition(~hover, alt.value(30), alt.value(100)) +).add_params(hover) + +background + points + text diff --git a/altair/examples/attribute_syntax/violin_plot.py b/altair/examples/attribute_syntax/violin_plot.py new file mode 100644 index 000000000..d09274d1e --- /dev/null +++ b/altair/examples/attribute_syntax/violin_plot.py @@ -0,0 +1,28 @@ +""" +Violin Plot +----------- +This example shows how to make a Violin Plot using Altair's density transform. +""" +# category: distributions +import altair as alt +from vega_datasets import data + +alt.Chart(data.cars(), width=100).transform_density( + 'Miles_per_Gallon', + as_=['Miles_per_Gallon', 'density'], + extent=[5, 50], + groupby=['Origin'] +).mark_area(orient='horizontal').encode( + alt.X('density:Q') + .stack('center') + .impute(None) + .title(None) + .axis(labels=False, values=[0], grid=False, ticks=True), + alt.Y('Miles_per_Gallon:Q'), + alt.Color('Origin:N'), + alt.Column('Origin:N') + .spacing(0) + .header(titleOrient='bottom', labelOrient='bottom', labelPadding=0) +).configure_view( + stroke=None +) diff --git a/altair/examples/attribute_syntax/wheat_wages.py b/altair/examples/attribute_syntax/wheat_wages.py new file mode 100644 index 000000000..81153712d --- /dev/null +++ b/altair/examples/attribute_syntax/wheat_wages.py @@ -0,0 +1,58 @@ +""" +Wheat and Wages +--------------- +A recreation of William Playfair's classic chart visualizing +the price of wheat, the wages of a mechanic, and the reigning British monarch. + +This is a more polished version of the simpler chart in :ref:`gallery_bar_and_line_with_dual_axis`. +""" +# category: case studies +import altair as alt +from vega_datasets import data + + +base_wheat = alt.Chart(data.wheat.url).transform_calculate( + year_end="+datum.year + 5") + +base_monarchs = alt.Chart(data.monarchs.url).transform_calculate( + offset="((!datum.commonwealth && datum.index % 2) ? -1: 1) * 2 + 95", + off2="((!datum.commonwealth && datum.index % 2) ? -1: 1) + 95", + y="95", + x="+datum.start + (+datum.end - +datum.start)/2" +) + +bars = base_wheat.mark_bar(**{"fill": "#aaa", "stroke": "#999"}).encode( + alt.X("year:Q").axis(format='d', tickCount=5), + alt.Y("wheat:Q").axis(zindex=1), + alt.X2("year_end") +) + +area = base_wheat.mark_area(**{"color": "#a4cedb", "opacity": 0.7}).encode( + alt.X("year:Q"), + alt.Y("wages:Q") +) + +area_line_1 = area.mark_line(**{"color": "#000", "opacity": 0.7}) +area_line_2 = area.mark_line(**{"yOffset": -2, "color": "#EE8182"}) + +top_bars = base_monarchs.mark_bar(stroke="#000").encode( + alt.X("start:Q"), + alt.X2("end"), + alt.Y("y:Q"), + alt.Y2("offset"), + alt.Fill("commonwealth:N").legend(None).scale(range=["black", "white"]) +) + +top_text = base_monarchs.mark_text(**{"yOffset": 14, "fontSize": 9, "fontStyle": "italic"}).encode( + alt.X("x:Q"), + alt.Y("off2:Q"), + alt.Text("name:N") +) + +(bars + area + area_line_1 + area_line_2 + top_bars + top_text).properties( + width=900, height=400 +).configure_axis( + title=None, gridColor="white", gridOpacity=0.25, domain=False +).configure_view( + stroke="transparent" +) diff --git a/altair/examples/attribute_syntax/wilkinson-dot-plot.py b/altair/examples/attribute_syntax/wilkinson-dot-plot.py new file mode 100644 index 000000000..55e31296c --- /dev/null +++ b/altair/examples/attribute_syntax/wilkinson-dot-plot.py @@ -0,0 +1,25 @@ +""" +Wilkinson Dot Plot +------------------ +An example of a `Wilkinson Dot Plot `_ +""" +# category: advanced calculations + +import altair as alt +import pandas as pd + +source = pd.DataFrame( + {"data":[1,1,1,1,1,1,1,1,1,1, + 2,2,2, + 3,3, + 4,4,4,4,4,4] + } +) + +alt.Chart(source, height=100).mark_circle(opacity=1).transform_window( + id='rank()', + groupby=['data'] +).encode( + alt.X('data:O'), + alt.Y('id:O').axis(None).sort('descending') +) diff --git a/altair/examples/attribute_syntax/wind_vector_map.py b/altair/examples/attribute_syntax/wind_vector_map.py new file mode 100644 index 000000000..56dcd674b --- /dev/null +++ b/altair/examples/attribute_syntax/wind_vector_map.py @@ -0,0 +1,57 @@ +""" +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 `_ +with an added base map. +""" +# category: maps +import altair as alt +from vega_datasets import data + +df_wind = data.windvectors() +data_world = alt.topo_feature(data.world_110m.url, "countries") + +wedge = alt.Chart(df_wind).mark_point(shape="wedge", filled=True).encode( + alt.Latitude("latitude"), + alt.Longitude("longitude"), + alt.Color("dir") + .scale(domain=[0, 360], scheme="rainbow") + .legend(None), + alt.Angle("dir").scale(domain=[0, 360], range=[180, 540]), + alt.Size("speed").scale(rangeMax=500) +).project("equalEarth") + +xmin, xmax, ymin, ymax = ( + df_wind.longitude.min(), + df_wind.longitude.max(), + df_wind.latitude.min(), + df_wind.latitude.max(), +) + +# clockwise, left-hand-rule +extent = [ + { + "type": "Polygon", + "coordinates": ( + ( + (xmax, ymax), + (xmax, ymin), + (xmin, ymin), + (xmin, ymax), + (xmax, ymax), + ), + ), + } +] + +# use fit combined with clip=True +base = ( + alt.Chart(data_world) + .mark_geoshape(clip=True, fill="lightgray", stroke="black", strokeWidth=0.5) + .project(type="equalEarth", fit=extent) +) + +base + wedge diff --git a/altair/examples/attribute_syntax/window_rank.py b/altair/examples/attribute_syntax/window_rank.py new file mode 100644 index 000000000..35796dffe --- /dev/null +++ b/altair/examples/attribute_syntax/window_rank.py @@ -0,0 +1,42 @@ +""" +Window Rank Line Chart +---------------------- +This example shows the Group F rankings in the 2018 World Cup after each matchday. +A window transformation is used to rank each after each match day, sorting by points and difference. +""" +# category: line charts +import altair as alt +import pandas as pd + +source = pd.DataFrame( + [ + {"team": "Germany", "matchday": 1, "point": 0, "diff": -1}, + {"team": "Germany", "matchday": 2, "point": 3, "diff": 0}, + {"team": "Germany", "matchday": 3, "point": 3, "diff": -2}, + {"team": "Mexico", "matchday": 1, "point": 3, "diff": 1}, + {"team": "Mexico", "matchday": 2, "point": 6, "diff": 2}, + {"team": "Mexico", "matchday": 3, "point": 6, "diff": -1}, + {"team": "South Korea", "matchday": 1, "point": 0, "diff": -1}, + {"team": "South Korea", "matchday": 2, "point": 0, "diff": -2}, + {"team": "South Korea", "matchday": 3, "point": 3, "diff": 0}, + {"team": "Sweden", "matchday": 1, "point": 3, "diff": 1}, + {"team": "Sweden", "matchday": 2, "point": 3, "diff": 0}, + {"team": "Sweden", "matchday": 3, "point": 6, "diff": 3}, + ] +) + +color_scale = alt.Scale( + domain=["Germany", "Mexico", "South Korea", "Sweden"], + range=["#000000", "#127153", "#C91A3C", "#0C71AB"], +) + +alt.Chart(source).mark_line().encode( + x="matchday:O", y="rank:O", color=alt.Color("team:N").scale(color_scale) +).transform_window( + rank="rank()", + sort=[ + alt.SortField("point", order="descending"), + alt.SortField("diff", order="descending"), + ], + groupby=["matchday"], +).properties(title="World Cup 2018: Group F Rankings") diff --git a/altair/examples/line_with_last_value_labeled.py b/altair/examples/line_with_last_value_labeled.py new file mode 100644 index 000000000..481f4e044 --- /dev/null +++ b/altair/examples/line_with_last_value_labeled.py @@ -0,0 +1,39 @@ +""" +Line Chart with Last Value Labeled +---------------------------------- +This chart shows a line chart with a label annotating the final value +""" +# category: line charts +import altair as alt +from vega_datasets import data + +# Import example data +source = data.stocks() + +# Create a common chart object +chart = ( + alt.Chart(source) + .transform_filter( + alt.datum.symbol != "IBM" + ) # A reduction of the dataset to clarify our example. Not required. + .encode(color=alt.Color("symbol", legend=None)) +) + +# Draw the line +line = chart.mark_line().encode(x="date:T", y="price:Q") + +# Use the `argmax` aggregate to limit the dataset to the final value +label = chart.encode( + x=alt.X("max(date):T"), + y=alt.Y("price:Q", aggregate=alt.ArgmaxDef(argmax="date")), + text="symbol", +) + +# Create a text label +text = label.mark_text(align="left", dx=4) + +# Create a circle annotation +circle = label.mark_circle() + +# Draw the chart with all the layers combined +line + circle + text diff --git a/altair/examples/tests/test_examples.py b/altair/examples/tests/test_examples.py index 125539946..6495232e6 100644 --- a/altair/examples/tests/test_examples.py +++ b/altair/examples/tests/test_examples.py @@ -1,10 +1,12 @@ import io +from itertools import chain import pkgutil import pytest from altair.utils.execeval import eval_block from altair import examples +from altair.examples import attribute_syntax try: import altair_saver # noqa: F401 @@ -24,7 +26,16 @@ def iter_example_filenames(): yield modname + ".py" -@pytest.mark.parametrize("filename", iter_example_filenames()) +def iter_attribute_syntax_filenames(): + for importer, modname, ispkg in pkgutil.iter_modules(attribute_syntax.__path__): + if ispkg or modname.startswith("_"): + continue + yield modname + ".py" + + +@pytest.mark.parametrize( + "filename", chain(iter_example_filenames(), iter_attribute_syntax_filenames()) +) def test_examples(filename: str): source = pkgutil.get_data(examples.__name__, filename) chart = eval_block(source) @@ -35,7 +46,9 @@ def test_examples(filename: str): @pytest.mark.parametrize("engine", ["vl-convert", "altair_saver"]) -@pytest.mark.parametrize("filename", iter_example_filenames()) +@pytest.mark.parametrize( + "filename", chain(iter_example_filenames(), iter_attribute_syntax_filenames()) +) def test_render_examples_to_png(engine, filename): if engine == "vl-convert" and vlc is None: pytest.skip("vl_convert not importable; cannot run mimebundle tests") diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py index 5e6256252..733f799fe 100644 --- a/altair/utils/schemapi.py +++ b/altair/utils/schemapi.py @@ -4,12 +4,15 @@ import contextlib import inspect import json +import textwrap from typing import Any import jsonschema import numpy as np import pandas as pd +from altair import vegalite + # If DEBUG_MODE is True, then schema objects are converted to dict and # validated at creation time. This slows things down, particularly for @@ -590,3 +593,60 @@ def from_dict( return cls(dct) else: return cls(dct) + + +class _PropertySetter(object): + def __init__(self, prop, schema): + self.prop = prop + self.schema = schema + + def __get__(self, obj, cls): + self.obj = obj + self.cls = cls + # The docs from the encoding class parameter (e.g. `bin` in X, Color, + # etc); this provides a general description of the parameter. + self.__doc__ = self.schema["description"].replace("__", "**") + property_name = f"{self.prop}"[0].upper() + f"{self.prop}"[1:] + if hasattr(vegalite, property_name): + altair_prop = getattr(vegalite, property_name) + # Add the docstring from the helper class (e.g. `BinParams`) so + # that all the parameter names of the helper class are included in + # the final docstring + attribute_index = altair_prop.__doc__.find("Attributes\n") + if attribute_index > -1: + self.__doc__ = ( + altair_prop.__doc__[:attribute_index].replace(" ", "") + + self.__doc__ + + textwrap.dedent( + f"\n\n {altair_prop.__doc__[attribute_index:]}" + ) + ) + # For short docsstrings such as Aggregate, Stack, et + else: + self.__doc__ = ( + altair_prop.__doc__.replace(" ", "") + "\n" + self.__doc__ + ) + # Add signatures and tab completion for the method and parameter names + # Currently works for `alt.X.bin` but not alt.X().bin` + self.__signature__ = inspect.signature(altair_prop) + self.__wrapped__ = inspect.getfullargspec(altair_prop) + self.__name__ = altair_prop.__name__ + else: + # It seems like bandPosition is the only parameter that doesn't + # have a helper class. + pass + return self + + def __call__(self, *args, **kwargs): + obj = self.obj.copy() + # TODO: use schema to validate + obj[self.prop] = args[0] if args else kwargs + return obj + + +def with_property_setters(cls): + """Decorator to add property setters to a Schema class.""" + schema = cls.resolve_references() + for prop, propschema in schema.get("properties", {}).items(): + setattr(cls, prop, _PropertySetter(prop, propschema)) + return cls diff --git a/altair/vegalite/v5/schema/channels.py b/altair/vegalite/v5/schema/channels.py index 09c0f1fb4..714dd9a4f 100644 --- a/altair/vegalite/v5/schema/channels.py +++ b/altair/vegalite/v5/schema/channels.py @@ -3,8 +3,9 @@ from . import core import pandas as pd -from altair.utils.schemapi import Undefined +from altair.utils.schemapi import Undefined, with_property_setters from altair.utils import parse_shorthand +from typing import overload, Type class FieldChannelMixin(object): @@ -64,7 +65,7 @@ def to_dict(self, validate=True, ignore=(), context=None): class ValueChannelMixin(object): def to_dict(self, validate=True, ignore=(), context=None): context = context or {} - condition = getattr(self, 'condition', Undefined) + condition = self._get('condition', Undefined) copy = self # don't copy unless we need to if condition is not Undefined: if isinstance(condition, core.SchemaBase): @@ -81,7 +82,7 @@ def to_dict(self, validate=True, ignore=(), context=None): class DatumChannelMixin(object): def to_dict(self, validate=True, ignore=(), context=None): context = context or {} - datum = getattr(self, 'datum', Undefined) + datum = self._get('datum', Undefined) copy = self # don't copy unless we need to if datum is not Undefined: if isinstance(datum, core.SchemaBase): @@ -91,6 +92,7 @@ def to_dict(self, validate=True, ignore=(), context=None): context=context) +@with_property_setters class Angle(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """Angle schema wrapper @@ -321,6 +323,105 @@ class Angle(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDef _class_is_valid_at_instantiation = False _encoding_name = "angle" + @overload + def aggregate(self, _: str, **kwds) -> 'Angle': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Angle': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Angle': + ... + + def bandPosition(self, _: float, **kwds) -> 'Angle': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Angle': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Angle': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Angle': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Angle': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Angle': + ... + + @overload + def field(self, _: str, **kwds) -> 'Angle': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Angle': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Angle': + ... + + @overload + def legend(self, _: None, **kwds) -> 'Angle': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Angle': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Angle': + ... + + @overload + def sort(self, **kwds) -> 'Angle': + ... + + @overload + def sort(self, **kwds) -> 'Angle': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Angle': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Angle': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Angle': + ... + + @overload + def timeUnit(self, **kwds) -> 'Angle': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Angle': + ... + + @overload + def title(self, **kwds) -> 'Angle': + ... + + @overload + def title(self, _: None, **kwds) -> 'Angle': + ... + + def type(self, _: str, **kwds) -> 'Angle': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -330,6 +431,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class AngleDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """AngleDatum schema wrapper @@ -445,12 +547,37 @@ class AngleDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnum """ _class_is_valid_at_instantiation = False _encoding_name = "angle" + + def bandPosition(self, _: float, **kwds) -> 'AngleDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'AngleDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'AngleDatum': + ... + + @overload + def title(self, **kwds) -> 'AngleDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'AngleDatum': + ... + + def type(self, _: str, **kwds) -> 'AngleDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(AngleDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class AngleValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """AngleValue schema wrapper @@ -469,10 +596,24 @@ class AngleValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDat _class_is_valid_at_instantiation = False _encoding_name = "angle" + @overload + def condition(self, **kwds) -> 'AngleValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'AngleValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'AngleValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(AngleValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Color(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull): """Color schema wrapper @@ -703,6 +844,105 @@ class Color(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDef _class_is_valid_at_instantiation = False _encoding_name = "color" + @overload + def aggregate(self, _: str, **kwds) -> 'Color': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Color': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Color': + ... + + def bandPosition(self, _: float, **kwds) -> 'Color': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Color': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Color': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Color': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Color': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Color': + ... + + @overload + def field(self, _: str, **kwds) -> 'Color': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Color': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Color': + ... + + @overload + def legend(self, _: None, **kwds) -> 'Color': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Color': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Color': + ... + + @overload + def sort(self, **kwds) -> 'Color': + ... + + @overload + def sort(self, **kwds) -> 'Color': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Color': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Color': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Color': + ... + + @overload + def timeUnit(self, **kwds) -> 'Color': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Color': + ... + + @overload + def title(self, **kwds) -> 'Color': + ... + + @overload + def title(self, _: None, **kwds) -> 'Color': + ... + + def type(self, _: str, **kwds) -> 'Color': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -712,6 +952,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class ColorDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGradientstringnull): """ColorDatum schema wrapper @@ -827,12 +1068,37 @@ class ColorDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGra """ _class_is_valid_at_instantiation = False _encoding_name = "color" + + def bandPosition(self, _: float, **kwds) -> 'ColorDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'ColorDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'ColorDatum': + ... + + @overload + def title(self, **kwds) -> 'ColorDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'ColorDatum': + ... + + def type(self, _: str, **kwds) -> 'ColorDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(ColorDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class ColorValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull): """ColorValue schema wrapper @@ -851,10 +1117,24 @@ class ColorValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDat _class_is_valid_at_instantiation = False _encoding_name = "color" + @overload + def condition(self, **kwds) -> 'ColorValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'ColorValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'ColorValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(ColorValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Column(FieldChannelMixin, core.RowColumnEncodingFieldDef): """Column schema wrapper @@ -1069,6 +1349,94 @@ class Column(FieldChannelMixin, core.RowColumnEncodingFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "column" + @overload + def aggregate(self, _: str, **kwds) -> 'Column': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Column': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Column': + ... + + def align(self, _: str, **kwds) -> 'Column': + ... + + def bandPosition(self, _: float, **kwds) -> 'Column': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Column': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Column': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Column': + ... + + def center(self, _: bool, **kwds) -> 'Column': + ... + + @overload + def field(self, _: str, **kwds) -> 'Column': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Column': + ... + + @overload + def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, labelAnchor=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOrient=Undefined, labelPadding=Undefined, labels=Undefined, orient=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOrient=Undefined, titlePadding=Undefined, **kwds) -> 'Column': + ... + + @overload + def header(self, _: None, **kwds) -> 'Column': + ... + + @overload + def sort(self, **kwds) -> 'Column': + ... + + @overload + def sort(self, _: str, **kwds) -> 'Column': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Column': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Column': + ... + + def spacing(self, _: float, **kwds) -> 'Column': + ... + + @overload + def timeUnit(self, **kwds) -> 'Column': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Column': + ... + + @overload + def title(self, **kwds) -> 'Column': + ... + + @overload + def title(self, _: None, **kwds) -> 'Column': + ... + + def type(self, _: str, **kwds) -> 'Column': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, bandPosition=Undefined, bin=Undefined, center=Undefined, field=Undefined, header=Undefined, sort=Undefined, spacing=Undefined, timeUnit=Undefined, @@ -1079,6 +1447,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, title=title, type=type, **kwds) +@with_property_setters class Description(FieldChannelMixin, core.StringFieldDefWithCondition): """Description schema wrapper @@ -1282,6 +1651,84 @@ class Description(FieldChannelMixin, core.StringFieldDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "description" + @overload + def aggregate(self, _: str, **kwds) -> 'Description': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Description': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Description': + ... + + def bandPosition(self, _: float, **kwds) -> 'Description': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Description': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Description': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Description': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Description': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Description': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Description': + ... + + @overload + def field(self, _: str, **kwds) -> 'Description': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Description': + ... + + @overload + def format(self, _: str, **kwds) -> 'Description': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Description': + ... + + def formatType(self, _: str, **kwds) -> 'Description': + ... + + @overload + def timeUnit(self, **kwds) -> 'Description': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Description': + ... + + @overload + def title(self, **kwds) -> 'Description': + ... + + @overload + def title(self, _: None, **kwds) -> 'Description': + ... + + def type(self, _: str, **kwds) -> 'Description': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -1291,6 +1738,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class DescriptionValue(ValueChannelMixin, core.StringValueDefWithCondition): """DescriptionValue schema wrapper @@ -1309,10 +1757,24 @@ class DescriptionValue(ValueChannelMixin, core.StringValueDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "description" + @overload + def condition(self, **kwds) -> 'DescriptionValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'DescriptionValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'DescriptionValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(DescriptionValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Detail(FieldChannelMixin, core.FieldDefWithoutScale): """Detail schema wrapper @@ -1474,6 +1936,65 @@ class Detail(FieldChannelMixin, core.FieldDefWithoutScale): _class_is_valid_at_instantiation = False _encoding_name = "detail" + @overload + def aggregate(self, _: str, **kwds) -> 'Detail': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Detail': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Detail': + ... + + def bandPosition(self, _: float, **kwds) -> 'Detail': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Detail': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Detail': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Detail': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Detail': + ... + + @overload + def field(self, _: str, **kwds) -> 'Detail': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Detail': + ... + + @overload + def timeUnit(self, **kwds) -> 'Detail': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Detail': + ... + + @overload + def title(self, **kwds) -> 'Detail': + ... + + @overload + def title(self, _: None, **kwds) -> 'Detail': + ... + + def type(self, _: str, **kwds) -> 'Detail': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): super(Detail, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -1481,6 +2002,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi title=title, type=type, **kwds) +@with_property_setters class Facet(FieldChannelMixin, core.FacetEncodingFieldDef): """Facet schema wrapper @@ -1733,6 +2255,115 @@ class Facet(FieldChannelMixin, core.FacetEncodingFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "facet" + @overload + def aggregate(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Facet': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Facet': + ... + + @overload + def align(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def align(self, column=Undefined, row=Undefined, **kwds) -> 'Facet': + ... + + def bandPosition(self, _: float, **kwds) -> 'Facet': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Facet': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Facet': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Facet': + ... + + def bounds(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def center(self, _: bool, **kwds) -> 'Facet': + ... + + @overload + def center(self, column=Undefined, row=Undefined, **kwds) -> 'Facet': + ... + + def columns(self, _: float, **kwds) -> 'Facet': + ... + + @overload + def field(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Facet': + ... + + @overload + def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, labelAnchor=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOrient=Undefined, labelPadding=Undefined, labels=Undefined, orient=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOrient=Undefined, titlePadding=Undefined, **kwds) -> 'Facet': + ... + + @overload + def header(self, _: None, **kwds) -> 'Facet': + ... + + @overload + def sort(self, **kwds) -> 'Facet': + ... + + @overload + def sort(self, _: str, **kwds) -> 'Facet': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Facet': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Facet': + ... + + @overload + def spacing(self, _: float, **kwds) -> 'Facet': + ... + + @overload + def spacing(self, column=Undefined, row=Undefined, **kwds) -> 'Facet': + ... + + @overload + def timeUnit(self, **kwds) -> 'Facet': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Facet': + ... + + @overload + def title(self, **kwds) -> 'Facet': + ... + + @overload + def title(self, _: None, **kwds) -> 'Facet': + ... + + def type(self, _: str, **kwds) -> 'Facet': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, bandPosition=Undefined, bin=Undefined, bounds=Undefined, center=Undefined, columns=Undefined, field=Undefined, header=Undefined, sort=Undefined, @@ -1743,6 +2374,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, spacing=spacing, timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class Fill(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull): """Fill schema wrapper @@ -1973,6 +2605,105 @@ class Fill(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefG _class_is_valid_at_instantiation = False _encoding_name = "fill" + @overload + def aggregate(self, _: str, **kwds) -> 'Fill': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Fill': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Fill': + ... + + def bandPosition(self, _: float, **kwds) -> 'Fill': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Fill': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Fill': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Fill': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Fill': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Fill': + ... + + @overload + def field(self, _: str, **kwds) -> 'Fill': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Fill': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Fill': + ... + + @overload + def legend(self, _: None, **kwds) -> 'Fill': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Fill': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Fill': + ... + + @overload + def sort(self, **kwds) -> 'Fill': + ... + + @overload + def sort(self, **kwds) -> 'Fill': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Fill': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Fill': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Fill': + ... + + @overload + def timeUnit(self, **kwds) -> 'Fill': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Fill': + ... + + @overload + def title(self, **kwds) -> 'Fill': + ... + + @overload + def title(self, _: None, **kwds) -> 'Fill': + ... + + def type(self, _: str, **kwds) -> 'Fill': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -1982,6 +2713,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class FillDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGradientstringnull): """FillDatum schema wrapper @@ -2097,12 +2829,37 @@ class FillDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGrad """ _class_is_valid_at_instantiation = False _encoding_name = "fill" + + def bandPosition(self, _: float, **kwds) -> 'FillDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillDatum': + ... + + @overload + def title(self, **kwds) -> 'FillDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'FillDatum': + ... + + def type(self, _: str, **kwds) -> 'FillDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(FillDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class FillValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull): """FillValue schema wrapper @@ -2121,10 +2878,24 @@ class FillValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatu _class_is_valid_at_instantiation = False _encoding_name = "fill" + @overload + def condition(self, **kwds) -> 'FillValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(FillValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class FillOpacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """FillOpacity schema wrapper @@ -2355,6 +3126,105 @@ class FillOpacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFi _class_is_valid_at_instantiation = False _encoding_name = "fillOpacity" + @overload + def aggregate(self, _: str, **kwds) -> 'FillOpacity': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'FillOpacity': + ... + + def bandPosition(self, _: float, **kwds) -> 'FillOpacity': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'FillOpacity': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def bin(self, _: None, **kwds) -> 'FillOpacity': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillOpacity': + ... + + @overload + def field(self, _: str, **kwds) -> 'FillOpacity': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def legend(self, _: None, **kwds) -> 'FillOpacity': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def scale(self, _: None, **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def sort(self, _: None, **kwds) -> 'FillOpacity': + ... + + @overload + def timeUnit(self, **kwds) -> 'FillOpacity': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'FillOpacity': + ... + + @overload + def title(self, **kwds) -> 'FillOpacity': + ... + + @overload + def title(self, _: None, **kwds) -> 'FillOpacity': + ... + + def type(self, _: str, **kwds) -> 'FillOpacity': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -2364,6 +3234,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class FillOpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """FillOpacityDatum schema wrapper @@ -2479,12 +3350,37 @@ class FillOpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatum """ _class_is_valid_at_instantiation = False _encoding_name = "fillOpacity" + + def bandPosition(self, _: float, **kwds) -> 'FillOpacityDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillOpacityDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillOpacityDatum': + ... + + @overload + def title(self, **kwds) -> 'FillOpacityDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'FillOpacityDatum': + ... + + def type(self, _: str, **kwds) -> 'FillOpacityDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(FillOpacityDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class FillOpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """FillOpacityValue schema wrapper @@ -2503,10 +3399,24 @@ class FillOpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFiel _class_is_valid_at_instantiation = False _encoding_name = "fillOpacity" + @overload + def condition(self, **kwds) -> 'FillOpacityValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'FillOpacityValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'FillOpacityValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(FillOpacityValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Href(FieldChannelMixin, core.StringFieldDefWithCondition): """Href schema wrapper @@ -2710,6 +3620,84 @@ class Href(FieldChannelMixin, core.StringFieldDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "href" + @overload + def aggregate(self, _: str, **kwds) -> 'Href': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Href': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Href': + ... + + def bandPosition(self, _: float, **kwds) -> 'Href': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Href': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Href': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Href': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Href': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Href': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Href': + ... + + @overload + def field(self, _: str, **kwds) -> 'Href': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Href': + ... + + @overload + def format(self, _: str, **kwds) -> 'Href': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Href': + ... + + def formatType(self, _: str, **kwds) -> 'Href': + ... + + @overload + def timeUnit(self, **kwds) -> 'Href': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Href': + ... + + @overload + def title(self, **kwds) -> 'Href': + ... + + @overload + def title(self, _: None, **kwds) -> 'Href': + ... + + def type(self, _: str, **kwds) -> 'Href': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -2719,6 +3707,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class HrefValue(ValueChannelMixin, core.StringValueDefWithCondition): """HrefValue schema wrapper @@ -2737,10 +3726,24 @@ class HrefValue(ValueChannelMixin, core.StringValueDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "href" + @overload + def condition(self, **kwds) -> 'HrefValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'HrefValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'HrefValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(HrefValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Key(FieldChannelMixin, core.FieldDefWithoutScale): """Key schema wrapper @@ -2902,6 +3905,65 @@ class Key(FieldChannelMixin, core.FieldDefWithoutScale): _class_is_valid_at_instantiation = False _encoding_name = "key" + @overload + def aggregate(self, _: str, **kwds) -> 'Key': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Key': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Key': + ... + + def bandPosition(self, _: float, **kwds) -> 'Key': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Key': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Key': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Key': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Key': + ... + + @overload + def field(self, _: str, **kwds) -> 'Key': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Key': + ... + + @overload + def timeUnit(self, **kwds) -> 'Key': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Key': + ... + + @overload + def title(self, **kwds) -> 'Key': + ... + + @overload + def title(self, _: None, **kwds) -> 'Key': + ... + + def type(self, _: str, **kwds) -> 'Key': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): super(Key, self).__init__(shorthand=shorthand, aggregate=aggregate, bandPosition=bandPosition, @@ -2909,6 +3971,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class Latitude(FieldChannelMixin, core.LatLongFieldDef): """Latitude schema wrapper @@ -3069,6 +4132,52 @@ class Latitude(FieldChannelMixin, core.LatLongFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "latitude" + @overload + def aggregate(self, _: str, **kwds) -> 'Latitude': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Latitude': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Latitude': + ... + + def bandPosition(self, _: float, **kwds) -> 'Latitude': + ... + + def bin(self, _: None, **kwds) -> 'Latitude': + ... + + @overload + def field(self, _: str, **kwds) -> 'Latitude': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Latitude': + ... + + @overload + def timeUnit(self, **kwds) -> 'Latitude': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Latitude': + ... + + @overload + def title(self, **kwds) -> 'Latitude': + ... + + @overload + def title(self, _: None, **kwds) -> 'Latitude': + ... + + def type(self, _: str, **kwds) -> 'Latitude': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): super(Latitude, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -3076,6 +4185,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class LatitudeDatum(DatumChannelMixin, core.DatumDef): """LatitudeDatum schema wrapper @@ -3182,11 +4292,28 @@ class LatitudeDatum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "latitude" + + def bandPosition(self, _: float, **kwds) -> 'LatitudeDatum': + ... + + @overload + def title(self, **kwds) -> 'LatitudeDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'LatitudeDatum': + ... + + def type(self, _: str, **kwds) -> 'LatitudeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(LatitudeDatum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) +@with_property_setters class Latitude2(FieldChannelMixin, core.SecondaryFieldDef): """Latitude2 schema wrapper @@ -3280,6 +4407,49 @@ class Latitude2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "latitude2" + @overload + def aggregate(self, _: str, **kwds) -> 'Latitude2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Latitude2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Latitude2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Latitude2': + ... + + def bin(self, _: None, **kwds) -> 'Latitude2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Latitude2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Latitude2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Latitude2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Latitude2': + ... + + @overload + def title(self, **kwds) -> 'Latitude2': + ... + + @overload + def title(self, _: None, **kwds) -> 'Latitude2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Latitude2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -3287,6 +4457,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class Latitude2Datum(DatumChannelMixin, core.DatumDef): """Latitude2Datum schema wrapper @@ -3393,11 +4564,28 @@ class Latitude2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "latitude2" + + def bandPosition(self, _: float, **kwds) -> 'Latitude2Datum': + ... + + @overload + def title(self, **kwds) -> 'Latitude2Datum': + ... + + @overload + def title(self, _: None, **kwds) -> 'Latitude2Datum': + ... + + def type(self, _: str, **kwds) -> 'Latitude2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Latitude2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) +@with_property_setters class Latitude2Value(ValueChannelMixin, core.PositionValueDef): """Latitude2Value schema wrapper @@ -3416,10 +4604,13 @@ class Latitude2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "latitude2" + + def __init__(self, value, **kwds): super(Latitude2Value, self).__init__(value=value, **kwds) +@with_property_setters class Longitude(FieldChannelMixin, core.LatLongFieldDef): """Longitude schema wrapper @@ -3580,6 +4771,52 @@ class Longitude(FieldChannelMixin, core.LatLongFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "longitude" + @overload + def aggregate(self, _: str, **kwds) -> 'Longitude': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Longitude': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Longitude': + ... + + def bandPosition(self, _: float, **kwds) -> 'Longitude': + ... + + def bin(self, _: None, **kwds) -> 'Longitude': + ... + + @overload + def field(self, _: str, **kwds) -> 'Longitude': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Longitude': + ... + + @overload + def timeUnit(self, **kwds) -> 'Longitude': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Longitude': + ... + + @overload + def title(self, **kwds) -> 'Longitude': + ... + + @overload + def title(self, _: None, **kwds) -> 'Longitude': + ... + + def type(self, _: str, **kwds) -> 'Longitude': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): super(Longitude, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -3587,6 +4824,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class LongitudeDatum(DatumChannelMixin, core.DatumDef): """LongitudeDatum schema wrapper @@ -3693,11 +4931,28 @@ class LongitudeDatum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "longitude" + + def bandPosition(self, _: float, **kwds) -> 'LongitudeDatum': + ... + + @overload + def title(self, **kwds) -> 'LongitudeDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'LongitudeDatum': + ... + + def type(self, _: str, **kwds) -> 'LongitudeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(LongitudeDatum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) +@with_property_setters class Longitude2(FieldChannelMixin, core.SecondaryFieldDef): """Longitude2 schema wrapper @@ -3791,6 +5046,49 @@ class Longitude2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "longitude2" + @overload + def aggregate(self, _: str, **kwds) -> 'Longitude2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Longitude2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Longitude2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Longitude2': + ... + + def bin(self, _: None, **kwds) -> 'Longitude2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Longitude2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Longitude2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Longitude2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Longitude2': + ... + + @overload + def title(self, **kwds) -> 'Longitude2': + ... + + @overload + def title(self, _: None, **kwds) -> 'Longitude2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Longitude2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -3798,6 +5096,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class Longitude2Datum(DatumChannelMixin, core.DatumDef): """Longitude2Datum schema wrapper @@ -3904,11 +5203,28 @@ class Longitude2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "longitude2" + + def bandPosition(self, _: float, **kwds) -> 'Longitude2Datum': + ... + + @overload + def title(self, **kwds) -> 'Longitude2Datum': + ... + + @overload + def title(self, _: None, **kwds) -> 'Longitude2Datum': + ... + + def type(self, _: str, **kwds) -> 'Longitude2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Longitude2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) +@with_property_setters class Longitude2Value(ValueChannelMixin, core.PositionValueDef): """Longitude2Value schema wrapper @@ -3927,10 +5243,13 @@ class Longitude2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "longitude2" + + def __init__(self, value, **kwds): super(Longitude2Value, self).__init__(value=value, **kwds) +@with_property_setters class Opacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """Opacity schema wrapper @@ -4161,6 +5480,105 @@ class Opacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldD _class_is_valid_at_instantiation = False _encoding_name = "opacity" + @overload + def aggregate(self, _: str, **kwds) -> 'Opacity': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Opacity': + ... + + def bandPosition(self, _: float, **kwds) -> 'Opacity': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Opacity': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Opacity': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Opacity': + ... + + @overload + def field(self, _: str, **kwds) -> 'Opacity': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def legend(self, _: None, **kwds) -> 'Opacity': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Opacity': + ... + + @overload + def sort(self, **kwds) -> 'Opacity': + ... + + @overload + def sort(self, **kwds) -> 'Opacity': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Opacity': + ... + + @overload + def timeUnit(self, **kwds) -> 'Opacity': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Opacity': + ... + + @overload + def title(self, **kwds) -> 'Opacity': + ... + + @overload + def title(self, _: None, **kwds) -> 'Opacity': + ... + + def type(self, _: str, **kwds) -> 'Opacity': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -4170,6 +5588,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class OpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """OpacityDatum schema wrapper @@ -4285,12 +5704,37 @@ class OpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefn """ _class_is_valid_at_instantiation = False _encoding_name = "opacity" + + def bandPosition(self, _: float, **kwds) -> 'OpacityDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'OpacityDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'OpacityDatum': + ... + + @overload + def title(self, **kwds) -> 'OpacityDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'OpacityDatum': + ... + + def type(self, _: str, **kwds) -> 'OpacityDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(OpacityDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class OpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """OpacityValue schema wrapper @@ -4309,10 +5753,24 @@ class OpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrD _class_is_valid_at_instantiation = False _encoding_name = "opacity" + @overload + def condition(self, **kwds) -> 'OpacityValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'OpacityValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'OpacityValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(OpacityValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Order(FieldChannelMixin, core.OrderFieldDef): """Order schema wrapper @@ -4475,6 +5933,68 @@ class Order(FieldChannelMixin, core.OrderFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "order" + @overload + def aggregate(self, _: str, **kwds) -> 'Order': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Order': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Order': + ... + + def bandPosition(self, _: float, **kwds) -> 'Order': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Order': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Order': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Order': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Order': + ... + + @overload + def field(self, _: str, **kwds) -> 'Order': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Order': + ... + + def sort(self, _: str, **kwds) -> 'Order': + ... + + @overload + def timeUnit(self, **kwds) -> 'Order': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Order': + ... + + @overload + def title(self, **kwds) -> 'Order': + ... + + @overload + def title(self, _: None, **kwds) -> 'Order': + ... + + def type(self, _: str, **kwds) -> 'Order': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -4483,6 +6003,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi type=type, **kwds) +@with_property_setters class OrderValue(ValueChannelMixin, core.OrderValueDef): """OrderValue schema wrapper @@ -4506,10 +6027,20 @@ class OrderValue(ValueChannelMixin, core.OrderValueDef): _class_is_valid_at_instantiation = False _encoding_name = "order" + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'OrderValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'OrderValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(OrderValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Radius(FieldChannelMixin, core.PositionFieldDefBase): """Radius schema wrapper @@ -4752,6 +6283,105 @@ class Radius(FieldChannelMixin, core.PositionFieldDefBase): _class_is_valid_at_instantiation = False _encoding_name = "radius" + @overload + def aggregate(self, _: str, **kwds) -> 'Radius': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Radius': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Radius': + ... + + def bandPosition(self, _: float, **kwds) -> 'Radius': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Radius': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Radius': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Radius': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Radius': + ... + + @overload + def field(self, _: str, **kwds) -> 'Radius': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Radius': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Radius': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Radius': + ... + + @overload + def sort(self, **kwds) -> 'Radius': + ... + + @overload + def sort(self, **kwds) -> 'Radius': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Radius': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Radius': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Radius': + ... + + @overload + def stack(self, _: str, **kwds) -> 'Radius': + ... + + @overload + def stack(self, _: None, **kwds) -> 'Radius': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'Radius': + ... + + @overload + def timeUnit(self, **kwds) -> 'Radius': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Radius': + ... + + @overload + def title(self, **kwds) -> 'Radius': + ... + + @overload + def title(self, _: None, **kwds) -> 'Radius': + ... + + def type(self, _: str, **kwds) -> 'Radius': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, scale=Undefined, sort=Undefined, stack=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -4761,6 +6391,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class RadiusDatum(DatumChannelMixin, core.PositionDatumDefBase): """RadiusDatum schema wrapper @@ -4910,12 +6541,49 @@ class RadiusDatum(DatumChannelMixin, core.PositionDatumDefBase): """ _class_is_valid_at_instantiation = False _encoding_name = "radius" + + def bandPosition(self, _: float, **kwds) -> 'RadiusDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'RadiusDatum': + ... + + @overload + def scale(self, _: None, **kwds) -> 'RadiusDatum': + ... + + @overload + def stack(self, _: str, **kwds) -> 'RadiusDatum': + ... + + @overload + def stack(self, _: None, **kwds) -> 'RadiusDatum': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'RadiusDatum': + ... + + @overload + def title(self, **kwds) -> 'RadiusDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'RadiusDatum': + ... + + def type(self, _: str, **kwds) -> 'RadiusDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, scale=Undefined, stack=Undefined, title=Undefined, type=Undefined, **kwds): super(RadiusDatum, self).__init__(datum=datum, bandPosition=bandPosition, scale=scale, stack=stack, title=title, type=type, **kwds) +@with_property_setters class RadiusValue(ValueChannelMixin, core.PositionValueDef): """RadiusValue schema wrapper @@ -4934,10 +6602,13 @@ class RadiusValue(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "radius" + + def __init__(self, value, **kwds): super(RadiusValue, self).__init__(value=value, **kwds) +@with_property_setters class Radius2(FieldChannelMixin, core.SecondaryFieldDef): """Radius2 schema wrapper @@ -5031,6 +6702,49 @@ class Radius2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "radius2" + @overload + def aggregate(self, _: str, **kwds) -> 'Radius2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Radius2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Radius2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Radius2': + ... + + def bin(self, _: None, **kwds) -> 'Radius2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Radius2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Radius2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Radius2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Radius2': + ... + + @overload + def title(self, **kwds) -> 'Radius2': + ... + + @overload + def title(self, _: None, **kwds) -> 'Radius2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Radius2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -5038,6 +6752,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class Radius2Datum(DatumChannelMixin, core.DatumDef): """Radius2Datum schema wrapper @@ -5144,11 +6859,28 @@ class Radius2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "radius2" + + def bandPosition(self, _: float, **kwds) -> 'Radius2Datum': + ... + + @overload + def title(self, **kwds) -> 'Radius2Datum': + ... + + @overload + def title(self, _: None, **kwds) -> 'Radius2Datum': + ... + + def type(self, _: str, **kwds) -> 'Radius2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Radius2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) +@with_property_setters class Radius2Value(ValueChannelMixin, core.PositionValueDef): """Radius2Value schema wrapper @@ -5167,10 +6899,13 @@ class Radius2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "radius2" + + def __init__(self, value, **kwds): super(Radius2Value, self).__init__(value=value, **kwds) +@with_property_setters class Row(FieldChannelMixin, core.RowColumnEncodingFieldDef): """Row schema wrapper @@ -5385,6 +7120,94 @@ class Row(FieldChannelMixin, core.RowColumnEncodingFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "row" + @overload + def aggregate(self, _: str, **kwds) -> 'Row': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Row': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Row': + ... + + def align(self, _: str, **kwds) -> 'Row': + ... + + def bandPosition(self, _: float, **kwds) -> 'Row': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Row': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Row': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Row': + ... + + def center(self, _: bool, **kwds) -> 'Row': + ... + + @overload + def field(self, _: str, **kwds) -> 'Row': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Row': + ... + + @overload + def header(self, format=Undefined, formatType=Undefined, labelAlign=Undefined, labelAnchor=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOrient=Undefined, labelPadding=Undefined, labels=Undefined, orient=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOrient=Undefined, titlePadding=Undefined, **kwds) -> 'Row': + ... + + @overload + def header(self, _: None, **kwds) -> 'Row': + ... + + @overload + def sort(self, **kwds) -> 'Row': + ... + + @overload + def sort(self, _: str, **kwds) -> 'Row': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Row': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Row': + ... + + def spacing(self, _: float, **kwds) -> 'Row': + ... + + @overload + def timeUnit(self, **kwds) -> 'Row': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Row': + ... + + @overload + def title(self, **kwds) -> 'Row': + ... + + @overload + def title(self, _: None, **kwds) -> 'Row': + ... + + def type(self, _: str, **kwds) -> 'Row': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, bandPosition=Undefined, bin=Undefined, center=Undefined, field=Undefined, header=Undefined, sort=Undefined, spacing=Undefined, timeUnit=Undefined, @@ -5395,6 +7218,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, align=Undefined, title=title, type=type, **kwds) +@with_property_setters class Shape(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefTypeForShapestringnull): """Shape schema wrapper @@ -5625,6 +7449,105 @@ class Shape(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDef _class_is_valid_at_instantiation = False _encoding_name = "shape" + @overload + def aggregate(self, _: str, **kwds) -> 'Shape': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Shape': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Shape': + ... + + def bandPosition(self, _: float, **kwds) -> 'Shape': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Shape': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Shape': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Shape': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Shape': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Shape': + ... + + @overload + def field(self, _: str, **kwds) -> 'Shape': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Shape': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Shape': + ... + + @overload + def legend(self, _: None, **kwds) -> 'Shape': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Shape': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Shape': + ... + + @overload + def sort(self, **kwds) -> 'Shape': + ... + + @overload + def sort(self, **kwds) -> 'Shape': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Shape': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Shape': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Shape': + ... + + @overload + def timeUnit(self, **kwds) -> 'Shape': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Shape': + ... + + @overload + def title(self, **kwds) -> 'Shape': + ... + + @overload + def title(self, _: None, **kwds) -> 'Shape': + ... + + def type(self, _: str, **kwds) -> 'Shape': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -5634,6 +7557,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class ShapeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefstringnull): """ShapeDatum schema wrapper @@ -5749,12 +7673,37 @@ class ShapeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefstr """ _class_is_valid_at_instantiation = False _encoding_name = "shape" + + def bandPosition(self, _: float, **kwds) -> 'ShapeDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'ShapeDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'ShapeDatum': + ... + + @overload + def title(self, **kwds) -> 'ShapeDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'ShapeDatum': + ... + + def type(self, _: str, **kwds) -> 'ShapeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(ShapeDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class ShapeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefTypeForShapestringnull): """ShapeValue schema wrapper @@ -5773,10 +7722,24 @@ class ShapeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDat _class_is_valid_at_instantiation = False _encoding_name = "shape" + @overload + def condition(self, **kwds) -> 'ShapeValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'ShapeValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'ShapeValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(ShapeValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Size(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """Size schema wrapper @@ -6007,6 +7970,105 @@ class Size(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefn _class_is_valid_at_instantiation = False _encoding_name = "size" + @overload + def aggregate(self, _: str, **kwds) -> 'Size': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Size': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Size': + ... + + def bandPosition(self, _: float, **kwds) -> 'Size': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Size': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Size': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Size': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Size': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Size': + ... + + @overload + def field(self, _: str, **kwds) -> 'Size': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Size': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Size': + ... + + @overload + def legend(self, _: None, **kwds) -> 'Size': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Size': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Size': + ... + + @overload + def sort(self, **kwds) -> 'Size': + ... + + @overload + def sort(self, **kwds) -> 'Size': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Size': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Size': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Size': + ... + + @overload + def timeUnit(self, **kwds) -> 'Size': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Size': + ... + + @overload + def title(self, **kwds) -> 'Size': + ... + + @overload + def title(self, _: None, **kwds) -> 'Size': + ... + + def type(self, _: str, **kwds) -> 'Size': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -6016,6 +8078,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class SizeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """SizeDatum schema wrapper @@ -6131,12 +8194,37 @@ class SizeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumb """ _class_is_valid_at_instantiation = False _encoding_name = "size" + + def bandPosition(self, _: float, **kwds) -> 'SizeDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'SizeDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'SizeDatum': + ... + + @overload + def title(self, **kwds) -> 'SizeDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'SizeDatum': + ... + + def type(self, _: str, **kwds) -> 'SizeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(SizeDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class SizeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """SizeValue schema wrapper @@ -6155,10 +8243,24 @@ class SizeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatu _class_is_valid_at_instantiation = False _encoding_name = "size" + @overload + def condition(self, **kwds) -> 'SizeValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'SizeValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'SizeValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(SizeValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Stroke(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull): """Stroke schema wrapper @@ -6389,6 +8491,105 @@ class Stroke(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDe _class_is_valid_at_instantiation = False _encoding_name = "stroke" + @overload + def aggregate(self, _: str, **kwds) -> 'Stroke': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Stroke': + ... + + def bandPosition(self, _: float, **kwds) -> 'Stroke': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Stroke': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Stroke': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Stroke': + ... + + @overload + def field(self, _: str, **kwds) -> 'Stroke': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def legend(self, _: None, **kwds) -> 'Stroke': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Stroke': + ... + + @overload + def sort(self, **kwds) -> 'Stroke': + ... + + @overload + def sort(self, **kwds) -> 'Stroke': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Stroke': + ... + + @overload + def timeUnit(self, **kwds) -> 'Stroke': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Stroke': + ... + + @overload + def title(self, **kwds) -> 'Stroke': + ... + + @overload + def title(self, _: None, **kwds) -> 'Stroke': + ... + + def type(self, _: str, **kwds) -> 'Stroke': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -6398,6 +8599,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class StrokeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGradientstringnull): """StrokeDatum schema wrapper @@ -6513,12 +8715,37 @@ class StrokeDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefGr """ _class_is_valid_at_instantiation = False _encoding_name = "stroke" + + def bandPosition(self, _: float, **kwds) -> 'StrokeDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeDatum': + ... + + @overload + def title(self, **kwds) -> 'StrokeDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'StrokeDatum': + ... + + def type(self, _: str, **kwds) -> 'StrokeDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(StrokeDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class StrokeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull): """StrokeValue schema wrapper @@ -6537,10 +8764,24 @@ class StrokeValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDa _class_is_valid_at_instantiation = False _encoding_name = "stroke" + @overload + def condition(self, **kwds) -> 'StrokeValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(StrokeValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class StrokeDash(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumberArray): """StrokeDash schema wrapper @@ -6771,6 +9012,105 @@ class StrokeDash(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFie _class_is_valid_at_instantiation = False _encoding_name = "strokeDash" + @overload + def aggregate(self, _: str, **kwds) -> 'StrokeDash': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'StrokeDash': + ... + + def bandPosition(self, _: float, **kwds) -> 'StrokeDash': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'StrokeDash': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def bin(self, _: None, **kwds) -> 'StrokeDash': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeDash': + ... + + @overload + def field(self, _: str, **kwds) -> 'StrokeDash': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def legend(self, _: None, **kwds) -> 'StrokeDash': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def scale(self, _: None, **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def sort(self, _: None, **kwds) -> 'StrokeDash': + ... + + @overload + def timeUnit(self, **kwds) -> 'StrokeDash': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'StrokeDash': + ... + + @overload + def title(self, **kwds) -> 'StrokeDash': + ... + + @overload + def title(self, _: None, **kwds) -> 'StrokeDash': + ... + + def type(self, _: str, **kwds) -> 'StrokeDash': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -6780,6 +9120,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class StrokeDashDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumberArray): """StrokeDashDatum schema wrapper @@ -6895,12 +9236,37 @@ class StrokeDashDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumD """ _class_is_valid_at_instantiation = False _encoding_name = "strokeDash" + + def bandPosition(self, _: float, **kwds) -> 'StrokeDashDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeDashDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeDashDatum': + ... + + @overload + def title(self, **kwds) -> 'StrokeDashDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'StrokeDashDatum': + ... + + def type(self, _: str, **kwds) -> 'StrokeDashDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(StrokeDashDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class StrokeDashValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumberArray): """StrokeDashValue schema wrapper @@ -6919,10 +9285,24 @@ class StrokeDashValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropField _class_is_valid_at_instantiation = False _encoding_name = "strokeDash" + @overload + def condition(self, **kwds) -> 'StrokeDashValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeDashValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeDashValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(StrokeDashValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class StrokeOpacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """StrokeOpacity schema wrapper @@ -7153,6 +9533,105 @@ class StrokeOpacity(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkProp _class_is_valid_at_instantiation = False _encoding_name = "strokeOpacity" + @overload + def aggregate(self, _: str, **kwds) -> 'StrokeOpacity': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'StrokeOpacity': + ... + + def bandPosition(self, _: float, **kwds) -> 'StrokeOpacity': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'StrokeOpacity': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def bin(self, _: None, **kwds) -> 'StrokeOpacity': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeOpacity': + ... + + @overload + def field(self, _: str, **kwds) -> 'StrokeOpacity': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def legend(self, _: None, **kwds) -> 'StrokeOpacity': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def scale(self, _: None, **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def sort(self, _: None, **kwds) -> 'StrokeOpacity': + ... + + @overload + def timeUnit(self, **kwds) -> 'StrokeOpacity': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'StrokeOpacity': + ... + + @overload + def title(self, **kwds) -> 'StrokeOpacity': + ... + + @overload + def title(self, _: None, **kwds) -> 'StrokeOpacity': + ... + + def type(self, _: str, **kwds) -> 'StrokeOpacity': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -7162,6 +9641,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class StrokeOpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """StrokeOpacityDatum schema wrapper @@ -7277,12 +9757,37 @@ class StrokeOpacityDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDat """ _class_is_valid_at_instantiation = False _encoding_name = "strokeOpacity" + + def bandPosition(self, _: float, **kwds) -> 'StrokeOpacityDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeOpacityDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeOpacityDatum': + ... + + @overload + def title(self, **kwds) -> 'StrokeOpacityDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'StrokeOpacityDatum': + ... + + def type(self, _: str, **kwds) -> 'StrokeOpacityDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(StrokeOpacityDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class StrokeOpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """StrokeOpacityValue schema wrapper @@ -7301,10 +9806,24 @@ class StrokeOpacityValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFi _class_is_valid_at_instantiation = False _encoding_name = "strokeOpacity" + @overload + def condition(self, **kwds) -> 'StrokeOpacityValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeOpacityValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeOpacityValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(StrokeOpacityValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class StrokeWidth(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber): """StrokeWidth schema wrapper @@ -7535,6 +10054,105 @@ class StrokeWidth(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFi _class_is_valid_at_instantiation = False _encoding_name = "strokeWidth" + @overload + def aggregate(self, _: str, **kwds) -> 'StrokeWidth': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'StrokeWidth': + ... + + def bandPosition(self, _: float, **kwds) -> 'StrokeWidth': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'StrokeWidth': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def bin(self, _: None, **kwds) -> 'StrokeWidth': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeWidth': + ... + + @overload + def field(self, _: str, **kwds) -> 'StrokeWidth': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def legend(self, aria=Undefined, clipHeight=Undefined, columnPadding=Undefined, columns=Undefined, cornerRadius=Undefined, description=Undefined, direction=Undefined, fillColor=Undefined, format=Undefined, formatType=Undefined, gradientLength=Undefined, gradientOpacity=Undefined, gradientStrokeColor=Undefined, gradientStrokeWidth=Undefined, gradientThickness=Undefined, gridAlign=Undefined, labelAlign=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, legendX=Undefined, legendY=Undefined, offset=Undefined, orient=Undefined, padding=Undefined, rowPadding=Undefined, strokeColor=Undefined, symbolDash=Undefined, symbolDashOffset=Undefined, symbolFillColor=Undefined, symbolLimit=Undefined, symbolOffset=Undefined, symbolOpacity=Undefined, symbolSize=Undefined, symbolStrokeColor=Undefined, symbolStrokeWidth=Undefined, symbolType=Undefined, tickCount=Undefined, tickMinStep=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titleOrient=Undefined, titlePadding=Undefined, type=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def legend(self, _: None, **kwds) -> 'StrokeWidth': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def scale(self, _: None, **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def sort(self, _: None, **kwds) -> 'StrokeWidth': + ... + + @overload + def timeUnit(self, **kwds) -> 'StrokeWidth': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'StrokeWidth': + ... + + @overload + def title(self, **kwds) -> 'StrokeWidth': + ... + + @overload + def title(self, _: None, **kwds) -> 'StrokeWidth': + ... + + def type(self, _: str, **kwds) -> 'StrokeWidth': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, legend=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -7544,6 +10162,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class StrokeWidthDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatumDefnumber): """StrokeWidthDatum schema wrapper @@ -7659,12 +10278,37 @@ class StrokeWidthDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionDatum """ _class_is_valid_at_instantiation = False _encoding_name = "strokeWidth" + + def bandPosition(self, _: float, **kwds) -> 'StrokeWidthDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeWidthDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeWidthDatum': + ... + + @overload + def title(self, **kwds) -> 'StrokeWidthDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'StrokeWidthDatum': + ... + + def type(self, _: str, **kwds) -> 'StrokeWidthDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, title=Undefined, type=Undefined, **kwds): super(StrokeWidthDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, title=title, type=type, **kwds) +@with_property_setters class StrokeWidthValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFieldOrDatumDefnumber): """StrokeWidthValue schema wrapper @@ -7683,10 +10327,24 @@ class StrokeWidthValue(ValueChannelMixin, core.ValueDefWithConditionMarkPropFiel _class_is_valid_at_instantiation = False _encoding_name = "strokeWidth" + @overload + def condition(self, **kwds) -> 'StrokeWidthValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'StrokeWidthValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'StrokeWidthValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(StrokeWidthValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Text(FieldChannelMixin, core.FieldOrDatumDefWithConditionStringFieldDefText): """Text schema wrapper @@ -7890,6 +10548,84 @@ class Text(FieldChannelMixin, core.FieldOrDatumDefWithConditionStringFieldDefTex _class_is_valid_at_instantiation = False _encoding_name = "text" + @overload + def aggregate(self, _: str, **kwds) -> 'Text': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Text': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Text': + ... + + def bandPosition(self, _: float, **kwds) -> 'Text': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Text': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Text': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Text': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Text': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Text': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Text': + ... + + @overload + def field(self, _: str, **kwds) -> 'Text': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Text': + ... + + @overload + def format(self, _: str, **kwds) -> 'Text': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Text': + ... + + def formatType(self, _: str, **kwds) -> 'Text': + ... + + @overload + def timeUnit(self, **kwds) -> 'Text': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Text': + ... + + @overload + def title(self, **kwds) -> 'Text': + ... + + @overload + def title(self, _: None, **kwds) -> 'Text': + ... + + def type(self, _: str, **kwds) -> 'Text': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -7899,6 +10635,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class TextDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionStringDatumDefText): """TextDatum schema wrapper @@ -8048,6 +10785,41 @@ class TextDatum(DatumChannelMixin, core.FieldOrDatumDefWithConditionStringDatumD """ _class_is_valid_at_instantiation = False _encoding_name = "text" + + def bandPosition(self, _: float, **kwds) -> 'TextDatum': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'TextDatum': + ... + + @overload + def condition(self, _: list, **kwds) -> 'TextDatum': + ... + + @overload + def format(self, _: str, **kwds) -> 'TextDatum': + ... + + @overload + def format(self, _: dict, **kwds) -> 'TextDatum': + ... + + def formatType(self, _: str, **kwds) -> 'TextDatum': + ... + + @overload + def title(self, **kwds) -> 'TextDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'TextDatum': + ... + + def type(self, _: str, **kwds) -> 'TextDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, condition=Undefined, format=Undefined, formatType=Undefined, title=Undefined, type=Undefined, **kwds): super(TextDatum, self).__init__(datum=datum, bandPosition=bandPosition, condition=condition, @@ -8055,6 +10827,7 @@ def __init__(self, datum, bandPosition=Undefined, condition=Undefined, format=Un **kwds) +@with_property_setters class TextValue(ValueChannelMixin, core.ValueDefWithConditionStringFieldDefText): """TextValue schema wrapper @@ -8073,10 +10846,24 @@ class TextValue(ValueChannelMixin, core.ValueDefWithConditionStringFieldDefText) _class_is_valid_at_instantiation = False _encoding_name = "text" + @overload + def condition(self, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, empty=Undefined, field=Undefined, format=Undefined, formatType=Undefined, param=Undefined, test=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds) -> 'TextValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'TextValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'TextValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(TextValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Theta(FieldChannelMixin, core.PositionFieldDefBase): """Theta schema wrapper @@ -8319,6 +11106,105 @@ class Theta(FieldChannelMixin, core.PositionFieldDefBase): _class_is_valid_at_instantiation = False _encoding_name = "theta" + @overload + def aggregate(self, _: str, **kwds) -> 'Theta': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Theta': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Theta': + ... + + def bandPosition(self, _: float, **kwds) -> 'Theta': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Theta': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Theta': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Theta': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Theta': + ... + + @overload + def field(self, _: str, **kwds) -> 'Theta': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Theta': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Theta': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Theta': + ... + + @overload + def sort(self, **kwds) -> 'Theta': + ... + + @overload + def sort(self, **kwds) -> 'Theta': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Theta': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Theta': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Theta': + ... + + @overload + def stack(self, _: str, **kwds) -> 'Theta': + ... + + @overload + def stack(self, _: None, **kwds) -> 'Theta': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'Theta': + ... + + @overload + def timeUnit(self, **kwds) -> 'Theta': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Theta': + ... + + @overload + def title(self, **kwds) -> 'Theta': + ... + + @overload + def title(self, _: None, **kwds) -> 'Theta': + ... + + def type(self, _: str, **kwds) -> 'Theta': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, scale=Undefined, sort=Undefined, stack=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -8327,6 +11213,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class ThetaDatum(DatumChannelMixin, core.PositionDatumDefBase): """ThetaDatum schema wrapper @@ -8476,12 +11363,49 @@ class ThetaDatum(DatumChannelMixin, core.PositionDatumDefBase): """ _class_is_valid_at_instantiation = False _encoding_name = "theta" + + def bandPosition(self, _: float, **kwds) -> 'ThetaDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'ThetaDatum': + ... + + @overload + def scale(self, _: None, **kwds) -> 'ThetaDatum': + ... + + @overload + def stack(self, _: str, **kwds) -> 'ThetaDatum': + ... + + @overload + def stack(self, _: None, **kwds) -> 'ThetaDatum': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'ThetaDatum': + ... + + @overload + def title(self, **kwds) -> 'ThetaDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'ThetaDatum': + ... + + def type(self, _: str, **kwds) -> 'ThetaDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, scale=Undefined, stack=Undefined, title=Undefined, type=Undefined, **kwds): super(ThetaDatum, self).__init__(datum=datum, bandPosition=bandPosition, scale=scale, stack=stack, title=title, type=type, **kwds) +@with_property_setters class ThetaValue(ValueChannelMixin, core.PositionValueDef): """ThetaValue schema wrapper @@ -8500,10 +11424,13 @@ class ThetaValue(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "theta" + + def __init__(self, value, **kwds): super(ThetaValue, self).__init__(value=value, **kwds) +@with_property_setters class Theta2(FieldChannelMixin, core.SecondaryFieldDef): """Theta2 schema wrapper @@ -8597,6 +11524,49 @@ class Theta2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "theta2" + @overload + def aggregate(self, _: str, **kwds) -> 'Theta2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Theta2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Theta2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Theta2': + ... + + def bin(self, _: None, **kwds) -> 'Theta2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Theta2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Theta2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Theta2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Theta2': + ... + + @overload + def title(self, **kwds) -> 'Theta2': + ... + + @overload + def title(self, _: None, **kwds) -> 'Theta2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Theta2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -8604,6 +11574,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi title=title, **kwds) +@with_property_setters class Theta2Datum(DatumChannelMixin, core.DatumDef): """Theta2Datum schema wrapper @@ -8710,11 +11681,28 @@ class Theta2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "theta2" + + def bandPosition(self, _: float, **kwds) -> 'Theta2Datum': + ... + + @overload + def title(self, **kwds) -> 'Theta2Datum': + ... + + @overload + def title(self, _: None, **kwds) -> 'Theta2Datum': + ... + + def type(self, _: str, **kwds) -> 'Theta2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Theta2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) +@with_property_setters class Theta2Value(ValueChannelMixin, core.PositionValueDef): """Theta2Value schema wrapper @@ -8733,10 +11721,13 @@ class Theta2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "theta2" + + def __init__(self, value, **kwds): super(Theta2Value, self).__init__(value=value, **kwds) +@with_property_setters class Tooltip(FieldChannelMixin, core.StringFieldDefWithCondition): """Tooltip schema wrapper @@ -8940,6 +11931,84 @@ class Tooltip(FieldChannelMixin, core.StringFieldDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "tooltip" + @overload + def aggregate(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Tooltip': + ... + + def bandPosition(self, _: float, **kwds) -> 'Tooltip': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Tooltip': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Tooltip': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Tooltip': + ... + + @overload + def field(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def format(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Tooltip': + ... + + def formatType(self, _: str, **kwds) -> 'Tooltip': + ... + + @overload + def timeUnit(self, **kwds) -> 'Tooltip': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Tooltip': + ... + + @overload + def title(self, **kwds) -> 'Tooltip': + ... + + @overload + def title(self, _: None, **kwds) -> 'Tooltip': + ... + + def type(self, _: str, **kwds) -> 'Tooltip': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -8949,6 +12018,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class TooltipValue(ValueChannelMixin, core.StringValueDefWithCondition): """TooltipValue schema wrapper @@ -8967,10 +12037,24 @@ class TooltipValue(ValueChannelMixin, core.StringValueDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "tooltip" + @overload + def condition(self, **kwds) -> 'TooltipValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'TooltipValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'TooltipValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(TooltipValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class Url(FieldChannelMixin, core.StringFieldDefWithCondition): """Url schema wrapper @@ -9168,11 +12252,89 @@ class Url(FieldChannelMixin, core.StringFieldDefWithCondition): ``type`` as they must have exactly the same type as their primary channels (e.g., ``x``, ``y`` ). - **See also:** `type `__ - documentation. - """ - _class_is_valid_at_instantiation = False - _encoding_name = "url" + **See also:** `type `__ + documentation. + """ + _class_is_valid_at_instantiation = False + _encoding_name = "url" + + @overload + def aggregate(self, _: str, **kwds) -> 'Url': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Url': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Url': + ... + + def bandPosition(self, _: float, **kwds) -> 'Url': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Url': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Url': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Url': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Url': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'Url': + ... + + @overload + def condition(self, _: list, **kwds) -> 'Url': + ... + + @overload + def field(self, _: str, **kwds) -> 'Url': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Url': + ... + + @overload + def format(self, _: str, **kwds) -> 'Url': + ... + + @overload + def format(self, _: dict, **kwds) -> 'Url': + ... + + def formatType(self, _: str, **kwds) -> 'Url': + ... + + @overload + def timeUnit(self, **kwds) -> 'Url': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Url': + ... + + @overload + def title(self, **kwds) -> 'Url': + ... + + @overload + def title(self, _: None, **kwds) -> 'Url': + ... + + def type(self, _: str, **kwds) -> 'Url': + ... + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, condition=Undefined, field=Undefined, format=Undefined, formatType=Undefined, @@ -9183,6 +12345,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi **kwds) +@with_property_setters class UrlValue(ValueChannelMixin, core.StringValueDefWithCondition): """UrlValue schema wrapper @@ -9201,10 +12364,24 @@ class UrlValue(ValueChannelMixin, core.StringValueDefWithCondition): _class_is_valid_at_instantiation = False _encoding_name = "url" + @overload + def condition(self, **kwds) -> 'UrlValue': + ... + + @overload + def condition(self, empty=Undefined, param=Undefined, test=Undefined, value=Undefined, **kwds) -> 'UrlValue': + ... + + @overload + def condition(self, _: list, **kwds) -> 'UrlValue': + ... + + def __init__(self, value, condition=Undefined, **kwds): super(UrlValue, self).__init__(value=value, condition=condition, **kwds) +@with_property_setters class X(FieldChannelMixin, core.PositionFieldDef): """X schema wrapper @@ -9464,6 +12641,121 @@ class X(FieldChannelMixin, core.PositionFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "x" + @overload + def aggregate(self, _: str, **kwds) -> 'X': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'X': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'X': + ... + + @overload + def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'X': + ... + + @overload + def axis(self, _: None, **kwds) -> 'X': + ... + + def bandPosition(self, _: float, **kwds) -> 'X': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'X': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'X': + ... + + @overload + def bin(self, _: str, **kwds) -> 'X': + ... + + @overload + def bin(self, _: None, **kwds) -> 'X': + ... + + @overload + def field(self, _: str, **kwds) -> 'X': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'X': + ... + + @overload + def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Undefined, **kwds) -> 'X': + ... + + @overload + def impute(self, _: None, **kwds) -> 'X': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'X': + ... + + @overload + def scale(self, _: None, **kwds) -> 'X': + ... + + @overload + def sort(self, **kwds) -> 'X': + ... + + @overload + def sort(self, **kwds) -> 'X': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'X': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'X': + ... + + @overload + def sort(self, _: None, **kwds) -> 'X': + ... + + @overload + def stack(self, _: str, **kwds) -> 'X': + ... + + @overload + def stack(self, _: None, **kwds) -> 'X': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'X': + ... + + @overload + def timeUnit(self, **kwds) -> 'X': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'X': + ... + + @overload + def title(self, **kwds) -> 'X': + ... + + @overload + def title(self, _: None, **kwds) -> 'X': + ... + + def type(self, _: str, **kwds) -> 'X': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, axis=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, impute=Undefined, scale=Undefined, sort=Undefined, stack=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -9473,6 +12765,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, axis=Undefined, ban type=type, **kwds) +@with_property_setters class XDatum(DatumChannelMixin, core.PositionDatumDef): """XDatum schema wrapper @@ -9639,12 +12932,65 @@ class XDatum(DatumChannelMixin, core.PositionDatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "x" + + @overload + def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'XDatum': + ... + + @overload + def axis(self, _: None, **kwds) -> 'XDatum': + ... + + def bandPosition(self, _: float, **kwds) -> 'XDatum': + ... + + @overload + def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Undefined, **kwds) -> 'XDatum': + ... + + @overload + def impute(self, _: None, **kwds) -> 'XDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'XDatum': + ... + + @overload + def scale(self, _: None, **kwds) -> 'XDatum': + ... + + @overload + def stack(self, _: str, **kwds) -> 'XDatum': + ... + + @overload + def stack(self, _: None, **kwds) -> 'XDatum': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'XDatum': + ... + + @overload + def title(self, **kwds) -> 'XDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'XDatum': + ... + + def type(self, _: str, **kwds) -> 'XDatum': + ... + + def __init__(self, datum, axis=Undefined, bandPosition=Undefined, impute=Undefined, scale=Undefined, stack=Undefined, title=Undefined, type=Undefined, **kwds): super(XDatum, self).__init__(datum=datum, axis=axis, bandPosition=bandPosition, impute=impute, scale=scale, stack=stack, title=title, type=type, **kwds) +@with_property_setters class XValue(ValueChannelMixin, core.PositionValueDef): """XValue schema wrapper @@ -9663,10 +13009,13 @@ class XValue(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "x" + + def __init__(self, value, **kwds): super(XValue, self).__init__(value=value, **kwds) +@with_property_setters class X2(FieldChannelMixin, core.SecondaryFieldDef): """X2 schema wrapper @@ -9760,12 +13109,56 @@ class X2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "x2" + @overload + def aggregate(self, _: str, **kwds) -> 'X2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'X2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'X2': + ... + + def bandPosition(self, _: float, **kwds) -> 'X2': + ... + + def bin(self, _: None, **kwds) -> 'X2': + ... + + @overload + def field(self, _: str, **kwds) -> 'X2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'X2': + ... + + @overload + def timeUnit(self, **kwds) -> 'X2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'X2': + ... + + @overload + def title(self, **kwds) -> 'X2': + ... + + @overload + def title(self, _: None, **kwds) -> 'X2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(X2, self).__init__(shorthand=shorthand, aggregate=aggregate, bandPosition=bandPosition, bin=bin, field=field, timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class X2Datum(DatumChannelMixin, core.DatumDef): """X2Datum schema wrapper @@ -9872,11 +13265,28 @@ class X2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "x2" + + def bandPosition(self, _: float, **kwds) -> 'X2Datum': + ... + + @overload + def title(self, **kwds) -> 'X2Datum': + ... + + @overload + def title(self, _: None, **kwds) -> 'X2Datum': + ... + + def type(self, _: str, **kwds) -> 'X2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(X2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) +@with_property_setters class X2Value(ValueChannelMixin, core.PositionValueDef): """X2Value schema wrapper @@ -9895,10 +13305,13 @@ class X2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "x2" + + def __init__(self, value, **kwds): super(X2Value, self).__init__(value=value, **kwds) +@with_property_setters class XError(FieldChannelMixin, core.SecondaryFieldDef): """XError schema wrapper @@ -9992,6 +13405,49 @@ class XError(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "xError" + @overload + def aggregate(self, _: str, **kwds) -> 'XError': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'XError': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'XError': + ... + + def bandPosition(self, _: float, **kwds) -> 'XError': + ... + + def bin(self, _: None, **kwds) -> 'XError': + ... + + @overload + def field(self, _: str, **kwds) -> 'XError': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'XError': + ... + + @overload + def timeUnit(self, **kwds) -> 'XError': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'XError': + ... + + @overload + def title(self, **kwds) -> 'XError': + ... + + @overload + def title(self, _: None, **kwds) -> 'XError': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(XError, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -9999,6 +13455,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi title=title, **kwds) +@with_property_setters class XErrorValue(ValueChannelMixin, core.ValueDefnumber): """XErrorValue schema wrapper @@ -10017,10 +13474,13 @@ class XErrorValue(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "xError" + + def __init__(self, value, **kwds): super(XErrorValue, self).__init__(value=value, **kwds) +@with_property_setters class XError2(FieldChannelMixin, core.SecondaryFieldDef): """XError2 schema wrapper @@ -10114,6 +13574,49 @@ class XError2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "xError2" + @overload + def aggregate(self, _: str, **kwds) -> 'XError2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'XError2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'XError2': + ... + + def bandPosition(self, _: float, **kwds) -> 'XError2': + ... + + def bin(self, _: None, **kwds) -> 'XError2': + ... + + @overload + def field(self, _: str, **kwds) -> 'XError2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'XError2': + ... + + @overload + def timeUnit(self, **kwds) -> 'XError2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'XError2': + ... + + @overload + def title(self, **kwds) -> 'XError2': + ... + + @overload + def title(self, _: None, **kwds) -> 'XError2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(XError2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -10121,6 +13624,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class XError2Value(ValueChannelMixin, core.ValueDefnumber): """XError2Value schema wrapper @@ -10139,10 +13643,13 @@ class XError2Value(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "xError2" + + def __init__(self, value, **kwds): super(XError2Value, self).__init__(value=value, **kwds) +@with_property_setters class XOffset(FieldChannelMixin, core.ScaleFieldDef): """XOffset schema wrapper @@ -10355,6 +13862,89 @@ class XOffset(FieldChannelMixin, core.ScaleFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "xOffset" + @overload + def aggregate(self, _: str, **kwds) -> 'XOffset': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'XOffset': + ... + + def bandPosition(self, _: float, **kwds) -> 'XOffset': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'XOffset': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def bin(self, _: None, **kwds) -> 'XOffset': + ... + + @overload + def field(self, _: str, **kwds) -> 'XOffset': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def scale(self, _: None, **kwds) -> 'XOffset': + ... + + @overload + def sort(self, **kwds) -> 'XOffset': + ... + + @overload + def sort(self, **kwds) -> 'XOffset': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def sort(self, _: None, **kwds) -> 'XOffset': + ... + + @overload + def timeUnit(self, **kwds) -> 'XOffset': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'XOffset': + ... + + @overload + def title(self, **kwds) -> 'XOffset': + ... + + @overload + def title(self, _: None, **kwds) -> 'XOffset': + ... + + def type(self, _: str, **kwds) -> 'XOffset': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -10363,6 +13953,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi sort=sort, timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class XOffsetDatum(DatumChannelMixin, core.ScaleDatumDef): """XOffsetDatum schema wrapper @@ -10482,12 +14073,37 @@ class XOffsetDatum(DatumChannelMixin, core.ScaleDatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "xOffset" + + def bandPosition(self, _: float, **kwds) -> 'XOffsetDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'XOffsetDatum': + ... + + @overload + def scale(self, _: None, **kwds) -> 'XOffsetDatum': + ... + + @overload + def title(self, **kwds) -> 'XOffsetDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'XOffsetDatum': + ... + + def type(self, _: str, **kwds) -> 'XOffsetDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, scale=Undefined, title=Undefined, type=Undefined, **kwds): super(XOffsetDatum, self).__init__(datum=datum, bandPosition=bandPosition, scale=scale, title=title, type=type, **kwds) +@with_property_setters class XOffsetValue(ValueChannelMixin, core.ValueDefnumber): """XOffsetValue schema wrapper @@ -10506,10 +14122,13 @@ class XOffsetValue(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "xOffset" + + def __init__(self, value, **kwds): super(XOffsetValue, self).__init__(value=value, **kwds) +@with_property_setters class Y(FieldChannelMixin, core.PositionFieldDef): """Y schema wrapper @@ -10769,6 +14388,121 @@ class Y(FieldChannelMixin, core.PositionFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "y" + @overload + def aggregate(self, _: str, **kwds) -> 'Y': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Y': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Y': + ... + + @overload + def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'Y': + ... + + @overload + def axis(self, _: None, **kwds) -> 'Y': + ... + + def bandPosition(self, _: float, **kwds) -> 'Y': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'Y': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'Y': + ... + + @overload + def bin(self, _: str, **kwds) -> 'Y': + ... + + @overload + def bin(self, _: None, **kwds) -> 'Y': + ... + + @overload + def field(self, _: str, **kwds) -> 'Y': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Y': + ... + + @overload + def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Undefined, **kwds) -> 'Y': + ... + + @overload + def impute(self, _: None, **kwds) -> 'Y': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'Y': + ... + + @overload + def scale(self, _: None, **kwds) -> 'Y': + ... + + @overload + def sort(self, **kwds) -> 'Y': + ... + + @overload + def sort(self, **kwds) -> 'Y': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'Y': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'Y': + ... + + @overload + def sort(self, _: None, **kwds) -> 'Y': + ... + + @overload + def stack(self, _: str, **kwds) -> 'Y': + ... + + @overload + def stack(self, _: None, **kwds) -> 'Y': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'Y': + ... + + @overload + def timeUnit(self, **kwds) -> 'Y': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Y': + ... + + @overload + def title(self, **kwds) -> 'Y': + ... + + @overload + def title(self, _: None, **kwds) -> 'Y': + ... + + def type(self, _: str, **kwds) -> 'Y': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, axis=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, impute=Undefined, scale=Undefined, sort=Undefined, stack=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -10778,6 +14512,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, axis=Undefined, ban type=type, **kwds) +@with_property_setters class YDatum(DatumChannelMixin, core.PositionDatumDef): """YDatum schema wrapper @@ -10944,12 +14679,65 @@ class YDatum(DatumChannelMixin, core.PositionDatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "y" + + @overload + def axis(self, aria=Undefined, bandPosition=Undefined, description=Undefined, domain=Undefined, domainCap=Undefined, domainColor=Undefined, domainDash=Undefined, domainDashOffset=Undefined, domainOpacity=Undefined, domainWidth=Undefined, format=Undefined, formatType=Undefined, grid=Undefined, gridCap=Undefined, gridColor=Undefined, gridDash=Undefined, gridDashOffset=Undefined, gridOpacity=Undefined, gridWidth=Undefined, labelAlign=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelBound=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFlush=Undefined, labelFlushOffset=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOffset=Undefined, labelOpacity=Undefined, labelOverlap=Undefined, labelPadding=Undefined, labelSeparation=Undefined, labels=Undefined, maxExtent=Undefined, minExtent=Undefined, offset=Undefined, orient=Undefined, position=Undefined, style=Undefined, tickBand=Undefined, tickCap=Undefined, tickColor=Undefined, tickCount=Undefined, tickDash=Undefined, tickDashOffset=Undefined, tickExtra=Undefined, tickMinStep=Undefined, tickOffset=Undefined, tickOpacity=Undefined, tickRound=Undefined, tickSize=Undefined, tickWidth=Undefined, ticks=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOpacity=Undefined, titlePadding=Undefined, titleX=Undefined, titleY=Undefined, translate=Undefined, values=Undefined, zindex=Undefined, **kwds) -> 'YDatum': + ... + + @overload + def axis(self, _: None, **kwds) -> 'YDatum': + ... + + def bandPosition(self, _: float, **kwds) -> 'YDatum': + ... + + @overload + def impute(self, frame=Undefined, keyvals=Undefined, method=Undefined, value=Undefined, **kwds) -> 'YDatum': + ... + + @overload + def impute(self, _: None, **kwds) -> 'YDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'YDatum': + ... + + @overload + def scale(self, _: None, **kwds) -> 'YDatum': + ... + + @overload + def stack(self, _: str, **kwds) -> 'YDatum': + ... + + @overload + def stack(self, _: None, **kwds) -> 'YDatum': + ... + + @overload + def stack(self, _: bool, **kwds) -> 'YDatum': + ... + + @overload + def title(self, **kwds) -> 'YDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'YDatum': + ... + + def type(self, _: str, **kwds) -> 'YDatum': + ... + + def __init__(self, datum, axis=Undefined, bandPosition=Undefined, impute=Undefined, scale=Undefined, stack=Undefined, title=Undefined, type=Undefined, **kwds): super(YDatum, self).__init__(datum=datum, axis=axis, bandPosition=bandPosition, impute=impute, scale=scale, stack=stack, title=title, type=type, **kwds) +@with_property_setters class YValue(ValueChannelMixin, core.PositionValueDef): """YValue schema wrapper @@ -10968,10 +14756,13 @@ class YValue(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "y" + + def __init__(self, value, **kwds): super(YValue, self).__init__(value=value, **kwds) +@with_property_setters class Y2(FieldChannelMixin, core.SecondaryFieldDef): """Y2 schema wrapper @@ -11065,12 +14856,56 @@ class Y2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "y2" + @overload + def aggregate(self, _: str, **kwds) -> 'Y2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'Y2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'Y2': + ... + + def bandPosition(self, _: float, **kwds) -> 'Y2': + ... + + def bin(self, _: None, **kwds) -> 'Y2': + ... + + @overload + def field(self, _: str, **kwds) -> 'Y2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'Y2': + ... + + @overload + def timeUnit(self, **kwds) -> 'Y2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'Y2': + ... + + @overload + def title(self, **kwds) -> 'Y2': + ... + + @overload + def title(self, _: None, **kwds) -> 'Y2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(Y2, self).__init__(shorthand=shorthand, aggregate=aggregate, bandPosition=bandPosition, bin=bin, field=field, timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class Y2Datum(DatumChannelMixin, core.DatumDef): """Y2Datum schema wrapper @@ -11177,11 +15012,28 @@ class Y2Datum(DatumChannelMixin, core.DatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "y2" + + def bandPosition(self, _: float, **kwds) -> 'Y2Datum': + ... + + @overload + def title(self, **kwds) -> 'Y2Datum': + ... + + @overload + def title(self, _: None, **kwds) -> 'Y2Datum': + ... + + def type(self, _: str, **kwds) -> 'Y2Datum': + ... + + def __init__(self, datum, bandPosition=Undefined, title=Undefined, type=Undefined, **kwds): super(Y2Datum, self).__init__(datum=datum, bandPosition=bandPosition, title=title, type=type, **kwds) +@with_property_setters class Y2Value(ValueChannelMixin, core.PositionValueDef): """Y2Value schema wrapper @@ -11200,10 +15052,13 @@ class Y2Value(ValueChannelMixin, core.PositionValueDef): _class_is_valid_at_instantiation = False _encoding_name = "y2" + + def __init__(self, value, **kwds): super(Y2Value, self).__init__(value=value, **kwds) +@with_property_setters class YError(FieldChannelMixin, core.SecondaryFieldDef): """YError schema wrapper @@ -11297,6 +15152,49 @@ class YError(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "yError" + @overload + def aggregate(self, _: str, **kwds) -> 'YError': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'YError': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'YError': + ... + + def bandPosition(self, _: float, **kwds) -> 'YError': + ... + + def bin(self, _: None, **kwds) -> 'YError': + ... + + @overload + def field(self, _: str, **kwds) -> 'YError': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'YError': + ... + + @overload + def timeUnit(self, **kwds) -> 'YError': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'YError': + ... + + @overload + def title(self, **kwds) -> 'YError': + ... + + @overload + def title(self, _: None, **kwds) -> 'YError': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(YError, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -11304,6 +15202,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi title=title, **kwds) +@with_property_setters class YErrorValue(ValueChannelMixin, core.ValueDefnumber): """YErrorValue schema wrapper @@ -11322,10 +15221,13 @@ class YErrorValue(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "yError" + + def __init__(self, value, **kwds): super(YErrorValue, self).__init__(value=value, **kwds) +@with_property_setters class YError2(FieldChannelMixin, core.SecondaryFieldDef): """YError2 schema wrapper @@ -11419,6 +15321,49 @@ class YError2(FieldChannelMixin, core.SecondaryFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "yError2" + @overload + def aggregate(self, _: str, **kwds) -> 'YError2': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'YError2': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'YError2': + ... + + def bandPosition(self, _: float, **kwds) -> 'YError2': + ... + + def bin(self, _: None, **kwds) -> 'YError2': + ... + + @overload + def field(self, _: str, **kwds) -> 'YError2': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'YError2': + ... + + @overload + def timeUnit(self, **kwds) -> 'YError2': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'YError2': + ... + + @overload + def title(self, **kwds) -> 'YError2': + ... + + @overload + def title(self, _: None, **kwds) -> 'YError2': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, timeUnit=Undefined, title=Undefined, **kwds): super(YError2, self).__init__(shorthand=shorthand, aggregate=aggregate, @@ -11426,6 +15371,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi timeUnit=timeUnit, title=title, **kwds) +@with_property_setters class YError2Value(ValueChannelMixin, core.ValueDefnumber): """YError2Value schema wrapper @@ -11444,10 +15390,13 @@ class YError2Value(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "yError2" + + def __init__(self, value, **kwds): super(YError2Value, self).__init__(value=value, **kwds) +@with_property_setters class YOffset(FieldChannelMixin, core.ScaleFieldDef): """YOffset schema wrapper @@ -11660,6 +15609,89 @@ class YOffset(FieldChannelMixin, core.ScaleFieldDef): _class_is_valid_at_instantiation = False _encoding_name = "yOffset" + @overload + def aggregate(self, _: str, **kwds) -> 'YOffset': + ... + + @overload + def aggregate(self, argmax=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def aggregate(self, argmin=Undefined, **kwds) -> 'YOffset': + ... + + def bandPosition(self, _: float, **kwds) -> 'YOffset': + ... + + @overload + def bin(self, _: bool, **kwds) -> 'YOffset': + ... + + @overload + def bin(self, anchor=Undefined, base=Undefined, binned=Undefined, divide=Undefined, extent=Undefined, maxbins=Undefined, minstep=Undefined, nice=Undefined, step=Undefined, steps=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def bin(self, _: None, **kwds) -> 'YOffset': + ... + + @overload + def field(self, _: str, **kwds) -> 'YOffset': + ... + + @overload + def field(self, repeat=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def scale(self, _: None, **kwds) -> 'YOffset': + ... + + @overload + def sort(self, **kwds) -> 'YOffset': + ... + + @overload + def sort(self, **kwds) -> 'YOffset': + ... + + @overload + def sort(self, field=Undefined, op=Undefined, order=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def sort(self, encoding=Undefined, order=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def sort(self, _: None, **kwds) -> 'YOffset': + ... + + @overload + def timeUnit(self, **kwds) -> 'YOffset': + ... + + @overload + def timeUnit(self, maxbins=Undefined, step=Undefined, unit=Undefined, utc=Undefined, **kwds) -> 'YOffset': + ... + + @overload + def title(self, **kwds) -> 'YOffset': + ... + + @overload + def title(self, _: None, **kwds) -> 'YOffset': + ... + + def type(self, _: str, **kwds) -> 'YOffset': + ... + + def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefined, bin=Undefined, field=Undefined, scale=Undefined, sort=Undefined, timeUnit=Undefined, title=Undefined, type=Undefined, **kwds): @@ -11668,6 +15700,7 @@ def __init__(self, shorthand=Undefined, aggregate=Undefined, bandPosition=Undefi sort=sort, timeUnit=timeUnit, title=title, type=type, **kwds) +@with_property_setters class YOffsetDatum(DatumChannelMixin, core.ScaleDatumDef): """YOffsetDatum schema wrapper @@ -11787,12 +15820,37 @@ class YOffsetDatum(DatumChannelMixin, core.ScaleDatumDef): """ _class_is_valid_at_instantiation = False _encoding_name = "yOffset" + + def bandPosition(self, _: float, **kwds) -> 'YOffsetDatum': + ... + + @overload + def scale(self, align=Undefined, base=Undefined, bins=Undefined, clamp=Undefined, constant=Undefined, domain=Undefined, domainMax=Undefined, domainMid=Undefined, domainMin=Undefined, exponent=Undefined, interpolate=Undefined, nice=Undefined, padding=Undefined, paddingInner=Undefined, paddingOuter=Undefined, range=Undefined, rangeMax=Undefined, rangeMin=Undefined, reverse=Undefined, round=Undefined, scheme=Undefined, type=Undefined, zero=Undefined, **kwds) -> 'YOffsetDatum': + ... + + @overload + def scale(self, _: None, **kwds) -> 'YOffsetDatum': + ... + + @overload + def title(self, **kwds) -> 'YOffsetDatum': + ... + + @overload + def title(self, _: None, **kwds) -> 'YOffsetDatum': + ... + + def type(self, _: str, **kwds) -> 'YOffsetDatum': + ... + + def __init__(self, datum, bandPosition=Undefined, scale=Undefined, title=Undefined, type=Undefined, **kwds): super(YOffsetDatum, self).__init__(datum=datum, bandPosition=bandPosition, scale=scale, title=title, type=type, **kwds) +@with_property_setters class YOffsetValue(ValueChannelMixin, core.ValueDefnumber): """YOffsetValue schema wrapper @@ -11811,5 +15869,7 @@ class YOffsetValue(ValueChannelMixin, core.ValueDefnumber): _class_is_valid_at_instantiation = False _encoding_name = "yOffset" + + def __init__(self, value, **kwds): super(YOffsetValue, self).__init__(value=value, **kwds) diff --git a/altair/vegalite/v5/tests/test_api.py b/altair/vegalite/v5/tests/test_api.py index 0b7f76612..6a98be8bb 100644 --- a/altair/vegalite/v5/tests/test_api.py +++ b/altair/vegalite/v5/tests/test_api.py @@ -1000,3 +1000,18 @@ def test_validate_dataset(): jsn = chart.to_json() assert jsn + + +def test_method_based_attr_setting(): + x1 = alt.X(field="foo") + x2 = alt.X().field("foo") + x3 = alt.X() + x3.field = "foo" + assert x1 == x2 == x3 + assert x1["field"] == x2["field"] == x3["field"] + + x1["field"] = "bah" + x2 = x2.field("bah") + x3.field = "bah" + assert x1 == x2 == x3 + assert x1.field != x1["field"] diff --git a/doc/user_guide/encodings/index.rst b/doc/user_guide/encodings/index.rst index 8d3821010..b46acf6b6 100644 --- a/doc/user_guide/encodings/index.rst +++ b/doc/user_guide/encodings/index.rst @@ -44,6 +44,44 @@ the chart. For example, below we adjust the y-axis title and increase the step b ) +.. _method-based-attribute-setting: + +Alternative Syntax for Channel Options +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Altair 5.0 introduced an alternative method-based syntax for setting channel options. In the example above, the ``axis`` option of the ``x`` channel encoding is set using the ``axis`` keyword argument: ``x=alt.X('Horsepower', axis=alt.Axis(tickMinStep=50))``. To define the same :class:`X` object using the alternative method-based syntax, we can use ``x=alt.X('Horsepower').axis(tickMinStep=50)``. In other words, the use of the ``axis`` keyword argument is replaced by the use of the ``axis`` method. + +The same technique works with all encoding channels and all channel options. For example, notice how we make the analogous change with respect to the ``title`` option of the ``y`` channel. The following produces the same chart as the previous example. + +.. altair-plot:: + import altair as alt + from vega_datasets import data + cars = data.cars() + + alt.Chart(cars).mark_point().encode( + x=alt.X('Horsepower').axis(tickMinStep=50), + y=alt.Y('Miles_per_Gallon').title('Miles per Gallon'), + color='Origin', + shape='Origin' + ) + +These option-setter methods can also be chained together, as in the following, in which we set the ``axis``, ``bin``, and ``scale`` options of the ``x`` channel by using the corresponding methods (``axis``, ``bin``, and ``scale``). We can break the ``x`` definition over multiple lines to improve readability. (This is valid syntax because of the enclosing parentheses from ``encode``.) + +.. altair-plot:: + import altair as alt + from vega_datasets import data + cars = data.cars() + + alt.Chart(cars).mark_point().encode( + x=alt.X('Horsepower') + .axis(ticks=False) + .bin(maxbins=10) + .scale(domain=(30,300), reverse=True), + y=alt.Y('Miles_per_Gallon').title('Miles per Gallon'), + color='Origin', + shape='Origin' + ) + .. _encoding-data-types: Encoding Data Types @@ -504,6 +542,20 @@ the color scale used for the lines, you can use ``value``, e.g. ``alt.value("red lines + rule +One caution is that ``alt.datum`` and ``alt.value`` do not possess the (newly introduced as of Altair 5.0) method-based syntax to set channel options described in :ref:`method-based-attribute-setting`. For example, if you are using ``alt.datum`` for the ``y`` channel encoding and you wish to use an option setter method (e.g., ``scale``), then you can use :class:`YDatum` instead. Here is a simple example. + +.. altair-plot:: + + import altair as alt + + bar = alt.Chart().mark_bar().encode( + y=alt.YDatum(220).scale(domain=(0,500)), + color=alt.value("darkkhaki") + ) + + bar + +If you were to instead use ``y=alt.datum(220).scale(domain=(0,500))``, an ``AttributeError`` would be raised, due to the fact that ``alt.datum(220)`` simply returns a Python dictionary and does not possess a ``scale`` attribute. If you insisted on producing the preceding example using ``alt.datum``, one option would be to use ``y=alt.datum(220, scale={"domain": (0,500)})``. Nevertheless, the ``alt.YDatum`` approach is strongly preferred to this "by-hand" approach of supplying a dictionary to ``scale``. As one benefit, tab-completions are available using the ``alt.YDatum`` approach. For example, typing ``alt.YDatum(220).scale(do`` and hitting ``tab`` in an environment such as JupyterLab will offer ``domain``, ``domainMax``, ``domainMid``, and ``domainMin`` as possible completions. .. toctree:: :hidden: diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index 4b9f2c942..7f17694ec 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -26,8 +26,10 @@ # Map of version name to github branch name. SCHEMA_VERSION = { + # Uncomment old vega-lite versions here when there are breaking changing + # that we don't want to backport "vega": {"v5": "v5.21.0"}, - "vega-lite": {"v3": "v3.4.0", "v4": "v4.17.0", "v5": "v5.2.0"}, + "vega-lite": {"v5": "v5.2.0"}, } reLink = re.compile(r"(?<=\[)([^\]]+)(?=\]\([^\)]+\))", re.M) @@ -145,7 +147,7 @@ def to_dict(self, validate=True, ignore=(), context=None): class ValueChannelMixin(object): def to_dict(self, validate=True, ignore=(), context=None): context = context or {} - condition = getattr(self, 'condition', Undefined) + condition = self._get('condition', Undefined) copy = self # don't copy unless we need to if condition is not Undefined: if isinstance(condition, core.SchemaBase): @@ -162,7 +164,7 @@ def to_dict(self, validate=True, ignore=(), context=None): class DatumChannelMixin(object): def to_dict(self, validate=True, ignore=(), context=None): context = context or {} - datum = getattr(self, 'datum', Undefined) + datum = self._get('datum', Undefined) copy = self # don't copy unless we need to if datum is not Undefined: if isinstance(datum, core.SchemaBase): @@ -176,11 +178,14 @@ def to_dict(self, validate=True, ignore=(), context=None): class FieldSchemaGenerator(SchemaGenerator): schema_class_template = textwrap.dedent( ''' + @with_property_setters class {classname}(FieldChannelMixin, core.{basename}): """{docstring}""" _class_is_valid_at_instantiation = False _encoding_name = "{encodingname}" + {method_code} + {init_code} ''' ) @@ -189,11 +194,14 @@ class {classname}(FieldChannelMixin, core.{basename}): class ValueSchemaGenerator(SchemaGenerator): schema_class_template = textwrap.dedent( ''' + @with_property_setters class {classname}(ValueChannelMixin, core.{basename}): """{docstring}""" _class_is_valid_at_instantiation = False _encoding_name = "{encodingname}" + {method_code} + {init_code} ''' ) @@ -202,10 +210,14 @@ class {classname}(ValueChannelMixin, core.{basename}): class DatumSchemaGenerator(SchemaGenerator): schema_class_template = textwrap.dedent( ''' + @with_property_setters class {classname}(DatumChannelMixin, core.{basename}): """{docstring}""" _class_is_valid_at_instantiation = False _encoding_name = "{encodingname}" + + {method_code} + {init_code} ''' ) @@ -427,8 +439,9 @@ def generate_vegalite_channel_wrappers(schemafile, version, imports=None): imports = [ "from . import core", "import pandas as pd", - "from altair.utils.schemapi import Undefined", + "from altair.utils.schemapi import Undefined, with_property_setters", "from altair.utils import parse_shorthand", + "from typing import overload, Type", ] contents = [HEADER] contents.extend(imports) @@ -483,6 +496,7 @@ def generate_vegalite_channel_wrappers(schemafile, version, imports=None): rootschema=schema, encodingname=prop, nodefault=nodefault, + haspropsetters=True, ) contents.append(gen.schema_class()) return "\n".join(contents) diff --git a/tools/schemapi/codegen.py b/tools/schemapi/codegen.py index 78460e582..b33c20c8f 100644 --- a/tools/schemapi/codegen.py +++ b/tools/schemapi/codegen.py @@ -111,6 +111,7 @@ def __init__( schemarepr=None, rootschemarepr=None, nodefault=(), + haspropsetters=False, **kwargs, ): self.classname = classname @@ -120,6 +121,7 @@ def __init__( self.schemarepr = schemarepr self.rootschemarepr = rootschemarepr self.nodefault = nodefault + self.haspropsetters = haspropsetters self.kwargs = kwargs def subclasses(self): @@ -148,6 +150,7 @@ def schema_class(self): rootschema=rootschemarepr, docstring=self.docstring(indent=4), init_code=self.init_code(indent=4), + method_code=self.method_code(indent=4), **self.kwargs, ) @@ -177,7 +180,7 @@ def docstring(self, indent=0): return indent_docstring(doc, indent_level=indent, width=100, lstrip=True) def init_code(self, indent=0): - """Return code suitablde for the __init__ function of a Schema class""" + """Return code suitable for the __init__ function of a Schema class""" info = SchemaInfo(self.schema, rootschema=self.rootschema) nonkeyword, required, kwds, invalid_kwds, additional = _get_args(info) @@ -188,6 +191,8 @@ def init_code(self, indent=0): args = ["self"] super_args = [] + self.init_kwds = sorted(kwds) + if nodefault: args.extend(sorted(nodefault)) elif nonkeyword: @@ -217,3 +222,61 @@ def init_code(self, indent=0): if indent: initfunc = ("\n" + indent * " ").join(initfunc.splitlines()) return initfunc + + _equiv_python_types = { + "string": "str", + "number": "float", + "integer": "int", + "object": "dict", + "boolean": "bool", + "array": "list", + "null": "None", + } + + def get_args(self, si): + contents = ["self"] + props = [] + # TODO: do we need to specialize the anyOf code? + if si.is_anyOf(): + props = sorted(list({p for si_sub in si.anyOf for p in si_sub.properties})) + elif si.properties: + props = si.properties + + if props: + contents.extend([p + "=Undefined" for p in props]) + elif si.type: + py_type = self._equiv_python_types[si.type] + contents.append(f"_: {py_type}") + + contents.append("**kwds") + + return contents + + def get_signature(self, attr, sub_si, indent, has_overload=False): + lines = [] + if has_overload: + lines.append("@overload") + args = ", ".join(self.get_args(sub_si)) + lines.append(f"def {attr}({args}) -> '{self.classname}':") + lines.append(indent * " " + "...\n") + return lines + + def setter_hint(self, attr, indent): + si = SchemaInfo(self.schema, self.rootschema).properties[attr] + if si.is_anyOf(): + signatures = [ + self.get_signature(attr, sub_si, indent, has_overload=True) + for sub_si in si.anyOf + ] + return [line for sig in signatures for line in sig] + else: + return self.get_signature(attr, si, indent) + + def method_code(self, indent=0): + """Return code to assist setter methods""" + if not self.haspropsetters: + return None + args = self.init_kwds + type_hints = [hint for a in args for hint in self.setter_hint(a, indent)] + + return ("\n" + indent * " ").join(type_hints) diff --git a/tools/schemapi/schemapi.py b/tools/schemapi/schemapi.py index 7895733c5..f05567da6 100644 --- a/tools/schemapi/schemapi.py +++ b/tools/schemapi/schemapi.py @@ -2,12 +2,15 @@ import contextlib import inspect import json +import textwrap from typing import Any import jsonschema import numpy as np import pandas as pd +from altair import vegalite + # If DEBUG_MODE is True, then schema objects are converted to dict and # validated at creation time. This slows things down, particularly for @@ -588,3 +591,60 @@ def from_dict( return cls(dct) else: return cls(dct) + + +class _PropertySetter(object): + def __init__(self, prop, schema): + self.prop = prop + self.schema = schema + + def __get__(self, obj, cls): + self.obj = obj + self.cls = cls + # The docs from the encoding class parameter (e.g. `bin` in X, Color, + # etc); this provides a general description of the parameter. + self.__doc__ = self.schema["description"].replace("__", "**") + property_name = f"{self.prop}"[0].upper() + f"{self.prop}"[1:] + if hasattr(vegalite, property_name): + altair_prop = getattr(vegalite, property_name) + # Add the docstring from the helper class (e.g. `BinParams`) so + # that all the parameter names of the helper class are included in + # the final docstring + attribute_index = altair_prop.__doc__.find("Attributes\n") + if attribute_index > -1: + self.__doc__ = ( + altair_prop.__doc__[:attribute_index].replace(" ", "") + + self.__doc__ + + textwrap.dedent( + f"\n\n {altair_prop.__doc__[attribute_index:]}" + ) + ) + # For short docsstrings such as Aggregate, Stack, et + else: + self.__doc__ = ( + altair_prop.__doc__.replace(" ", "") + "\n" + self.__doc__ + ) + # Add signatures and tab completion for the method and parameter names + # Currently works for `alt.X.bin` but not alt.X().bin` + self.__signature__ = inspect.signature(altair_prop) + self.__wrapped__ = inspect.getfullargspec(altair_prop) + self.__name__ = altair_prop.__name__ + else: + # It seems like bandPosition is the only parameter that doesn't + # have a helper class. + pass + return self + + def __call__(self, *args, **kwargs): + obj = self.obj.copy() + # TODO: use schema to validate + obj[self.prop] = args[0] if args else kwargs + return obj + + +def with_property_setters(cls): + """Decorator to add property setters to a Schema class.""" + schema = cls.resolve_references() + for prop, propschema in schema.get("properties", {}).items(): + setattr(cls, prop, _PropertySetter(prop, propschema)) + return cls diff --git a/tools/schemapi/utils.py b/tools/schemapi/utils.py index ba5cbfbae..38875ab0a 100644 --- a/tools/schemapi/utils.py +++ b/tools/schemapi/utils.py @@ -192,17 +192,19 @@ def short_description(self): else: return self.medium_description + _simple_types = { + "string": "string", + "number": "float", + "integer": "integer", + "object": "mapping", + "boolean": "boolean", + "array": "list", + "null": "None", + } + @property def medium_description(self): - _simple_types = { - "string": "string", - "number": "float", - "integer": "integer", - "object": "mapping", - "boolean": "boolean", - "array": "list", - "null": "None", - } + if self.is_list(): return "[{0}]".format( ", ".join(self.child(s).short_description for s in self.schema) @@ -236,8 +238,8 @@ def medium_description(self): return "Mapping(required=[{}])".format(", ".join(self.required)) elif self.is_array(): return "List({})".format(self.child(self.items).short_description) - elif self.type in _simple_types: - return _simple_types[self.type] + elif self.type in self._simple_types: + return self._simple_types[self.type] elif not self.type: import warnings