MCPcopy
hub / github.com/Kanaries/pygwalker / encode

Method encode

pygwalker/api/component.py:307–357  ·  view source on GitHub ↗

Encode fields. example: .encode(x="field_0", y="field_1", color="field_2") .encode(x="field_0", y="SUM(field_1)")

(
        self,
        x: Union[str, List[str]] = "",
        y: Union[str, List[str]] = "",
        color: str = "",
        opacity: str = "",
        size: str = "",
        shape: str = "",
        radius: str = "",
        theta: str = "",
        longitude: str = "",
        latitude: str = "",
        geoid: str = "",
        details: str = "",
        text: str = "",
    )

Source from the content-addressed store, hash-verified

305
306 # pylint: disable=unused-argument
307 def encode(
308 self,
309 x: Union[str, List[str]] = "",
310 y: Union[str, List[str]] = "",
311 color: str = "",
312 opacity: str = "",
313 size: str = "",
314 shape: str = "",
315 radius: str = "",
316 theta: str = "",
317 longitude: str = "",
318 latitude: str = "",
319 geoid: str = "",
320 details: str = "",
321 text: str = "",
322 ) -> "Component":
323 """
324 Encode fields.
325 example: .encode(x="field_0", y="field_1", color="field_2")
326 .encode(x="field_0", y="SUM(field_1)")
327 """
328 all_params = {
329 key: [value] if isinstance(value, str) else value
330 for key, value in locals().items()
331 if key != "self"
332 }
333 copied_obj = self.copy()
334 params_key_map = {
335 "x": "columns",
336 "y": "rows",
337 "geoid": "geoId",
338 }
339
340 for key, field_str_list in all_params.items():
341 field_list = []
342 for field_str in field_str_list:
343 if not field_str:
344 continue
345 field_info = copied_obj._convert_string_to_field_info(field_str)
346 if field_info.get("aggName"):
347 copied_obj._update_single_chart_spec("config__defaultAggregated", True)
348 field_list.append(field_info)
349 if field_info["fid"] not in copied_obj._field_map:
350 copied_obj._field_map[field_info["fid"]] = field_info
351 if field_info["analyticType"] == "dimension":
352 copied_obj._single_chart_spec["encodings"]["dimensions"].append(field_info)
353 else:
354 copied_obj._single_chart_spec["encodings"]["measures"].append(field_info)
355 copied_obj._single_chart_spec["encodings"][params_key_map.get(key, key)] = field_list
356
357 return copied_obj
358
359 # pylint: enable=unused-argument
360 def layout(

Callers 12

create_cloud_datasetMethod · 0.80
compress_dataFunction · 0.80
_get_pl_dataset_hashFunction · 0.80
_get_pd_dataset_hashFunction · 0.80
_get_modin_dataset_hashFunction · 0.80
_get_spark_dataset_hashFunction · 0.80
get_dataset_hashFunction · 0.80
base36encodeFunction · 0.80
export_chart_svgMethod · 0.80
compress_dataMethod · 0.80
do_GETMethod · 0.80
do_POSTMethod · 0.80

Calls 3

copyMethod · 0.95

Tested by

no test coverage detected