Skip to content

Commit

Permalink
docs: polish action section (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
Koooooo-7 committed Feb 4, 2024
1 parent f2ab671 commit 7646fee
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions docs/en-us/event-and-action.md
Expand Up @@ -49,21 +49,21 @@ A full example on bar chart:
bar := charts.NewBar()
JFunc := ` (params) => alert(params.name) `
bar.SetGlobalOptions(
charts.WithEventListeners(
event.Listener{
EventName: "click",
Handler: opts.FuncOpts(JFunc),
},
event.Listener{
EventName: "mouseup",
Query: "'series'",
Handler: opts.FuncOpts(JFunc),
},
event.Listener{
EventName: "mouseover",
Query: "{ seriesName: 'go-echarts' }",
Handler: opts.FuncOpts(JFunc),
}
charts.WithEventListeners(
event.Listener{
EventName: "click",
Handler: opts.FuncOpts(JFunc),
},
event.Listener{
EventName: "mouseup",
Query: "'series'",
Handler: opts.FuncOpts(JFunc),
},
event.Listener{
EventName: "mouseover",
Query: "{ seriesName: 'go-echarts' }",
Handler: opts.FuncOpts(JFunc),
}
)

```
Expand All @@ -75,14 +75,16 @@ It allows to manually trigger events on charts to make the chart dynamic.

To be honest, it is hard to implement the full functions since we can not run all things
like a pure JS.
Considering for a chart lib, the target is not implement a echarts engine in go.
Unfortunately, we hasn't provide a action api yet, for the *static* `dispatchAction`.
Considering for a chart lib, the target is not implement an echarts engine in go.
On the one hand, the `action`/`animation` things are moreover the `charts` scope, on the other hand, there is
hard to decide where to put the `dispatchAction` part, inside other JS functions? or a static one?
Hence, we haven't provided an action api yet, for the *static* `dispatchAction`.

So, is it no way to make it?
**Actually, we do have one more thing...**
?> **Actually, we do have one more thing...**

With the power of `%MY_ECHARTS` (see `dive-into` chapter),
you get the echarts instance, you get the world.
absolutely, when you hold the echarts instance, you get the whole world.

!> Talk is cheap, show you the code :)

Expand Down Expand Up @@ -171,4 +173,14 @@ func PieWithDispatchAction() *charts.Pie {

```

So, you can make the `dispatchAction` purely in JS insertion instead of building some go types.

```js
const myChart = %MY_ECHARTS%;
myChart.dispatchAction({
...
});

```

Although it seems a little tricky, enough as a workaround. If you really need it.

0 comments on commit 7646fee

Please sign in to comment.