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

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

Closed
JieChang opened this issue Dec 8, 2016 · 1 comment

Comments

@JieChang
Copy link

JieChang commented Dec 8, 2016

`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…

@JieChang JieChang closed this as completed Dec 8, 2016
@hustcc
Copy link
Owner

hustcc commented Dec 8, 2016

自己close了?解决了?

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

2 participants