mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-01-23 09:46:10 +01:00
174 lines
4.7 KiB
TypeScript
174 lines
4.7 KiB
TypeScript
import { AfterViewInit, Component, Input } from '@angular/core';
|
|
import { NbThemeService } from '@nebular/theme';
|
|
|
|
declare const echarts: any;
|
|
|
|
@Component({
|
|
selector: 'ngx-solar',
|
|
styleUrls: ['./solar.component.scss'],
|
|
template: `
|
|
<div echarts [options]="option" class="echart">
|
|
</div>
|
|
<div class="info">
|
|
<div class="date">June 7, 2017</div>
|
|
<div class="value">6. 421 kWh</div>
|
|
<div class="details"><span>out of</span> 8.421 kWh</div>
|
|
</div>
|
|
`,
|
|
})
|
|
export class SolarComponent implements AfterViewInit {
|
|
|
|
private value: number = 0;
|
|
|
|
@Input('chartValue')
|
|
set chartValue(value: number) {
|
|
this.value = value;
|
|
if (this.option.series) {
|
|
this.option.series[0].data[0].value = value;
|
|
this.option.series[0].data[1].value = 100 - value;
|
|
this.option.series[1].data[0].value = value;
|
|
}
|
|
}
|
|
|
|
option: any = {};
|
|
|
|
constructor(private theme: NbThemeService) {
|
|
}
|
|
|
|
ngAfterViewInit() {
|
|
this.theme.getJsTheme().delay(1).subscribe(config => {
|
|
|
|
const solarTheme: any = config.variables.solar;
|
|
|
|
this.option = Object.assign({}, {
|
|
tooltip: {
|
|
trigger: 'item',
|
|
formatter: '{a} <br/>{b} : {c} ({d}%)',
|
|
},
|
|
series: [
|
|
{
|
|
name: ' ',
|
|
clockWise: true,
|
|
hoverAnimation: false,
|
|
type: 'pie',
|
|
center: ['35%', '50%'],
|
|
radius: solarTheme.radius,
|
|
data: [
|
|
{
|
|
value: this.value,
|
|
name: ' ',
|
|
label: {
|
|
normal: {
|
|
position: 'center',
|
|
formatter: '{d}%',
|
|
textStyle: {
|
|
fontSize: '22',
|
|
fontFamily: config.variables.fontSecondary,
|
|
color: config.variables.colorFgHeading,
|
|
},
|
|
},
|
|
},
|
|
tooltip: {
|
|
show: false,
|
|
},
|
|
itemStyle: {
|
|
normal: {
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
{
|
|
offset: 0,
|
|
color: solarTheme.gradientLeft,
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: solarTheme.gradientRight,
|
|
},
|
|
]),
|
|
shadowColor: solarTheme.shadowColor,
|
|
shadowBlur: 0,
|
|
shadowOffsetX: 0,
|
|
shadowOffsetY: 3,
|
|
},
|
|
},
|
|
hoverAnimation: false,
|
|
},
|
|
{
|
|
value: 100 - this.value,
|
|
name: ' ',
|
|
tooltip: {
|
|
show: false,
|
|
},
|
|
label: {
|
|
normal: {
|
|
position: 'inner',
|
|
},
|
|
},
|
|
itemStyle: {
|
|
normal: {
|
|
color: config.variables.layoutBg,
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: ' ',
|
|
clockWise: true,
|
|
hoverAnimation: false,
|
|
type: 'pie',
|
|
center: ['35%', '50%'],
|
|
radius: solarTheme.radius,
|
|
data: [
|
|
{
|
|
value: this.value,
|
|
name: ' ',
|
|
label: {
|
|
normal: {
|
|
position: 'inner',
|
|
show: false,
|
|
},
|
|
},
|
|
tooltip: {
|
|
show: false,
|
|
},
|
|
itemStyle: {
|
|
normal: {
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
{
|
|
offset: 0,
|
|
color: solarTheme.gradientLeft,
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: solarTheme.gradientRight,
|
|
},
|
|
]),
|
|
shadowColor: solarTheme.shadowColor,
|
|
shadowBlur: 7,
|
|
},
|
|
},
|
|
hoverAnimation: false,
|
|
},
|
|
{
|
|
value: 28,
|
|
name: ' ',
|
|
tooltip: {
|
|
show: false,
|
|
},
|
|
label: {
|
|
normal: {
|
|
position: 'inner',
|
|
},
|
|
},
|
|
itemStyle: {
|
|
normal: {
|
|
color: 'none',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
});
|
|
});
|
|
}
|
|
}
|