diff options
Diffstat (limited to 'server/sonar-web/src/main/js/components/charts/word-cloud.js')
-rw-r--r-- | server/sonar-web/src/main/js/components/charts/word-cloud.js | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/server/sonar-web/src/main/js/components/charts/word-cloud.js b/server/sonar-web/src/main/js/components/charts/word-cloud.js index bb7beaad8a6..b9fbaeb2959 100644 --- a/server/sonar-web/src/main/js/components/charts/word-cloud.js +++ b/server/sonar-web/src/main/js/components/charts/word-cloud.js @@ -30,7 +30,7 @@ export const Word = React.createClass({ link: React.PropTypes.string.isRequired }, - render () { + render() { let tooltipAttrs = {}; if (this.props.tooltip) { tooltipAttrs = { @@ -38,7 +38,11 @@ export const Word = React.createClass({ 'title': this.props.tooltip }; } - return <a {...tooltipAttrs} style={{ fontSize: this.props.size }} href={this.props.link}>{this.props.text}</a>; + return ( + <a {...tooltipAttrs} style={{ fontSize: this.props.size }} href={this.props.link}> + {this.props.text} + </a> + ); } }); @@ -50,28 +54,32 @@ export const WordCloud = React.createClass({ mixins: [TooltipsMixin], - getDefaultProps () { + getDefaultProps() { return { sizeRange: [10, 24] }; }, - render () { + render() { const len = this.props.items.length; const sortedItems = sortBy(this.props.items, (item, idx) => { const index = len - idx; - return (index % 2) * (len - index) + index / 2; + return index % 2 * (len - index) + index / 2; }); - const sizeScale = d3.scale.linear() - .domain([0, d3.max(this.props.items, d => d.size)]) - .range(this.props.sizeRange); - const words = sortedItems - .map((item, index) => <Word key={index} - text={item.text} - size={sizeScale(item.size)} - link={item.link} - tooltip={item.tooltip}/>); + const sizeScale = d3.scale + .linear() + .domain([0, d3.max(this.props.items, d => d.size)]) + .range(this.props.sizeRange); + const words = sortedItems.map((item, index) => ( + <Word + key={index} + text={item.text} + size={sizeScale(item.size)} + link={item.link} + tooltip={item.tooltip} + /> + )); return <div className="word-cloud">{words}</div>; } }); |