igniteui-angular-charts
Version:
Ignite UI Angular charting components for building rich data visualizations for modern web apps.
126 lines (123 loc) • 4.07 kB
JavaScript
import { toPoint, toSpinal, initializePropertiesFromCss, NamePatcher } from "igniteui-angular-core";
//some of the build tools don't like styles not being an array literal for Angular
//export const LegendBaseStyles: string[] = [`
//`];
/**
* Represents the base class for a legend in IgxDataChartComponent.
*/
export class IgxLegendBaseComponent {
constructor() {
this._zoneRunner = null;
this.__p = null;
this._hasUserValues = new Set();
this._stylingContainer = null;
this._stylingParent = null;
this._inStyling = false;
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
this.onImplementationCreated();
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
}
get i() {
return this._implementation;
}
onImplementationCreated() {
}
/**
* Gets if the legend is item-wise.
*/
get isItemwise() {
return this.i.isItemwise;
}
/**
* Gets if the legend is a financial legend.
*/
get isFinancial() {
return this.i.isFinancial;
}
findByName(name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
return null;
}
get hasUserValues() {
return this._hasUserValues;
}
__m(propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
}
_styling(container, component, parent) {
if (this._inStyling) {
return;
}
this._inStyling = true;
this._stylingContainer = container;
this._stylingParent = component;
let genericPrefix = "";
let typeName = this.i.$type.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
genericPrefix = toSpinal("LegendBaseComponent");
let additionalPrefixes = [];
let prefix = toSpinal(typeName);
additionalPrefixes.push(prefix + "-");
let b = this.i.$type.baseType;
while (b && b.name != "Object" &&
b.name != "Base" &&
b.name != "Control" &&
b.Name != "DependencyObject" &&
b.Name != "FrameworkElement") {
typeName = b.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
let basePrefix = toSpinal(typeName);
additionalPrefixes.push(basePrefix + "-");
b = b.baseType;
}
if (parent) {
let parentTypeName = parent.i.$type.name;
if (parentTypeName.indexOf("Xam") === 0) {
parentTypeName = parentTypeName.substring(3);
}
let parentPrefix = toSpinal(parentTypeName);
additionalPrefixes.push(parentPrefix + "-" + genericPrefix + "-");
additionalPrefixes.push(parentPrefix + "-" + prefix + "-");
}
initializePropertiesFromCss(container, this, genericPrefix + "-", this.hasUserValues, false, additionalPrefixes);
if (this._otherStyling) {
this._otherStyling(container, component, parent);
}
this._inStyling = false;
}
/**
* Use to force the Legend to check for differences in text content.
*/
flushTextContentChangedCheck() {
this.i.flushTextContentChangedCheck();
}
/**
* Returns the legend visuals expressed as a serialized string.
*/
exportSerializedVisualData() {
let iv = this.i.exportSerializedVisualData();
return (iv);
}
simulateHover(point) {
this.i.bh(toPoint(point));
}
simulateClick(point) {
this.i.bg(toPoint(point));
}
simulateMouseLeave() {
this.i.bi();
}
}