|
9 | 9 | from typing import TYPE_CHECKING, Any |
10 | 10 |
|
11 | 11 | from altair.expr.core import ConstExpression, FunctionExpression |
12 | | -from altair.vegalite.v5.schema.core import ExprRef as _ExprRef |
| 12 | +from altair.vegalite.v6.schema.core import ExprRef as _ExprRef |
13 | 13 |
|
14 | 14 | if sys.version_info >= (3, 12): |
15 | 15 | from typing import override |
@@ -172,8 +172,18 @@ class expr(_ExprRef, metaclass=_ExprMeta): |
172 | 172 | https://en.wikipedia.org/wiki/Continuous_uniform_distribution |
173 | 173 | .. _*unit*: |
174 | 174 | https://vega.github.io/vega/docs/api/time/#time-units |
| 175 | + .. _ascending from Vega Utils: |
| 176 | + https://vega.github.io/vega/docs/api/util/#ascending |
175 | 177 | .. _JavaScript's String.replace: |
176 | 178 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace |
| 179 | + .. _Base64: |
| 180 | + https://developer.mozilla.org/en-US/docs/Glossary/Base64 |
| 181 | + .. _ASCII: |
| 182 | + https://developer.mozilla.org/en-US/docs/Glossary/ASCII |
| 183 | + .. _Window.btoa(): |
| 184 | + https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa |
| 185 | + .. _Window.atob(): |
| 186 | + https://developer.mozilla.org/en-US/docs/Web/API/Window/atob |
177 | 187 | .. _d3-format specifier: |
178 | 188 | https://github.com/d3/d3-format/ |
179 | 189 | .. _*units*: |
@@ -1175,6 +1185,16 @@ def slice( |
1175 | 1185 | """ |
1176 | 1186 | return FunctionExpression("slice", (array, start, end)) |
1177 | 1187 |
|
| 1188 | + @classmethod |
| 1189 | + def sort(cls, array: IntoExpression, /) -> Expression: |
| 1190 | + """ |
| 1191 | + Sorts the array in natural order using `ascending from Vega Utils`_. |
| 1192 | +
|
| 1193 | + .. _ascending from Vega Utils: |
| 1194 | + https://vega.github.io/vega/docs/api/util/#ascending |
| 1195 | + """ |
| 1196 | + return FunctionExpression("sort", (array,)) |
| 1197 | + |
1178 | 1198 | @classmethod |
1179 | 1199 | def span(cls, array: IntoExpression, /) -> Expression: |
1180 | 1200 | """Returns the span of ``array``: the difference between the last and first elements, or *array[array.length-1] - array[0]*.""" |
@@ -1281,6 +1301,38 @@ def upper(cls, string: IntoExpression, /) -> Expression: |
1281 | 1301 | """Transforms ``string`` to upper-case letters.""" |
1282 | 1302 | return FunctionExpression("upper", (string,)) |
1283 | 1303 |
|
| 1304 | + @classmethod |
| 1305 | + def btoa(cls, string: IntoExpression, /) -> Expression: |
| 1306 | + """ |
| 1307 | + Creates a `Base64`_-encoded `ASCII`_ string. |
| 1308 | +
|
| 1309 | + Same as JavaScript's `Window.alt.expr.btoa()`_. |
| 1310 | +
|
| 1311 | + .. _Base64: |
| 1312 | + https://developer.mozilla.org/en-US/docs/Glossary/Base64 |
| 1313 | + .. _ASCII: |
| 1314 | + https://developer.mozilla.org/en-US/docs/Glossary/ASCII |
| 1315 | + .. _Window.alt.expr.btoa(): |
| 1316 | + https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa |
| 1317 | + """ |
| 1318 | + return FunctionExpression("btoa", (string,)) |
| 1319 | + |
| 1320 | + @classmethod |
| 1321 | + def atob(cls, string: IntoExpression, /) -> Expression: |
| 1322 | + """ |
| 1323 | + Decodes an `ASCII`_ string that was encoded with `Base64`_. |
| 1324 | +
|
| 1325 | + Same as JavaScript's `Window.alt.expr.atob()`_. |
| 1326 | +
|
| 1327 | + .. _ASCII: |
| 1328 | + https://developer.mozilla.org/en-US/docs/Glossary/ASCII |
| 1329 | + .. _Base64: |
| 1330 | + https://developer.mozilla.org/en-US/docs/Glossary/Base64 |
| 1331 | + .. _Window.alt.expr.atob(): |
| 1332 | + https://developer.mozilla.org/en-US/docs/Web/API/Window/atob |
| 1333 | + """ |
| 1334 | + return FunctionExpression("atob", (string,)) |
| 1335 | + |
1284 | 1336 | @classmethod |
1285 | 1337 | def merge( |
1286 | 1338 | cls, object1: IntoExpression, object2: IntoExpression = None, *args: Any |
|
0 commit comments