UNPKG

@swimlane/ngx-charts

Version:

Declarative Charting Framework for Angular2 and beyond!

64 lines (55 loc) 1.26 kB
import { Component, Input, SimpleChanges, Output, EventEmitter, OnChanges, ChangeDetectionStrategy, HostListener } from '@angular/core'; @Component({ selector: 'g[ngx-charts-circle]', template: ` <svg:circle [attr.cx]="cx" [attr.cy]="cy" [attr.r]="r" [attr.fill]="fill" [attr.stroke]="stroke" [attr.opacity]="circleOpacity" [attr.class]="classNames" [attr.pointer-events]="pointerEvents" /> `, changeDetection: ChangeDetectionStrategy.OnPush }) export class CircleComponent implements OnChanges { @Input() cx; @Input() cy; @Input() r; @Input() fill; @Input() stroke; @Input() data; @Input() classNames; @Input() circleOpacity; @Input() pointerEvents; @Output() select = new EventEmitter(); @Output() activate = new EventEmitter(); @Output() deactivate = new EventEmitter(); @HostListener('click') onClick() { this.select.emit(this.data); } @HostListener('mouseenter') onMouseEnter(): void { this.activate.emit(this.data); } @HostListener('mouseleave') onMouseLeave(): void { this.deactivate.emit(this.data); } ngOnChanges(changes: SimpleChanges): void { this.classNames = this.classNames.join(' ') + 'circle'; } }