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

引用整个echarts太大了,只需要几个chart类型 #57

Closed
benweizhu opened this issue May 11, 2017 · 9 comments
Closed

引用整个echarts太大了,只需要几个chart类型 #57

benweizhu opened this issue May 11, 2017 · 9 comments

Comments

@benweizhu
Copy link

echarts: 2.7 MB (47.3%)
react-dom: 535.36 KB (9.16%)
moment: 455.55 KB (7.79%)
zrender: 439.99 KB (7.52%)
core-js: 197.72 KB (3.38%)
react-router: 103.24 KB (1.77%)
react: 103.13 KB (1.76%)
lodash: 60.78 KB (1.04%)
history: 55.74 KB (0.953%)
  warning: 1.76 KB (3.17%)
  <self>: 53.98 KB (96.8%)
buffer: 47.47 KB (0.812%)
react-datetime-slot: 38.92 KB (0.666%)
  object-assign: 817 B (2.05%)
  <self>: 38.13 KB (98.0%)
react-popover: 36.95 KB (0.632%)
react-redux: 36.22 KB (0.619%)
axios: 35.04 KB (0.599%)
fbjs: 30.79 KB (0.526%)
react-datetime: 29.11 KB (0.498%)
  object-assign: 817 B (2.74%)
  <self>: 28.31 KB (97.3%)
create-react-class: 27 KB (0.462%)
regenerator-runtime: 23.24 KB (0.397%)
prop-types: 21.42 KB (0.366%)
redux: 20.35 KB (0.348%)
lodash.assign: 16.35 KB (0.280%)
react-modal: 14.62 KB (0.250%)
redux-logger: 14.16 KB (0.242%)
react-fileupload: 12.47 KB (0.213%)
react-onclickoutside: 11.96 KB (0.204%)
deep-diff: 11.21 KB (0.192%)
react-router-redux: 11.05 KB (0.189%)
debug: 8.89 KB (0.152%)
redux-promise-middleware: 7.12 KB (0.122%)
lodash.debounce: 6.89 KB (0.118%)
css-vendor: 6.4 KB (0.109%)
lodash-es: 5.74 KB (0.0981%)
echarts-for-react: 5.47 KB (0.0936%)
process: 5.17 KB (0.0885%)
deep-equal: 3.8 KB (0.0650%)
lodash._getnative: 3.78 KB (0.0646%)
lodash.throttle: 3.45 KB (0.0590%)

我只需要用到里面其中几个echart,可不可以选择性的使用chart???

@hustcc
Copy link
Owner

hustcc commented May 11, 2017

#3,暂时没有想到比较好的方案,既能保证稳定性,又能保证兼容性。

个人想法是:

  1. 保持目前的 ReactEcharts 实例使用方式;
  2. 另外还提供 Line、Bar 等不同的 export 来单独引入不同的 echarts 模块,减少代码量。

@benweizhu
Copy link
Author

我发现,有很大的一个数据来自于地图的China.js或者world.js,如果有require

@hustcc
Copy link
Owner

hustcc commented May 12, 2017

China.js 或者 world.js 默认是没有加入到 echarts 的,需要自己手动引入。

@SidKwok
Copy link
Collaborator

SidKwok commented May 27, 2017

可以用peerDependency的方法,让用户引入echarts,那样子就可以让用户自定义需要引入的地图类型了

@hustcc
Copy link
Owner

hustcc commented May 27, 2017

理论上 echarts 确实是 peerDependency,package.json 也应该修改。

但是修改为 peerDependency 并不能解决打包太大的问题吧?

@SidKwok
Copy link
Collaborator

SidKwok commented May 27, 2017

@hustcc 其实我的意思是,你在项目里面直接引入了echarts啊,你可以不引入,然后让用户自己引入,所以就变成了:

import echarts from 'echarts';
import Chart from 'echarts-for-react';

<Chart echarts={echarts} />

这样子用户应该就可以自定义echarts的地图类型了

@hustcc
Copy link
Owner

hustcc commented May 27, 2017

能够兼容现在的写法吗?比如用户不在乎 echarts 的大小,可以继续保持以前的写法。

@SidKwok
Copy link
Collaborator

SidKwok commented May 27, 2017

@hustcc 我想想 然后提一份pr给你看看

@hustcc hustcc closed this as completed in 96d7338 May 29, 2017
@hustcc
Copy link
Owner

hustcc commented May 29, 2017

v1.3.5 版本发布,支持自定义加载 echarts 模块,减少打包之后的 js 文件大小,感谢 @SidKwok

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

No branches or pull requests

3 participants