igniteui-angular-charts
Version:
Ignite UI Angular charting components for building rich data visualizations for modern web apps.
133 lines (132 loc) • 5.8 kB
JavaScript
import { Component, ChangeDetectionStrategy, ViewChild, ViewContainerRef, Input, NgZone, Renderer2, Injector } from '@angular/core';
import { AngularRenderer } from "igniteui-angular-core";
import { TypeRegistrar } from "igniteui-angular-core";
import { IgxPieChartBaseComponent } from './igx-pie-chart-base-component';
import { DataChartStylingDefaults } from './DataChartStylingDefaults';
import { XamPieChart } from './XamPieChart';
import { NamePatcher } from "igniteui-angular-core";
import * as i0 from "@angular/core";
/**
* Represents Infragistics IgxPieChartComponent control.
*/
export class IgxPieChartComponent extends IgxPieChartBaseComponent {
set height(value) {
this._height = value;
this.renderer.setStyle(this._elRef.element.nativeElement, "height", value);
this._chart.notifyContainerResized();
}
get height() {
return this._height;
}
set width(value) {
this._width = value;
this.renderer.setStyle(this._elRef.element.nativeElement, "width", value);
this._chart.notifyContainerResized();
}
get width() {
return this._width;
}
constructor(renderer, _elRef, ngZone, injector) {
super();
this.renderer = renderer;
this._elRef = _elRef;
this.ngZone = ngZone;
this.injector = injector;
this._root = null;
this._dataSource = null;
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
this._zoneRunner = (act) => ngZone.run(act);
this.container = renderer.createElement("div");
renderer.appendChild(_elRef.element.nativeElement, this.container);
renderer.setStyle(this.container, "display", "block");
renderer.setStyle(this.container, "width", "100%");
renderer.setStyle(this.container, "height", "100%");
var root;
root = this.container;
if (this.container != null) {
root = this.container;
}
this._root = root;
var ren = new AngularRenderer(root, this.renderer, window.document, this.ngZone, true, DataChartStylingDefaults);
this._wrapper = ren;
var chart = this.i;
this._chart = chart;
chart.provideContainer(ren);
this.bindData();
chart.notifyContainerResized();
ren.addSizeWatcher(() => {
this._chart.notifyContainerResized();
});
}
ngAfterViewInit() {
this.updateStyle();
this.i.notifyContainerResized();
}
ngOnDestroy() {
this._chart.destroy();
this._wrapper.destroy();
}
updateStyle() {
this._styling(this._root, this);
}
createImplementation() {
return new XamPieChart();
}
get i() {
return this._implementation;
}
createSeriesComponent(type) {
if (TypeRegistrar.isRegistered(type)) {
let s = TypeRegistrar.create(type);
s.owner = this;
s._provideRenderer(this.renderer);
return s;
}
else {
//we shouldn't get here, hopefully.
throw Error("series type not loaded: " + type);
}
}
set dataSource(value) {
this._dataSource = value;
this.bindData();
}
get dataSource() {
return this._dataSource;
}
bindData() {
if (this._chart != null && this._chart !== undefined) {
this._chart.itemsSource = this._dataSource;
}
}
/**
* Gets or sets the legend used for the current chart.
*/
get legend() {
if (this.i.legend != null)
return this.i.legend.externalObject;
}
set legend(v) {
if (v != undefined && v != null)
this.i.legend = v.i;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0-rc.1", ngImport: i0, type: IgxPieChartComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0-rc.1", type: IgxPieChartComponent, isStandalone: true, selector: "igx-pie-chart", inputs: { height: "height", width: "width", dataSource: "dataSource", legend: "legend" }, host: { classAttribute: "ig-pie-chart igx-pie-chart" }, providers: [], viewQueries: [{ propertyName: "_dynamicContent", first: true, predicate: ["dynamicContent"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, ngImport: i0, template: `<ng-container #dynamicContent></ng-container>`, isInline: true, styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0-rc.1", ngImport: i0, type: IgxPieChartComponent, decorators: [{
type: Component,
args: [{ selector: 'igx-pie-chart', template: `<ng-container #dynamicContent></ng-container>`, changeDetection: ChangeDetectionStrategy.OnPush, providers: [], host: { 'class': 'ig-pie-chart igx-pie-chart' }, styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"] }]
}], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ViewContainerRef }, { type: i0.NgZone }, { type: i0.Injector }], propDecorators: { _dynamicContent: [{
type: ViewChild,
args: ["dynamicContent", { read: ViewContainerRef, static: true }]
}], height: [{
type: Input
}], width: [{
type: Input
}], dataSource: [{
type: Input
}], legend: [{
type: Input
}] } });