import React from 'react'; export default class CircleGauge extends React.Component { constructor(props) { super(props); this.state = {}; } // close constructor render () { const values = this.props.values || [ 15 , 35, 20, 30 ]; const colors = this.props.colorMap || [ "#900", "#090", "#009", "#ff0" ] const startingOffset = 25; let currentSum = 0; const getOffset = function(value) { let thisOffset; if (currentSum == 0) { thisOffset = startingOffset; } else { thisOffset = (100 - currentSum) + startingOffset; } currentSum += value; return thisOffset; } // close getOffset function generateQuickGuid() { return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); } // close generateQuickGuid const thisID = this.props.id || generateQuickGuid(); return ( { values.map( (value, index) => { const thisOffset = getOffset(value); return ( ) }) } ); // return } // close render } // close CircleGauge