Git Product home page Git Product logo

echarts-for-react's Introduction

echarts-for-react

The simplest, and the best React wrapper for Apache ECharts.

npm Build Status Coverage NPM downloads License ECharts Ver React Ver

Install

$ npm install --save echarts-for-react

# `echarts` is the peerDependence of `echarts-for-react`, you can install echarts with your own version.
$ npm install --save echarts

Then use it.

import ReactECharts from 'echarts-for-react';

// render echarts option.
<ReactECharts option={this.getOption()} />

You can run website.

$ git clone [email protected]:hustcc/echarts-for-react.git

$ npm install

$ npm start

Then open http://127.0.0.1:8081/ in your browser. or see https://git.hust.cc/echarts-for-react/ which is deploy on gh-pages.

Usage

Code of a simple demo code showed below. For more example can see: https://git.hust.cc/echarts-for-react/

import React from 'react';
import ReactECharts from 'echarts-for-react';  // or var ReactECharts = require('echarts-for-react');

<ReactECharts
  option={this.getOption()}
  notMerge={true}
  lazyUpdate={true}
  theme={"theme_name"}
  onChartReady={this.onChartReadyCallback}
  onEvents={EventsDict}
  opts={}
/>

Import ECharts.js modules manually to reduce bundle size

With Echarts.js v5:

import React from 'react';
// import the core library.
import ReactEChartsCore from 'echarts-for-react/lib/core';
// Import the echarts core module, which provides the necessary interfaces for using echarts.
import * as echarts from 'echarts/core';
// Import charts, all with Chart suffix
import {
  // LineChart,
  BarChart,
  // PieChart,
  // ScatterChart,
  // RadarChart,
  // MapChart,
  // TreeChart,
  // TreemapChart,
  // GraphChart,
  // GaugeChart,
  // FunnelChart,
  // ParallelChart,
  // SankeyChart,
  // BoxplotChart,
  // CandlestickChart,
  // EffectScatterChart,
  // LinesChart,
  // HeatmapChart,
  // PictorialBarChart,
  // ThemeRiverChart,
  // SunburstChart,
  // CustomChart,
} from 'echarts/charts';
// import components, all suffixed with Component
import {
  // GridSimpleComponent,
  GridComponent,
  // PolarComponent,
  // RadarComponent,
  // GeoComponent,
  // SingleAxisComponent,
  // ParallelComponent,
  // CalendarComponent,
  // GraphicComponent,
  // ToolboxComponent,
  TooltipComponent,
  // AxisPointerComponent,
  // BrushComponent,
  TitleComponent,
  // TimelineComponent,
  // MarkPointComponent,
  // MarkLineComponent,
  // MarkAreaComponent,
  // LegendComponent,
  // LegendScrollComponent,
  // LegendPlainComponent,
  // DataZoomComponent,
  // DataZoomInsideComponent,
  // DataZoomSliderComponent,
  // VisualMapComponent,
  // VisualMapContinuousComponent,
  // VisualMapPiecewiseComponent,
  // AriaComponent,
  // TransformComponent,
  DatasetComponent,
} from 'echarts/components';
// Import renderer, note that introducing the CanvasRenderer or SVGRenderer is a required step
import {
  CanvasRenderer,
  // SVGRenderer,
} from 'echarts/renderers';

// Register the required components
echarts.use(
  [TitleComponent, TooltipComponent, GridComponent, BarChart, CanvasRenderer]
);

// The usage of ReactEChartsCore are same with above.
<ReactEChartsCore
  echarts={echarts}
  option={this.getOption()}
  notMerge={true}
  lazyUpdate={true}
  theme={"theme_name"}
  onChartReady={this.onChartReadyCallback}
  onEvents={EventsDict}
  opts={}
/>

With Echarts.js v3 or v4:

import React from 'react';
// import the core library.
import ReactEChartsCore from 'echarts-for-react/lib/core';

// then import echarts modules those you have used manually.
import echarts from 'echarts/lib/echarts';
// import 'echarts/lib/chart/line';
import 'echarts/lib/chart/bar';
// import 'echarts/lib/chart/pie';
// import 'echarts/lib/chart/scatter';
// import 'echarts/lib/chart/radar';

// import 'echarts/lib/chart/map';
// import 'echarts/lib/chart/treemap';
// import 'echarts/lib/chart/graph';
// import 'echarts/lib/chart/gauge';
// import 'echarts/lib/chart/funnel';
// import 'echarts/lib/chart/parallel';
// import 'echarts/lib/chart/sankey';
// import 'echarts/lib/chart/boxplot';
// import 'echarts/lib/chart/candlestick';
// import 'echarts/lib/chart/effectScatter';
// import 'echarts/lib/chart/lines';
// import 'echarts/lib/chart/heatmap';

// import 'echarts/lib/component/graphic';
// import 'echarts/lib/component/grid';
// import 'echarts/lib/component/legend';
import 'echarts/lib/component/tooltip';
// import 'echarts/lib/component/polar';
// import 'echarts/lib/component/geo';
// import 'echarts/lib/component/parallel';
// import 'echarts/lib/component/singleAxis';
// import 'echarts/lib/component/brush';

import 'echarts/lib/component/title';

// import 'echarts/lib/component/dataZoom';
// import 'echarts/lib/component/visualMap';

// import 'echarts/lib/component/markPoint';
// import 'echarts/lib/component/markLine';
// import 'echarts/lib/component/markArea';

// import 'echarts/lib/component/timeline';
// import 'echarts/lib/component/toolbox';

// import 'zrender/lib/vml/vml';

// The usage of ReactEChartsCore are same with above.
<ReactEChartsCore
  echarts={echarts}
  option={this.getOption()}
  notMerge={true}
  lazyUpdate={true}
  theme={"theme_name"}
  onChartReady={this.onChartReadyCallback}
  onEvents={EventsDict}
  opts={}
/>

For Next.js user, code transpilation is needed.

// next.config.js
const withTM = require("next-transpile-modules")(["echarts", "zrender"]);

module.exports = withTM({})

Props of Component

  • option (required, object)

the echarts option config, can see https://echarts.apache.org/option.html#title.

  • notMerge (optional, object)

when setOption, not merge the data, default is false. See https://echarts.apache.org/api.html#echartsInstance.setOption.

  • lazyUpdate (optional, object)

when setOption, lazy update the data, default is false. See https://echarts.apache.org/api.html#echartsInstance.setOption.

  • style (optional, object)

the style of echarts div. object, default is {height: '300px'}.

  • className (optional, string)

the class of echarts div. you can setting the css style of charts by class name.

  • theme (optional, string)

the theme of echarts. string, should registerTheme before use it (theme object format: https://github.com/ecomfe/echarts/blob/master/theme/dark.js). e.g.

// import echarts
import echarts from 'echarts';
...
// register theme object
echarts.registerTheme('my_theme', {
  backgroundColor: '#f4cccc'
});
...
// render the echarts use option `theme`
<ReactECharts
  option={this.getOption()}
  style={{height: '300px', width: '100%'}}
  className='echarts-for-echarts'
  theme='my_theme' />
  • onChartReady (optional, function)

when the chart is ready, will callback the function with the echarts object as it's paramter.

  • loadingOption (optional, object)

the echarts loading option config, can see https://echarts.apache.org/api.html#echartsInstance.showLoading.

  • showLoading (optional, bool, default: false)

bool, when the chart is rendering, show the loading mask.

  • onEvents (optional, array(string=>function) )

binding the echarts event, will callback with the echarts event object, and the echart object as it's paramters. e.g:

const onEvents = {
  'click': this.onChartClick,
  'legendselectchanged': this.onChartLegendselectchanged
}
...
<ReactECharts
  option={this.getOption()}
  style={{ height: '300px', width: '100%' }}
  onEvents={onEvents}
/>

for more event key name, see: https://echarts.apache.org/api.html#events

  • opts (optional, object)

the opts of echarts. object, will be used when initial echarts instance by echarts.init. Document here.

<ReactECharts
  option={this.getOption()}
  style={{ height: '300px' }}
  opts={{renderer: 'svg'}} // use svg to render the chart.
/>
  • autoResize (optional, boolean)

decide whether to trigger this.resize when window resize. default is true.

Component API & Echarts API

the Component only has one API named getEchartsInstance.

  • getEchartsInstance() : get the echarts instance object, then you can use any API of echarts.

for example:

// render the echarts component below with rel
<ReactECharts
  ref={(e) => { this.echartRef = e; }}
  option={this.getOption()}
/>

// then get the `ReactECharts` use this.echarts_react

const echartInstance = this.echartRef.getEchartsInstance();
// then you can use any API of echarts.
const base64 = echartInstance.getDataURL();

About API of echarts, can see https://echarts.apache.org/api.html#echartsInstance.

You can use the API to do:

  1. binding / unbinding event.
  2. dynamic charts with dynamic data.
  3. get the echarts dom / dataURL / base64, save the chart to png.
  4. release the charts.

FAQ

How to render the chart with svg when using echarts 4.x

Use the props opts of component with renderer = 'svg'. For example:

<ReactECharts
  option={this.getOption()}
  style={{height: '300px'}}
  opts={{renderer: 'svg'}} // use svg to render the chart.
/>

How to resolve Error Component series.scatter3D not exists. Load it first.

Install and import echarts-gl module when you want to create a GL instance

npm install --save echarts-gl
import 'echarts-gl'
import ReactECharts from "echarts-for-react";

<ReactECharts
  option={GL_OPTION}
/>

LICENSE

MIT@hustcc.

echarts-for-react's People

Contributors

100gle avatar fakership avatar hustcc avatar mobeigi avatar mr-milk avatar n0099 avatar poozhu avatar shichencong avatar sjfkai avatar sthenault avatar superlbr avatar tisonkun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

echarts-for-react's Issues

高度自适应应该怎么做

如题,是竖向的柱状图,固定每条柱状图的宽度和间距,让图表高度自适应,这个怎么做呢

单页面多次更新option数据合并了

echartObj.setOption(this.props.option);
这里应该有一个参数notMerge
如果不传会是false,多次setOption,如果上次的数据比这次的数据多,会有错乱的效果
能否将这个参数加到ReactEcharts的props里

map放大或者移动地图坐标点不跟随地图移动,发生错位

//基础配置 参考 http://echarts.baidu.com/demo.html#effectScatter-map
//初始的状态,
 mapoption: mapoption,

需要动态显示地图上点指标内容,比如下单量、支付量等,因此需要清空实例重新渲染
this.refs[name] && this.refs[name].getEchartsInstance().clear()
//调用完成后重新设置option数据

  this.setState({
          mapoption: mapoption,
    })
此时放大或者移动地图坐标点不跟随地图移动,再不清空实例的情况下是好用的。

 //调用
 <div className="col-md-12">
       <ReactEcharts
             ref="mapoption"
             option={this.state.mapoption}
             style={{height: '1200px', width: '100%'}}/>  

 </div>

"version": "1.2.2": 存在2个 Warning

Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.

Warning: A Component: React.createClass is deprecated and will be removed in version 16. Use plain JavaScript classes instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement.

建议更新依赖包

any clue what would cause this error: "Uncaught TypeError: Cannot read property 'resize' of null"?

My setup is that I have multiple sets of data and config for different chart types, so it allows to dynamically switch between multi chart types. It just simply pass everything as props to this HOC called echarts-base-chart, then it uses the echarts-for-react inside it.

Recently, I found it will throw this error when I switch the chart from one type to another. So I'm wondering what would cause this error?
screen shot 2017-03-17 at 2 14 00 pm

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

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???

一个问题

我有一个echarts-for-react组件,假设叫做小白吧。
小白是一个折线图。可以把自己正确的画出来。
小白有一个铃铛,本来是当当的响,当某些事情发生的时候,我setState({铃铛:当当当})。
这个时候小白会render,echarts也会render,但是其实图并没有任何变化。
所以我怎么做,才不会让echart重新render呢?
thankyou.

resize如何改变高度?

elementResizeEvent(this.refs.echartsDom, function() {
            let div = document.getElementById(id),
                width =
 div.style.width|| div.clientWidth || div.offsetWidth || div.scrollWidth,
                height = width * 0.5;

            this.setState = {
                width:width,
                height:height
            }
            echartObj.resize();
        });
//-------------------------------------------------------------------
 render() {
        let  style = {width:this.state.width,height:this.state.height} || {height: '300px'};
        // for render
       return (
            <div id={this.state.id}
                 ref='echartsDom'
                 style={style}
                 />
        );
    }
//------------------------------------------------------------------

我想实现的效果是宽高比一定,高度随宽度变化而变化。
使用this.setState也没用,因为componentDidMount后不再render了。
请问这该怎么解决呀?

关于项目中直接引用'echarts-for-react'直接报错的问题

在OSX环境下使用webpack编译发生如下错误,

ERROR in ./~/echarts-for-react/lib/echarts-for-react.js
Module build failed: ReferenceError: Unknown plugin "transform-es3-member-expression-literals" specified in "/Users/mikako/Desktop/allbaidutest/baidu/atm-idp/noc/node_modules/echarts-for-react/.babelrc" at 0, attempted to resolve

在modules中把'echarts-for-react'的babelrc注释掉即可正常编译,依赖版本如下

    "echarts": "^3.2.3",
    "echarts-for-react": "^1.1.5",
    "express": "^4.14.0",
    "history": "^4.0.0",
    "immutable": "^3.8.1",
    "isomorphic-fetch": "^2.2.1",
    "react": "^15.2.1",
    "react-css-modules": "^3.7.9",
    "react-dom": "^15.2.1",
    "react-redux": "^4.4.5",
    "react-router": "^2.7.0",
    "react-router-redux": "^4.0.5",
    "redux": "^3.5.2",
    "redux-thunk": "^2.1.0"

New prop for setting canvas id/extra className

This would be a simple but convenient feature but right now I don't have the time to implement it....
I would send a PR after I finish my current project if you think this is a good suggestion, and you guys still haven't implemented it.

Please let me know if you think this feature is redundant. Thanks!!

写了一个简单的demo,可是一直报错Cannot use 'in' operator to search for 'x' in

`class Charts extends React.Component {

constructor(props) {
    super(props);
    this.state = {
        option: {
            title: {
                text: 'Step Line'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data:[ 'Step Middle']
            },
            grid: {
                left: '3%',
                right: '3%',
                bottom: '3%',
                containLabel: true
            },
            toolbox: {

            },
            xAxis: {
                type: 'category',
                data: [],
                splitLine: {
                    show: true
                }
            },
            yAxis: {
                type: 'value',
                splitLine: {
                    show: false
                }
            },
            series: [
                {
                    name:'Step Middle',
                    type:'line',
                    step: 'middle',
                    data:[]
                }
            ]
        },
        showChart: false,
    };
}

componentWillMount () {
    this.getChartDatas();
}

getChartDatas () {
    ajax({
        api: 'orderGoodsChartsData',
        method: 'get',
        data: {},
        withCredentials: true,
        crossOrigin: true
    }, suc => {
        if(suc.success != true){
            Toast.error(suc.message || '获取图表信息异常');
        }else{
            let data = suc.data || {},
                option = this.state.option;
                option.title = data.title;
                option.xAxis.data = data.jxch && data.jxch.date;
                option.series[0].data = data.jxch && data.jxch.out;
            this.setState({option: option, showChart: true});
        }
    }, err => {
        Toast.error('获取图表信息异常');
    });
}

render () {
    console.log('option',this.state.option);
    if(this.state.showChart){
        return (
            <div>
                <ReactEcharts
                    option={this.state.option}
                    style={{height: '300px', width: '100%'}}
                    lazyUpdate={true}
                    theme={"theme_name"}
                    onChartReady={() => { console.log('onChartReady'); }}
                    onEvents={{
                        'click': () => {console.log('clickCharts');}
                    }} />
            </div>
        );
    }
    else{
        return <div></div>;
    }
}

}

export default Charts;`

image
Uploading image.png…

wordCloud

引入这个怎么实现词云图?

stillShowZeroSum属性失效

在react环境下,饼图值为零时想设置饼图不显示,可是总是失效,在官网demo下实验好用,移到项目中就失效,不知道为什么,求大神指点!!!

[BABEL]

TransformError: /Users/xxxx/workspace/xxxx/node_modules/echarts-for-react/lib/echarts-for-react.js: [BABEL] /Users/xxxx/workspace/xxxx/node_modules/echarts-for-react/lib/echarts-for-react.js: Unknown option: foreign.Children. Check out http://babeljs.io/docs/usage/options/ for more info
怎么办呢

dva结合echarts-for-react

dva结合ant design的table组件:展示组件第一次获得初始state为null,table显示暂无数据,第二次获取到了model返回的ajax请求接口数据,数据填充
dva结合echarts-for-react:展示组件第一次获得初始state为null,ReactEcharts获取的数据为null直接报错没有进入数据填充阶段
解决方案:

{chart? <ReactEcharts
                    option={getOption(chart)}
                    style={{height: '400px'}} /> : 'test'}

这是我目前的解决方案,想问echarts-for-react现在是怎么处理数据还没就位的情况的

浏览器窗口大小发生改变时,图表高度能否也跟着变化?

在窗口变化时,如果获取窗口变化后的宽度按比例计算出高度,把值用setState存入state中(div的height取state里的值),但是这样会调用DidUpdate,图表重新初始化生成,而不是通过echartObj.resize();,请问有什么解决方法可以让宽高都发生变化,并且看上去图表只是放大缩小,并不会重新生成?

Uncaught (in promise) TypeError: Cannot read property 'eachItemGraphicEl' of undefined

如题,最近几天出现的错误,详细信息如下:

Uncaught (in promise) TypeError: Cannot read property 'eachItemGraphicEl' of undefined
    at ExtendedClass._renderPointer (http://localhost/webpack_dll/lib.js:178362:25)
    at ExtendedClass._renderMain (http://localhost/webpack_dll/lib.js:178219:19)
    at ExtendedClass.render (http://localhost/webpack_dll/lib.js:178138:19)
    at ECharts.<anonymous> (http://localhost/webpack_dll/lib.js:137917:24)
    at ExtendedClass.<anonymous> (http://localhost/webpack_dll/lib.js:139205:21)
    at Array.forEach (native)
    at each (http://localhost/webpack_dll/lib.js:139678:18)
    at ExtendedClass.eachSeries (http://localhost/webpack_dll/lib.js:139203:14)
    at ECharts.doRender (http://localhost/webpack_dll/lib.js:137914:18)
    at ECharts.update (http://localhost/webpack_dll/lib.js:137351:23)
_renderPointer	@	GaugeView.js:275
_renderMain	@	GaugeView.js:132
render	@	GaugeView.js:51
(anonymous)	@	echarts.js:1230
(anonymous)	@	Global.js:499
each	@	util.js:260
eachSeries	@	Global.js:497
doRender	@	echarts.js:1227
update	@	echarts.js:664
prepareAndUpdate	@	echarts.js:793
echartsProto.setOption	@	echarts.js:290
renderEchartDom	@	echarts-for-react.js:81
ReactEcharts_componentDidMount	@	echarts-for-react.js:33
(anonymous)	@	ReactCompositeComponent.js:264
measureLifeCyclePerf	@	ReactCompositeComponent.js:74
(anonymous)	@	ReactCompositeComponent.js:263
notifyAll	@	CallbackQueue.js:67
close	@	ReactReconcileTransaction.js:81
closeAll	@	Transaction.js:204
perform	@	Transaction.js:151
perform	@	Transaction.js:138
perform	@	ReactUpdates.js:90
flushBatchedUpdates	@	ReactUpdates.js:173
closeAll	@	Transaction.js:204
perform	@	Transaction.js:151
batchedUpdates	@	ReactDefaultBatchingStrategy.js:63
enqueueUpdate	@	ReactUpdates.js:201
enqueueUpdate	@	ReactUpdateQueue.js:25
enqueueSetState	@	ReactUpdateQueue.js:210
ReactComponent.setState	@	ReactComponent.js:64
handleChange	@	connect.js:302
dispatch	@	createStore.js:186
dispatch	@	instrument.js:599
(anonymous)	@	index.js:208
fetchApi.then.actionWith.type	@	api.js:199

经过调试发现应该是 echarts 最近的版本(@3.4.0 )更新导致的,建议 package.json 修改下版本控制:

"echarts": "^3.1.1" => "echarts": "~3.1.1"

map设置zoom属性问题

当设置zoom属性为1.5倍的时候,默认显示是正常的,滑动鼠标滚轮放大地图,停留1s后自己又还原到默认的zoom值,想要的是停留放大后的地图效果,

    geo: {
        map: 'china',
        label: {
            emphasis: {
                show: false
            }
        },
        zoom: 1.5,
        roam: true,
        itemStyle: {
            normal: {
                areaColor: '#323c48',
                borderColor: '#111'
            },
            emphasis: {
                areaColor: '#2a333d'
            }
        }
    },

怎么获取缩放比例

echarts 只查到可以通过myChart.chart.map._mapDataMap.china.transform.baseScale来获取缩放比例,echarts-for-react呢?

怎么动态加载

现在的版本加载了所有module,导致整体js大很多,怎么才能动态加载呢

Unknown prop `option`

按照示例在图表组件上使用option属性会报错
code

import chart from 'echarts-for-react'
……
<chart styleName="chart-warp" option={this.state.option}></chart>

error

Unknown prop `option` on <chart> tag. Remove this prop from the element

关于dynamic chart图片显示堆叠的问题

你好,我的电脑是MAC Pro OS操作系统,浏览器版本是Chrome 50.0.2661.102 (64-bit)。

当将ReactEChart的style的height设置为100%时,Dynamic Chart显示异常,出现堆叠的情况。
注:我的图表空间的父节点的height是700px,不存在收到父节点高度的影响。

当我们将Chrome的版本更新至最新时,图表显示正常。
请抽时间解决一下,我们这边也努力寻找一下原因,保持联系啊。
若你那边有结果了请告诉我们一声。多谢兄弟了,谢谢 ~

代码如下:
image

异常图片如下:
image

词云热点分析

百度词云这个chart渲染不出来

http://gallery.echartsjs.com/editor.html?c=xBJ11Hguze
option = {
title: {
text: '热点分析',
link: 'https://www.baidu.com/s?wd=' + encodeURIComponent('ECharts'),
x: 'center',
textStyle: {
fontSize: 23
}

},
backgroundColor: '#F7F7F7',
tooltip: {
    show: true
},
toolbox: {
    feature: {
        saveAsImage: {
            iconStyle: {
                normal: {
                    color: '#FFFFFF'
                }
            }
        }
    }
},
series: [{
    name: '热点分析',
    type: 'wordCloud',
    //size: ['9%', '99%'],
    sizeRange: [6, 66],
    //textRotation: [0, 45, 90, -45],
    rotationRange: [-45, 90],
    //shape: 'circle',
    textPadding: 0,
    autoSize: {
        enable: true,
        minSize: 6
    },
    textStyle: {
        normal: {
            color: function() {
                return 'rgb(' + [
                    Math.round(Math.random() * 160),
                    Math.round(Math.random() * 160),
                    Math.round(Math.random() * 160)
                ].join(',') + ')';
            }
        },
        emphasis: {
            shadowBlur: 10,
            shadowColor: '#333'
        }
    },
    data: [{
        name: "Jayfee",
        value: 666
    }, {
        name: "Nancy",
        value: 520
    }]
}]

};

//myChart.setOption(option);
myChart.on('click', function(params) {
//alert((params.name));
window.open('https://www.baidu.com/s?wd=' + encodeURIComponent(params.name));

});

How to use it in ES5

I use var ReactEcharts = require('echarts-for-react/lib/echarts-for-react'); to include the ReactEcharts,
and then

var Trend = React.createClass({
    render : function(){
        return (
            <div style={{background: "white", padding: "10px 0"}}>
                <div style={{height:'200px',width:'95%',margin: '0 auto'}}>
                    <ReactEcharts 
                        option={this.getOption()} 
                        style={{height: '200px', width: '100%'}}  /> 

                </div>
            </div>
        );
    },
    getOption : function(){
        var option = {
            // 省略
        };

        return option;
    }
});

At last I render Trend, the console report

bundle.js:91294 Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method ofTrend Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method ofTrend.

I wonder where is wrong.

TypeError: dom.getAttribute is not a function

react有版本限制吗??这个问题是怎么回事?

  echarts.getInstanceByDom = function (dom) {
	        var key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
	        return instances[key];
	    };

  getEchartsInstance: function getEchartsInstance() {
	        // return the echart object
	        return _echarts2['default'].getInstanceByDom(this.refs.echartsDom) || _echarts2['default'].init(this.refs.echartsDom, this.props.theme);
	    },

提示 Series has not been initialized yet.

使用了最简单的线形图和柱形图,console 都会出现这个错误。

原因是:本项目的 package.json 中对于 echarts 依赖版本控制不够严格,所以导致 echarts 直接升到最新的 3.4,导致不兼容。

升级使用 [email protected] 即可解决这个问题。

最近准备会更新本项目,并且支持最新的 echarts 3.4 版本。

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.