@@ -2,6 +2,7 @@ import React from 'react';
22import { isNumber , round } from 'lodash' ;
33import NoData from 'ui/components/Graphs/NoData' ;
44import numeral from 'numeral' ;
5+ import styled from 'styled-components' ;
56import tooltipFactory from 'react-toolbox/lib/tooltip' ;
67import { Link } from 'react-toolbox/lib/link' ;
78import { getPercentage } from 'ui/utils/defaultTitles' ;
@@ -40,16 +41,34 @@ const resultsIconStyles = {
4041 width : '40px' ,
4142} ;
4243
43- const renderCount = ( { color, count, tooltip, hasBenchmark } ) => (
44+ const ContextLabel = styled . div ( ( ) => ( {
45+ 'font-size' : '20p' ,
46+ 'margin-bottom' : '5px' ,
47+ 'margin-top' : '-10px' ,
48+ 'white-space' : 'nowrap' ,
49+ overflow : 'hidden' ,
50+ 'text-overflow' : 'ellipsis'
51+ } ) ) ;
52+
53+
54+ const renderCount = ( { color, count, tooltip, hasBenchmark, hasContextLabel } ) => (
4455 < TooltipLink
45- style = { { color, height : hasBenchmark ? null : '100%' } }
56+ style = { { color, height : hasBenchmark || hasContextLabel ? null : '100%' } }
4657 label = { formatShortNumber ( count ) }
4758 tooltip = { tooltip }
4859 tooltipPosition = "top"
4960 tooltipDelay = { 600 }
5061 active />
5162) ;
5263
64+ const renderСontextLabel = ( { contextLabel, fontSize, color } ) => (
65+ < ContextLabel
66+ style = { { fontSize, color } }
67+ key = "contextLabel" >
68+ { contextLabel }
69+ </ ContextLabel >
70+ ) ;
71+
5372const renderBenchmark = ( { percentage, model } ) => {
5473 if ( percentage . result === 'N/A' ) {
5574 return percentage . result ;
@@ -73,39 +92,42 @@ const renderBenchmark = ({ percentage, model }) => {
7392 ) ;
7493} ;
7594
76- const getCountFontsize = ( { height, width, hasBenchmark, maxSize } ) => {
77- let fontSize = hasBenchmark ? `${ maxSize / 40 } ` : `${ maxSize / 20 } ` ;
78- const tripHeight = hasBenchmark ? 220 : 150 ;
95+ const getCountFontsize = ( { height, width, hasBenchmark, hasContextLabel , maxSize } ) => {
96+ let fontSize = hasBenchmark || hasContextLabel ? `${ maxSize / 40 } ` : `${ maxSize / 20 } ` ;
97+ const tripHeight = hasBenchmark || hasContextLabel ? 550 : 200 ;
7998 if ( height < tripHeight ) {
80- if ( ! hasBenchmark ) {
99+ if ( ! hasBenchmark && ! hasContextLabel ) {
81100 fontSize = width > 200 ? 4.5 : 3.5 ;
82101 }
83102 } else if ( width < 550 ) {
84103 fontSize = width / 60 ;
104+ console . log ( `fontSize: ${ fontSize } ` ) ;
85105 }
86106 if ( fontSize > 12 ) fontSize = 12 ;
87107 return `${ fontSize } em` ;
88108} ;
89109
90110const renderCounter = ( { color, results, model, height, width } ) => {
91111 const maxSize = Math . min ( height , width ) ;
92- const fontSize = ( width < 332 ) || ( maxSize < 245 ) ? '13px ' : '0.2em ' ;
112+ const fontSize = ( width < 332 ) || ( maxSize < 245 ) ? '18px ' : '0.25em ' ;
93113 const hasBenchmark = results . size > 1 ;
114+ const hasContextLabel = model . get ( 'contextLabel' , '' ) !== '' ;
94115 const benchmarkCount = hasBenchmark ? getBenchmarkResultCount ( results ) : null ;
95116 const count = getResultCount ( results ) ;
96117 const percentage = getPercentage ( count , benchmarkCount ) ;
97118
98119 const tooltip = hasBenchmark ? formatBenchmarkTooltip ( { count, benchmarkCount } ) : formatTooltip ( count ) ;
99- const countFontsize = getCountFontsize ( { height, width, hasBenchmark, maxSize } ) ;
100- const renderedCount = renderCount ( { color, count, tooltip, hasBenchmark } ) ;
120+ const countFontsize = getCountFontsize ( { height, width, hasBenchmark, hasContextLabel , maxSize } ) ;
121+ const renderedCount = renderCount ( { color, count, tooltip, hasBenchmark, hasContextLabel } ) ;
101122 const renderedBenchmark = hasBenchmark ? renderBenchmark ( { percentage, model } ) : null ;
102-
123+ const renderedContextLabel = renderСontextLabel ( { contextLabel : model . get ( 'contextLabel' , '' ) , fontSize , color } ) ;
103124
104125 return (
105126 < div style = { { height : '100%' } } >
106127 < div
107128 style = { { width, fontSize : countFontsize , height : '100%' , textAlign : 'center' } } >
108- { renderedCount }
129+ { renderedCount }
130+ { renderedContextLabel }
109131 < div
110132 key = "benchmark"
111133 style = { {
0 commit comments