Skip to content

Commit

Permalink
adding echarts.options_kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrotsmnrd committed Aug 24, 2023
1 parent 49be3ec commit 37f11db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions panel/models/echarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def __js_skip__(cls):

data = Nullable(Dict(String, Any))

options_kwargs = Nullable(Dict(String, Any))

event_config = Dict(String, Any)

js_events = Dict(String, List(Any))
Expand Down
14 changes: 8 additions & 6 deletions panel/models/echarts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class EChartsView extends HTMLBoxView {
_plot(): void {
if ((window as any).echarts == null)
return
this._chart.setOption(this.model.data, true);
this._chart.setOption(this.model.data, this.model.options_kwargs );
}

_resize(): void {
Expand Down Expand Up @@ -137,6 +137,7 @@ export namespace ECharts {
export type Attrs = p.AttrsOf<Props>
export type Props = HTMLBox.Props & {
data: p.Property<any>
options_kwargs: p.Property<any>
event_config: p.Property<any>
js_events: p.Property<any>
renderer: p.Property<string>
Expand All @@ -159,11 +160,12 @@ export class ECharts extends HTMLBox {
this.prototype.default_view = EChartsView

this.define<ECharts.Props>(({ Any, String }) => ({
data: [ Any, {} ],
event_config: [ Any, {} ],
js_events: [ Any, {} ],
theme: [ String, "default"],
renderer: [ String, "canvas"]
data: [ Any, {} ],
options_kwargs:[ Any, {} ],
event_config: [ Any, {} ],
js_events: [ Any, {} ],
theme: [ String, "default"],
renderer: [ String, "canvas"]
}))
}
}
4 changes: 4 additions & 0 deletions panel/pane/echarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class ECharts(ModelPane):
object = param.Parameter(default=None, doc="""
The Echarts object being wrapped. Can be an Echarts dictionary or a pyecharts chart""")

options_kwargs = param.Parameter(default=None, doc="""
An optional dict of options passed to Echarts.setOption. Allows to fine-tune the rendering behavior.
""")

renderer = param.ObjectSelector(default="canvas", objects=["canvas", "svg"], doc="""
Whether to render as HTML canvas or SVG""")

Expand Down

0 comments on commit 37f11db

Please sign in to comment.