Skip to content

Commit

Permalink
Merge pull request #24 from DataShades/DATASHADES-344
Browse files Browse the repository at this point in the history
DATASHADES-344 / align functionality across all engines
  • Loading branch information
alexmorev authored Jan 12, 2025
2 parents 22aadba + 702668e commit a933567
Show file tree
Hide file tree
Showing 6 changed files with 663 additions and 149 deletions.
7 changes: 4 additions & 3 deletions ckanext/charts/assets/js/charts-render-observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ ckan.module("charts-render-observable", function ($, _) {

switch (this.options.config.type) {
case "bar":
plot = Plot.barY(this.options.config.data, this.options.config.settings).plot();
plot = Plot.barY(this.options.config.data, this.options.config.settings).plot(this.options.config.plot);
break;
case "horizontal-bar":
plot = Plot.barX(this.options.config.data, this.options.config.settings).plot();
plot = Plot.barX(this.options.config.data, this.options.config.settings).plot(this.options.config.plot);
break;
case "scatter":
plot = Plot.dot(this.options.config.data, this.options.config.settings).plot();
this.options.config.settings["r"] = (d) => d.radius;
plot = Plot.dot(this.options.config.data, this.options.config.settings).plot(this.options.config.plot);
break;
case "line":
plot = Plot.line(this.options.config.data, this.options.config.settings).plot(this.options.config.plot);
Expand Down
31 changes: 23 additions & 8 deletions ckanext/charts/chart_builders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ def __init__(

self.df = filtered_df

if self.settings.pop("sort_x", False):
if self.settings.get("sort_x", False):
self.df.sort_values(by=self.settings["x"], inplace=True)

if self.settings.pop("sort_y", False):
if self.settings.get("sort_y", False):
self.df.sort_values(by=self.settings["y"], inplace=True)

self.df = self.df.head(self.get_limit())
Expand Down Expand Up @@ -316,11 +316,11 @@ def chart_xlabel_field(self) -> dict[str, Any]:
],
}

def chart_ylabel_left_field(self) -> dict[str, Any]:
def chart_ylabel_field(self) -> dict[str, Any]:
return {
"field_name": "chart_ylabel_left",
"label": "Chart Y axe left label",
"form_placeholder": "Left Y label",
"field_name": "chart_ylabel",
"label": "Chart Y axe label",
"form_placeholder": "Y label",
"group": "Styles",
"type": "str",
"help_text": "Label for the Y-axis on the left side",
Expand Down Expand Up @@ -793,8 +793,8 @@ def size_field(self, choices: list[dict[str, str]]) -> dict[str, Any]:
"label": "Size",
"group": "Structure",
"help_text": "Select a column for the size",
"type": "str"
}
"type": "str",
},
)

return field
Expand Down Expand Up @@ -824,3 +824,18 @@ def engine_details_field(self) -> dict[str, Any]:
"group": "Structure",
"exclude_from_mkdocs": True,
}

def size_max_field(self) -> dict[str, Any]:
return {
"field_name": "size_max",
"label": "Size Max",
"form_snippet": "chart_range.html",
"min": 0,
"max": 100,
"step": 1,
"group": "Structure",
"validators": [
self.get_validator("default")(100),
self.get_validator("int_validator"),
],
}
Loading

0 comments on commit a933567

Please sign in to comment.