Skip to content

Commit

Permalink
Appended scatter chart in demo project
Browse files Browse the repository at this point in the history
  • Loading branch information
RinMinase committed May 26, 2021
1 parent 304403c commit 5149e59
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
13 changes: 12 additions & 1 deletion demo/src/app/scatter-chart/scatter-chart.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<p>
scatter-chart works!
<canvas baseChart
chartType="scatter"
[datasets]="chartData"
[options]="chartOptions">
</canvas>

<button mat-button
mat-raised-button
color="primary"
(click)="randomizer()">
Randomize
</button>
</p>
35 changes: 31 additions & 4 deletions demo/src/app/scatter-chart/scatter-chart.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
import { Component, OnInit } from "@angular/core";
import { Component } from "@angular/core";
import { ChartDatasets, ChartOptions } from "@rinminase/ng-charts";

import { AppService } from "@app/app.service";

@Component({
selector: "app-scatter-chart",
templateUrl: "./scatter-chart.component.html",
})
export class ScatterChartComponent implements OnInit {
constructor() {}
export class ScatterChartComponent {
chartOptions: ChartOptions = {
responsive: true,
};

chartData: ChartDatasets = [
{
data: [
{ x: 1, y: 1 },
{ x: 2, y: 3 },
{ x: 3, y: -2 },
{ x: 4, y: 4 },
{ x: 5, y: -3 },
],
label: "Series A",
pointRadius: 10,
},
];

constructor(private service: AppService) {}

ngOnInit(): void {}
// Disregard this function, as this just randomizes the values in an array
randomizer(): void {
this.chartData[0].data = this.service.randomize(
this.chartData[0].data,
"scatter",
);
}
}

0 comments on commit 5149e59

Please sign in to comment.