import React from 'react'; import PropTypes from 'prop-types'; import { Row, Col, FormControl, OverlayTrigger, Popover, } from 'react-bootstrap'; import Select from 'react-select'; import InfoTooltipWithTrigger from '../../../components/InfoTooltipWithTrigger'; import BoundsControl from './BoundsControl'; const propTypes = { onChange: PropTypes.func, }; const defaultProps = { onChange: () => {}, }; const comparisonTypeOptions = [ { value: 'value', label: 'Actual value' }, { value: 'diff', label: 'Difference' }, { value: 'perc', label: 'Percentage' }, { value: 'perc_change', label: 'Percentage Change' }, ]; const colTypeOptions = [ { value: 'time', label: 'Time Comparison' }, { value: 'contrib', label: 'Contribution' }, { value: 'spark', label: 'Sparkline' }, { value: 'avg', label: 'Period Average' }, ]; export default class TimeSeriesColumnControl extends React.Component { constructor(props) { super(props); const state = { ...props }; delete state.onChange; this.state = state; this.onChange = this.onChange.bind(this); } onChange() { this.props.onChange(this.state); } onSelectChange(attr, opt) { this.setState({ [attr]: opt.value }, this.onChange); } onTextInputChange(attr, event) { this.setState({ [attr]: event.target.value }, this.onChange); } onBoundsChange(bounds) { this.setState({ bounds }, this.onChange); } setType() { } textSummary() { return `${this.state.label}`; } edit() { } formRow(label, tooltip, ttLabel, control) { return ( {`${label} `} {control} ); } renderPopover() { return (
{this.formRow( 'Label', 'The column header label', 'time-lag', , )} {this.formRow( 'Tooltip', 'Column header tooltip', 'col-tooltip', , )} {this.formRow( 'Type', 'Type of comparison, value difference or percentage', 'col-type', , )} {this.state.colType !== 'spark' && this.formRow( 'Color bounds', ( `Number bounds used for color encoding from red to blue. Reverse the numbers for blue to red. To get pure red or blue, you can enter either only min or max.` ), 'bounds', , )} {this.formRow( 'Number format', 'Optional d3 number format string', 'd3-format', , )} {this.state.colType === 'spark' && this.formRow( 'Date format', 'Optional d3 date format string', 'date-format', , )}
); } render() { return ( {this.textSummary()}{' '} ); } } TimeSeriesColumnControl.propTypes = propTypes; TimeSeriesColumnControl.defaultProps = defaultProps;