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 = Object.assign({}, 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( 'Bounds', ( 'Number bounds used for color coding from red to green. ' + 'Reverse the number for green to red. To get boolean ' + 'red or green without spectrum, you can use either only ' + 'min, or max, depending on whether small or big should be ' + 'green or red.' ), 'bounds', , )} {this.formRow( 'D3 format', 'D3 format string', 'd3-format', , )}
); } render() { return ( {this.textSummary()}{' '} ); } } TimeSeriesColumnControl.propTypes = propTypes; TimeSeriesColumnControl.defaultProps = defaultProps;