Skip to content

Commit 5149e59

Browse files
committedMay 26, 2021
Appended scatter chart in demo project
1 parent 304403c commit 5149e59

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
<p>
2-
scatter-chart works!
2+
<canvas baseChart
3+
chartType="scatter"
4+
[datasets]="chartData"
5+
[options]="chartOptions">
6+
</canvas>
7+
8+
<button mat-button
9+
mat-raised-button
10+
color="primary"
11+
(click)="randomizer()">
12+
Randomize
13+
</button>
314
</p>
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
1-
import { Component, OnInit } from "@angular/core";
1+
import { Component } from "@angular/core";
2+
import { ChartDatasets, ChartOptions } from "@rinminase/ng-charts";
3+
4+
import { AppService } from "@app/app.service";
25

36
@Component({
47
selector: "app-scatter-chart",
58
templateUrl: "./scatter-chart.component.html",
69
})
7-
export class ScatterChartComponent implements OnInit {
8-
constructor() {}
10+
export class ScatterChartComponent {
11+
chartOptions: ChartOptions = {
12+
responsive: true,
13+
};
14+
15+
chartData: ChartDatasets = [
16+
{
17+
data: [
18+
{ x: 1, y: 1 },
19+
{ x: 2, y: 3 },
20+
{ x: 3, y: -2 },
21+
{ x: 4, y: 4 },
22+
{ x: 5, y: -3 },
23+
],
24+
label: "Series A",
25+
pointRadius: 10,
26+
},
27+
];
28+
29+
constructor(private service: AppService) {}
930

10-
ngOnInit(): void {}
31+
// Disregard this function, as this just randomizes the values in an array
32+
randomizer(): void {
33+
this.chartData[0].data = this.service.randomize(
34+
this.chartData[0].data,
35+
"scatter",
36+
);
37+
}
1138
}

0 commit comments

Comments
 (0)
Please sign in to comment.