igniteui-webcomponents-charts
Version:
Ignite UI Web Components charting components for building rich data visualizations using TypeScript APIs.
176 lines (175 loc) • 6.74 kB
JavaScript
import { __extends } from "tslib";
import { WebComponentRenderer } from "igniteui-webcomponents-core";
import { TypeRegistrar } from "igniteui-webcomponents-core";
import { IgcPieChartBaseComponent } from './igc-pie-chart-base-component';
import { DataChartStylingDefaults } from './DataChartStylingDefaults';
import { XamPieChart } from './XamPieChart';
import { getAllPropertyNames, toSpinal, NamePatcher } from "igniteui-webcomponents-core";
import { RegisterElementHelper } from "igniteui-webcomponents-core";
export var IgcPieChartComponent = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgcPieChartComponent, _super);
function IgcPieChartComponent() {
var _this = _super.call(this) || this;
_this._disconnected = false;
_this._dataSource = null;
if (_this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this));
}
_this._renderer = new WebComponentRenderer(_this, document, true, DataChartStylingDefaults);
_this._implementation = _this.createImplementation();
_this.container = _this._renderer.createElement("div");
_this._renderer.updateRoot(_this.container);
//this._renderer.rootWrapper.append(this._container);
_this.container.setStyleProperty("display", "block");
_this.container.setStyleProperty("width", "100%");
_this.container.setStyleProperty("height", "100%");
var root;
root = _this.container;
if (_this.container.getNativeElement() != null) {
root = _this.container.getNativeElement();
}
_this._wrapper = _this._renderer;
var chart = _this.i;
_this._chart = chart;
chart.provideContainer(_this._renderer);
_this.bindData();
chart.notifyContainerResized();
_this._renderer.addSizeWatcher(function () {
_this._chart.notifyContainerResized();
});
return _this;
}
Object.defineProperty(IgcPieChartComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
this.style.height = value;
this.notifyContainerResized();
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcPieChartComponent.prototype, "width", {
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
this.style.width = value;
this.notifyContainerResized();
},
enumerable: false,
configurable: true
});
IgcPieChartComponent.prototype.notifyContainerResized = function () {
this._chart.notifyContainerResized();
};
IgcPieChartComponent.prototype.disconnectedCallback = function () {
this._disconnected = true;
if (this.i) {
this.i.onDetachedFromUI();
}
};
IgcPieChartComponent.prototype.connectedCallback = function () {
if (this._disconnected) {
this._disconnected = false;
if (this.i) {
this.i.onAttachedToUI();
}
return;
}
this.classList.add("ig-pie-chart");
this.classList.add("igc-pie-chart");
this.appendChild(this.container.getNativeElement());
this._attached = true;
this.style.display = "block";
this.style.height = this._height;
this.style.width = this._width;
this._flushQueuedAttributes();
// supports themes or custom properties set in CSS
this._styling(this, this);
};
IgcPieChartComponent.prototype.destroy = function () {
this._chart.destroy();
this._wrapper.destroy();
};
IgcPieChartComponent.prototype.createImplementation = function () {
return new XamPieChart();
};
Object.defineProperty(IgcPieChartComponent.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
IgcPieChartComponent.prototype.createSeriesComponent = function (type) {
if (TypeRegistrar.isRegistered(type)) {
var 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);
}
};
Object.defineProperty(IgcPieChartComponent.prototype, "dataSource", {
get: function () {
return this._dataSource;
},
set: function (value) {
this._dataSource = value;
this.bindData();
},
enumerable: false,
configurable: true
});
IgcPieChartComponent.prototype.bindData = function () {
if (this._chart != null && this._chart !== undefined) {
this._chart.itemsSource = this._dataSource;
}
};
Object.defineProperty(IgcPieChartComponent.prototype, "legend", {
/**
* Gets or sets the legend used for the current chart.
*/
get: function () {
if (this.i.legend != null)
return this.i.legend.externalObject;
},
set: function (v) {
if (v != undefined && v != null)
this.i.legend = v.i;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgcPieChartComponent, "observedAttributes", {
get: function () {
if (IgcPieChartComponent._observedAttributesIgcPieChartComponent == null) {
var names = getAllPropertyNames(IgcPieChartComponent);
for (var i = 0; i < names.length; i++) {
names[i] = toSpinal(names[i]);
}
IgcPieChartComponent._observedAttributesIgcPieChartComponent = names;
}
return IgcPieChartComponent._observedAttributesIgcPieChartComponent;
},
enumerable: false,
configurable: true
});
IgcPieChartComponent.register = function () {
if (!IgcPieChartComponent._isElementRegistered) {
IgcPieChartComponent._isElementRegistered = true;
RegisterElementHelper.registerElement(IgcPieChartComponent.htmlTagName, IgcPieChartComponent);
}
};
IgcPieChartComponent._observedAttributesIgcPieChartComponent = null;
IgcPieChartComponent.htmlTagName = "igc-pie-chart";
IgcPieChartComponent._isElementRegistered = false;
return IgcPieChartComponent;
}(IgcPieChartBaseComponent));