igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
149 lines (148 loc) • 4.44 kB
JavaScript
import { __extends } from "tslib";
import * as React from 'react';
import { IgrLegendBase } from './igr-legend-base';
import { Legend } from "./Legend";
import { LegendOrientation_$type } from './LegendOrientation';
import { ReactRenderer } from "igniteui-react-core";
import { DataChartStylingDefaults } from './DataChartStylingDefaults';
import { ensureEnum } from "igniteui-react-core";
/**
* Represents a legend in a IgxDataChartComponent control.
*
* The `Legend` helps end-user identify visuals of chart series with contextual information related to the data plotted in the chart control.
*
* ```ts
* <IgrDataChart
* dataSource={this.data}
* ref={this.onChartRef} width="100%" height="400px">
* <IgrCategoryXAxis name="xAxis" label="Country" />
* <IgrNumericYAxis name="yAxis" minimumValue={0} />
*
* <IgrLegend ref={this.onLegendRef}
* orientation="Horizontal" />
* ```
*
* ```ts
* public onChartRef(chart: IgrDataChart) {
* this.chart = chart;
* if (this.legend) {
* this.chart.legend = this.legend;
* }
* }
*
* public onLegendRef(legend: IgrLegend) {
* this.legend = legend;
* if (this.chart) {
* this.chart.legend = this.legend;
* }
* }
* ```
*/
var IgrLegend = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgrLegend, _super);
function IgrLegend(props) {
var _this = _super.call(this, props) || 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;
_this.i.provideContainer(ren);
return _this;
}
IgrLegend.prototype.render = function () {
var div = React.createElement("div", {
className: "ig-legend igr-legend",
ref: this._getMainRef
});
return div;
};
IgrLegend.prototype._getMainRef = function (div) {
this._elRef = div;
};
IgrLegend.prototype.componentDidMount = function () {
_super.prototype.componentDidMount.call(this);
this.initializeContent();
};
IgrLegend.prototype.initializeContent = function () {
this._elRef.appendChild(this.container.getNativeElement());
};
IgrLegend.prototype.destroy = function () {
this._wrapper.destroy();
this.i.provideContainer(null);
};
IgrLegend.prototype.createImplementation = function () {
return new Legend();
};
Object.defineProperty(IgrLegend.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrLegend.prototype, "orientation", {
/**
* Gets or sets the current Legend object's orientation.
*
* ```ts
* <IgrLegend ref={this.onLegendRef}
* orientation="Horizontal" />
* ```
*/
get: function () {
return this.i.bg;
},
set: function (v) {
this.i.bg = ensureEnum(LegendOrientation_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrLegend.prototype, "textColor", {
/**
* Gets or sets color of text
*
* ```ts
* <IgrLegend ref={this.onLegendRef}
* textColor= "red" />
* ```
*/
get: function () {
return this.i.bm;
},
set: function (v) {
this.i.bm = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgrLegend.prototype, "textStyle", {
/**
* Gets or sets style of text.
*
* ```ts
* <IgrLegend ref={this.onLegendRef}
* textStyle= "9pt Verdana" />
* ```
*/
get: function () {
return this.i.bn;
},
set: function (v) {
this.i.bn = v;
},
enumerable: false,
configurable: true
});
return IgrLegend;
}(IgrLegendBase));
export { IgrLegend };