Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATASHADES-344 / align functionality across all engines #24

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading