Skip to content

Commit

Permalink
#38: small code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
m4nv3ru committed Apr 13, 2022
1 parent 0881e82 commit 8230a85
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ export default class BubbleChart extends React.Component {
constructor(props) {
super(props);
this.styles = _.assign({}, chartStyle);
const { width, height } = this.props;

this.state = {
componentMounted: false,
content: this.props.content,
colors: this.createColorSchema(_.map(this.props.content, 'id')),
width: this.props.width || 0,
height: this.props.height || 0
width: width || 0,
height: height || 0
};
window.addEventListener('resize', () => this.visualizeChart());
}
Expand Down Expand Up @@ -87,12 +89,14 @@ export default class BubbleChart extends React.Component {
return;
}

const bubbleArea = d3.select(this.bubbleAreaRef);
const { hierarchy, pack, select } = d3;

const bubbleArea = select(this.bubbleAreaRef);
bubbleArea.selectAll('a').remove();

const { clientWidth, clientHeight } = this.svgRef;
const layout = d3.pack().size([clientWidth, clientHeight]);
const root = d3.hierarchy({ children: this.state.content }).sum(d => d.activity);
const layout = pack().size([clientWidth, clientHeight]);
const root = hierarchy({ children: this.state.content }).sum(d => d.activity);
layout(root);

const leaf = bubbleArea.selectAll('a').data(root.leaves()).join('a').attr('transform', d => `translate(${d.x},${d.y})`);
Expand Down

0 comments on commit 8230a85

Please sign in to comment.