Skip to content

Commit

Permalink
fix: fix observable chart exposing unnecessary method to doc, remote …
Browse files Browse the repository at this point in the history
…auto from js
  • Loading branch information
mutantsan committed Jan 16, 2025
1 parent 87cf995 commit 4d9e304
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 129 deletions.
3 changes: 0 additions & 3 deletions ckanext/charts/assets/js/charts-render-observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ ckan.module("charts-render-observable", function ($, _) {
case "pie":
plot = PieChart(this.options.config.data, this.options.config.settings);
break;
case "auto":
plot = Plot.auto(this.options.config.data, this.options.config.settings).plot();
break;
default:
return;
}
Expand Down
6 changes: 3 additions & 3 deletions ckanext/charts/chart_builders/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_supported_forms(cls) -> list[type[Any]]:
ObservableScatterForm,
]

def is_column_datetime(self, column: str) -> bool:
def _is_column_datetime(self, column: str) -> bool:
"""Check if string values of the certain column are convertable
to datetime type.
Expand Down Expand Up @@ -249,7 +249,7 @@ def _prepare_data(self) -> dict[str, Any]:
Returns:
Line chart data dictionary
"""
if self.is_column_datetime(self.settings["x"]):
if self._is_column_datetime(self.settings["x"]):
# Remove unnecessary columns and duplicates from x-axis column
self.df = self.df[[self.settings["x"], self.settings["y"][0]]]
self.df.drop_duplicates(subset=[self.settings["x"]], inplace=True)
Expand Down Expand Up @@ -297,7 +297,7 @@ def _prepare_data(self) -> dict[str, Any]:
data["plot"]["grid"] = True
data["plot"]["x"]["ticks"] = self.DEFAULT_AXIS_TICKS_NUMBER

if self.is_column_datetime(self.settings["x"]):
if self._is_column_datetime(self.settings["x"]):
data["plot"]["x"]["type"] = "utc"
data["settings"]["y"] = self.settings["y"][0]
if self.settings.get("split_data"):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies = [
]
license = {text = "AGPL"}
requires-python = ">=3.8"
version = "1.2.0"
version = "1.2.1"

[project.optional-dependencies]
pyarrow = ["pyarrow>=16.0.0,<17.0.0"]
Expand Down
123 changes: 2 additions & 121 deletions site/engines/observable/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<div data-md-component="skip">


<a href="#charts.chart_builders.observable.ObservableBuilder.is_column_datetime" class="md-skip">
<a href="#bar-chart" class="md-skip">
Skip to content
</a>

Expand Down Expand Up @@ -487,15 +487,6 @@
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>

<li class="md-nav__item">
<a href="#charts.chart_builders.observable.ObservableBuilder.is_column_datetime" class="md-nav__link">
<span class="md-ellipsis">
is_column_datetime
</span>
</a>

</li>

<li class="md-nav__item">
<a href="#bar-chart" class="md-nav__link">
<span class="md-ellipsis">
Expand Down Expand Up @@ -982,15 +973,6 @@
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>

<li class="md-nav__item">
<a href="#charts.chart_builders.observable.ObservableBuilder.is_column_datetime" class="md-nav__link">
<span class="md-ellipsis">
is_column_datetime
</span>
</a>

</li>

<li class="md-nav__item">
<a href="#bar-chart" class="md-nav__link">
<span class="md-ellipsis">
Expand Down Expand Up @@ -1179,7 +1161,7 @@ <h1>Observable</h1>
<span class="n">ObservableScatterForm</span><span class="p">,</span>
<span class="p">]</span>

<span class="k">def</span> <span class="nf">is_column_datetime</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">_is_column_datetime</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Check if string values of the certain column are convertable</span>
<span class="sd"> to datetime type.</span>

Expand Down Expand Up @@ -1259,107 +1241,6 @@ <h1>Observable</h1>



<div class="doc doc-object doc-function">


<h2 id="charts.chart_builders.observable.ObservableBuilder.is_column_datetime" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <code class="highlight language-python"><span class="n">is_column_datetime</span><span class="p">(</span><span class="n">column</span><span class="p">)</span></code>

</h2>


<div class="doc doc-contents ">

<p>Check if string values of the certain column are convertable
to datetime type.</p>


<table>
<thead>
<tr>
<th><span class="doc-section-title">PARAMETER</span></th>
<th><span>DESCRIPTION</span></th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>column</code></td>
<td class="doc-param-details">
<div class="doc-md-description">
<p>name of the column to check</p>
</div>
<p>
<span class="doc-param-annotation">
<b>TYPE:</b>
<code>str</code>
</span>
</p>
</td>
</tr>
</tbody>
</table>


<table>
<thead>
<tr>
<th><span class="doc-section-title">RETURNS</span></th>
<th><span>DESCRIPTION</span></th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<span class="doc-returns-annotation">
<code>bool</code>
</span>
</td>
<td class="doc-returns-details">
<div class="doc-md-description">
<p>True if values can be converted to datetime type, otherwise - False</p>
</div>
</td>
</tr>
</tbody>
</table>

<details class="quote">
<summary>Source code in <code>ckanext/charts/chart_builders/observable.py</code></summary>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">30</span>
<span class="normal">31</span>
<span class="normal">32</span>
<span class="normal">33</span>
<span class="normal">34</span>
<span class="normal">35</span>
<span class="normal">36</span>
<span class="normal">37</span>
<span class="normal">38</span>
<span class="normal">39</span>
<span class="normal">40</span>
<span class="normal">41</span>
<span class="normal">42</span>
<span class="normal">43</span>
<span class="normal">44</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="k">def</span> <span class="nf">is_column_datetime</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Check if string values of the certain column are convertable</span>
<span class="sd"> to datetime type.</span>

<span class="sd"> Args:</span>
<span class="sd"> column (str): name of the column to check</span>

<span class="sd"> Returns:</span>
<span class="sd"> True if values can be converted to datetime type, otherwise - False</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">pd</span><span class="o">.</span><span class="n">to_datetime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="p">[</span><span class="n">column</span><span class="p">],</span> <span class="nb">format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">DEFAULT_DATETIME_FORMAT</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span>
<span class="k">return</span> <span class="kc">True</span>
</code></pre></div></td></tr></table></div>
</details>
</div>

</div>



</div>
Expand Down
Binary file modified site/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion site/search/search_index.json

Large diffs are not rendered by default.

0 comments on commit 4d9e304

Please sign in to comment.