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

Adding support for events back #20

Closed
wants to merge 2 commits into from

Conversation

brightxml
Copy link
Contributor

hi,
I tried several code on adding support for events back to python. without API interface changing.
usage like this
on python side:
add return statements after other js code.

  events={
    "click": "function(params) {alert(params.name); return params.name }"
  }
  s=st_pyecharts(b,events=events)

and s is the value when designated events triggered.

please help taking a look.
thx

Bright Xie

@andfanilo andfanilo self-requested a review December 10, 2021 08:48
Copy link
Owner

@andfanilo andfanilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @brightxml !

I love it! Thanks for prototyping and testing this, this is fabulous.

I have small nitpicks and then ready to merge and release ;)

EDIT: reference to issue #19

@@ -54,6 +54,7 @@ const EchartsChart = (props: ComponentProps) => {
let match = funcReg.exec(v)
if (match) {
const funcStr = match[1]
// eslint-disable-next-line
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, my eslint does not tell me anything here, what warning do you get when you remove this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is when I run npm start, the terminal ouput this, tell me to add this line. but When I run this at home, it disappear...I guess it's because VS environment I set up.

@@ -73,12 +74,33 @@ const EchartsChart = (props: ComponentProps) => {
const cleanTheme = registerTheme(theme)

if (isObject(map)) {
echarts.registerMap(map.mapName, map.geoJson, map.specialAreas)
echarts.registerMap(map.mapName, map.geoJson, map.specialAreas)
Copy link
Owner

@andfanilo andfanilo Dec 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your IDE was not configured to use prettier because you have 4 spaces instead of 2..
Could you try running npx prettier --write .\src\EchartsChart.tsx from the streamlit_echarts/frontend folder when you're done with your edits?

*/
const keys=Object.keys(cleanOnEvents)
const getReturnOfcleanOnEvents:any={}
keys.forEach(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can write Object.keys(cleanOnEvents).forEach(function (key) { directly :) I think it's clear enough

@andfanilo
Copy link
Owner

PS: aaah sorry for the merge conflict. Normally if you just put your code before the useEffect I just pushed it should be all good.

@brightxml
Copy link
Contributor Author

I'll repush.

1 similar comment
@brightxml
Copy link
Contributor Author

I'll repush.

@brightxml brightxml closed this Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants