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

Remove Perspective toggle_config #6721

Merged
merged 4 commits into from
Apr 17, 2024
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
Binary file modified examples/assets/perspective_edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions examples/reference/panes/Perspective.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"* **`split_by`** (list): A list of columns to pivot by. e.g. `[\"x\", \"y\"]`\n",
"* **`theme`** (str): The theme of the viewer, available options include `'pro'`, `'pro-dark'`, `'monokai'`, `'solarized'`, `'solarized-dark'` and `'vaporwave'`\n",
"* **`title`** (str): Title for the Perspective Viewer.\n",
"* **`toggle_config`** (bool): Whether to show the config menu. Default is True.\n",
"\n",
"##### Callbacks\n",
"\n",
Expand Down Expand Up @@ -127,7 +126,7 @@
"tags": []
},
"source": [
"You might also hide the *config menu* via the `toggle_config` parameter."
"You might also hide the *config menu* via the `settings` parameter."
]
},
{
Expand All @@ -138,7 +137,7 @@
},
"outputs": [],
"source": [
"pn.pane.Perspective(df, columns=[\"float\"], group_by=[\"category\"], plugin='d3_y_bar', toggle_config=False, width=1000, height=300)"
"pn.pane.Perspective(df, columns=[\"float\"], group_by=[\"category\"], plugin='d3_y_bar', settings=False, width=1000, height=300)"
]
},
{
Expand Down
2 changes: 0 additions & 2 deletions panel/models/perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ class Perspective(HTMLBox):

source = Instance(ColumnDataSource)

toggle_config = Bool(True)

theme = Enum(*PERSPECTIVE_THEMES, default="pro")

title = Either(String(), Null())
Expand Down
17 changes: 7 additions & 10 deletions panel/models/perspective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class PerspectiveView extends HTMLBoxView {
this.connect(this.model.source.patching, () => this.patch())

const {
schema, toggle_config, columns, expressions, split_by, group_by,
schema, columns, expressions, split_by, group_by,
aggregates, filters, sort, plugin, selectable, editable, theme,
title, settings,
} = this.model.properties
Expand All @@ -98,9 +98,6 @@ export class PerspectiveView extends HTMLBoxView {
this.perspective_element.load(this.table)
})
})
this.on_change(toggle_config, () => {
this.perspective_element.toggleConfig()
})
this.on_change(columns, not_updating(() => {
this.perspective_element.restore({columns: this.model.columns})
}))
Expand Down Expand Up @@ -170,10 +167,12 @@ export class PerspectiveView extends HTMLBoxView {
})
container.innerHTML = "<perspective-viewer style='height:100%; width:100%;'></perspective-viewer>"
this.perspective_element = container.children[0]
this.perspective_element.resetThemes([...Object.values(THEMES)]).catch(() => {})
if (this.model.toggle_config) {
this.perspective_element.toggleConfig()
}

const themesArray = Object.values(THEMES)
const filteredThemes = themesArray.filter(t => t !== this.model.theme)
const orderedThemes = [this.model.theme, ...filteredThemes]
this.perspective_element.resetThemes(orderedThemes).catch(() => {})

set_size(container, this.model)
this.shadow_el.appendChild(container)

Expand Down Expand Up @@ -295,7 +294,6 @@ export namespace Perspective {
plugin: p.Property<any>
plugin_config: p.Property<any>
selectable: p.Property<boolean | null>
toggle_config: p.Property<boolean>
schema: p.Property<any>
settings: p.Property<boolean>
sort: p.Property<any[] | null>
Expand Down Expand Up @@ -333,7 +331,6 @@ export class Perspective extends HTMLBox {
selectable: [ Bool, true ],
settings: [ Bool, true ],
schema: [ Any, {} ],
toggle_config: [ Bool, true ],
sort: [ Nullable(List(List(Str))), null ],
source: [ Ref(ColumnDataSource) ],
theme: [ Str, "pro" ],
Expand Down
7 changes: 0 additions & 7 deletions panel/pane/perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ class Perspective(ModelPane, ReactiveData):
settings = param.Boolean(default=True, doc="""
Whether to show the settings menu.""")

toggle_config = param.Boolean(default=True, doc="""
Whether to show the config menu.""")

theme = param.ObjectSelector(default='pro', objects=THEMES, doc="""
The style of the PerspectiveViewer. For example pro-dark""")

Expand Down Expand Up @@ -382,10 +379,6 @@ def _get_properties(self, doc, source=None):
if 'theme' in props and 'material' in props['theme']:
props['theme'] = props['theme'].replace('material', 'pro')
del props['object']
if props.get('toggle_config'):
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
props['height'] = self.height or 300
else:
props['height'] = self.height or 150
if source is None:
source = ColumnDataSource(data=self._data)
else:
Expand Down