huridocs/uwazi

View on GitHub
app/react/Charts/components/ColoredBar.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import React from 'react';
import PropTypes from 'prop-types';
import { Rectangle } from 'recharts';

import colorScheme, { light as colorSchemeLight } from '../utils/colorScheme';

const ColoredBar = props => {
  const { index, color } = props;
  const colorPallete = color !== 'light' ? colorScheme : colorSchemeLight;
  return <Rectangle {...props} stroke="none" fill={colorPallete[index % colorScheme.length]} />;
};

ColoredBar.defaultProps = {
  color: 'default',
  index: 0,
};

ColoredBar.propTypes = {
  color: PropTypes.string,
  index: PropTypes.number,
};

export default ColoredBar;