/**
 * Created by baoyinghai on 6/22/17.
 */
import React from 'react';
import {Bar} from 'react-chartjs-2';
import { Input } from '../../../../components/mxa';

const data = {
  labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  datasets: [
    {
      label: 'My First dataset',
      backgroundColor: 'rgba(255,99,132,0.2)',
      borderColor: 'rgba(255,99,132,1)',
      borderWidth: 1,
      hoverBackgroundColor: 'rgba(255,99,132,0.4)',
      hoverBorderColor: 'rgba(255,99,132,1)',
      data: [65, 59, 80, 81, 56, 55, 40]
    }
  ]
};

export default class MXBar extends React.Component {

  render() {
    const { width, height } = this.props;
    return (
      <div>
        <Bar data={data} width={width} height={height - 15} options={{ maintainAspectRatio: false}} />
      </div>
    );
  }
}

export const BarSetting = {
  getKeys: keys => keys,
  setFormItems: (key, setting) => {
    return {
      key,
      label: key,
      comp: <Input />,
      initData: (setting && setting[key]) || key
    };
  }
};