Mise à jour de Monitor.py et autres scripts
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
# ruff: noqa: F403
|
||||
from .v5 import *
|
||||
@@ -0,0 +1,2 @@
|
||||
# ruff: noqa
|
||||
from .v5.api import *
|
||||
66
myenv/lib/python3.11/site-packages/altair/vegalite/data.py
Normal file
66
myenv/lib/python3.11/site-packages/altair/vegalite/data.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Callable, overload
|
||||
|
||||
from altair.utils.core import sanitize_pandas_dataframe
|
||||
from altair.utils.data import DataTransformerRegistry as _DataTransformerRegistry
|
||||
from altair.utils.data import (
|
||||
MaxRowsError,
|
||||
check_data_type,
|
||||
limit_rows,
|
||||
sample,
|
||||
to_csv,
|
||||
to_json,
|
||||
to_values,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from altair.utils.data import DataType, ToValuesReturnType
|
||||
from altair.utils.plugin_registry import PluginEnabler
|
||||
|
||||
|
||||
@overload
|
||||
def default_data_transformer(
|
||||
data: None = ..., max_rows: int = ...
|
||||
) -> Callable[[DataType], ToValuesReturnType]: ...
|
||||
@overload
|
||||
def default_data_transformer(
|
||||
data: DataType, max_rows: int = ...
|
||||
) -> ToValuesReturnType: ...
|
||||
def default_data_transformer(
|
||||
data: DataType | None = None, max_rows: int = 5000
|
||||
) -> Callable[[DataType], ToValuesReturnType] | ToValuesReturnType:
|
||||
if data is None:
|
||||
|
||||
def pipe(data: DataType, /) -> ToValuesReturnType:
|
||||
data = limit_rows(data, max_rows=max_rows)
|
||||
return to_values(data)
|
||||
|
||||
return pipe
|
||||
|
||||
else:
|
||||
return to_values(limit_rows(data, max_rows=max_rows))
|
||||
|
||||
|
||||
class DataTransformerRegistry(_DataTransformerRegistry):
|
||||
def disable_max_rows(self) -> PluginEnabler:
|
||||
"""Disable the MaxRowsError."""
|
||||
options = self.options
|
||||
if self.active in {"default", "vegafusion"}:
|
||||
options = options.copy()
|
||||
options["max_rows"] = None
|
||||
return self.enable(**options)
|
||||
|
||||
|
||||
__all__ = (
|
||||
"DataTransformerRegistry",
|
||||
"MaxRowsError",
|
||||
"check_data_type",
|
||||
"default_data_transformer",
|
||||
"limit_rows",
|
||||
"sample",
|
||||
"sanitize_pandas_dataframe",
|
||||
"to_csv",
|
||||
"to_json",
|
||||
"to_values",
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
from altair.utils.display import (
|
||||
DefaultRendererReturnType,
|
||||
Displayable,
|
||||
HTMLRenderer,
|
||||
RendererRegistry,
|
||||
default_renderer_base,
|
||||
json_renderer_base,
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
"DefaultRendererReturnType",
|
||||
"Displayable",
|
||||
"HTMLRenderer",
|
||||
"RendererRegistry",
|
||||
"default_renderer_base",
|
||||
"json_renderer_base",
|
||||
)
|
||||
@@ -0,0 +1,4 @@
|
||||
"""Altair schema wrappers."""
|
||||
|
||||
# ruff: noqa: F403
|
||||
from .v5.schema import *
|
||||
@@ -0,0 +1,652 @@
|
||||
# ruff: noqa: F401, F403, F405
|
||||
from altair.expr.core import datum
|
||||
from altair.vegalite.v5 import api, compiler, schema
|
||||
from altair.vegalite.v5.api import *
|
||||
from altair.vegalite.v5.compiler import vegalite_compilers
|
||||
from altair.vegalite.v5.data import (
|
||||
MaxRowsError,
|
||||
data_transformers,
|
||||
default_data_transformer,
|
||||
limit_rows,
|
||||
sample,
|
||||
to_csv,
|
||||
to_json,
|
||||
to_values,
|
||||
)
|
||||
from altair.vegalite.v5.display import (
|
||||
VEGA_VERSION,
|
||||
VEGAEMBED_VERSION,
|
||||
VEGALITE_VERSION,
|
||||
VegaLite,
|
||||
renderers,
|
||||
)
|
||||
from altair.vegalite.v5.schema import *
|
||||
|
||||
# The content of __all__ is automatically written by
|
||||
# tools/update_init_file.py. Do not modify directly.
|
||||
|
||||
__all__ = [
|
||||
"SCHEMA_URL",
|
||||
"SCHEMA_VERSION",
|
||||
"TOPLEVEL_ONLY_KEYS",
|
||||
"URI",
|
||||
"VEGAEMBED_VERSION",
|
||||
"VEGALITE_VERSION",
|
||||
"VEGA_VERSION",
|
||||
"X2",
|
||||
"Y2",
|
||||
"Aggregate",
|
||||
"AggregateOp",
|
||||
"AggregateTransform",
|
||||
"AggregatedFieldDef",
|
||||
"Align",
|
||||
"AllSortString",
|
||||
"Angle",
|
||||
"AngleDatum",
|
||||
"AngleValue",
|
||||
"AnyMark",
|
||||
"AnyMarkConfig",
|
||||
"AreaConfig",
|
||||
"ArgmaxDef",
|
||||
"ArgminDef",
|
||||
"AutoSizeParams",
|
||||
"AutosizeType",
|
||||
"Axis",
|
||||
"AxisConfig",
|
||||
"AxisOrient",
|
||||
"AxisResolveMap",
|
||||
"BBox",
|
||||
"BarConfig",
|
||||
"BaseTitleNoValueRefs",
|
||||
"Baseline",
|
||||
"Bin",
|
||||
"BinExtent",
|
||||
"BinParams",
|
||||
"BinTransform",
|
||||
"BindCheckbox",
|
||||
"BindDirect",
|
||||
"BindInput",
|
||||
"BindRadioSelect",
|
||||
"BindRange",
|
||||
"Binding",
|
||||
"BinnedTimeUnit",
|
||||
"Blend",
|
||||
"BoxPlot",
|
||||
"BoxPlotConfig",
|
||||
"BoxPlotDef",
|
||||
"BrushConfig",
|
||||
"CalculateTransform",
|
||||
"Categorical",
|
||||
"ChainedWhen",
|
||||
"Chart",
|
||||
"ChartDataType",
|
||||
"Color",
|
||||
"ColorDatum",
|
||||
"ColorDef",
|
||||
"ColorName",
|
||||
"ColorScheme",
|
||||
"ColorValue",
|
||||
"Column",
|
||||
"CompositeMark",
|
||||
"CompositeMarkDef",
|
||||
"CompositionConfig",
|
||||
"ConcatChart",
|
||||
"ConcatSpecGenericSpec",
|
||||
"ConditionalAxisColor",
|
||||
"ConditionalAxisLabelAlign",
|
||||
"ConditionalAxisLabelBaseline",
|
||||
"ConditionalAxisLabelFontStyle",
|
||||
"ConditionalAxisLabelFontWeight",
|
||||
"ConditionalAxisNumber",
|
||||
"ConditionalAxisNumberArray",
|
||||
"ConditionalAxisPropertyAlignnull",
|
||||
"ConditionalAxisPropertyColornull",
|
||||
"ConditionalAxisPropertyFontStylenull",
|
||||
"ConditionalAxisPropertyFontWeightnull",
|
||||
"ConditionalAxisPropertyTextBaselinenull",
|
||||
"ConditionalAxisPropertynumberArraynull",
|
||||
"ConditionalAxisPropertynumbernull",
|
||||
"ConditionalAxisPropertystringnull",
|
||||
"ConditionalAxisString",
|
||||
"ConditionalMarkPropFieldOrDatumDef",
|
||||
"ConditionalMarkPropFieldOrDatumDefTypeForShape",
|
||||
"ConditionalParameterMarkPropFieldOrDatumDef",
|
||||
"ConditionalParameterMarkPropFieldOrDatumDefTypeForShape",
|
||||
"ConditionalParameterStringFieldDef",
|
||||
"ConditionalParameterValueDefGradientstringnullExprRef",
|
||||
"ConditionalParameterValueDefTextExprRef",
|
||||
"ConditionalParameterValueDefnumber",
|
||||
"ConditionalParameterValueDefnumberArrayExprRef",
|
||||
"ConditionalParameterValueDefnumberExprRef",
|
||||
"ConditionalParameterValueDefstringExprRef",
|
||||
"ConditionalParameterValueDefstringnullExprRef",
|
||||
"ConditionalPredicateMarkPropFieldOrDatumDef",
|
||||
"ConditionalPredicateMarkPropFieldOrDatumDefTypeForShape",
|
||||
"ConditionalPredicateStringFieldDef",
|
||||
"ConditionalPredicateValueDefAlignnullExprRef",
|
||||
"ConditionalPredicateValueDefColornullExprRef",
|
||||
"ConditionalPredicateValueDefFontStylenullExprRef",
|
||||
"ConditionalPredicateValueDefFontWeightnullExprRef",
|
||||
"ConditionalPredicateValueDefGradientstringnullExprRef",
|
||||
"ConditionalPredicateValueDefTextBaselinenullExprRef",
|
||||
"ConditionalPredicateValueDefTextExprRef",
|
||||
"ConditionalPredicateValueDefnumber",
|
||||
"ConditionalPredicateValueDefnumberArrayExprRef",
|
||||
"ConditionalPredicateValueDefnumberArraynullExprRef",
|
||||
"ConditionalPredicateValueDefnumberExprRef",
|
||||
"ConditionalPredicateValueDefnumbernullExprRef",
|
||||
"ConditionalPredicateValueDefstringExprRef",
|
||||
"ConditionalPredicateValueDefstringnullExprRef",
|
||||
"ConditionalStringFieldDef",
|
||||
"ConditionalValueDefGradientstringnullExprRef",
|
||||
"ConditionalValueDefTextExprRef",
|
||||
"ConditionalValueDefnumber",
|
||||
"ConditionalValueDefnumberArrayExprRef",
|
||||
"ConditionalValueDefnumberExprRef",
|
||||
"ConditionalValueDefstringExprRef",
|
||||
"ConditionalValueDefstringnullExprRef",
|
||||
"Config",
|
||||
"CsvDataFormat",
|
||||
"Cursor",
|
||||
"Cyclical",
|
||||
"Data",
|
||||
"DataFormat",
|
||||
"DataSource",
|
||||
"DataType",
|
||||
"Datasets",
|
||||
"DateTime",
|
||||
"DatumChannelMixin",
|
||||
"DatumDef",
|
||||
"Day",
|
||||
"DensityTransform",
|
||||
"DerivedStream",
|
||||
"Description",
|
||||
"DescriptionValue",
|
||||
"Detail",
|
||||
"DictInlineDataset",
|
||||
"DictSelectionInit",
|
||||
"DictSelectionInitInterval",
|
||||
"Diverging",
|
||||
"DomainUnionWith",
|
||||
"DsvDataFormat",
|
||||
"Element",
|
||||
"Encoding",
|
||||
"EncodingSortField",
|
||||
"ErrorBand",
|
||||
"ErrorBandConfig",
|
||||
"ErrorBandDef",
|
||||
"ErrorBar",
|
||||
"ErrorBarConfig",
|
||||
"ErrorBarDef",
|
||||
"ErrorBarExtent",
|
||||
"EventStream",
|
||||
"EventType",
|
||||
"Expr",
|
||||
"ExprRef",
|
||||
"ExtentTransform",
|
||||
"Facet",
|
||||
"FacetChart",
|
||||
"FacetEncodingFieldDef",
|
||||
"FacetFieldDef",
|
||||
"FacetMapping",
|
||||
"FacetSpec",
|
||||
"FacetedEncoding",
|
||||
"FacetedUnitSpec",
|
||||
"Feature",
|
||||
"FeatureCollection",
|
||||
"FeatureGeometryGeoJsonProperties",
|
||||
"Field",
|
||||
"FieldChannelMixin",
|
||||
"FieldDefWithoutScale",
|
||||
"FieldEqualPredicate",
|
||||
"FieldGTEPredicate",
|
||||
"FieldGTPredicate",
|
||||
"FieldLTEPredicate",
|
||||
"FieldLTPredicate",
|
||||
"FieldName",
|
||||
"FieldOneOfPredicate",
|
||||
"FieldOrDatumDefWithConditionDatumDefGradientstringnull",
|
||||
"FieldOrDatumDefWithConditionDatumDefnumber",
|
||||
"FieldOrDatumDefWithConditionDatumDefnumberArray",
|
||||
"FieldOrDatumDefWithConditionDatumDefstringnull",
|
||||
"FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull",
|
||||
"FieldOrDatumDefWithConditionMarkPropFieldDefTypeForShapestringnull",
|
||||
"FieldOrDatumDefWithConditionMarkPropFieldDefnumber",
|
||||
"FieldOrDatumDefWithConditionMarkPropFieldDefnumberArray",
|
||||
"FieldOrDatumDefWithConditionStringDatumDefText",
|
||||
"FieldOrDatumDefWithConditionStringFieldDefText",
|
||||
"FieldOrDatumDefWithConditionStringFieldDefstring",
|
||||
"FieldRange",
|
||||
"FieldRangePredicate",
|
||||
"FieldValidPredicate",
|
||||
"Fill",
|
||||
"FillDatum",
|
||||
"FillOpacity",
|
||||
"FillOpacityDatum",
|
||||
"FillOpacityValue",
|
||||
"FillValue",
|
||||
"FilterTransform",
|
||||
"Fit",
|
||||
"FlattenTransform",
|
||||
"FoldTransform",
|
||||
"FontStyle",
|
||||
"FontWeight",
|
||||
"FormatConfig",
|
||||
"Generator",
|
||||
"GenericUnitSpecEncodingAnyMark",
|
||||
"GeoJsonFeature",
|
||||
"GeoJsonFeatureCollection",
|
||||
"GeoJsonProperties",
|
||||
"Geometry",
|
||||
"GeometryCollection",
|
||||
"Gradient",
|
||||
"GradientStop",
|
||||
"GraticuleGenerator",
|
||||
"GraticuleParams",
|
||||
"HConcatChart",
|
||||
"HConcatSpecGenericSpec",
|
||||
"Header",
|
||||
"HeaderConfig",
|
||||
"HexColor",
|
||||
"Href",
|
||||
"HrefValue",
|
||||
"Impute",
|
||||
"ImputeMethod",
|
||||
"ImputeParams",
|
||||
"ImputeSequence",
|
||||
"ImputeTransform",
|
||||
"InlineData",
|
||||
"InlineDataset",
|
||||
"Interpolate",
|
||||
"IntervalSelectionConfig",
|
||||
"IntervalSelectionConfigWithoutType",
|
||||
"JoinAggregateFieldDef",
|
||||
"JoinAggregateTransform",
|
||||
"JsonDataFormat",
|
||||
"Key",
|
||||
"LabelOverlap",
|
||||
"LatLongDef",
|
||||
"LatLongFieldDef",
|
||||
"Latitude",
|
||||
"Latitude2",
|
||||
"Latitude2Datum",
|
||||
"Latitude2Value",
|
||||
"LatitudeDatum",
|
||||
"LayerChart",
|
||||
"LayerRepeatMapping",
|
||||
"LayerRepeatSpec",
|
||||
"LayerSpec",
|
||||
"LayoutAlign",
|
||||
"Legend",
|
||||
"LegendBinding",
|
||||
"LegendConfig",
|
||||
"LegendOrient",
|
||||
"LegendResolveMap",
|
||||
"LegendStreamBinding",
|
||||
"LineConfig",
|
||||
"LineString",
|
||||
"LinearGradient",
|
||||
"LocalMultiTimeUnit",
|
||||
"LocalSingleTimeUnit",
|
||||
"Locale",
|
||||
"LoessTransform",
|
||||
"LogicalAndPredicate",
|
||||
"LogicalNotPredicate",
|
||||
"LogicalOrPredicate",
|
||||
"Longitude",
|
||||
"Longitude2",
|
||||
"Longitude2Datum",
|
||||
"Longitude2Value",
|
||||
"LongitudeDatum",
|
||||
"LookupData",
|
||||
"LookupSelection",
|
||||
"LookupTransform",
|
||||
"Mark",
|
||||
"MarkConfig",
|
||||
"MarkDef",
|
||||
"MarkInvalidDataMode",
|
||||
"MarkPropDefGradientstringnull",
|
||||
"MarkPropDefnumber",
|
||||
"MarkPropDefnumberArray",
|
||||
"MarkPropDefstringnullTypeForShape",
|
||||
"MarkType",
|
||||
"MaxRowsError",
|
||||
"MergedStream",
|
||||
"Month",
|
||||
"MultiLineString",
|
||||
"MultiPoint",
|
||||
"MultiPolygon",
|
||||
"MultiTimeUnit",
|
||||
"NamedData",
|
||||
"NonArgAggregateOp",
|
||||
"NonLayerRepeatSpec",
|
||||
"NonNormalizedSpec",
|
||||
"NumberLocale",
|
||||
"NumericArrayMarkPropDef",
|
||||
"NumericMarkPropDef",
|
||||
"OffsetDef",
|
||||
"Opacity",
|
||||
"OpacityDatum",
|
||||
"OpacityValue",
|
||||
"Order",
|
||||
"OrderFieldDef",
|
||||
"OrderOnlyDef",
|
||||
"OrderValue",
|
||||
"OrderValueDef",
|
||||
"Orient",
|
||||
"Orientation",
|
||||
"OverlayMarkDef",
|
||||
"Padding",
|
||||
"Parameter",
|
||||
"ParameterExpression",
|
||||
"ParameterExtent",
|
||||
"ParameterName",
|
||||
"ParameterPredicate",
|
||||
"Parse",
|
||||
"ParseValue",
|
||||
"PivotTransform",
|
||||
"Point",
|
||||
"PointSelectionConfig",
|
||||
"PointSelectionConfigWithoutType",
|
||||
"PolarDef",
|
||||
"Polygon",
|
||||
"Position",
|
||||
"Position2Def",
|
||||
"PositionDatumDef",
|
||||
"PositionDatumDefBase",
|
||||
"PositionDef",
|
||||
"PositionFieldDef",
|
||||
"PositionFieldDefBase",
|
||||
"PositionValueDef",
|
||||
"Predicate",
|
||||
"PredicateComposition",
|
||||
"PrimitiveValue",
|
||||
"Projection",
|
||||
"ProjectionConfig",
|
||||
"ProjectionType",
|
||||
"QuantileTransform",
|
||||
"RadialGradient",
|
||||
"Radius",
|
||||
"Radius2",
|
||||
"Radius2Datum",
|
||||
"Radius2Value",
|
||||
"RadiusDatum",
|
||||
"RadiusValue",
|
||||
"RangeConfig",
|
||||
"RangeEnum",
|
||||
"RangeRaw",
|
||||
"RangeRawArray",
|
||||
"RangeScheme",
|
||||
"RectConfig",
|
||||
"RegressionTransform",
|
||||
"RelativeBandSize",
|
||||
"RepeatChart",
|
||||
"RepeatMapping",
|
||||
"RepeatRef",
|
||||
"RepeatSpec",
|
||||
"Resolve",
|
||||
"ResolveMode",
|
||||
"Root",
|
||||
"Row",
|
||||
"RowColLayoutAlign",
|
||||
"RowColboolean",
|
||||
"RowColnumber",
|
||||
"RowColumnEncodingFieldDef",
|
||||
"SampleTransform",
|
||||
"Scale",
|
||||
"ScaleBinParams",
|
||||
"ScaleBins",
|
||||
"ScaleConfig",
|
||||
"ScaleDatumDef",
|
||||
"ScaleFieldDef",
|
||||
"ScaleInterpolateEnum",
|
||||
"ScaleInterpolateParams",
|
||||
"ScaleInvalidDataConfig",
|
||||
"ScaleInvalidDataShowAsValueangle",
|
||||
"ScaleInvalidDataShowAsValuecolor",
|
||||
"ScaleInvalidDataShowAsValuefill",
|
||||
"ScaleInvalidDataShowAsValuefillOpacity",
|
||||
"ScaleInvalidDataShowAsValueopacity",
|
||||
"ScaleInvalidDataShowAsValueradius",
|
||||
"ScaleInvalidDataShowAsValueshape",
|
||||
"ScaleInvalidDataShowAsValuesize",
|
||||
"ScaleInvalidDataShowAsValuestroke",
|
||||
"ScaleInvalidDataShowAsValuestrokeDash",
|
||||
"ScaleInvalidDataShowAsValuestrokeOpacity",
|
||||
"ScaleInvalidDataShowAsValuestrokeWidth",
|
||||
"ScaleInvalidDataShowAsValuetheta",
|
||||
"ScaleInvalidDataShowAsValuex",
|
||||
"ScaleInvalidDataShowAsValuexOffset",
|
||||
"ScaleInvalidDataShowAsValuey",
|
||||
"ScaleInvalidDataShowAsValueyOffset",
|
||||
"ScaleInvalidDataShowAsangle",
|
||||
"ScaleInvalidDataShowAscolor",
|
||||
"ScaleInvalidDataShowAsfill",
|
||||
"ScaleInvalidDataShowAsfillOpacity",
|
||||
"ScaleInvalidDataShowAsopacity",
|
||||
"ScaleInvalidDataShowAsradius",
|
||||
"ScaleInvalidDataShowAsshape",
|
||||
"ScaleInvalidDataShowAssize",
|
||||
"ScaleInvalidDataShowAsstroke",
|
||||
"ScaleInvalidDataShowAsstrokeDash",
|
||||
"ScaleInvalidDataShowAsstrokeOpacity",
|
||||
"ScaleInvalidDataShowAsstrokeWidth",
|
||||
"ScaleInvalidDataShowAstheta",
|
||||
"ScaleInvalidDataShowAsx",
|
||||
"ScaleInvalidDataShowAsxOffset",
|
||||
"ScaleInvalidDataShowAsy",
|
||||
"ScaleInvalidDataShowAsyOffset",
|
||||
"ScaleResolveMap",
|
||||
"ScaleType",
|
||||
"SchemaBase",
|
||||
"SchemeParams",
|
||||
"SecondaryFieldDef",
|
||||
"SelectionConfig",
|
||||
"SelectionExpression",
|
||||
"SelectionInit",
|
||||
"SelectionInitInterval",
|
||||
"SelectionInitIntervalMapping",
|
||||
"SelectionInitMapping",
|
||||
"SelectionParameter",
|
||||
"SelectionPredicateComposition",
|
||||
"SelectionResolution",
|
||||
"SelectionType",
|
||||
"SequenceGenerator",
|
||||
"SequenceParams",
|
||||
"SequentialMultiHue",
|
||||
"SequentialSingleHue",
|
||||
"Shape",
|
||||
"ShapeDatum",
|
||||
"ShapeDef",
|
||||
"ShapeValue",
|
||||
"SharedEncoding",
|
||||
"SingleDefUnitChannel",
|
||||
"SingleTimeUnit",
|
||||
"Size",
|
||||
"SizeDatum",
|
||||
"SizeValue",
|
||||
"Sort",
|
||||
"SortArray",
|
||||
"SortByChannel",
|
||||
"SortByChannelDesc",
|
||||
"SortByEncoding",
|
||||
"SortField",
|
||||
"SortOrder",
|
||||
"Spec",
|
||||
"SphereGenerator",
|
||||
"StackOffset",
|
||||
"StackTransform",
|
||||
"StandardType",
|
||||
"Step",
|
||||
"StepFor",
|
||||
"Stream",
|
||||
"StringFieldDef",
|
||||
"StringFieldDefWithCondition",
|
||||
"StringValueDefWithCondition",
|
||||
"Stroke",
|
||||
"StrokeCap",
|
||||
"StrokeDash",
|
||||
"StrokeDashDatum",
|
||||
"StrokeDashValue",
|
||||
"StrokeDatum",
|
||||
"StrokeJoin",
|
||||
"StrokeOpacity",
|
||||
"StrokeOpacityDatum",
|
||||
"StrokeOpacityValue",
|
||||
"StrokeValue",
|
||||
"StrokeWidth",
|
||||
"StrokeWidthDatum",
|
||||
"StrokeWidthValue",
|
||||
"StyleConfigIndex",
|
||||
"SymbolShape",
|
||||
"Text",
|
||||
"TextBaseline",
|
||||
"TextDatum",
|
||||
"TextDef",
|
||||
"TextDirection",
|
||||
"TextValue",
|
||||
"Then",
|
||||
"Theta",
|
||||
"Theta2",
|
||||
"Theta2Datum",
|
||||
"Theta2Value",
|
||||
"ThetaDatum",
|
||||
"ThetaValue",
|
||||
"TickConfig",
|
||||
"TickCount",
|
||||
"TimeInterval",
|
||||
"TimeIntervalStep",
|
||||
"TimeLocale",
|
||||
"TimeUnit",
|
||||
"TimeUnitParams",
|
||||
"TimeUnitTransform",
|
||||
"TimeUnitTransformParams",
|
||||
"Title",
|
||||
"TitleAnchor",
|
||||
"TitleConfig",
|
||||
"TitleFrame",
|
||||
"TitleOrient",
|
||||
"TitleParams",
|
||||
"Tooltip",
|
||||
"TooltipContent",
|
||||
"TooltipValue",
|
||||
"TopLevelConcatSpec",
|
||||
"TopLevelFacetSpec",
|
||||
"TopLevelHConcatSpec",
|
||||
"TopLevelLayerSpec",
|
||||
"TopLevelMixin",
|
||||
"TopLevelParameter",
|
||||
"TopLevelRepeatSpec",
|
||||
"TopLevelSelectionParameter",
|
||||
"TopLevelSpec",
|
||||
"TopLevelUnitSpec",
|
||||
"TopLevelVConcatSpec",
|
||||
"TopoDataFormat",
|
||||
"Transform",
|
||||
"Type",
|
||||
"TypeForShape",
|
||||
"TypedFieldDef",
|
||||
"UnitSpec",
|
||||
"UnitSpecWithFrame",
|
||||
"Url",
|
||||
"UrlData",
|
||||
"UrlValue",
|
||||
"UtcMultiTimeUnit",
|
||||
"UtcSingleTimeUnit",
|
||||
"VConcatChart",
|
||||
"VConcatSpecGenericSpec",
|
||||
"ValueChannelMixin",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefTypeForShapestringnull",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefnumber",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefnumberArray",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefstringnull",
|
||||
"ValueDefWithConditionStringFieldDefText",
|
||||
"ValueDefnumber",
|
||||
"ValueDefnumberwidthheightExprRef",
|
||||
"VariableParameter",
|
||||
"Vector2DateTime",
|
||||
"Vector2Vector2number",
|
||||
"Vector2boolean",
|
||||
"Vector2number",
|
||||
"Vector2string",
|
||||
"Vector3number",
|
||||
"Vector7string",
|
||||
"Vector10string",
|
||||
"Vector12string",
|
||||
"VegaLite",
|
||||
"VegaLiteSchema",
|
||||
"ViewBackground",
|
||||
"ViewConfig",
|
||||
"When",
|
||||
"WindowEventType",
|
||||
"WindowFieldDef",
|
||||
"WindowOnlyOp",
|
||||
"WindowTransform",
|
||||
"X",
|
||||
"X2Datum",
|
||||
"X2Value",
|
||||
"XDatum",
|
||||
"XError",
|
||||
"XError2",
|
||||
"XError2Value",
|
||||
"XErrorValue",
|
||||
"XOffset",
|
||||
"XOffsetDatum",
|
||||
"XOffsetValue",
|
||||
"XValue",
|
||||
"Y",
|
||||
"Y2Datum",
|
||||
"Y2Value",
|
||||
"YDatum",
|
||||
"YError",
|
||||
"YError2",
|
||||
"YError2Value",
|
||||
"YErrorValue",
|
||||
"YOffset",
|
||||
"YOffsetDatum",
|
||||
"YOffsetValue",
|
||||
"YValue",
|
||||
"api",
|
||||
"binding",
|
||||
"binding_checkbox",
|
||||
"binding_radio",
|
||||
"binding_range",
|
||||
"binding_select",
|
||||
"channels",
|
||||
"check_fields_and_encodings",
|
||||
"compiler",
|
||||
"concat",
|
||||
"condition",
|
||||
"core",
|
||||
"data_transformers",
|
||||
"datum",
|
||||
"default_data_transformer",
|
||||
"graticule",
|
||||
"hconcat",
|
||||
"layer",
|
||||
"limit_rows",
|
||||
"load_schema",
|
||||
"mixins",
|
||||
"param",
|
||||
"renderers",
|
||||
"repeat",
|
||||
"sample",
|
||||
"schema",
|
||||
"selection",
|
||||
"selection_interval",
|
||||
"selection_multi",
|
||||
"selection_point",
|
||||
"selection_single",
|
||||
"sequence",
|
||||
"sphere",
|
||||
"to_csv",
|
||||
"to_json",
|
||||
"to_values",
|
||||
"topo_feature",
|
||||
"value",
|
||||
"vconcat",
|
||||
"vegalite_compilers",
|
||||
"when",
|
||||
"with_property_setters",
|
||||
]
|
||||
5213
myenv/lib/python3.11/site-packages/altair/vegalite/v5/api.py
Normal file
5213
myenv/lib/python3.11/site-packages/altair/vegalite/v5/api.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
from typing import Final
|
||||
|
||||
from altair.utils._importers import import_vl_convert
|
||||
from altair.utils.compiler import VegaLiteCompilerRegistry
|
||||
|
||||
ENTRY_POINT_GROUP: Final = "altair.vegalite.v5.vegalite_compiler"
|
||||
vegalite_compilers = VegaLiteCompilerRegistry(entry_point_group=ENTRY_POINT_GROUP)
|
||||
|
||||
|
||||
def vl_convert_compiler(vegalite_spec: dict) -> dict:
|
||||
"""Vega-Lite to Vega compiler that uses vl-convert."""
|
||||
from . import SCHEMA_VERSION
|
||||
|
||||
vlc = import_vl_convert()
|
||||
|
||||
# Compute vl-convert's vl_version string (of the form 'v5_8')
|
||||
# from SCHEMA_VERSION (of the form 'v5.8.0')
|
||||
vl_version = "_".join(SCHEMA_VERSION.split(".")[:2])
|
||||
return vlc.vegalite_to_vega(vegalite_spec, vl_version=vl_version)
|
||||
|
||||
|
||||
vegalite_compilers.register("vl-convert", vl_convert_compiler)
|
||||
vegalite_compilers.enable("vl-convert")
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Final
|
||||
|
||||
from altair.utils._vegafusion_data import vegafusion_data_transformer
|
||||
from altair.vegalite.data import (
|
||||
DataTransformerRegistry,
|
||||
MaxRowsError,
|
||||
default_data_transformer,
|
||||
limit_rows,
|
||||
sample,
|
||||
to_csv,
|
||||
to_json,
|
||||
to_values,
|
||||
)
|
||||
|
||||
# ==============================================================================
|
||||
# VegaLite 5 data transformers
|
||||
# ==============================================================================
|
||||
|
||||
|
||||
ENTRY_POINT_GROUP: Final = "altair.vegalite.v5.data_transformer"
|
||||
|
||||
|
||||
data_transformers = DataTransformerRegistry(entry_point_group=ENTRY_POINT_GROUP)
|
||||
data_transformers.register("default", default_data_transformer)
|
||||
data_transformers.register("json", to_json)
|
||||
# FIXME: `to_csv` cannot accept all `DataType` https://github.com/vega/altair/issues/3441
|
||||
data_transformers.register("csv", to_csv) # type: ignore[arg-type]
|
||||
data_transformers.register("vegafusion", vegafusion_data_transformer)
|
||||
data_transformers.enable("default")
|
||||
|
||||
|
||||
__all__ = (
|
||||
"MaxRowsError",
|
||||
"default_data_transformer",
|
||||
"limit_rows",
|
||||
"sample",
|
||||
"to_csv",
|
||||
"to_json",
|
||||
"to_values",
|
||||
"vegafusion_data_transformer",
|
||||
)
|
||||
191
myenv/lib/python3.11/site-packages/altair/vegalite/v5/display.py
Normal file
191
myenv/lib/python3.11/site-packages/altair/vegalite/v5/display.py
Normal file
@@ -0,0 +1,191 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Final
|
||||
|
||||
from altair.utils.mimebundle import spec_to_mimebundle
|
||||
from altair.vegalite.display import (
|
||||
Displayable,
|
||||
HTMLRenderer,
|
||||
RendererRegistry,
|
||||
default_renderer_base,
|
||||
json_renderer_base,
|
||||
)
|
||||
|
||||
from .schema import SCHEMA_VERSION
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from altair.vegalite.display import DefaultRendererReturnType
|
||||
|
||||
|
||||
VEGALITE_VERSION: Final = SCHEMA_VERSION.lstrip("v")
|
||||
VEGA_VERSION: Final = "5"
|
||||
VEGAEMBED_VERSION: Final = "6"
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# VegaLite v5 renderer logic
|
||||
# ==============================================================================
|
||||
|
||||
|
||||
# The MIME type for Vega-Lite 5.x releases.
|
||||
VEGALITE_MIME_TYPE: Final = "application/vnd.vegalite.v5+json"
|
||||
|
||||
# The MIME type for Vega 5.x releases.
|
||||
VEGA_MIME_TYPE: Final = "application/vnd.vega.v5+json"
|
||||
|
||||
# The entry point group that can be used by other packages to declare other
|
||||
# renderers that will be auto-detected. Explicit registration is also
|
||||
# allowed by the PluginRegistery API.
|
||||
ENTRY_POINT_GROUP: Final = "altair.vegalite.v5.renderer"
|
||||
|
||||
# The display message when rendering fails
|
||||
DEFAULT_DISPLAY: Final = f"""\
|
||||
<VegaLite {VEGALITE_VERSION.split('.')[0]} object>
|
||||
|
||||
If you see this message, it means the renderer has not been properly enabled
|
||||
for the frontend that you are using. For more information, see
|
||||
https://altair-viz.github.io/user_guide/display_frontends.html#troubleshooting
|
||||
"""
|
||||
|
||||
renderers = RendererRegistry(entry_point_group=ENTRY_POINT_GROUP)
|
||||
|
||||
here = str(Path(__file__).parent)
|
||||
|
||||
|
||||
def mimetype_renderer(spec: dict, **metadata) -> DefaultRendererReturnType:
|
||||
return default_renderer_base(spec, VEGALITE_MIME_TYPE, DEFAULT_DISPLAY, **metadata)
|
||||
|
||||
|
||||
def json_renderer(spec: dict, **metadata) -> DefaultRendererReturnType:
|
||||
return json_renderer_base(spec, DEFAULT_DISPLAY, **metadata)
|
||||
|
||||
|
||||
def png_renderer(spec: dict, **metadata) -> dict[str, bytes]:
|
||||
# To get proper return value type, would need to write complex
|
||||
# overload signatures for spec_to_mimebundle based on `format`
|
||||
return spec_to_mimebundle( # type: ignore[return-value]
|
||||
spec,
|
||||
format="png",
|
||||
mode="vega-lite",
|
||||
vega_version=VEGA_VERSION,
|
||||
vegaembed_version=VEGAEMBED_VERSION,
|
||||
vegalite_version=VEGALITE_VERSION,
|
||||
**metadata,
|
||||
)
|
||||
|
||||
|
||||
def svg_renderer(spec: dict, **metadata) -> dict[str, str]:
|
||||
# To get proper return value type, would need to write complex
|
||||
# overload signatures for spec_to_mimebundle based on `format`
|
||||
return spec_to_mimebundle(
|
||||
spec,
|
||||
format="svg",
|
||||
mode="vega-lite",
|
||||
vega_version=VEGA_VERSION,
|
||||
vegaembed_version=VEGAEMBED_VERSION,
|
||||
vegalite_version=VEGALITE_VERSION,
|
||||
**metadata,
|
||||
)
|
||||
|
||||
|
||||
def jupyter_renderer(spec: dict, **metadata):
|
||||
"""Render chart using the JupyterChart Jupyter Widget."""
|
||||
from altair import Chart, JupyterChart
|
||||
|
||||
# Configure offline mode
|
||||
offline = metadata.get("offline", False)
|
||||
|
||||
# mypy doesn't see the enable_offline class method for some reason
|
||||
JupyterChart.enable_offline(offline=offline) # type: ignore[attr-defined]
|
||||
|
||||
# propagate embed options
|
||||
embed_options = metadata.get("embed_options")
|
||||
|
||||
# Need to ignore attr-defined mypy rule because mypy doesn't see _repr_mimebundle_
|
||||
# conditionally defined in AnyWidget
|
||||
return JupyterChart(
|
||||
chart=Chart.from_dict(spec), embed_options=embed_options
|
||||
)._repr_mimebundle_() # type: ignore[attr-defined]
|
||||
|
||||
|
||||
def browser_renderer(
|
||||
spec: dict, offline=False, using=None, port=0, **metadata
|
||||
) -> dict[str, str]:
|
||||
from altair.utils._show import open_html_in_browser
|
||||
|
||||
if offline:
|
||||
metadata["template"] = "inline"
|
||||
mimebundle = spec_to_mimebundle(
|
||||
spec,
|
||||
format="html",
|
||||
mode="vega-lite",
|
||||
vega_version=VEGA_VERSION,
|
||||
vegaembed_version=VEGAEMBED_VERSION,
|
||||
vegalite_version=VEGALITE_VERSION,
|
||||
**metadata,
|
||||
)
|
||||
html = mimebundle["text/html"]
|
||||
open_html_in_browser(html, using=using, port=port)
|
||||
return {}
|
||||
|
||||
|
||||
html_renderer = HTMLRenderer(
|
||||
mode="vega-lite",
|
||||
template="universal",
|
||||
vega_version=VEGA_VERSION,
|
||||
vegaembed_version=VEGAEMBED_VERSION,
|
||||
vegalite_version=VEGALITE_VERSION,
|
||||
)
|
||||
|
||||
|
||||
olli_renderer = HTMLRenderer(
|
||||
mode="vega-lite",
|
||||
template="olli",
|
||||
vega_version=VEGA_VERSION,
|
||||
vegaembed_version=VEGAEMBED_VERSION,
|
||||
vegalite_version=VEGALITE_VERSION,
|
||||
)
|
||||
|
||||
renderers.register("default", html_renderer)
|
||||
renderers.register("html", html_renderer)
|
||||
renderers.register("colab", html_renderer)
|
||||
renderers.register("kaggle", html_renderer)
|
||||
renderers.register("zeppelin", html_renderer)
|
||||
renderers.register("mimetype", mimetype_renderer)
|
||||
renderers.register("jupyterlab", mimetype_renderer)
|
||||
renderers.register("nteract", mimetype_renderer)
|
||||
renderers.register("json", json_renderer)
|
||||
renderers.register("png", png_renderer)
|
||||
renderers.register("svg", svg_renderer)
|
||||
# FIXME: Caused by upstream # type: ignore[unreachable]
|
||||
# https://github.com/manzt/anywidget/blob/b7961305a7304f4d3def1fafef0df65db56cf41e/anywidget/widget.py#L80-L81
|
||||
renderers.register("jupyter", jupyter_renderer) # pyright: ignore[reportArgumentType]
|
||||
renderers.register("browser", browser_renderer)
|
||||
renderers.register("olli", olli_renderer)
|
||||
renderers.enable("default")
|
||||
|
||||
|
||||
class VegaLite(Displayable):
|
||||
"""An IPython/Jupyter display class for rendering VegaLite 5."""
|
||||
|
||||
renderers = renderers
|
||||
schema_path = (__name__, "schema/vega-lite-schema.json")
|
||||
|
||||
|
||||
def vegalite(spec: dict, validate: bool = True) -> None:
|
||||
"""
|
||||
Render and optionally validate a VegaLite 5 spec.
|
||||
|
||||
This will use the currently enabled renderer to render the spec.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
spec: dict
|
||||
A fully compliant VegaLite 5 spec, with the data portion fully processed.
|
||||
validate: bool
|
||||
Should the spec be validated against the VegaLite 5 schema?
|
||||
"""
|
||||
from IPython.display import display
|
||||
|
||||
display(VegaLite(spec, validate=validate))
|
||||
@@ -0,0 +1,571 @@
|
||||
# ruff: noqa: F403, F405
|
||||
# The contents of this file are automatically written by
|
||||
# tools/generate_schema_wrapper.py. Do not modify directly.
|
||||
|
||||
from altair.vegalite.v5.schema import channels, core
|
||||
from altair.vegalite.v5.schema.channels import *
|
||||
from altair.vegalite.v5.schema.core import *
|
||||
|
||||
SCHEMA_VERSION = "v5.20.1"
|
||||
|
||||
SCHEMA_URL = "https://vega.github.io/schema/vega-lite/v5.20.1.json"
|
||||
|
||||
__all__ = [
|
||||
"SCHEMA_URL",
|
||||
"SCHEMA_VERSION",
|
||||
"URI",
|
||||
"X2",
|
||||
"Y2",
|
||||
"Aggregate",
|
||||
"AggregateOp",
|
||||
"AggregateTransform",
|
||||
"AggregatedFieldDef",
|
||||
"Align",
|
||||
"AllSortString",
|
||||
"Angle",
|
||||
"AngleDatum",
|
||||
"AngleValue",
|
||||
"AnyMark",
|
||||
"AnyMarkConfig",
|
||||
"AreaConfig",
|
||||
"ArgmaxDef",
|
||||
"ArgminDef",
|
||||
"AutoSizeParams",
|
||||
"AutosizeType",
|
||||
"Axis",
|
||||
"AxisConfig",
|
||||
"AxisOrient",
|
||||
"AxisResolveMap",
|
||||
"BBox",
|
||||
"BarConfig",
|
||||
"BaseTitleNoValueRefs",
|
||||
"Baseline",
|
||||
"BinExtent",
|
||||
"BinParams",
|
||||
"BinTransform",
|
||||
"BindCheckbox",
|
||||
"BindDirect",
|
||||
"BindInput",
|
||||
"BindRadioSelect",
|
||||
"BindRange",
|
||||
"Binding",
|
||||
"BinnedTimeUnit",
|
||||
"Blend",
|
||||
"BoxPlot",
|
||||
"BoxPlotConfig",
|
||||
"BoxPlotDef",
|
||||
"BrushConfig",
|
||||
"CalculateTransform",
|
||||
"Categorical",
|
||||
"Color",
|
||||
"ColorDatum",
|
||||
"ColorDef",
|
||||
"ColorName",
|
||||
"ColorScheme",
|
||||
"ColorValue",
|
||||
"Column",
|
||||
"CompositeMark",
|
||||
"CompositeMarkDef",
|
||||
"CompositionConfig",
|
||||
"ConcatSpecGenericSpec",
|
||||
"ConditionalAxisColor",
|
||||
"ConditionalAxisLabelAlign",
|
||||
"ConditionalAxisLabelBaseline",
|
||||
"ConditionalAxisLabelFontStyle",
|
||||
"ConditionalAxisLabelFontWeight",
|
||||
"ConditionalAxisNumber",
|
||||
"ConditionalAxisNumberArray",
|
||||
"ConditionalAxisPropertyAlignnull",
|
||||
"ConditionalAxisPropertyColornull",
|
||||
"ConditionalAxisPropertyFontStylenull",
|
||||
"ConditionalAxisPropertyFontWeightnull",
|
||||
"ConditionalAxisPropertyTextBaselinenull",
|
||||
"ConditionalAxisPropertynumberArraynull",
|
||||
"ConditionalAxisPropertynumbernull",
|
||||
"ConditionalAxisPropertystringnull",
|
||||
"ConditionalAxisString",
|
||||
"ConditionalMarkPropFieldOrDatumDef",
|
||||
"ConditionalMarkPropFieldOrDatumDefTypeForShape",
|
||||
"ConditionalParameterMarkPropFieldOrDatumDef",
|
||||
"ConditionalParameterMarkPropFieldOrDatumDefTypeForShape",
|
||||
"ConditionalParameterStringFieldDef",
|
||||
"ConditionalParameterValueDefGradientstringnullExprRef",
|
||||
"ConditionalParameterValueDefTextExprRef",
|
||||
"ConditionalParameterValueDefnumber",
|
||||
"ConditionalParameterValueDefnumberArrayExprRef",
|
||||
"ConditionalParameterValueDefnumberExprRef",
|
||||
"ConditionalParameterValueDefstringExprRef",
|
||||
"ConditionalParameterValueDefstringnullExprRef",
|
||||
"ConditionalPredicateMarkPropFieldOrDatumDef",
|
||||
"ConditionalPredicateMarkPropFieldOrDatumDefTypeForShape",
|
||||
"ConditionalPredicateStringFieldDef",
|
||||
"ConditionalPredicateValueDefAlignnullExprRef",
|
||||
"ConditionalPredicateValueDefColornullExprRef",
|
||||
"ConditionalPredicateValueDefFontStylenullExprRef",
|
||||
"ConditionalPredicateValueDefFontWeightnullExprRef",
|
||||
"ConditionalPredicateValueDefGradientstringnullExprRef",
|
||||
"ConditionalPredicateValueDefTextBaselinenullExprRef",
|
||||
"ConditionalPredicateValueDefTextExprRef",
|
||||
"ConditionalPredicateValueDefnumber",
|
||||
"ConditionalPredicateValueDefnumberArrayExprRef",
|
||||
"ConditionalPredicateValueDefnumberArraynullExprRef",
|
||||
"ConditionalPredicateValueDefnumberExprRef",
|
||||
"ConditionalPredicateValueDefnumbernullExprRef",
|
||||
"ConditionalPredicateValueDefstringExprRef",
|
||||
"ConditionalPredicateValueDefstringnullExprRef",
|
||||
"ConditionalStringFieldDef",
|
||||
"ConditionalValueDefGradientstringnullExprRef",
|
||||
"ConditionalValueDefTextExprRef",
|
||||
"ConditionalValueDefnumber",
|
||||
"ConditionalValueDefnumberArrayExprRef",
|
||||
"ConditionalValueDefnumberExprRef",
|
||||
"ConditionalValueDefstringExprRef",
|
||||
"ConditionalValueDefstringnullExprRef",
|
||||
"Config",
|
||||
"CsvDataFormat",
|
||||
"Cursor",
|
||||
"Cyclical",
|
||||
"Data",
|
||||
"DataFormat",
|
||||
"DataSource",
|
||||
"Datasets",
|
||||
"DateTime",
|
||||
"DatumChannelMixin",
|
||||
"DatumDef",
|
||||
"Day",
|
||||
"DensityTransform",
|
||||
"DerivedStream",
|
||||
"Description",
|
||||
"DescriptionValue",
|
||||
"Detail",
|
||||
"DictInlineDataset",
|
||||
"DictSelectionInit",
|
||||
"DictSelectionInitInterval",
|
||||
"Diverging",
|
||||
"DomainUnionWith",
|
||||
"DsvDataFormat",
|
||||
"Element",
|
||||
"Encoding",
|
||||
"EncodingSortField",
|
||||
"ErrorBand",
|
||||
"ErrorBandConfig",
|
||||
"ErrorBandDef",
|
||||
"ErrorBar",
|
||||
"ErrorBarConfig",
|
||||
"ErrorBarDef",
|
||||
"ErrorBarExtent",
|
||||
"EventStream",
|
||||
"EventType",
|
||||
"Expr",
|
||||
"ExprRef",
|
||||
"ExtentTransform",
|
||||
"Facet",
|
||||
"FacetEncodingFieldDef",
|
||||
"FacetFieldDef",
|
||||
"FacetSpec",
|
||||
"FacetedEncoding",
|
||||
"FacetedUnitSpec",
|
||||
"Feature",
|
||||
"FeatureCollection",
|
||||
"FeatureGeometryGeoJsonProperties",
|
||||
"Field",
|
||||
"FieldChannelMixin",
|
||||
"FieldDefWithoutScale",
|
||||
"FieldEqualPredicate",
|
||||
"FieldGTEPredicate",
|
||||
"FieldGTPredicate",
|
||||
"FieldLTEPredicate",
|
||||
"FieldLTPredicate",
|
||||
"FieldName",
|
||||
"FieldOneOfPredicate",
|
||||
"FieldOrDatumDefWithConditionDatumDefGradientstringnull",
|
||||
"FieldOrDatumDefWithConditionDatumDefnumber",
|
||||
"FieldOrDatumDefWithConditionDatumDefnumberArray",
|
||||
"FieldOrDatumDefWithConditionDatumDefstringnull",
|
||||
"FieldOrDatumDefWithConditionMarkPropFieldDefGradientstringnull",
|
||||
"FieldOrDatumDefWithConditionMarkPropFieldDefTypeForShapestringnull",
|
||||
"FieldOrDatumDefWithConditionMarkPropFieldDefnumber",
|
||||
"FieldOrDatumDefWithConditionMarkPropFieldDefnumberArray",
|
||||
"FieldOrDatumDefWithConditionStringDatumDefText",
|
||||
"FieldOrDatumDefWithConditionStringFieldDefText",
|
||||
"FieldOrDatumDefWithConditionStringFieldDefstring",
|
||||
"FieldRange",
|
||||
"FieldRangePredicate",
|
||||
"FieldValidPredicate",
|
||||
"Fill",
|
||||
"FillDatum",
|
||||
"FillOpacity",
|
||||
"FillOpacityDatum",
|
||||
"FillOpacityValue",
|
||||
"FillValue",
|
||||
"FilterTransform",
|
||||
"Fit",
|
||||
"FlattenTransform",
|
||||
"FoldTransform",
|
||||
"FontStyle",
|
||||
"FontWeight",
|
||||
"FormatConfig",
|
||||
"Generator",
|
||||
"GenericUnitSpecEncodingAnyMark",
|
||||
"GeoJsonFeature",
|
||||
"GeoJsonFeatureCollection",
|
||||
"GeoJsonProperties",
|
||||
"Geometry",
|
||||
"GeometryCollection",
|
||||
"Gradient",
|
||||
"GradientStop",
|
||||
"GraticuleGenerator",
|
||||
"GraticuleParams",
|
||||
"HConcatSpecGenericSpec",
|
||||
"Header",
|
||||
"HeaderConfig",
|
||||
"HexColor",
|
||||
"Href",
|
||||
"HrefValue",
|
||||
"ImputeMethod",
|
||||
"ImputeParams",
|
||||
"ImputeSequence",
|
||||
"ImputeTransform",
|
||||
"InlineData",
|
||||
"InlineDataset",
|
||||
"Interpolate",
|
||||
"IntervalSelectionConfig",
|
||||
"IntervalSelectionConfigWithoutType",
|
||||
"JoinAggregateFieldDef",
|
||||
"JoinAggregateTransform",
|
||||
"JsonDataFormat",
|
||||
"Key",
|
||||
"LabelOverlap",
|
||||
"LatLongDef",
|
||||
"LatLongFieldDef",
|
||||
"Latitude",
|
||||
"Latitude2",
|
||||
"Latitude2Datum",
|
||||
"Latitude2Value",
|
||||
"LatitudeDatum",
|
||||
"LayerRepeatMapping",
|
||||
"LayerRepeatSpec",
|
||||
"LayerSpec",
|
||||
"LayoutAlign",
|
||||
"Legend",
|
||||
"LegendBinding",
|
||||
"LegendConfig",
|
||||
"LegendOrient",
|
||||
"LegendResolveMap",
|
||||
"LegendStreamBinding",
|
||||
"LineConfig",
|
||||
"LineString",
|
||||
"LinearGradient",
|
||||
"LocalMultiTimeUnit",
|
||||
"LocalSingleTimeUnit",
|
||||
"Locale",
|
||||
"LoessTransform",
|
||||
"LogicalAndPredicate",
|
||||
"LogicalNotPredicate",
|
||||
"LogicalOrPredicate",
|
||||
"Longitude",
|
||||
"Longitude2",
|
||||
"Longitude2Datum",
|
||||
"Longitude2Value",
|
||||
"LongitudeDatum",
|
||||
"LookupSelection",
|
||||
"LookupTransform",
|
||||
"Mark",
|
||||
"MarkConfig",
|
||||
"MarkDef",
|
||||
"MarkInvalidDataMode",
|
||||
"MarkPropDefGradientstringnull",
|
||||
"MarkPropDefnumber",
|
||||
"MarkPropDefnumberArray",
|
||||
"MarkPropDefstringnullTypeForShape",
|
||||
"MarkType",
|
||||
"MergedStream",
|
||||
"Month",
|
||||
"MultiLineString",
|
||||
"MultiPoint",
|
||||
"MultiPolygon",
|
||||
"MultiTimeUnit",
|
||||
"NamedData",
|
||||
"NonArgAggregateOp",
|
||||
"NonLayerRepeatSpec",
|
||||
"NonNormalizedSpec",
|
||||
"NumberLocale",
|
||||
"NumericArrayMarkPropDef",
|
||||
"NumericMarkPropDef",
|
||||
"OffsetDef",
|
||||
"Opacity",
|
||||
"OpacityDatum",
|
||||
"OpacityValue",
|
||||
"Order",
|
||||
"OrderFieldDef",
|
||||
"OrderOnlyDef",
|
||||
"OrderValue",
|
||||
"OrderValueDef",
|
||||
"Orient",
|
||||
"Orientation",
|
||||
"OverlayMarkDef",
|
||||
"Padding",
|
||||
"ParameterExtent",
|
||||
"ParameterName",
|
||||
"ParameterPredicate",
|
||||
"Parse",
|
||||
"ParseValue",
|
||||
"PivotTransform",
|
||||
"Point",
|
||||
"PointSelectionConfig",
|
||||
"PointSelectionConfigWithoutType",
|
||||
"PolarDef",
|
||||
"Polygon",
|
||||
"Position",
|
||||
"Position2Def",
|
||||
"PositionDatumDef",
|
||||
"PositionDatumDefBase",
|
||||
"PositionDef",
|
||||
"PositionFieldDef",
|
||||
"PositionFieldDefBase",
|
||||
"PositionValueDef",
|
||||
"Predicate",
|
||||
"PredicateComposition",
|
||||
"PrimitiveValue",
|
||||
"Projection",
|
||||
"ProjectionConfig",
|
||||
"ProjectionType",
|
||||
"QuantileTransform",
|
||||
"RadialGradient",
|
||||
"Radius",
|
||||
"Radius2",
|
||||
"Radius2Datum",
|
||||
"Radius2Value",
|
||||
"RadiusDatum",
|
||||
"RadiusValue",
|
||||
"RangeConfig",
|
||||
"RangeEnum",
|
||||
"RangeRaw",
|
||||
"RangeRawArray",
|
||||
"RangeScheme",
|
||||
"RectConfig",
|
||||
"RegressionTransform",
|
||||
"RelativeBandSize",
|
||||
"RepeatMapping",
|
||||
"RepeatRef",
|
||||
"RepeatSpec",
|
||||
"Resolve",
|
||||
"ResolveMode",
|
||||
"Root",
|
||||
"Row",
|
||||
"RowColLayoutAlign",
|
||||
"RowColboolean",
|
||||
"RowColnumber",
|
||||
"RowColumnEncodingFieldDef",
|
||||
"SampleTransform",
|
||||
"Scale",
|
||||
"ScaleBinParams",
|
||||
"ScaleBins",
|
||||
"ScaleConfig",
|
||||
"ScaleDatumDef",
|
||||
"ScaleFieldDef",
|
||||
"ScaleInterpolateEnum",
|
||||
"ScaleInterpolateParams",
|
||||
"ScaleInvalidDataConfig",
|
||||
"ScaleInvalidDataShowAsValueangle",
|
||||
"ScaleInvalidDataShowAsValuecolor",
|
||||
"ScaleInvalidDataShowAsValuefill",
|
||||
"ScaleInvalidDataShowAsValuefillOpacity",
|
||||
"ScaleInvalidDataShowAsValueopacity",
|
||||
"ScaleInvalidDataShowAsValueradius",
|
||||
"ScaleInvalidDataShowAsValueshape",
|
||||
"ScaleInvalidDataShowAsValuesize",
|
||||
"ScaleInvalidDataShowAsValuestroke",
|
||||
"ScaleInvalidDataShowAsValuestrokeDash",
|
||||
"ScaleInvalidDataShowAsValuestrokeOpacity",
|
||||
"ScaleInvalidDataShowAsValuestrokeWidth",
|
||||
"ScaleInvalidDataShowAsValuetheta",
|
||||
"ScaleInvalidDataShowAsValuex",
|
||||
"ScaleInvalidDataShowAsValuexOffset",
|
||||
"ScaleInvalidDataShowAsValuey",
|
||||
"ScaleInvalidDataShowAsValueyOffset",
|
||||
"ScaleInvalidDataShowAsangle",
|
||||
"ScaleInvalidDataShowAscolor",
|
||||
"ScaleInvalidDataShowAsfill",
|
||||
"ScaleInvalidDataShowAsfillOpacity",
|
||||
"ScaleInvalidDataShowAsopacity",
|
||||
"ScaleInvalidDataShowAsradius",
|
||||
"ScaleInvalidDataShowAsshape",
|
||||
"ScaleInvalidDataShowAssize",
|
||||
"ScaleInvalidDataShowAsstroke",
|
||||
"ScaleInvalidDataShowAsstrokeDash",
|
||||
"ScaleInvalidDataShowAsstrokeOpacity",
|
||||
"ScaleInvalidDataShowAsstrokeWidth",
|
||||
"ScaleInvalidDataShowAstheta",
|
||||
"ScaleInvalidDataShowAsx",
|
||||
"ScaleInvalidDataShowAsxOffset",
|
||||
"ScaleInvalidDataShowAsy",
|
||||
"ScaleInvalidDataShowAsyOffset",
|
||||
"ScaleResolveMap",
|
||||
"ScaleType",
|
||||
"SchemaBase",
|
||||
"SchemeParams",
|
||||
"SecondaryFieldDef",
|
||||
"SelectionConfig",
|
||||
"SelectionInit",
|
||||
"SelectionInitInterval",
|
||||
"SelectionInitIntervalMapping",
|
||||
"SelectionInitMapping",
|
||||
"SelectionParameter",
|
||||
"SelectionResolution",
|
||||
"SelectionType",
|
||||
"SequenceGenerator",
|
||||
"SequenceParams",
|
||||
"SequentialMultiHue",
|
||||
"SequentialSingleHue",
|
||||
"Shape",
|
||||
"ShapeDatum",
|
||||
"ShapeDef",
|
||||
"ShapeValue",
|
||||
"SharedEncoding",
|
||||
"SingleDefUnitChannel",
|
||||
"SingleTimeUnit",
|
||||
"Size",
|
||||
"SizeDatum",
|
||||
"SizeValue",
|
||||
"Sort",
|
||||
"SortArray",
|
||||
"SortByChannel",
|
||||
"SortByChannelDesc",
|
||||
"SortByEncoding",
|
||||
"SortField",
|
||||
"SortOrder",
|
||||
"Spec",
|
||||
"SphereGenerator",
|
||||
"StackOffset",
|
||||
"StackTransform",
|
||||
"StandardType",
|
||||
"Step",
|
||||
"StepFor",
|
||||
"Stream",
|
||||
"StringFieldDef",
|
||||
"StringFieldDefWithCondition",
|
||||
"StringValueDefWithCondition",
|
||||
"Stroke",
|
||||
"StrokeCap",
|
||||
"StrokeDash",
|
||||
"StrokeDashDatum",
|
||||
"StrokeDashValue",
|
||||
"StrokeDatum",
|
||||
"StrokeJoin",
|
||||
"StrokeOpacity",
|
||||
"StrokeOpacityDatum",
|
||||
"StrokeOpacityValue",
|
||||
"StrokeValue",
|
||||
"StrokeWidth",
|
||||
"StrokeWidthDatum",
|
||||
"StrokeWidthValue",
|
||||
"StyleConfigIndex",
|
||||
"SymbolShape",
|
||||
"Text",
|
||||
"TextBaseline",
|
||||
"TextDatum",
|
||||
"TextDef",
|
||||
"TextDirection",
|
||||
"TextValue",
|
||||
"Theta",
|
||||
"Theta2",
|
||||
"Theta2Datum",
|
||||
"Theta2Value",
|
||||
"ThetaDatum",
|
||||
"ThetaValue",
|
||||
"TickConfig",
|
||||
"TickCount",
|
||||
"TimeInterval",
|
||||
"TimeIntervalStep",
|
||||
"TimeLocale",
|
||||
"TimeUnit",
|
||||
"TimeUnitParams",
|
||||
"TimeUnitTransform",
|
||||
"TimeUnitTransformParams",
|
||||
"TitleAnchor",
|
||||
"TitleConfig",
|
||||
"TitleFrame",
|
||||
"TitleOrient",
|
||||
"TitleParams",
|
||||
"Tooltip",
|
||||
"TooltipContent",
|
||||
"TooltipValue",
|
||||
"TopLevelConcatSpec",
|
||||
"TopLevelFacetSpec",
|
||||
"TopLevelHConcatSpec",
|
||||
"TopLevelLayerSpec",
|
||||
"TopLevelParameter",
|
||||
"TopLevelRepeatSpec",
|
||||
"TopLevelSelectionParameter",
|
||||
"TopLevelSpec",
|
||||
"TopLevelUnitSpec",
|
||||
"TopLevelVConcatSpec",
|
||||
"TopoDataFormat",
|
||||
"Transform",
|
||||
"Type",
|
||||
"TypeForShape",
|
||||
"TypedFieldDef",
|
||||
"UnitSpec",
|
||||
"UnitSpecWithFrame",
|
||||
"Url",
|
||||
"UrlData",
|
||||
"UrlValue",
|
||||
"UtcMultiTimeUnit",
|
||||
"UtcSingleTimeUnit",
|
||||
"VConcatSpecGenericSpec",
|
||||
"ValueChannelMixin",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefGradientstringnull",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefTypeForShapestringnull",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefnumber",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefnumberArray",
|
||||
"ValueDefWithConditionMarkPropFieldOrDatumDefstringnull",
|
||||
"ValueDefWithConditionStringFieldDefText",
|
||||
"ValueDefnumber",
|
||||
"ValueDefnumberwidthheightExprRef",
|
||||
"VariableParameter",
|
||||
"Vector2DateTime",
|
||||
"Vector2Vector2number",
|
||||
"Vector2boolean",
|
||||
"Vector2number",
|
||||
"Vector2string",
|
||||
"Vector3number",
|
||||
"Vector7string",
|
||||
"Vector10string",
|
||||
"Vector12string",
|
||||
"VegaLiteSchema",
|
||||
"ViewBackground",
|
||||
"ViewConfig",
|
||||
"WindowEventType",
|
||||
"WindowFieldDef",
|
||||
"WindowOnlyOp",
|
||||
"WindowTransform",
|
||||
"X",
|
||||
"X2Datum",
|
||||
"X2Value",
|
||||
"XDatum",
|
||||
"XError",
|
||||
"XError2",
|
||||
"XError2Value",
|
||||
"XErrorValue",
|
||||
"XOffset",
|
||||
"XOffsetDatum",
|
||||
"XOffsetValue",
|
||||
"XValue",
|
||||
"Y",
|
||||
"Y2Datum",
|
||||
"Y2Value",
|
||||
"YDatum",
|
||||
"YError",
|
||||
"YError2",
|
||||
"YError2Value",
|
||||
"YErrorValue",
|
||||
"YOffset",
|
||||
"YOffsetDatum",
|
||||
"YOffsetValue",
|
||||
"YValue",
|
||||
"channels",
|
||||
"core",
|
||||
"load_schema",
|
||||
"with_property_setters",
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
22040
myenv/lib/python3.11/site-packages/altair/vegalite/v5/schema/channels.py
Normal file
22040
myenv/lib/python3.11/site-packages/altair/vegalite/v5/schema/channels.py
Normal file
File diff suppressed because it is too large
Load Diff
27199
myenv/lib/python3.11/site-packages/altair/vegalite/v5/schema/core.py
Normal file
27199
myenv/lib/python3.11/site-packages/altair/vegalite/v5/schema/core.py
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
125
myenv/lib/python3.11/site-packages/altair/vegalite/v5/theme.py
Normal file
125
myenv/lib/python3.11/site-packages/altair/vegalite/v5/theme.py
Normal file
@@ -0,0 +1,125 @@
|
||||
"""Tools for enabling and registering chart themes."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Final, Literal, get_args
|
||||
|
||||
from altair.utils.deprecation import deprecated_static_only
|
||||
from altair.utils.plugin_registry import Plugin, PluginRegistry
|
||||
from altair.vegalite.v5.schema._config import ThemeConfig
|
||||
from altair.vegalite.v5.schema._typing import VegaThemes
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import sys
|
||||
from functools import partial
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import LiteralString
|
||||
else:
|
||||
from typing_extensions import LiteralString
|
||||
if sys.version_info >= (3, 10):
|
||||
from typing import TypeAlias
|
||||
else:
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from altair.utils.plugin_registry import PluginEnabler
|
||||
|
||||
|
||||
AltairThemes: TypeAlias = Literal["default", "opaque"]
|
||||
VEGA_THEMES: list[LiteralString] = list(get_args(VegaThemes))
|
||||
|
||||
|
||||
# HACK: See for `LiteralString` requirement in `name`
|
||||
# https://github.com/vega/altair/pull/3526#discussion_r1743350127
|
||||
class ThemeRegistry(PluginRegistry[Plugin[ThemeConfig], ThemeConfig]):
|
||||
def enable(
|
||||
self,
|
||||
name: LiteralString | AltairThemes | VegaThemes | None = None,
|
||||
**options: Any,
|
||||
) -> PluginEnabler[Plugin[ThemeConfig], ThemeConfig]:
|
||||
"""
|
||||
Enable a theme by name.
|
||||
|
||||
This can be either called directly, or used as a context manager.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name : string (optional)
|
||||
The name of the theme to enable. If not specified, then use the
|
||||
current active name.
|
||||
**options :
|
||||
Any additional parameters will be passed to the theme as keyword
|
||||
arguments
|
||||
|
||||
Returns
|
||||
-------
|
||||
PluginEnabler:
|
||||
An object that allows enable() to be used as a context manager
|
||||
|
||||
Notes
|
||||
-----
|
||||
Default `vega` themes can be previewed at https://vega.github.io/vega-themes/
|
||||
"""
|
||||
return super().enable(name, **options)
|
||||
|
||||
def get(self) -> partial[ThemeConfig] | Plugin[ThemeConfig] | None:
|
||||
"""Return the currently active theme."""
|
||||
return super().get()
|
||||
|
||||
def names(self) -> list[str]:
|
||||
"""Return the names of the registered and entry points themes."""
|
||||
return super().names()
|
||||
|
||||
@deprecated_static_only(
|
||||
"Deprecated since `altair=5.5.0`. Use @altair.theme.register instead.",
|
||||
category=None,
|
||||
)
|
||||
def register(
|
||||
self, name: str, value: Plugin[ThemeConfig] | None
|
||||
) -> Plugin[ThemeConfig] | None:
|
||||
return super().register(name, value)
|
||||
|
||||
|
||||
class VegaTheme:
|
||||
"""Implementation of a builtin vega theme."""
|
||||
|
||||
def __init__(self, theme: str) -> None:
|
||||
self.theme = theme
|
||||
|
||||
def __call__(self) -> ThemeConfig:
|
||||
return {
|
||||
"usermeta": {"embedOptions": {"theme": self.theme}},
|
||||
"config": {"view": {"continuousWidth": 300, "continuousHeight": 300}},
|
||||
}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"VegaTheme({self.theme!r})"
|
||||
|
||||
|
||||
# The entry point group that can be used by other packages to declare other
|
||||
# themes that will be auto-detected. Explicit registration is also
|
||||
# allowed by the PluginRegistry API.
|
||||
ENTRY_POINT_GROUP: Final = "altair.vegalite.v5.theme"
|
||||
|
||||
# NOTE: `themes` def has an entry point group
|
||||
themes = ThemeRegistry(entry_point_group=ENTRY_POINT_GROUP)
|
||||
|
||||
themes.register(
|
||||
"default",
|
||||
lambda: {"config": {"view": {"continuousWidth": 300, "continuousHeight": 300}}},
|
||||
)
|
||||
themes.register(
|
||||
"opaque",
|
||||
lambda: {
|
||||
"config": {
|
||||
"background": "white",
|
||||
"view": {"continuousWidth": 300, "continuousHeight": 300},
|
||||
}
|
||||
},
|
||||
)
|
||||
themes.register("none", ThemeConfig)
|
||||
|
||||
for theme in VEGA_THEMES:
|
||||
themes.register(theme, VegaTheme(theme))
|
||||
|
||||
themes.enable("default")
|
||||
Reference in New Issue
Block a user