igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
148 lines (147 loc) • 5.04 kB
JavaScript
import { __extends } from "tslib";
import * as React from 'react';
import { ReactRenderer } from "igniteui-react-core";
import { TypeRegistrar } from "igniteui-react-core";
import { IgrPieChartBase } from './igr-pie-chart-base';
import { DataChartStylingDefaults } from './DataChartStylingDefaults';
import { XamPieChart } from './XamPieChart';
import { NamePatcher } from "igniteui-react-core";
var IgrPieChart = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgrPieChart, _super);
function IgrPieChart(props) {
var _this = _super.call(this, props) || this;
_this._dataSource = null;
if (_this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this));
}
_this._getMainRef = _this._getMainRef.bind(_this);
var container;
if (document) {
container = document.createElement("div");
container.style.display = "block";
container.style.width = "100%";
container.style.height = "100%";
}
var root;
root = container;
var ren = new ReactRenderer(root, document, true, DataChartStylingDefaults);
_this.container = ren.getWrapper(container);
_this._wrapper = ren;
var chart = _this.i;
_this._chart = chart;
chart.provideContainer(ren);
_this.bindData();
chart.notifyContainerResized();
ren.addSizeWatcher(function () {
_this._chart.notifyContainerResized();
});
return _this;
}
Object.defineProperty(IgrPieChart.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
if (this._elRef) {
this._elRef.style.height = value;
this._chart.notifyContainerResized();
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrPieChart.prototype, "width", {
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
if (this._elRef) {
this._elRef.style.width = value;
this._chart.notifyContainerResized();
}
},
enumerable: false,
configurable: true
});
IgrPieChart.prototype._getMainRef = function (ref) {
this._elRef = ref;
};
IgrPieChart.prototype.render = function () {
var div = React.createElement("div", {
className: "ig-pie-chart igr-pie-chart",
ref: this._getMainRef
});
return div;
};
IgrPieChart.prototype.destroy = function () {
this._chart.destroy();
this._wrapper.destroy();
};
IgrPieChart.prototype.componentDidMount = function () {
_super.prototype.componentDidMount.call(this);
this._elRef.style.width = this._width ? this._width : "";
this._elRef.style.height = this._height ? this._height : "";
this._elRef.appendChild(this.container.getNativeElement());
this._styling(this._elRef, this);
this._chart.notifyContainerResized();
};
IgrPieChart.prototype.componentWillUnmount = function () {
};
IgrPieChart.prototype.createImplementation = function () {
return new XamPieChart();
};
Object.defineProperty(IgrPieChart.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
IgrPieChart.prototype.createSeriesComponent = function (type) {
if (TypeRegistrar.isRegistered(type)) {
var s = TypeRegistrar.create(type);
s.owner = this;
s._provideRenderer(this._wrapper);
return s;
}
else {
//we shouldn't get here, hopefully.
throw Error("series type not loaded: " + type);
}
};
Object.defineProperty(IgrPieChart.prototype, "dataSource", {
get: function () {
return this._dataSource;
},
set: function (value) {
this._dataSource = value;
this.bindData();
},
enumerable: false,
configurable: true
});
IgrPieChart.prototype.bindData = function () {
if (this._chart != null && this._chart !== undefined) {
this._chart.itemsSource = this._dataSource;
}
};
Object.defineProperty(IgrPieChart.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
});
return IgrPieChart;
}(IgrPieChartBase));
export { IgrPieChart };