1414import React , { Component } from 'react' ;
1515import * as d3 from 'd3' ;
1616
17- const colors = [ '#2C4870' , '#519331' , '#AA5039' , '#8B2F5F' , '#C5B738' , '#858DFF' , '#FF8D02' , '#FFCD51' , '#ACDAE6' , '#FC997E' , '#CF93AD' , '#AA3939' , '#AA6C39' , '#226666' , ]
17+ const colors = [ '#2C4870' , '#519331' , '#AA5039' , '#8B2F5F' , '#C5B738' , '#858DFF' , '#FF8D02' , '#FFCD51' , '#ACDAE6' , '#FC997E' , '#CF93AD' , '#AA3939' , '#AA6C39' , '#226666' ] ;
1818
1919let root = { } ;
2020class Chart extends Component {
@@ -34,7 +34,7 @@ class Chart extends Component {
3434 componentDidUpdate ( ) {
3535 const { hierarchy } = this . props ;
3636 root = JSON . parse ( JSON . stringify ( hierarchy ) ) ;
37- console . log ( " Chart -> componentDidUpdate -> hierarchy" , hierarchy ) ;
37+ console . log ( ' Chart -> componentDidUpdate -> hierarchy' , hierarchy ) ;
3838 this . maked3Tree ( ) ;
3939 }
4040
@@ -46,7 +46,6 @@ class Chart extends Component {
4646 }
4747
4848 maked3Tree ( ) {
49-
5049 this . removed3Tree ( ) ;
5150 // const margin = {
5251 // top: 0,
@@ -76,9 +75,9 @@ class Chart extends Component {
7675 const tree = d3 . tree ( )
7776 // this assigns width of tree to be 2pi
7877 // .size([2 * Math.PI, radius / 1.3])
79- . nodeSize ( [ width / 10 , height / 10 ] )
78+ . nodeSize ( [ width / 10 , height / 10 ] )
8079 // .separation(function (a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
81- . separation ( function ( a , b ) { return ( a . parent == b . parent ? 2 : 2 ) } ) ;
80+ . separation ( function ( a , b ) { return ( a . parent == b . parent ? 2 : 2 ) ; } ) ;
8281
8382 const d3root = tree ( hierarchy ) ;
8483
@@ -92,9 +91,7 @@ class Chart extends Component {
9291 . append ( 'path' )
9392 . attr ( 'class' , 'link' )
9493 . attr ( 'd' , d3 . linkRadial ( )
95- . angle ( d => {
96- return d . x
97- } )
94+ . angle ( d => d . x )
9895 . radius ( d => d . y ) ) ;
9996
10097 const node = g . selectAll ( '.node' )
@@ -103,15 +100,14 @@ class Chart extends Component {
103100 . enter ( )
104101 . append ( 'g' )
105102 . style ( 'fill' , function ( d ) {
106- if ( d . data . branch < colors . length ) {
107- return colors [ d . data . branch ]
108- } else {
109- let indexColors = d . data . branch - colors . length ;
110- while ( indexColors > colors . length ) {
111- indexColors = indexColors - colors . length ;
112- }
113- return colors [ indexColors ]
103+ if ( d . data . branch < colors . length ) {
104+ return colors [ d . data . branch ] ;
105+ }
106+ let indexColors = d . data . branch - colors . length ;
107+ while ( indexColors > colors . length ) {
108+ indexColors -= colors . length ;
114109 }
110+ return colors [ indexColors ] ;
115111 } )
116112 . attr ( 'class' , 'node--internal' )
117113 // })
@@ -176,7 +172,7 @@ class Chart extends Component {
176172
177173 chartContainer . call ( d3 . zoom ( )
178174 . extent ( [ [ 0 , 0 ] , [ width , height ] ] )
179- . scaleExtent ( [ 0 , 8 ] ) //scaleExtent([minimum scale factor, maximum scale factor])
175+ . scaleExtent ( [ 0 , 8 ] ) // scaleExtent([minimum scale factor, maximum scale factor])
180176 . on ( 'zoom' , zoomed ) ) ;
181177
182178 function dragstarted ( ) {
0 commit comments