Skip to content

Commit bb6d75c

Browse files
committed
Initial commit for YAML download button in circular heatmap
1 parent 25e9205 commit bb6d75c

5 files changed

Lines changed: 80 additions & 16 deletions

File tree

package-lock.json

Lines changed: 59 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@angular/platform-browser-dynamic": "~13.3.0",
2222
"@angular/router": "~13.3.0",
2323
"d3": "^7.5.0",
24+
"js-yaml": "^4.1.0",
2425
"markdown-it": "^13.0.1",
2526
"rxjs": "~7.5.0",
2627
"tslib": "^2.3.0",
@@ -33,6 +34,7 @@
3334
"@angular/compiler-cli": "~13.3.0",
3435
"@types/d3": "^7.4.0",
3536
"@types/jasmine": "~3.10.0",
37+
"@types/js-yaml": "^4.0.5",
3638
"@types/markdown-it": "^12.2.3",
3739
"@types/node": "^12.11.1",
3840
"@types/yamljs": "^0.2.31",

src/app/component/circular-heatmap/circular-heatmap.component.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
stroke: #000;
88
shape-rendering: crispEdges;
99
}
10-
.abc{
10+
.heatmapClass{
1111
background-color: aquamarine;
1212
}
1313
.example-card {
@@ -16,3 +16,7 @@
1616
margin:5%;
1717
padding: 20px;
1818
}
19+
.buttonClass{
20+
float: right;
21+
margin: 5%;
22+
}

src/app/component/circular-heatmap/circular-heatmap.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="col-md-3">
44
</div>
55
<div class="col-md-6">
6-
<div id="chart" class="abc">
6+
<div id="chart" class="heatmapClass">
77
<mat-card class="example-card" *ngIf="showTaskCard">
88
<mat-card-title-group>
99
<mat-card-title>{{taskHeader}}</mat-card-title>
@@ -25,8 +25,8 @@
2525
</p>
2626
</mat-card-content>
2727
</mat-card>
28-
</div>
29-
28+
<button class="buttonClass" (click)="SaveDemo()">Save As</button>
29+
</div>
3030
</div>
3131
<div class="col-md-3">
3232
</div>

src/app/component/circular-heatmap/circular-heatmap.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22
import { ymlService } from '../../service/yaml-parser/yaml-parser.service';
33
import * as d3 from 'd3';
4+
import * as yaml from "js-yaml"
45

56
export interface taskSchema{
67
taskName:string
@@ -124,6 +125,16 @@ export class CircularHeatmapComponent implements OnInit {
124125

125126
}
126127

128+
SaveDemo() {
129+
let yamlStr = yaml.dump(this.YamlObject);
130+
let file = new Blob([yamlStr], { type: 'text/csv;charset=utf-8' });
131+
var link = document.createElement('a');
132+
link.href = window.URL.createObjectURL(file);
133+
link.download = './hlll.txt'
134+
link.click();
135+
link.remove();
136+
}
137+
127138
loadCircularHeatMap(dataset:any, dom_element_to_append_to:string, radial_labels:string[], segment_labels:string[]) {
128139
//d3.select(dom_element_to_append_to).selectAll('svg').exit()
129140
//console.log(dataset)

0 commit comments

Comments
 (0)