uv-charts-dashboard
Version:
A dashboard for uvCharts examples
81 lines (71 loc) • 2.18 kB
text/typescript
import { Component, Input, OnInit } from '@angular/core';
import { CommonService } from '../../shared/common.service';
export class LineChartComponent implements OnInit {
private uv: any;
private data: any;
private text: any;
private metaData: {};
compress: boolean;
constructor(private commonService: CommonService) {
this.uv = commonService.uv;
}
ngOnInit() {
this.commonService.getRealTimeData().subscribe((data) => { this.data = data; this.makeChart(this.data) });
this.commonService.getDetails().subscribe((data) => { this.text = data; });
}
makeChart(data: {}) {
this.metaData = {
graph: {
orientation: 'Vertical'
},
dimension: {
height: 200,
width: 400
},
label: {
precision: 100
},
meta: {
position: '#line-chart-div',
caption: 'Production of Vegetables',
hlabel: 'Years',
vlabel: 'Production',
vsublabel: 'in \'000 tonne'
},
axis: {
showsubticks: false
}
};
if (this.compress) {
this.metaData = {
graph: {
orientation: 'Vertical'
},
margin: {
left: 10,
right: 10,
bottom: 10
},
dimension: {
height: 200,
width: 200
},
label: {
precision: 100
},
meta: {
position: '#line-chart-div',
},
axis: {
showtext: false
}
};
}
this.uv.chart('line', data, this.metaData);
}
}