Comments (38)
在 state 中放一个 option 数据,先 setOption 为一个空的对象,然后在请求数据成功之后,再 setState 设置请求到的 option 数据。
from echarts-for-react.
v1.3.5 版本发布,支持自定义加载 echarts 模块,减少打包之后的 js 文件大小,感谢 @SidKwok
from echarts-for-react.
很好的问题,echarts官方是支持按需引入的,但是echarts-for-react是直接引入了echarts,确实会增加不需要的引入,也会包体大小。
我要想想怎么解决,你有比较好的解决办法吗?
from echarts-for-react.
我觉得是这样的吧。echarts 有lib和umd build两种. 在commonjs里面应该import lib里面的代码,这样只需要import需要的模块。[实际上我没看过源码,不过一般是这样的吧。就如import { map } from 'lodash'一样 ]
from echarts-for-react.
这个做法可行,对于用户(开发者)来说,需要按需引入,入门会稍难一些,所以还是需要兼容目前的写法。
from echarts-for-react.
ReactEcharts 内部只需要最小依赖 echarts/lib/echarts
即可,
让用户自己去管理使用的echarts功能模块怎么样?
import echarts from 'echarts/lib/echarts'
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/bar'
....
....
import ReactEcharts from 'echarts-for-react'
from echarts-for-react.
以后有时间也可以自己写babel插件来解决
from echarts-for-react.
@codering 我的想法是增加一个modules属性传入进入,如果这个属性为空,那么就引入全部echarts,否则就应用最小依赖。
这样的好处在于可以兼容旧版本的代码,不然以前的用户一升级导致代码除了bug,那不是坑爹^_^~
from echarts-for-react.
modules属性值是 ?
from echarts-for-react.
<ReactEcharts
modules={[]}
... />
组件的props。
from echarts-for-react.
@hustcc 数组里的值是什么? 是echarts里功能模块路径吗?然后内部异步加载?
from echarts-for-react.
嗯,模块路径这样可行吗?
首先肯定是需要兼容旧版本代码的
from echarts-for-react.
既然都是写路径,我宁愿用我先前说的方案。
用户完全可以单独建一个echartsLib.js,专门管理需要的echarts功能模块:
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/bar'
....
....
然后你内部依赖改到最小,用户的用法什么都没变,只是多依赖了一个echartsLib.js,而且这个配置是全局通用的,也可以异步加载,感觉这样的兼容性是最好的。
from echarts-for-react.
可以通过uiwebview整合到react-native项目里么
from echarts-for-react.
使用webview的话,理论上是没有问题的~~~
react-native的呼声很高啊,我抽时间学习一下rn,然后测试试试看~
from echarts-for-react.
有没有一个单个的demo,或者都整合在一个文件的,现在的bundle.js太乱看不懂。
from echarts-for-react.
demo目录就是网页的全部代码…
from echarts-for-react.
单独的一个bar或者line的demo,这样那个bundle.js能不能简化?初学看不懂
from echarts-for-react.
https://github.com/hustcc/echarts-for-react/blob/master/demo/SimpleChartComponent.jsx
看这个文件,这个是http://git.hust.cc/echarts-for-react/#/echarts/simple?_k=2xkjj3 这个图。
from echarts-for-react.
web前端脚本还是加载不出来,这个有没有前端脚本的demo
from echarts-for-react.
这个就是前端脚本啊,你学习了react了没?
from echarts-for-react.
就学了一点这种简单的http://www.ruanyifeng.com/blog/2015/03/react.html,你的这种应该比较高级,看不懂,引用那些JSX文件也显示不出来结果
from echarts-for-react.
内部暴露一个setModules方法,用户在入口文件配置依赖的模块,如果没有配置,默认引入最小依赖,这种对现在的使用也不会造成影响,同时支持用户自己配置依赖模块。
from echarts-for-react.
如果没有配置 setModules ,默认引入最小依赖。
这样会影响已经使用的人吧,一旦他们升级 echarts-for-react 版本,就必须修改代码。如果没有设置,默认为全量引入,这样貌似可以。
from echarts-for-react.
这样会影响已经使用的人吧,一旦他们升级 echarts-for-react 版本,就必须修改代码。如果没有设置,默认为全量引入,这样貌似可以。
嗯
from echarts-for-react.
你如果有兴趣,可以提交一个 pr 啊,另外在实例中添加一个 demo。^_^
from echarts-for-react.
地图相关的组件,我想在页面进来的时候向后端发请求拿到数据,然后渲染到页面上,不知道怎么设置setOption,求指教
from echarts-for-react.
感谢!!!
from echarts-for-react.
@RelaxLiu 客气了,注意以后有问题的时候,如果 issue 中没有相关的主题,可以新建一个 issue,而不是把问题提到一个不相关的 issue 上面。^_^
from echarts-for-react.
@hustcc 了解
from echarts-for-react.
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/bar'
现在可以这样引入组件吗?
是否已经支持
from echarts-for-react.
还不支持~ @liaohui1080 具体来说不知道如何实现比较好,如果你有一些想法,欢迎讨论或者 pr。
from echarts-for-react.
@codering 如何集成到webpack中进行按需加载echarts和这个echarts-react?自己在项目内部中新建所说的echarts-lib,然后webpack会自动引入?
from echarts-for-react.
@hustcc 能否提供一个支持按需加载的版本,或者给个整体思路
from echarts-for-react.
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/bar'
在使用本项目组件的时候,先 import 需要的部分,试试看打包出来的 bundle 会不会减少。
from echarts-for-react.
https://github.com/recharts/babel-plugin-recharts
from echarts-for-react.
@hustcc 感觉通过babel-plugin无法按需加载 获取不到echarts的option
from echarts-for-react.
babel-plugin-recharts 和这个相关没有什么关系啊~
from echarts-for-react.
Related Issues (20)
- percentage `name (undefined%)` when series data is empty `series.data:[ ]` HOT 1
- Allow setting `id` and `data-testid` HOT 1
- Feature Request: RTL support
- Project status HOT 3
- Not support @typescript-eslint/parser 6.x
- 主题theme似乎不生效?
- react 5.1 增加了resize动画的功能,echarts-for-react v3.0.2 应该如何调用? HOT 1
- Typing does not support charts v5.4.3
- How to override the readonly style for position relative? HOT 2
- I can not append Data while Zooming
- Table Component
- 动态切换主题
- How to connect several charts on chart load? HOT 2
- How to update datasets on zoom event? HOT 2
- [bug] : Inconsistent Zoom Functionality with ECharts: Seeking Guidance on Mouse Scroll and Button Control Integration
- Tree branch once opened does not retract back on closing it HOT 1
- How to rewrite this example with echarts-for-react
- add type to EChartsOption
- Update Required type Opts ( and add support for SSR) HOT 2
- Unable to show date labels inside cells
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from echarts-for-react.