/**
 * Created by baoyinghai on 5/26/17.
 */
import React from 'react';
import Setting from './setting';
import './chart-sum.less';


export default class MXSum extends React.Component {

  processData = () => {
    const { dataSource, chartSetting = {} } = this.props;
    const { column } = chartSetting;
    return dataSource.reduce((sum, row) => sum + row[column], 0);
  };

  render() {
    let data = this.processData();
    // if (isNaN(data)) {
    //   data = '请修改配置！';
    // }
    return (
      <div className="chart-sum-wrapper">
        <span>{data}</span>
      </div>
    );
  }
}

export const SumSetting = Setting;