L iUdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z mZmZmZmZmZmZddlmZddlmZmZdd lmZmZdd lmZdd lmZm Z m!Z!m"Z"m#Z#dd l$m%Z%dd l&m'Z'm(Z(m)Z)m*Z*m+Z+ddl,m-Z-ddl.m/Z/m0Z0m1Z1ddl2m3Z3ddl4m5Z6ddl7m8Z8ddl9m:Z:ddl;mm?Z?m@Z@e rddlAmBZBmCZCddlDZEddlFmGZGddlHmIZIddlJmKZKhdZLdeMd<eNeOe fZPdeMd<edZQdeMd <ejZSGd!d"ed#$ZTe Gd%d&ZUd3d'ZV d4d(ZW d5 d6d)ZX d7d*ZYd3d+ZZd8d,Z[ d9d-Z\d:d.Z]d;d/Z^Gd0d1Z_dxyx2y2keyrowhrefsizetextcolorfacetordershapecolumndetailxErroryErroropacitytooltipxError2yError2latitude longitude fillOpacity strokeWidth strokeOpacityr _CHANNELSr VegaLiteSpec)z alt.Chartzalt.ConcatChartzalt.FacetChartzalt.HConcatChartzalt.LayerChartzalt.RepeatChartzalt.VConcatChart AltairChartceZdZUdZded<y) VegaLiteStatea The schema for the Vega-Lite event state. The event state is stored in a dictionary-like object that supports both key and attribute notation. Event states cannot be programmatically changed or set through Session State. Only selection events are supported at this time. Attributes ---------- selection : dict The state of the ``on_select`` event. This attribute returns a dictionary-like object that supports both key and attribute notation. The name of each Vega-Lite selection parameter becomes an attribute in the ``selection`` dictionary. The format of the data within each attribute is determined by the selection parameter definition within Vega-Lite. Examples -------- The following two examples have equivalent definitions. Each one has a point and interval selection parameter include in the chart definition. The point selection parameter is named ``"point_selection"``. The interval or box selection parameter is named ``"interval_selection"``. **Example 1: Chart selections with ``st.altair_chart``** >>> import altair as alt >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"]) >>> >>> point_selector = alt.selection_point("point_selection") >>> interval_selector = alt.selection_interval("interval_selection") >>> chart = ( ... alt.Chart(df) ... .mark_circle() ... .encode( ... x="a", ... y="b", ... size="c", ... color="c", ... tooltip=["a", "b", "c"], ... fillOpacity=alt.condition(point_selector, alt.value(1), alt.value(0.3)), ... ) ... .add_params(point_selector, interval_selector) ... ) >>> >>> event = st.altair_chart(chart, key="alt_chart", on_select="rerun") >>> >>> event **Example 2: Chart selections with ``st.vega_lite_chart``** >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"]) >>> >>> spec = { ... "mark": {"type": "circle", "tooltip": True}, ... "params": [ ... {"name": "interval_selection", "select": "interval"}, ... {"name": "point_selection", "select": "point"}, ... ], ... "encoding": { ... "x": {"field": "a", "type": "quantitative"}, ... "y": {"field": "b", "type": "quantitative"}, ... "size": {"field": "c", "type": "quantitative"}, ... "color": {"field": "c", "type": "quantitative"}, ... "fillOpacity": { ... "condition": {"param": "point_selection", "value": 1}, ... "value": 0.3, ... }, ... }, ... } >>> >>> event = st.vega_lite_chart(df, spec, key="vega_chart", on_select="rerun") >>> >>> event Try selecting points in this interactive example. When you click a point, the selection will appear under the attribute, ``"point_selection"``, which is the name given to the point selection parameter. Similarly, when you make an interval selection, it will appear under the attribute ``"interval_selection"``. You can give your selection parameters other names if desired. If you hold ``Shift`` while selecting points, existing point selections will be preserved. Interval selections are not preserved when making additional selections. .. output:: https://doc-chart-events-vega-lite-state.streamlit.app height: 600px zRequired[AttributeDictionary] selectionN)__name__ __module__ __qualname____doc____annotations__d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/vega_charts.pyrOrO{sdL-,rWrOF)totalc,eZdZUdZded<ddZddZy) VegaLiteStateSerdezQVegaLiteStateSerde is used to serialize and deserialize the VegaLite Chart state.z Sequence[str]selection_parameterscdt|jDcic]}|ic}i}||n'tdttj|}d|vr|}tdt|Scc}w)NrPrO)r*r\r jsonloads)selfui_valueparamempty_selection_stateselection_states rX deserializezVegaLiteStateSerde.deserializes ,(,(A(ABuB0  "o':4::h;O'PQ  o -3OO%8%IJJCs A. c8tj|tS)N)default)r^dumpsstr)r`rds rX serializezVegaLiteStateSerde.serializeszz/377rWN)ra str | NonereturnrO)rdrOrlri)rQrRrSrTrUrerjrVrWrXr[r[s[''K&8rWr[c<|jd}t|tsy|jd}t|tsyd|vr|jdd|d<|jd}t|trd|vr|jdd|d<yyyy)zPatches null legend titles in the 'color' channel of the spec. This is a fix for the Vega-Lite bug where null legend titles cause a wrong formatting of the chart as shown on the issue #9339. encodingNr:title legend)get isinstancedict)specrn color_specrqs rX_patch_null_legend_titlesrws xx #H h %g&J j$ '*!8!@! 7 ^^H %F&$Gv$5&**W:M:Uw;V$5rWc @|r%tfitj|tn tt dk(r t ddvrBdvxsdvxrt fddD}dvr |r d d d d<n|r d d d d<nd d d d<tS)Nrz/Vega-Lite charts require a non-empty spec dict.autosizer;rnc3,K|] }|dv ywrnNrV.0r1rus rX z*_prepare_vega_lite_spec..3sOqQ$z**Or6r>r;vconcatzfit-xpadding)typecontainspadfit)rtr unflattenrKlenr$anyrw)ruuse_container_widthkwargsis_facet_charts` rX_prepare_vega_lite_specrs  DCI// BCDz 4yA~#$UVV !D $  QO4NOO   !4(/YGD  (-9ED ).9ED d# KrWcd|vr|djD]l\}}|jj}t||_d|_t |tr|ntj||j_ n|d=d|vr'|d}t |tr d|vr|d}|d=n|}|d=|%tj||j_ yy)zmAdds the data to the proto and removes it from the spec dict. These operations will happen in-place. datasetsTdatavaluesN) itemsraddrinamehas_namersbytesrconvert_anything_to_arrow_bytesrrt)protorur dataset_name dataset_datadataset data_specs rX_marshall_chart_datarCsT*.z*:*@*@*B  &L,nn((*G|,GL#G lE2#CCLQ LL  "  ~L i &9$ *LDV  (HHN rWcddl}tjdr |j}n |j}i}|j j dtt5|jdk(r|jdn t}|j jd|}|5|5|j}ddddddddd|d<|S#1swY xYw#1swY$xYw#1swY(xYw) z9Convert an Altair chart object to a Vega-Lite chart spec.rNz5.5.0to_arrow_datasetrgnone)rr) altairris_altair_version_less_thanthemesthemedata_transformersregister_to_arrow_dataset_altair_globals_lockactiveenablerto_dict) altair_chartalt alt_themer theme_contextdata_transformer chart_dicts rX!_convert_altair_to_vega_lite_specrvs,,W5JJ II  "H""#57HI 4 )2(8(8I(EI  V $;= 0077 8  4! 4)113  4 44$&Jz   4 4 4 444s=A C0%C$(C9C$C0C! C$$C- )C00C9cLtfddDsdvr tdy)aRaise an exception if the spec contains a multi-view chart (view composition). This is intended to be used as a temporary solution to prevent selections on multi-view charts. There are too many edge cases to handle selections on these charts correctly, so we're disallowing them for now. More information about view compositions: https://vega.github.io/vega-lite/docs/composition.html c3&K|]}|v ywNrV)r}r5rus rXr~z._disallow_multi_view_charts..s UCC4K Us)layerhconcatrconcatrurnzSelections are not yet supported for multi-view charts (chart compositions). If you would like to use selections on multi-view charts, please upvote this [Github issue](https://github.com/streamlit/streamlit/issues/8643).N)rr$)rus`rX_disallow_multi_view_chartsrs4 U#T UU T !# W   "rWc|rd|vr tSt}|dD]:}|jds|jds'|j|d<|S)zBExtract the names of all valid selection parameters from the spec.paramsrselect)setrrr)ru param_namesrbs rX_extract_selection_parametersrs^ 84'u %Kh+ 99V 8!4 OOE&M * + rWct|}|s td| t|St|tr|g}|D]}||vstd|d|dt|S)aParse and check the user provided selection modes. This will raise an exception if no valid selection parameters are found in the spec or if the user provided selection modes are not defined in the spec. Parameters ---------- spec : VegaLiteSpec The Vega-Lite chart specification. selection_mode : str, Iterable[str], or None The user provided selection mode(s). Returns ------- list[str] The parsed selection mode(s) that should be activated. aSelections are activated, but the provided chart spec does not have any selections defined. To add selections to `st.altair_chart`, check out the documentation [here](https://altair-viz.github.io/user_guide/interactions.html#selections-capturing-chart-interactions). For adding selections to `st.vega_lite_chart`, take a look at the specification [here](https://vega.github.io/vega-lite/docs/selection.html).zSelection parameter 'zH' is not defined in the chart spec. Available selection parameters are: .)rr$sortedrsri)ruselection_modeall_selection_paramsselection_names rX_parse_selection_moders09> # a  *++.#&()) !5 5'''78==Q rWceZdZdZed d"ddddddddd d#dZed d"dddddddddd d$d Zed  d"dddddd d ddddd d%dZed d"dddddddddd d&dZe dddddddd d'dZ e ddddddd d(dZ eddddddddd d)dZ e d*dddddddd d+dZ e d*ddddddd d,dZ ed d*dddddddd d-dZ d. d/dZ d0 d1d Z ed2d!Zy)3VegaChartsMixinaMMix-in class for all vega-related chart commands. Altair is a python wrapper on top of the vega-lite spec. And our built-in chart commands are just another layer on-top of Altair. All of these chart commands will be eventually converted to a vega-lite spec and rendered using the same vega-lite chart component. line_chartNstretchcontent)r1r2x_labely_labelr:widthheightrcttj||||||d|||dk( \} } td|j | | d| ||S)a!Display a line chart. This is syntax-sugar around ``st.altair_chart``. The main difference is this command uses the data's own column and indices to figure out the chart's Altair spec. As a result this is easier to use for many "just plot this" scenarios, while being less customizable. Parameters ---------- data : Anything supported by st.dataframe Data to be plotted. x : str or None Column name or key associated to the x-axis data. If ``x`` is ``None`` (default), Streamlit uses the data index for the x-axis values. y : str, Sequence of str, or None Column name(s) or key(s) associated to the y-axis data. If this is ``None`` (default), Streamlit draws the data of all remaining columns as data series. If this is a ``Sequence`` of strings, Streamlit draws several series on the same chart by melting your wide-format table into a long-format table behind the scenes. x_label : str or None The label for the x-axis. If this is ``None`` (default), Streamlit will use the column name specified in ``x`` if available, or else no label will be displayed. y_label : str or None The label for the y-axis. If this is ``None`` (default), Streamlit will use the column name(s) specified in ``y`` if available, or else no label will be displayed. color : str, tuple, Sequence of str, Sequence of tuple, or None The color to use for different lines in this chart. For a line chart with just one line, this can be: - None, to use the default color. - A hex string like "#ffaa00" or "#ffaa0088". - An RGB or RGBA tuple with the red, green, blue, and alpha components specified as ints from 0 to 255 or floats from 0.0 to 1.0. For a line chart with multiple lines, where the dataframe is in long format (that is, y is None or just one column), this can be: - None, to use the default colors. - The name of a column in the dataset. Data points will be grouped into lines of the same color based on the value of this column. In addition, if the values in this column match one of the color formats above (hex string or color tuple), then that color will be used. For example: if the dataset has 1000 rows, but this column only contains the values "adult", "child", and "baby", then those 1000 datapoints will be grouped into three lines whose colors will be automatically selected from the default palette. But, if for the same 1000-row dataset, this column contained the values "#ffaa00", "#f0f", "#0000ff", then then those 1000 datapoints would still be grouped into three lines, but their colors would be "#ffaa00", "#f0f", "#0000ff" this time around. For a line chart with multiple lines, where the dataframe is in wide format (that is, y is a Sequence of columns), this can be: - None, to use the default colors. - A list of string colors or color tuples to be used for each of the lines in the chart. This list should have the same length as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]`` for three lines). You can set the default colors in the ``theme.chartCategoryColors`` configuration option. width : "stretch", "content", or int The width of the chart element. This can be one of the following: - ``"stretch"`` (default): The width of the element matches the width of the parent container. - ``"content"``: The width of the element matches the width of its content, but doesn't exceed the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. height : "content", "stretch", or int The height of the chart element. This can be one of the following: - ``"content"`` (default): The height of the element matches the height of its content. - ``"stretch"``: The height of the element matches the height of its content or the height of the parent container, whichever is larger. If the element is not in a parent container, the height of the element matches the height of its content. - An integer specifying the height in pixels: The element has a fixed height. If the content is larger than the specified height, scrolling is enabled. use_container_width : bool or None Whether to override the chart's native width with the width of the parent container. This can be one of the following: - ``None`` (default): Streamlit will use the chart's default behavior. - ``True``: Streamlit sets the width of the chart to match the width of the parent container. - ``False``: Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. .. deprecated:: ``use_container_width`` is deprecated and will be removed in a future release. For ``use_container_width=True``, use ``width="stretch"``. Examples -------- **Example 1: Basic line chart from a dataframe** If you don't use any of the optional parameters, Streamlit plots each column as a separate line, uses the index as the x values, and labels each series with the column name: >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"]) >>> >>> st.line_chart(df) .. output:: https://doc-line-chart.streamlit.app/ height: 440px **Example 2: Line chart from specific dataframe columns** You can choose different columns to use for the x and y values. If your dataframe is in long format (all y-values in one column), you can set the line colors from another column. If the column contains color strings, the colors will be applied directly and the series will be unlabeled. If the column contains other values, those values will label each line, and the line colors will be selected from the default color palette. You can configure this color palette in the ``theme.chartCategoryColors`` configuration option. >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame( ... { ... "col1": list(range(20)) * 3, ... "col2": rng(0).standard_normal(60), ... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20, ... } ... ) >>> >>> st.line_chart(df, x="col1", y="col2", color="col3") .. output:: https://doc-line-chart1.streamlit.app/ height: 440px **Example 3: Line chart from wide-format dataframe** If your dataframe is in wide format (y-values are in multiple columns), you can pass a list of columns to the ``y`` parameter. Each column name becomes a series label. To override the default colors, pass a list of colors to the ``color`` parameter, one for each series: >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"]) >>> >>> st.line_chart( ... df, ... x="a", ... y=["b", "c"], ... color=["#FF0000", "#0000FF"], ... ) .. output:: https://doc-line-chart2.streamlit.app/ height: 440px Nr chart_typer x_from_user y_from_user x_axis_label y_axis_labelcolor_from_usersize_from_userrrrr/ streamlitrradd_rows_metadatarr)rrLINEr _altair_chart) r`rr1r2rrr:rrrchartrs rXrzVegaChartsMixin.line_chartasv^$2 ~~  !!&)!3 $       $7!"3    rW area_chart) r1r2rrr:stackrrrc t|dd|dus|d}ttj||||||d|| ||dk( \} } t d|j | | d | || S) a'Display an area chart. This is syntax-sugar around ``st.altair_chart``. The main difference is this command uses the data's own column and indices to figure out the chart's Altair spec. As a result this is easier to use for many "just plot this" scenarios, while being less customizable. Parameters ---------- data : Anything supported by st.dataframe Data to be plotted. x : str or None Column name or key associated to the x-axis data. If ``x`` is ``None`` (default), Streamlit uses the data index for the x-axis values. y : str, Sequence of str, or None Column name(s) or key(s) associated to the y-axis data. If this is ``None`` (default), Streamlit draws the data of all remaining columns as data series. If this is a ``Sequence`` of strings, Streamlit draws several series on the same chart by melting your wide-format table into a long-format table behind the scenes. x_label : str or None The label for the x-axis. If this is ``None`` (default), Streamlit will use the column name specified in ``x`` if available, or else no label will be displayed. y_label : str or None The label for the y-axis. If this is ``None`` (default), Streamlit will use the column name(s) specified in ``y`` if available, or else no label will be displayed. color : str, tuple, Sequence of str, Sequence of tuple, or None The color to use for different series in this chart. For an area chart with just 1 series, this can be: - None, to use the default color. - A hex string like "#ffaa00" or "#ffaa0088". - An RGB or RGBA tuple with the red, green, blue, and alpha components specified as ints from 0 to 255 or floats from 0.0 to 1.0. For an area chart with multiple series, where the dataframe is in long format (that is, y is None or just one column), this can be: - None, to use the default colors. - The name of a column in the dataset. Data points will be grouped into series of the same color based on the value of this column. In addition, if the values in this column match one of the color formats above (hex string or color tuple), then that color will be used. For example: if the dataset has 1000 rows, but this column only contains the values "adult", "child", and "baby", then those 1000 datapoints will be grouped into three series whose colors will be automatically selected from the default palette. But, if for the same 1000-row dataset, this column contained the values "#ffaa00", "#f0f", "#0000ff", then then those 1000 datapoints would still be grouped into 3 series, but their colors would be "#ffaa00", "#f0f", "#0000ff" this time around. For an area chart with multiple series, where the dataframe is in wide format (that is, y is a Sequence of columns), this can be: - None, to use the default colors. - A list of string colors or color tuples to be used for each of the series in the chart. This list should have the same length as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]`` for three lines). You can set the default colors in the ``theme.chartCategoryColors`` configuration option. stack : bool, "normalize", "center", or None Whether to stack the areas. If this is ``None`` (default), Streamlit uses Vega's default. Other values can be as follows: - ``True``: The areas form a non-overlapping, additive stack within the chart. - ``False``: The areas overlap each other without stacking. - ``"normalize"``: The areas are stacked and the total height is normalized to 100% of the height of the chart. - ``"center"``: The areas are stacked and shifted to center their baseline, which creates a steamgraph. width : "stretch", "content", or int The width of the chart element. This can be one of the following: - ``"stretch"`` (default): The width of the element matches the width of the parent container. - ``"content"``: The width of the element matches the width of its content, but doesn't exceed the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. height : "stretch", "content", or int The height of the chart element. This can be one of the following: - ``"content"`` (default): The height of the element matches the height of its content. - ``"stretch"``: The height of the element matches the height of its content or the height of the parent container, whichever is larger. If the element is not in a parent container, the height of the element matches the height of its content. - An integer specifying the height in pixels: The element has a fixed height. If the content is larger than the specified height, scrolling is enabled. use_container_width : bool or None Whether to override the chart's native width with the width of the parent container. This can be one of the following: - ``None`` (default): Streamlit will use the chart's default behavior. - ``True``: Streamlit sets the width of the chart to match the width of the parent container. - ``False``: Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. .. deprecated:: ``use_container_width`` is deprecated and will be removed in a future release. For ``use_container_width=True``, use ``width="stretch"``. Examples -------- **Example 1: Basic area chart from a dataframe** If you don't use any of the optional parameters, Streamlit plots each column as a separate area, uses the index as the x values, and labels each series with the column name: >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"]) >>> >>> st.area_chart(df) .. output:: https://doc-area-chart.streamlit.app/ height: 440px **Example 2: Area chart from specific dataframe columns** You can choose different columns to use for the x and y values. If your dataframe is in long format (all y-values in one column), you can set the area colors from another column. If the column contains color strings, the colors will be applied directly and the series will be unlabeled. If the column contains other values, those values will label each area, and the area colors will be selected from the default color palette. You can configure this color palette in the ``theme.chartCategoryColors`` configuration option. >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame( ... { ... "col1": list(range(20)) * 3, ... "col2": rng(0).standard_normal(60), ... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20, ... } ... ) >>> >>> st.area_chart(df, x="col1", y="col2", color="col3") .. output:: https://doc-area-chart1.streamlit.app/ height: 440px **Example 3: Area chart from wide-format dataframe** If your dataframe is in wide format (y-values are in multiple columns), you can pass a list of columns to the ``y`` parameter. Each column name becomes a series label. To override the default colors, pass a list of colors to the ``color`` parameter, one for each series. If your areas are overlapping, use colors with some transparency (alpha channel) for the best results. >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame( ... { ... "col1": list(range(20)), ... "col2": rng(0).standard_normal(20), ... "col3": rng(1).standard_normal(20), ... } ... ) >>> >>> st.area_chart( ... df, ... x="col1", ... y=["col2", "col3"], ... color=["#FF000080", "#0000FF80"], ... ) .. output:: https://doc-area-chart2.streamlit.app/ height: 440px **Example 4: Area chart with different stacking** You can adjust the stacking behavior by setting ``stack``. You can create a streamgraph by setting ``stack="center"``: >>> import streamlit as st >>> from vega_datasets import data >>> >>> df = data.unemployment_across_industries() >>> >>> st.area_chart(df, x="date", y="count", color="series", stack="center") .. output:: https://doc-area-chart-steamgraph.streamlit.app/ height: 440px z st.area_chartzDhttps://docs.streamlit.io/develop/api-reference/charts/st.area_chartFNlayeredr) rrrrrrrrrrrrr/rr)rrrAREAr r) r`rr1r2rrr:rrrrrrs rXrzVegaChartsMixin.area_chartJsj "   R  E>U]E#1 ~~  !!&)!3 $       $7!"3    rW bar_chartFT) r1r2rrr: horizontalsortrrrrc "t| ddtjdr| dur td|rtj ntj } t| ||||||d| | | | ||\}}td|j|| d || | S) a-Display a bar chart. This is syntax-sugar around ``st.altair_chart``. The main difference is this command uses the data's own column and indices to figure out the chart's Altair spec. As a result this is easier to use for many "just plot this" scenarios, while being less customizable. Parameters ---------- data : Anything supported by st.dataframe Data to be plotted. x : str or None Column name or key associated to the x-axis data. If ``x`` is ``None`` (default), Streamlit uses the data index for the x-axis values. y : str, Sequence of str, or None Column name(s) or key(s) associated to the y-axis data. If this is ``None`` (default), Streamlit draws the data of all remaining columns as data series. If this is a ``Sequence`` of strings, Streamlit draws several series on the same chart by melting your wide-format table into a long-format table behind the scenes. x_label : str or None The label for the x-axis. If this is ``None`` (default), Streamlit will use the column name specified in ``x`` if available, or else no label will be displayed. y_label : str or None The label for the y-axis. If this is ``None`` (default), Streamlit will use the column name(s) specified in ``y`` if available, or else no label will be displayed. color : str, tuple, Sequence of str, Sequence of tuple, or None The color to use for different series in this chart. For a bar chart with just one series, this can be: - None, to use the default color. - A hex string like "#ffaa00" or "#ffaa0088". - An RGB or RGBA tuple with the red, green, blue, and alpha components specified as ints from 0 to 255 or floats from 0.0 to 1.0. For a bar chart with multiple series, where the dataframe is in long format (that is, y is None or just one column), this can be: - None, to use the default colors. - The name of a column in the dataset. Data points will be grouped into series of the same color based on the value of this column. In addition, if the values in this column match one of the color formats above (hex string or color tuple), then that color will be used. For example: if the dataset has 1000 rows, but this column only contains the values "adult", "child", and "baby", then those 1000 datapoints will be grouped into three series whose colors will be automatically selected from the default palette. But, if for the same 1000-row dataset, this column contained the values "#ffaa00", "#f0f", "#0000ff", then then those 1000 datapoints would still be grouped into 3 series, but their colors would be "#ffaa00", "#f0f", "#0000ff" this time around. For a bar chart with multiple series, where the dataframe is in wide format (that is, y is a Sequence of columns), this can be: - None, to use the default colors. - A list of string colors or color tuples to be used for each of the series in the chart. This list should have the same length as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]`` for three lines). You can set the default colors in the ``theme.chartCategoryColors`` configuration option. horizontal : bool Whether to make the bars horizontal. If this is ``False`` (default), the bars display vertically. If this is ``True``, Streamlit swaps the x-axis and y-axis and the bars display horizontally. sort : bool or str How to sort the bars. This can be one of the following: - ``True`` (default): The bars are sorted automatically along the independent/categorical axis with Altair's default sorting. This also correctly sorts ordered categorical columns (``pd.Categorical``). - ``False``: The bars are shown in data order without sorting. - The name of a column (e.g. ``"col1"``): The bars are sorted by that column in ascending order. - The name of a column with a minus-sign prefix (e.g. ``"-col1"``): The bars are sorted by that column in descending order. stack : bool, "normalize", "center", "layered", or None Whether to stack the bars. If this is ``None`` (default), Streamlit uses Vega's default. Other values can be as follows: - ``True``: The bars form a non-overlapping, additive stack within the chart. - ``False``: The bars display side by side. - ``"layered"``: The bars overlap each other without stacking. - ``"normalize"``: The bars are stacked and the total height is normalized to 100% of the height of the chart. - ``"center"``: The bars are stacked and shifted to center the total height around an axis. width : "stretch", "content", or int The width of the chart element. This can be one of the following: - ``"stretch"`` (default): The width of the element matches the width of the parent container. - ``"content"``: The width of the element matches the width of its content, but doesn't exceed the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. height : "stretch", "content", or int The height of the chart element. This can be one of the following: - ``"content"`` (default): The height of the element matches the height of its content. - ``"stretch"``: The height of the element matches the height of its content or the height of the parent container, whichever is larger. If the element is not in a parent container, the height of the element matches the height of its content. - An integer specifying the height in pixels: The element has a fixed height. If the content is larger than the specified height, scrolling is enabled. use_container_width : bool or None Whether to override the chart's native width with the width of the parent container. This can be one of the following: - ``None`` (default): Streamlit will use the chart's default behavior. - ``True``: Streamlit sets the width of the chart to match the width of the parent container. - ``False``: Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. .. deprecated:: ``use_container_width`` is deprecated and will be removed in a future release. For ``use_container_width=True``, use ``width="stretch"``. Examples -------- **Example 1: Basic bar chart from a dataframe** If you don't use any of the optional parameters, Streamlit plots each column as a series of bars, uses the index as the x values, and labels each series with the column name: >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"]) >>> >>> st.bar_chart(df) .. output:: https://doc-bar-chart.streamlit.app/ height: 440px **Example 2: Bar chart from specific dataframe columns** You can choose different columns to use for the x and y values. If your dataframe is in long format (all y-values in one column), you can set the bar colors from another column. If the column contains color strings, the colors will be applied directly and the series will be unlabeled. If the column contains other values, those values will label each series, and the bar colors will be selected from the default color palette. You can configure this color palette in the ``theme.chartCategoryColors`` configuration option. >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame( ... { ... "col1": list(range(20)) * 3, ... "col2": rng(0).standard_normal(60), ... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20, ... } ... ) >>> >>> st.bar_chart(df, x="col1", y="col2", color="col3") .. output:: https://doc-bar-chart1.streamlit.app/ height: 440px **Example 3: Bar chart from wide-format dataframe** If your dataframe is in wide format (y-values are in multiple columns), you can pass a list of columns to the ``y`` parameter. Each column name becomes a series label. To override the default colors, pass a list of colors to the ``color`` parameter, one for each series: >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame( ... { ... "col1": list(range(20)), ... "col2": rng(0).standard_normal(20), ... "col3": rng(1).standard_normal(20), ... } ... ) >>> >>> st.bar_chart( ... df, ... x="col1", ... y=["col2", "col3"], ... color=["#FF0000", "#0000FF"], ... ) .. output:: https://doc-bar-chart2.streamlit.app/ height: 440px **Example 4: Horizontal bar chart** You can use the ``horizontal`` parameter to display horizontal bars instead of vertical bars. This is useful when you have long labels on the x-axis, or when you want to display a large number of categories. This example requires ``vega_datasets`` to be installed. >>> import streamlit as st >>> from vega_datasets import data >>> >>> source = data.barley() >>> >>> st.bar_chart(source, x="variety", y="yield", color="site", horizontal=True) .. output:: https://doc-bar-chart-horizontal.streamlit.app/ height: 440px **Example 5: Unstacked bar chart** You can configure the stacking behavior of the bars by setting the ``stack`` parameter. Set it to ``False`` to display bars side by side. This example requires ``vega_datasets`` to be installed. >>> import streamlit as st >>> from vega_datasets import data >>> >>> source = data.barley() >>> >>> st.bar_chart(source, x="year", y="yield", color="site", stack=False) .. output:: https://doc-bar-chart-unstacked.streamlit.app/ height: 440px z st.bar_chartzChttps://docs.streamlit.io/develop/api-reference/charts/st.bar_chart5.0.0FziStreamlit does not support non-stacked (grouped) bar charts with Altair 4.x. Please upgrade to Version 5.N)rrrrrrrrrrrrrsort_from_userr/rr) rrrr$rHORIZONTAL_BAR VERTICAL_BARrr r)r`rr1r2rrr:rrrrrrbar_chart_typerrs rXrzVegaChartsMixin.bar_chartisx "   Q   0 0 9eun';  )3I $ $ 8N8N $2%  ! 3!$       $7!"3    rW scatter_chart) r1r2rrr:r8rrrc ttj||||||||| |dk( \} } td|j | | d| || S)a"Display a scatterplot chart. This is syntax-sugar around ``st.altair_chart``. The main difference is this command uses the data's own column and indices to figure out the chart's Altair spec. As a result this is easier to use for many "just plot this" scenarios, while being less customizable. Parameters ---------- data : Anything supported by st.dataframe Data to be plotted. x : str or None Column name or key associated to the x-axis data. If ``x`` is ``None`` (default), Streamlit uses the data index for the x-axis values. y : str, Sequence of str, or None Column name(s) or key(s) associated to the y-axis data. If this is ``None`` (default), Streamlit draws the data of all remaining columns as data series. If this is a ``Sequence`` of strings, Streamlit draws several series on the same chart by melting your wide-format table into a long-format table behind the scenes. x_label : str or None The label for the x-axis. If this is ``None`` (default), Streamlit will use the column name specified in ``x`` if available, or else no label will be displayed. y_label : str or None The label for the y-axis. If this is ``None`` (default), Streamlit will use the column name(s) specified in ``y`` if available, or else no label will be displayed. color : str, tuple, Sequence of str, Sequence of tuple, or None The color of the circles representing each datapoint. This can be: - None, to use the default color. - A hex string like "#ffaa00" or "#ffaa0088". - An RGB or RGBA tuple with the red, green, blue, and alpha components specified as ints from 0 to 255 or floats from 0.0 to 1.0. - The name of a column in the dataset where the color of that datapoint will come from. If the values in this column are in one of the color formats above (hex string or color tuple), then that color will be used. Otherwise, the color will be automatically picked from the default palette. For example: if the dataset has 1000 rows, but this column only contains the values "adult", "child", and "baby", then those 1000 datapoints be shown using three colors from the default palette. But if this column only contains floats or ints, then those 1000 datapoints will be shown using a colors from a continuous color gradient. Finally, if this column only contains the values "#ffaa00", "#f0f", "#0000ff", then then each of those 1000 datapoints will be assigned "#ffaa00", "#f0f", or "#0000ff" as appropriate. If the dataframe is in wide format (that is, y is a Sequence of columns), this can also be: - A list of string colors or color tuples to be used for each of the series in the chart. This list should have the same length as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]`` for three series). size : str, float, int, or None The size of the circles representing each point. This can be: - A number like 100, to specify a single size to use for all datapoints. - The name of the column to use for the size. This allows each datapoint to be represented by a circle of a different size. width : "stretch", "content", or int The width of the chart element. This can be one of the following: - ``"stretch"`` (default): The width of the element matches the width of the parent container. - ``"content"``: The width of the element matches the width of its content, but doesn't exceed the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. height : "stretch", "content", or int The height of the chart element. This can be one of the following: - ``"content"`` (default): The height of the element matches the height of its content. - ``"stretch"``: The height of the element matches the height of its content or the height of the parent container, whichever is larger. If the element is not in a parent container, the height of the element matches the height of its content. - An integer specifying the height in pixels: The element has a fixed height. If the content is larger than the specified height, scrolling is enabled. use_container_width : bool or None Whether to override the chart's native width with the width of the parent container. This can be one of the following: - ``None`` (default): Streamlit will use the chart's default behavior. - ``True``: Streamlit sets the width of the chart to match the width of the parent container. - ``False``: Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. .. deprecated:: ``use_container_width`` is deprecated and will be removed in a future release. For ``use_container_width=True``, use ``width="stretch"``. Examples -------- **Example 1: Basic scatter chart from a dataframe** If you don't use any of the optional parameters, Streamlit plots each column as a color-coded group of points, uses the index as the x values, and labels each group with the column name: >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"]) >>> >>> st.scatter_chart(df) .. output:: https://doc-scatter-chart.streamlit.app/ height: 440px **Example 2: Scatter chart from specific dataframe columns** You can choose different columns to use for the x and y values. If your dataframe is in long format (all y-values in one column), you can set the scatter point colors from another column. If the column contains color strings, the colors will be applied directly and each color group will be unlabeled. If the column contains other values, those values will label each group, and the scatter point colors will be selected from the default color palette. You can configure this color palette in the ``theme.chartCategoryColors`` configuration option. >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame( ... rng(0).standard_normal((20, 3)), columns=["col1", "col2", "col3"] ... ) >>> df["col4"] = rng(0).choice(["a", "b", "c"], 20) >>> >>> st.scatter_chart( ... df, ... x="col1", ... y="col2", ... color="col4", ... size="col3", ... ) .. output:: https://doc-scatter-chart1.streamlit.app/ height: 440px **Example 3: Scatter chart from wide-format dataframe** If your dataframe is in wide format (y-values are in multiple columns), you can pass a list of columns to the ``y`` parameter. Each column name becomes a group label. To override the default colors, pass a list of colors to the ``color`` parameter, one for each group: >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame( ... rng(0).standard_normal((20, 4)), ... columns=["col1", "col2", "col3", "col4"], ... ) >>> >>> st.scatter_chart( ... df, ... x="col1", ... y=["col2", "col3"], ... size="col4", ... color=["#FF0000", "#0000FF"], ... ) .. output:: https://doc-scatter-chart2.streamlit.app/ height: 440px rrr/rr)rrSCATTERr r) r`rr1r2rrr:r8rrrrrs rXrzVegaChartsMixin.scatter_chartsx|$2 ((  !!&)!3 $       $7!"3    rWrignore)rrrrr5 on_selectrrcyrrV r`rrrrrr5r rs rXrzVegaChartsMixin.altair_chartsrW)rrrrr5rcyrrVr s rXrzVegaChartsMixin.altair_chartsrWc 4|j||||||||S)aDisplay a chart using the Vega-Altair library. `Vega-Altair `_ is a declarative statistical visualization library for Python, based on Vega and Vega-Lite. Parameters ---------- altair_chart : altair.Chart The Altair chart object to display. See https://altair-viz.github.io/gallery/ for examples of graph descriptions. width : "stretch", "content", int, or None The width of the chart element. This can be one of the following: - ``"stretch"``: The width of the element matches the width of the parent container. - ``"content"``: The width of the element matches the width of its content, but doesn't exceed the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. - ``None`` (default): Streamlit uses ``"stretch"`` for most charts, and uses ``"content"`` for the following multi-view charts: - Facet charts: the spec contains ``"facet"`` or encodings for ``"row"``, ``"column"``, or ``"facet"``. - Horizontal concatenation charts: the spec contains ``"hconcat"``. - Repeat charts: the spec contains ``"repeat"``. height : "content", "stretch", or int The height of the chart element. This can be one of the following: - ``"content"`` (default): The height of the element matches the height of its content. - ``"stretch"``: The height of the element matches the height of its content or the height of the parent container, whichever is larger. If the element is not in a parent container, the height of the element matches the height of its content. - An integer specifying the height in pixels: The element has a fixed height. If the content is larger than the specified height, scrolling is enabled. use_container_width : bool or None Whether to override the chart's native width with the width of the parent container. This can be one of the following: - ``None`` (default): Streamlit will use the parent container's width for all charts except those with known incompatibility (``altair.Facet``, ``altair.HConcatChart``, and ``altair.RepeatChart``). - ``True``: Streamlit sets the width of the chart to match the width of the parent container. - ``False``: Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. .. deprecated:: ``use_container_width`` is deprecated and will be removed in a future release. For ``use_container_width=True``, use ``width="stretch"``. theme : "streamlit" or None The theme of the chart. If ``theme`` is ``"streamlit"`` (default), Streamlit uses its own design default. If ``theme`` is ``None``, Streamlit falls back to the default behavior of the library. The ``"streamlit"`` theme can be partially customized through the configuration options ``theme.chartCategoricalColors`` and ``theme.chartSequentialColors``. Font configuration options are also applied. key : str An optional string to use for giving this element a stable identity. If ``key`` is ``None`` (default), this element's identity will be determined based on the values of the other parameters. Additionally, if selections are activated and ``key`` is provided, Streamlit will register the key in Session State to store the selection state. The selection state is read-only. on_select : "ignore", "rerun", or callable How the figure should respond to user selection events. This controls whether or not the figure behaves like an input widget. ``on_select`` can be one of the following: - ``"ignore"`` (default): Streamlit will not react to any selection events in the chart. The figure will not behave like an input widget. - ``"rerun"``: Streamlit will rerun the app when the user selects data in the chart. In this case, ``st.altair_chart`` will return the selection data as a dictionary. - A ``callable``: Streamlit will rerun the app and execute the ``callable`` as a callback function before the rest of the app. In this case, ``st.altair_chart`` will return the selection data as a dictionary. To use selection events, the object passed to ``altair_chart`` must include selection parameters. To learn about defining interactions in Altair and how to declare selection-type parameters, see `Interactive Charts `_ in Altair's documentation. selection_mode : str or Iterable of str The selection parameters Streamlit should use. If ``selection_mode`` is ``None`` (default), Streamlit will use all selection parameters defined in the chart's Altair spec. When Streamlit uses a selection parameter, selections from that parameter will trigger a rerun and be included in the selection state. When Streamlit does not use a selection parameter, selections from that parameter will not trigger a rerun and not be included in the selection state. Selection parameters are identified by their ``name`` property. Returns ------- element or dict If ``on_select`` is ``"ignore"`` (default), this command returns an internal placeholder for the chart element that can be used with the ``.add_rows()`` method. Otherwise, this command returns a dictionary-like object that supports both key and attribute notation. The attributes are described by the ``VegaLiteState`` dictionary schema. Example ------- >>> import altair as alt >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame(rng(0).standard_normal((60, 3)), columns=["a", "b", "c"]) >>> >>> chart = ( ... alt.Chart(df) ... .mark_circle() ... .encode(x="a", y="b", size="c", color="c", tooltip=["a", "b", "c"]) ... ) >>> >>> st.altair_chart(chart) .. output:: https://doc-vega-lite-chart.streamlit.app/ height: 450px )rrrrrr5r r)rr s rXrzVegaChartsMixin.altair_charts5P!!% 3)"  rWc yrrV r`rrurrrrr5r rrs rXvega_lite_chartzVegaChartsMixin.vega_lite_chart{srWc yrrVrs rXrzVegaChartsMixin.vega_lite_chartsrWrc :|jd||||||| ||d | S)aDisplay a chart using the Vega-Lite library. `Vega-Lite `_ is a high-level grammar for defining interactive graphics. Parameters ---------- data : Anything supported by st.dataframe Either the data to be plotted or a Vega-Lite spec containing the data (which more closely follows the Vega-Lite API). spec : dict or None The Vega-Lite spec for the chart. If ``spec`` is ``None`` (default), Streamlit uses the spec passed in ``data``. You cannot pass a spec to both ``data`` and ``spec``. See https://vega.github.io/vega-lite/docs/ for more info. width : "stretch", "content", int, or None The width of the chart element. This can be one of the following: - ``"stretch"``: The width of the element matches the width of the parent container. - ``"content"``: The width of the element matches the width of its content, but doesn't exceed the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. - ``None`` (default): Streamlit uses ``"stretch"`` for most charts, and uses ``"content"`` for the following multi-view charts: - Facet charts: the spec contains ``"facet"`` or encodings for ``"row"``, ``"column"``, or ``"facet"``. - Horizontal concatenation charts: the spec contains ``"hconcat"``. - Repeat charts: the spec contains ``"repeat"``. height : "content", "stretch", or int The height of the chart element. This can be one of the following: - ``"content"`` (default): The height of the element matches the height of its content. - ``"stretch"``: The height of the element matches the height of its content or the height of the parent container, whichever is larger. If the element is not in a parent container, the height of the element matches the height of its content. - An integer specifying the height in pixels: The element has a fixed height. If the content is larger than the specified height, scrolling is enabled. use_container_width : bool or None Whether to override the chart's native width with the width of the parent container. This can be one of the following: - ``None`` (default): Streamlit will use the parent container's width for all charts except those with known incompatibility (``altair.Facet``, ``altair.HConcatChart``, and ``altair.RepeatChart``). - ``True``: Streamlit sets the width of the chart to match the width of the parent container. - ``False``: Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. .. deprecated:: ``use_container_width`` is deprecated and will be removed in a future release. For ``use_container_width=True``, use ``width="stretch"``. theme : "streamlit" or None The theme of the chart. If ``theme`` is ``"streamlit"`` (default), Streamlit uses its own design default. If ``theme`` is ``None``, Streamlit falls back to the default behavior of the library. The ``"streamlit"`` theme can be partially customized through the configuration options ``theme.chartCategoricalColors`` and ``theme.chartSequentialColors``. Font configuration options are also applied. key : str An optional string to use for giving this element a stable identity. If ``key`` is ``None`` (default), this element's identity will be determined based on the values of the other parameters. Additionally, if selections are activated and ``key`` is provided, Streamlit will register the key in Session State to store the selection state. The selection state is read-only. on_select : "ignore", "rerun", or callable How the figure should respond to user selection events. This controls whether or not the figure behaves like an input widget. ``on_select`` can be one of the following: - ``"ignore"`` (default): Streamlit will not react to any selection events in the chart. The figure will not behave like an input widget. - ``"rerun"``: Streamlit will rerun the app when the user selects data in the chart. In this case, ``st.vega_lite_chart`` will return the selection data as a dictionary. - A ``callable``: Streamlit will rerun the app and execute the ``callable`` as a callback function before the rest of the app. In this case, ``st.vega_lite_chart`` will return the selection data as a dictionary. To use selection events, the Vega-Lite spec defined in ``data`` or ``spec`` must include selection parameters from the charting library. To learn about defining interactions in Vega-Lite, see `Dynamic Behaviors with Parameters `_ in Vega-Lite's documentation. selection_mode : str or Iterable of str The selection parameters Streamlit should use. If ``selection_mode`` is ``None`` (default), Streamlit will use all selection parameters defined in the chart's Vega-Lite spec. When Streamlit uses a selection parameter, selections from that parameter will trigger a rerun and be included in the selection state. When Streamlit does not use a selection parameter, selections from that parameter will not trigger a rerun and not be included in the selection state. Selection parameters are identified by their ``name`` property. **kwargs : any The Vega-Lite spec for the chart as keywords. This is an alternative to ``spec``. Returns ------- element or dict If ``on_select`` is ``"ignore"`` (default), this command returns an internal placeholder for the chart element that can be used with the ``.add_rows()`` method. Otherwise, this command returns a dictionary-like object that supports both key and attribute notation. The attributes are described by the ``VegaLiteState`` dictionary schema. Example ------- >>> import pandas as pd >>> import streamlit as st >>> from numpy.random import default_rng as rng >>> >>> df = pd.DataFrame(rng(0).standard_normal((60, 3)), columns=["a", "b", "c"]) >>> >>> st.vega_lite_chart( ... df, ... { ... "mark": {"type": "circle", "tooltip": True}, ... "encoding": { ... "x": {"field": "a", "type": "quantitative"}, ... "y": {"field": "b", "type": "quantitative"}, ... "size": {"field": "c", "type": "quantitative"}, ... "color": {"field": "c", "type": "quantitative"}, ... }, ... }, ... ) .. output:: https://doc-vega-lite-chart.streamlit.app/ height: 450px Examples of Vega-Lite usage without Streamlit can be found at https://vega.github.io/vega-lite/examples/. Most of those can be easily translated to the syntax shown above. ) rrurrr5r rrrrV)_vega_lite_chartrs rXrzVegaChartsMixin.vega_lite_chartsDr%t$$   3)    rWc tjdr|dk7r tdt|} |j d| ||||||||  S)zInternal method to enqueue a vega-lite chart element based on an Altair chart. See the `altair_chart` method docstring for more information. rr zStreamlit does not support selections with Altair 4.x. Please upgrade to Version 5. If you would like to use Altair 4.x with selections, please upvote this [Github issue](https://github.com/streamlit/streamlit/issues/8516).N) rrurrr5r rrrr)rrr$rr) r`rrrr5r rrrrvega_lite_specs rXrzVegaChartsMixin._altair_chartbsn"  0 0 9i8>S'[ ;<H$$ 3)/%  rWc  |dvrtd|d|dvrt|std|dt|}|dk7} | r4t|} t|j|| r t d|nd d d | t |tr|d }i|0| .d vxsd vxrtfddD}|s dvsdvsdnd} |2ttddddd d |rd} nt | tsd} | t| dt| dt}||n| dk(}t|fi| t!||t#t%j&|_|||_|xsd|_| rXt%j.|j(}t1|t3||}|j4j7|t9|j|_t=}t?d|d |j|j(|j@j@|jBDcgc]}|jDc}||| |_#tI|}tK|jFt|r|nd |jL|jN|d }tQ| | !}|jjSd|||"|jTStQ| | !}|jjSd|||"Scc}w)#zInternal method to enqueue a vega-lite chart element based on a vega-lite spec. See the `vega_lite_chart` method docstring for more information. )rNzYou set theme="us" while Streamlit charts only support theme=”streamlit” or theme=None to fallback to the default library theme.)r rerunzYou have passed zH to `on_select`. But only 'ignore', 'rerun', or a callable is supported.r r(NF) on_change default_valuewrites_allowedenable_check_callback_rulesr;rnc3,K|] }|dv ywr{rVr|s rXr~z3VegaChartsMixin._vega_lite_chart..sS1d:..Srrrrepeatrrrrz 2025-12-31zFor `use_container_width=True`, use `width='stretch'`. For `use_container_width=False`, use `width='content'` or specify an integer width.)include_st_prefix)show_in_browserT) allow_contentrarrow_vega_lite_chart) user_keykey_as_main_identitydgrvega_lite_datanamed_datasetsrrr string_value)on_change_handler deserializer serializerctx value_type)rr)r layout_config)+r$callabler#r r&r rsrtrrrintrrArrowVegaLiteChartProtorrrr^rhrurrr_rrrextendrform_idr'r"rrridr[r)rerjr_enqueuevalue)r`rrurrr5r rrrrris_selection_activated is_callbackrvega_lite_protouse_container_width_for_spec final_specparsed_selection_modesr-rserde widget_stater/s ` rXrz VegaChartsMixin._vega_lite_chartsx$ + +'!%)!!  / /8K'"9+.77  Sk!*h!6 !#9-K !?J$/;PT"$,7   dD !dlDD <D  &5=%_d"US8RSS  ')t*;x4?O   * $,) j&+ !& #!s+!   5 5d313#. )# % 't-ITVT_dD9 9D9IJ  *2EO / %  !O$8$89J ' 3&;:~%V "  * * 1 12H I&5dgg&>O #$&C!@'%*77.33 /3388=LE*""/7 /B)".. ??) L)uVDM GG  '"3+    %% %%5@ ww # /'    ; Vs2Lctd|S)zGet our DeltaGenerator.r/)r )r`s rXr&zVegaChartsMixin.dg9 s$d++rWr)rr.r1rkr2str | Sequence[str] | Nonerrkrrkr: str | Color | list[Color] | Nonerrrrr bool | Nonerlr/)rr.r1rkr2rArrkrrkr:rBrbool | ChartStackType | NonerrrrrrCrlr/)rr.r1rkr2rArrkrrkr:rBrboolrz bool | strrrDrrrrrrCrlr/)rr.r1rkr2rArrkrrkr:rBr8zstr | float | int | NonerrrrrrCrlr/)rrMr Width | NonerrrrCrLiteral['streamlit'] | Noner5 Key | Noner Literal['ignore']rstr | Iterable[str] | Nonerlr/)rrMrrFrrrrCrrGr5rHr !Literal['rerun'] | WidgetCallbackrrJrlrO)rrMrrFrrrrCrrGr5rHr +Literal['rerun', 'ignore'] | WidgetCallbackrrJrlDeltaGenerator | VegaLiteState)NN)rr.ruVegaLiteSpec | NonerrFrrrrCrrGr5rHr rIrrJrrrlr/)rr.rurNrrFrrrrCrrGr5rHr rKrrJrrrlrO)rr.rurNrrFrrrrCrrGr5rHr rLrrJrrrlrM)NrNr NNNr)rrMrrCrrGr5rHr rLrrJrAddRowsMetadata | NonerrFrrrlrM) NNNrNr NNNr)rr.rurNrrCrrGr5rHr rLrrJrrOrrFrrrrrlrM)rlr/)rQrRrSrTr&rrrrrrrrrpropertyr&rVrWrXrrXsL!f (,""26 "+/f f   f & f  f f 0f f f )f  f "f PL!\ (,""26.2 "+/\ \   \ & \  \ \ 0\ ,\ \ \ )\  \ "\ |K F (,""26 .2 "+/F F   F & F  F F 0F F F ,F F F )F  F !F P O$t (,""26)- "+/t t   t & t  t t 0t 't t t )t  t %t n #"+/-8'/59 !     ) +  % 3     #"+/-859 !     ) +  5 3    N# #"+/-8AI59p !p  p  p ) p +p p ?p 3p  (p $p f$(  #"+/-8'/59  "     ) +  % 3      $(  #"+/-859  "     ) +  5 3     %&$(C #"+/-8AI59C C "C  C  C )C +C C ?C 3C C  (C 'C P,0-8AI5948""% !% )% + %  % ? % 3% 2% % %  (% R$(+/-8AI5948""n n "n ) n + n  n ?n 3n 2n n n n  (n `,,rWrcftj|}tt|}|||<d|iS)zAltair data transformer that serializes the data, creates a stable name based on the hash of the data, stores the bytes into the datasets mapping and returns this name to have it be used in Altair. r)rrr+ri)rr data_bytesrs rXrr? s5 ??EJ C O $DHTN D>rW)rurLrlNone)rurLrrErrrlrLr)rr2rurLrr.rlrS)rrMrlrL)rurLrlzset[str])rurLrrJrlz list[str])rrirrirlri)rrirlri)rrrzdict[str, Any]rlzdict[str, str])arT __future__rr^r threading contextlibr dataclassesrtypingrrrr r r r r rtyping_extensionsrrrrstreamlit.deprecation_utilrrstreamlit.elements.libr+streamlit.elements.lib.built_in_chart_utilsrrrrr!streamlit.elements.lib.form_utilsr#streamlit.elements.lib.layout_utilsrrrrrstreamlit.elements.lib.policiesr streamlit.elements.lib.utilsr!r"r#streamlit.errorsr$&streamlit.proto.ArrowVegaLiteChart_pb2r%r2streamlit.runtime.metrics_utilr&7streamlit.runtime.scriptrunner_utils.script_run_contextr'streamlit.runtime.stater(r)streamlit.utilr*r+collections.abcr,r-rrstreamlit.dataframe_utilr.streamlit.delta_generatorr/!streamlit.elements.lib.color_utilr0rKrUrtrirLrMLockrrOr[rwrrrrrrrrrrrVrWrXrlsX" "!   '/->BUU2:VC82-87 5:sCx. i( Y&y~~'g-IUg-T 88 880& &&& &X0O "0O 0O 0O 0Of111h *"2" 2".2"2"jB/dd,d,N7 rW