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

如何在图表中增加点击事件呢? #19

Closed
cheneyszp opened this issue Apr 10, 2019 · 2 comments
Closed

如何在图表中增加点击事件呢? #19

cheneyszp opened this issue Apr 10, 2019 · 2 comments
Labels

Comments

@cheneyszp
Copy link

ECharts 是支持在图表中添加事件的,用户的操作将会触发相应的事件。开发者可以监听这些事件,然后通过回调函数做相应的处理,比如跳转到一个地址,或者弹出对话框,或者做数据下钻等等。

https://echarts.baidu.com/tutorial.html#ECharts%20%E4%B8%AD%E7%9A%84%E4%BA%8B%E4%BB%B6%E5%92%8C%E8%A1%8C%E4%B8%BA

在go-echarts中怎么操作呢?望指教。

@electricbubble
Copy link
Contributor

@cheneyszp
Copy link
Author

给大家做参考:

bar := charts.NewBar()
bar.SetGlobalOptions(charts.TitleOpts{Title: "Bar-示例图"}, charts.ToolboxOpts{Show: true}, charts.InitOpts{AssetsHost: "http://127.0.0.1:8081/assets/"})
bar.AddXAxis(nameItems).
AddYAxis("商家A", randInt()).
AddYAxis("商家B", randInt())
fn := fmt.Sprintf( myChart_%s.on('click', function (params) { alert('You clicked on a ' + params.name + ' element.'); console.log(params.name); });, bar.ChartID)
bar.AddJSFuncs(fn)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants