@@ -6,6 +6,7 @@ import Lollipop, {lollipopSpec} from './components/Lollipop'
66import Domain , { domainSpec } from './components/Domain'
77import SVGAxis from './components/SVGAxis'
88import Tooltip from './components/Tooltip'
9+ import Legend from './components/Legend'
910
1011const LOLLIPOP_ID_CLASS_PREFIX = 'lollipop-'
1112const DOMAIN_ID_CLASS_PREFIX = 'domain-'
@@ -193,57 +194,8 @@ class LollipopPlot extends React.Component {
193194 return ( this . props . lollipops . find ( lollipop => ( lollipop . count > this . yMax ( ) ) ) ? '>= ' : '' ) + this . yMax ( )
194195 }
195196
196- renderDomainLegendItems = ( uniqueDomains ) => {
197- return uniqueDomains . map ( ( d , idx ) => {
198- return (
199- < React . Fragment >
200- < rect
201- fill = { d . color }
202- x = { 770 }
203- y = { 32 + ( 15 * idx ) + 'px' }
204- width = { 10 }
205- height = { 10 }
206- />
207- < text
208- x = { 785 }
209- y = { 40 + ( 15 * idx ) + 'px' }
210- style = { {
211- fontSize : '11px' ,
212- fontFamily : 'arial'
213- } }
214- >
215- { d . label }
216- </ text >
217- </ React . Fragment > )
218- } )
219- }
220-
221- pfamDomainsLegend = ( ) => {
222- const { domains} = this . props
223- const uniqueDomains = Array . from ( new Set ( domains . map ( d => d . label ) ) )
224- . map ( label => ( {
225- label : label ,
226- color : domains . find ( d => d . label === label ) . color
227- } ) )
228- return (
229- < g >
230- < text x = '770'
231- y = '20'
232- style = { {
233- fontSize : '12px' ,
234- fontWeight : 'bold' ,
235- fontFamily : 'arial' ,
236- fill : '#333'
237- } }
238- >
239- Pfam domains:
240- </ text >
241- { this . renderDomainLegendItems ( uniqueDomains ) }
242- </ g >
243- )
244- }
245-
246197 render ( ) {
198+ const { domains} = this . props
247199 return (
248200 < React . Fragment >
249201 < svg xmlns = 'http://www.w3.org/2000/svg' width = { this . svgWidth ( ) + 200 } height = { this . svgHeight ( ) }
@@ -267,7 +219,7 @@ class LollipopPlot extends React.Component {
267219 />
268220 { this . lollipops ( ) }
269221 { this . domains ( ) }
270- { this . pfamDomainsLegend ( ) }
222+ < Legend domains = { domains } />
271223 < SVGAxis
272224 key = 'horz'
273225 x = { this . geneX ( ) }
0 commit comments