andfanilo / streamlit-echarts

A Streamlit component to render ECharts.
https://share.streamlit.io/andfanilo/streamlit-echarts-demo/master/app.py
MIT License
537 stars 66 forks source link

echarts.graphic.LinearGradient not working #10

Closed andfanilo closed 3 years ago

andfanilo commented 3 years ago
color: new echarts.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                        {offset: 0, color: '#83bff6'},
                        {offset: 0.5, color: '#188df0'},
                        {offset: 1, color: '#188df0'}
                    ]
                )

doesn't work. I suppose the echarts namespace was minified and doesn't exist anymore?

https://echarts.apache.org/examples/en/editor.html?c=bar-gradient

liunux4odoo commented 3 years ago

yes, you are right, the global variable echarts does not exist anymore after webpacking, so the LinearGradient will not work with the built chunks. variable echarts has lots of APIs that can be set to chart option in runtime. In webpack environment, you can only use them when developing , e.g. echarts.registerMap, in build chunks it does not exist either.

andfanilo commented 3 years ago

Yeah, which is too bad :(

I wanted to try referring back to the echarts instance through a ref but the Streamlit lifecycle makes it hard to go back and forth between Python and JS afterwards anyway _(absolutely not easy to do streamlit_echarts.setOption or streamlitecharts.registerMap after the component was set, everything must be done when initializing the component and then eventually rerunning the script by changing component arguments to animate between 2 states)

Thanks for your comment, it helped reinforce my thoughts about it :) I may close this soon as "Unresolved"

Fanilo

andfanilo commented 3 years ago

Actually I'll close this in favor of #4