'use strict'; var React = require('react'), _ = require('lodash'), styler = require('react-styler'); var ChartLegend2 = React.createClass({ displayName: 'ChartLegend2', propTypes: { series: React.PropTypes.array, colors: React.PropTypes.array, onChange: React.PropTypes.func }, mixins: [styler.mixinFor('ChartLegend2')], getInitialState() { return { toggledOffSeries: [] }; }, handleToggleLine(index) { let toggledOffSeries = _.clone(this.state.toggledOffSeries); let indexIndex = toggledOffSeries.indexOf(index); if (indexIndex !== -1) { toggledOffSeries.splice(indexIndex, 1); } else { toggledOffSeries.push(index); } if (toggledOffSeries.length < this.props.series.length) { this.setState({toggledOffSeries}); this.props.onChange && this.props.onChange(_.clone(toggledOffSeries)); } }, render() { let cn = this.className; let {series, colors, description} = this.props; let {toggledOffSeries} = this.state; return