Giter Club home page Giter Club logo

Comments (38)

hustcc avatar hustcc commented on July 18, 2024 6

在 state 中放一个 option 数据,先 setOption 为一个空的对象,然后在请求数据成功之后,再 setState 设置请求到的 option 数据。

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024 1

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

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

很好的问题,echarts官方是支持按需引入的,但是echarts-for-react是直接引入了echarts,确实会增加不需要的引入,也会包体大小。

我要想想怎么解决,你有比较好的解决办法吗?

from echarts-for-react.

ZhengHe-MD avatar ZhengHe-MD commented on July 18, 2024

我觉得是这样的吧。echarts 有lib和umd build两种. 在commonjs里面应该import lib里面的代码,这样只需要import需要的模块。[实际上我没看过源码,不过一般是这样的吧。就如import { map } from 'lodash'一样 ]

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

这个做法可行,对于用户(开发者)来说,需要按需引入,入门会稍难一些,所以还是需要兼容目前的写法。

from echarts-for-react.

codering avatar codering commented on July 18, 2024

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.

codering avatar codering commented on July 18, 2024

以后有时间也可以自己写babel插件来解决

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

@codering 我的想法是增加一个modules属性传入进入,如果这个属性为空,那么就引入全部echarts,否则就应用最小依赖。

这样的好处在于可以兼容旧版本的代码,不然以前的用户一升级导致代码除了bug,那不是坑爹^_^~

from echarts-for-react.

codering avatar codering commented on July 18, 2024

modules属性值是 ?

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024
<ReactEcharts 
    modules={[]}
    ... />

组件的props。

from echarts-for-react.

codering avatar codering commented on July 18, 2024

@hustcc 数组里的值是什么? 是echarts里功能模块路径吗?然后内部异步加载?

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

嗯,模块路径这样可行吗?
首先肯定是需要兼容旧版本代码的

from echarts-for-react.

codering avatar codering commented on July 18, 2024

既然都是写路径,我宁愿用我先前说的方案。
用户完全可以单独建一个echartsLib.js,专门管理需要的echarts功能模块:
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/bar'

....
....

然后你内部依赖改到最小,用户的用法什么都没变,只是多依赖了一个echartsLib.js,而且这个配置是全局通用的,也可以异步加载,感觉这样的兼容性是最好的。

from echarts-for-react.

walter211 avatar walter211 commented on July 18, 2024

可以通过uiwebview整合到react-native项目里么

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

使用webview的话,理论上是没有问题的~~~
react-native的呼声很高啊,我抽时间学习一下rn,然后测试试试看~

from echarts-for-react.

Sinovel avatar Sinovel commented on July 18, 2024

有没有一个单个的demo,或者都整合在一个文件的,现在的bundle.js太乱看不懂。

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

demo目录就是网页的全部代码…

from echarts-for-react.

Sinovel avatar Sinovel commented on July 18, 2024

单独的一个bar或者line的demo,这样那个bundle.js能不能简化?初学看不懂

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

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.

Sinovel avatar Sinovel commented on July 18, 2024

web前端脚本还是加载不出来,这个有没有前端脚本的demo

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

这个就是前端脚本啊,你学习了react了没?

from echarts-for-react.

Sinovel avatar Sinovel commented on July 18, 2024

就学了一点这种简单的http://www.ruanyifeng.com/blog/2015/03/react.html,你的这种应该比较高级,看不懂,引用那些JSX文件也显示不出来结果

from echarts-for-react.

cdoneshot avatar cdoneshot commented on July 18, 2024

内部暴露一个setModules方法,用户在入口文件配置依赖的模块,如果没有配置,默认引入最小依赖,这种对现在的使用也不会造成影响,同时支持用户自己配置依赖模块。

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

如果没有配置 setModules ,默认引入最小依赖。

这样会影响已经使用的人吧,一旦他们升级 echarts-for-react 版本,就必须修改代码。如果没有设置,默认为全量引入,这样貌似可以。

from echarts-for-react.

cdoneshot avatar cdoneshot commented on July 18, 2024

这样会影响已经使用的人吧,一旦他们升级 echarts-for-react 版本,就必须修改代码。如果没有设置,默认为全量引入,这样貌似可以。

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

你如果有兴趣,可以提交一个 pr 啊,另外在实例中添加一个 demo。^_^

from echarts-for-react.

RelaxLiu avatar RelaxLiu commented on July 18, 2024

地图相关的组件,我想在页面进来的时候向后端发请求拿到数据,然后渲染到页面上,不知道怎么设置setOption,求指教

from echarts-for-react.

RelaxLiu avatar RelaxLiu commented on July 18, 2024

感谢!!!

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

@RelaxLiu 客气了,注意以后有问题的时候,如果 issue 中没有相关的主题,可以新建一个 issue,而不是把问题提到一个不相关的 issue 上面。^_^

from echarts-for-react.

RelaxLiu avatar RelaxLiu commented on July 18, 2024

@hustcc 了解

from echarts-for-react.

liaohui1080 avatar liaohui1080 commented on July 18, 2024

@hustcc

import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/bar'

现在可以这样引入组件吗?
是否已经支持

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

还不支持~ @liaohui1080 具体来说不知道如何实现比较好,如果你有一些想法,欢迎讨论或者 pr。

from echarts-for-react.

sbyps avatar sbyps commented on July 18, 2024

@codering 如何集成到webpack中进行按需加载echarts和这个echarts-react?自己在项目内部中新建所说的echarts-lib,然后webpack会自动引入?

from echarts-for-react.

sbyps avatar sbyps commented on July 18, 2024

@hustcc 能否提供一个支持按需加载的版本,或者给个整体思路

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/bar'

在使用本项目组件的时候,先 import 需要的部分,试试看打包出来的 bundle 会不会减少。

from echarts-for-react.

sbyps avatar sbyps commented on July 18, 2024

https://github.com/recharts/babel-plugin-recharts

from echarts-for-react.

jindada avatar jindada commented on July 18, 2024

@hustcc 感觉通过babel-plugin无法按需加载 获取不到echarts的option

from echarts-for-react.

hustcc avatar hustcc commented on July 18, 2024

babel-plugin-recharts 和这个相关没有什么关系啊~

from echarts-for-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.