File tree 2 files changed +43
-5
lines changed
demo/src/app/scatter-chart
2 files changed +43
-5
lines changed Original file line number Diff line number Diff line change 1
1
< 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 >
3
14
</ p >
Original file line number Diff line number Diff line change 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" ;
2
5
3
6
@Component ( {
4
7
selector : "app-scatter-chart" ,
5
8
templateUrl : "./scatter-chart.component.html" ,
6
9
} )
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 ) { }
9
30
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
+ }
11
38
}
You can’t perform that action at this time.
0 commit comments