Skip to content

Commit

Permalink
feat: make basic works
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 28, 2020
1 parent d6f35cc commit bd7a2d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
20 changes: 7 additions & 13 deletions projects/ledge-render/src/lib/chart/ledge-fish-bone/fishbone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ const fishbone = () => {
// .on('tick', _tick);

const forceLayout = d3.forceSimulation()
// .force("charge", d3.forceManyBody().strength(10))
.force("x", d3.forceX(width / 2).strength(1))
.force("y", d3.forceY(height / 2).strength(1))
.force("center", d3.forceCenter(width / 2, height / 2))
.force('center', d3.forceCenter(width / 2, height / 2))
.force('link', d3.forceLink().distance(_linkDistance))
.on('tick', ticked);

Expand Down Expand Up @@ -109,9 +106,8 @@ const fishbone = () => {

// create the links
link = $.selectAll('.link')
.data(dataLinks);

link.enter()
.data(dataLinks)
.enter()
.append('line')
.attr('class', (d) => {
return 'link link-' + d.depth;
Expand All @@ -123,11 +119,9 @@ const fishbone = () => {
link.exit().remove();

// establish the node selection
node = $.selectAll('.node').data(dataNodes);


// actually create nodes
node.enter().append('g')
node = $.selectAll('.node')
.data(dataNodes)
.enter().append('g')
.attr('class',
(d) => {
return 'node' + (d.root ? ' root' : '');
Expand Down Expand Up @@ -328,7 +322,7 @@ const fishbone = () => {
dataNodes.forEach(d => {
// handle the middle... could probably store the root width...
if (d.root) {
// d.x = width - (marginSize + d.root.getBBox().width);
d.x = width - (marginSize + root.getBBox().width);
}
if (d.tail) {
d.x = marginSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export class LedgeFishBoneComponent implements OnInit, AfterViewInit {
const fb = fishbone();
d3.select(this.chart.nativeElement)
.append('svg')
.attr('width', 1200).attr('height', 800)
.attr('width', 1200)
.attr('height', 800)
.datum(data)
.call(fb.defaultArrow)
.call(fb);
Expand Down

0 comments on commit bd7a2d3

Please sign in to comment.