index.jsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React, { Component } from "react";
  2. import style from "../index.less";
  3. import { Radio} from '@commonComp';
  4. import echarts from 'echarts';
  5. class ChartItem extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.drawChart = this.drawChart.bind(this);
  9. }
  10. drawChart(id){
  11. var myChart = echarts.init(document.getElementById(id));
  12. // 指定图表的配置项和数据
  13. var option = {
  14. tooltip: {},
  15. legend: {
  16. data:['销量']
  17. },
  18. xAxis: {
  19. data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
  20. },
  21. yAxis: {},
  22. series: [{
  23. name: '销量',
  24. type: 'line',
  25. data: [5, 20, 36, 10, 10, 20]
  26. }]
  27. };
  28. // 使用刚指定的配置项和数据显示图表。
  29. myChart.setOption(option);
  30. }
  31. componentDidMount(){
  32. this.drawChart('chart1');
  33. this.drawChart('chart2');
  34. }
  35. render() {
  36. const {title,data } = this.props;
  37. return <div className={style['assess-item']}>
  38. <h2>{title}</h2>
  39. <div className={style['item-content']}>
  40. <div className={style["chart-box"]} id={'chart1'}></div>
  41. <div className={style["chart-box"]} id={'chart2'}></div>
  42. </div>
  43. </div>;
  44. }
  45. }
  46. export default ChartItem;