Skip to content

Commit

Permalink
feat(fishbone): add config for height & width
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 28, 2020
1 parent c4e7586 commit fa95d63
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
10 changes: 8 additions & 2 deletions projects/ledge-render/src/lib/chart/ledge-fish-bone/fishbone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const fishbone = () => {
let dataLinks = [];

const my: any = undefined;
const width = 1200;
const height = 800;
let width = 1200;
let height = 800;

// d3 selections and related things used in tick function
let node;
Expand Down Expand Up @@ -406,6 +406,12 @@ const fishbone = () => {
return my;
};

fb1.setWidthHeight = (w, h) => {
width = w;
height = h;
forceLayout.force('center', d3.forceCenter(width / 2, height / 2))
}

return fb1;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,24 @@ export class LedgeFishBoneComponent implements OnInit, AfterViewInit {

ngAfterViewInit(): void {
const data = this.data[0];
console.log(data);
const fb = fishbone();
let width = 1200;
let height = 800;

if (this.config) {
if (this.config.width) {
width = this.config.width;
}
if (this.config.height) {
height = this.config.height;
}
}

fb.setWidthHeight(width, height);
d3.select(this.chart.nativeElement)
.append('svg')
.attr('width', 1200)
.attr('height', 800)
.attr('width', width)
.attr('height', height)
.datum(data)
.call(fb.defaultArrow)
.call(fb);
Expand Down
7 changes: 7 additions & 0 deletions src/assets/docs/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
- Path to Production
- Feat
- Design
- Pair Review
- Dev
- PrePush
- Code Review
- Test
- Desk Check
- Build
- Deploy
- Operatino
config: {"height": 600, "width": 800}
```

## 读书雷达
Expand Down

0 comments on commit fa95d63

Please sign in to comment.