src/app/manage-learn/shared/components/scatter-chart/scatter-chart.component.ts
OnInit
selector | scatter-chart |
styleUrls | ./scatter-chart.component.scss |
templateUrl | ./scatter-chart.component.html |
Properties |
Methods |
Inputs |
data | |
Type : any
|
|
questionNumber | |
Type : any
|
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
chartConstructor |
Type : string
|
Default value : 'chart'
|
chartObj |
oneToOneFlag |
Default value : true
|
runOutsideAngular |
Default value : false
|
updateFlag |
Default value : false
|
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'scatter-chart',
templateUrl: './scatter-chart.component.html',
styleUrls: ['./scatter-chart.component.scss'],
})
export class ScatterChartComponent implements OnInit {
@Input() data;
@Input() questionNumber;
chartConstructor = 'chart'; // optional string, defaults to 'chart'
updateFlag = false; // optional boolean
oneToOneFlag = true; // optional boolean, defaults to false
runOutsideAngular = false;
chartObj;
ngOnInit() {
if (this.data && this.data.chart && this.data.chart.data) {
for (const outer of this.data.chart.data) {
for (const inner of outer.data) {
inner.y = parseInt(inner.y);
}
}
}
this.chartObj = {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'scatter',
},
xAxis: this.data.chart.xAxis,
yAxis: this.data.chart.yAxis,
title: {
text: ' ',
},
tooltip: {
// pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
scatter: {
lineWidth: 2,
},
},
credits: {
enabled: false,
},
legend: {
enabled: false,
},
series: this.data ? this.data.chart.data : null,
};
setTimeout(() => {
}, 1000);
}
}
<div *ngIf="chartObj">
<div class="heading" *ngIf="data?.question">
<h4>{{ questionNumber }}) {{ data?.question }}</h4>
</div>
<div *ngIf="data?.schoolName">
<h4 style="padding: 10px">{{ questionNumber }}. {{ data?.schoolName }}</h4>
</div>
<div *ngIf="data?.chart?.data">
<div id="{{ 'container' + questionNumber }}"></div>
</div>
<div class="errorMsg" *ngIf="!data?.chart?.data">No data found</div>
</div>
./scatter-chart.component.scss