reactjs+echarts实现绘图

时间:2025-04-03 09:18:54
var Hello = ({ componentDidMount:function(){ (this.); this.drawCharts(this.); }, drawCharts:function(dataSet){ var myChart = (('charts')); // 指定图表的配置项和数据 var option = { title: { text: 'ECharts 入门示例' }, tooltip: {}, legend: { data:['销量'] }, xAxis: { data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"] }, yAxis: {}, series: [{ name: '销量', type: 'bar', data: dataSet }] }; // 使用刚指定的配置项和数据显示图表 (option); }, /*注意return后面的js有自动加;的习惯*/ render: function() { return <div> <h1>Hello {this.}</h1> <div id="charts" data={dataSet}></div> </div>; } }); /*props向组件内部传递*/ var dataSet=[100,20,30,0,0,0]; ( <Hello name="World"data={dataSet}/>, ('example') );