igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
348 lines (347 loc) • 9.49 kB
JavaScript
import * as React from 'react';
import { HorizontalAlignment_$type } from "igniteui-react-core";
import { VerticalAlignment_$type } from "igniteui-react-core";
import { TreemapNodeStyle } from "./TreemapNodeStyle";
import { TypeRegistrar } from "igniteui-react-core";
import { NamePatcher, getModifiedProps, isValidProp, brushToString, stringToBrush, ensureEnum, ensureBool, toSpinal, initializePropertiesFromCss } from "igniteui-react-core";
/**
* Represents a style to apply to a treemap node.
*/
export class IgrTreemapNodeStyle extends React.Component {
createImplementation() {
return new TreemapNodeStyle();
}
get nativeElement() {
return this._implementation.nativeElement;
}
/**
* @hidden
*/
get i() {
return this._implementation;
} /**
* @hidden
*/
static _createFromInternal(internal) {
if (!internal) {
return null;
}
if (!internal.$type) {
return null;
}
let name = internal.$type.name;
let externalName = "Igr" + name;
if (!TypeRegistrar.isRegistered(externalName)) {
return null;
}
return TypeRegistrar.create(externalName);
}
onImplementationCreated() {
}
constructor(props) {
super(props);
this.mounted = false;
this.__p = null;
this._hasUserValues = new Set();
this._stylingContainer = null;
this._stylingParent = null;
this._inStyling = false;
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
this._implementation = this.createImplementation();
this._implementation.externalObject = this;
this.onImplementationCreated();
if (this._initializeAdapters) {
this._initializeAdapters();
}
}
componentDidMount() {
this.mounted = true;
for (const p of Object.keys(this.props)) {
if (isValidProp(this, p)) {
this[p] = this.props[p];
}
}
}
shouldComponentUpdate(nextProps, nextState) {
const mod = getModifiedProps(this.props, nextProps);
for (const p of Object.keys(mod)) {
if (isValidProp(this, p)) {
this[p] = mod[p];
}
}
return true;
}
render() {
return null;
}
/**
* Gets or sets the background to use for the header when it is hovered.
*/
get headerHoverBackground() {
return brushToString(this.i.bg);
}
set headerHoverBackground(v) {
this.i.bg = stringToBrush(v);
}
/**
* Gets or sets the background to use for the header.
*/
get headerBackground() {
return brushToString(this.i.bf);
}
set headerBackground(v) {
this.i.bf = stringToBrush(v);
}
/**
* Gets or sets the text color to use for the header.
*/
get headerTextColor() {
return brushToString(this.i.bi);
}
set headerTextColor(v) {
this.i.bi = stringToBrush(v);
}
/**
* Gets or sets the label to use for the node.
*/
get label() {
return this.i.aq;
}
set label(v) {
this.i.aq = v;
}
/**
* Gets or sets the text color to use for the nodes.
*/
get textColor() {
return brushToString(this.i.bk);
}
set textColor(v) {
this.i.bk = stringToBrush(v);
}
/**
* Gets or sets the text color to use for the header.
*/
get headerHoverTextColor() {
return brushToString(this.i.bh);
}
set headerHoverTextColor(v) {
this.i.bh = stringToBrush(v);
}
/**
* Gets or sets the left margin to use for the header.
*/
get headerLabelLeftMargin() {
return this.i.u;
}
set headerLabelLeftMargin(v) {
this.i.u = +v;
}
/**
* Gets or sets the top margin to use for the header.
*/
get headerLabelTopMargin() {
return this.i.w;
}
set headerLabelTopMargin(v) {
this.i.w = +v;
}
/**
* Gets or sets the right margin to use for the header.
*/
get headerLabelRightMargin() {
return this.i.v;
}
set headerLabelRightMargin(v) {
this.i.v = +v;
}
/**
* Gets or sets the bottom margin to use for the labels.
*/
get headerLabelBottomMargin() {
return this.i.t;
}
set headerLabelBottomMargin(v) {
this.i.t = +v;
}
/**
* Gets or sets the left margin to use for the labels.
*/
get labelLeftMargin() {
return this.i.y;
}
set labelLeftMargin(v) {
this.i.y = +v;
}
/**
* Gets or sets the top margin to use for the labels.
*/
get labelTopMargin() {
return this.i.aa;
}
set labelTopMargin(v) {
this.i.aa = +v;
}
/**
* Gets or sets the right margin to use for the labels.
*/
get labelRightMargin() {
return this.i.z;
}
set labelRightMargin(v) {
this.i.z = +v;
}
/**
* Gets or sets the bottom margin to use for the labels.
*/
get labelBottomMargin() {
return this.i.x;
}
set labelBottomMargin(v) {
this.i.x = +v;
}
/**
* Gets or sets the height to use for the header.
*/
get headerHeight() {
return this.i.s;
}
set headerHeight(v) {
this.i.s = +v;
}
/**
* Gets or sets the horizontal alignment to use for the node labels.
*/
get labelHorizontalAlignment() {
return this.i.a6;
}
set labelHorizontalAlignment(v) {
this.i.a6 = ensureEnum(HorizontalAlignment_$type, v);
}
/**
* Gets or sets the vertical alignment to use for the node labels.
*/
get labelVerticalAlignment() {
return this.i.bm;
}
set labelVerticalAlignment(v) {
this.i.bm = ensureEnum(VerticalAlignment_$type, v);
}
/**
* Gets or sets the fill color to use for the nodes.
*/
get fill() {
return brushToString(this.i.be);
}
set fill(v) {
this.i.be = stringToBrush(v);
}
/**
* Gets or sets the outline to use for the nodes.
*/
get outline() {
return brushToString(this.i.bj);
}
set outline(v) {
this.i.bj = stringToBrush(v);
}
/**
* Gets or sets the stroke thickness to use for the node outline.
*/
get strokeThickness() {
return this.i.ac;
}
set strokeThickness(v) {
this.i.ac = +v;
}
/**
* Gets or sets the opacity to use for the node.
*/
get opacity() {
return this.i.ab;
}
set opacity(v) {
this.i.ab = +v;
}
/**
* Gets or sets the fade opacity that should be used when highlighting.
*/
get fadeOpacity() {
return this.i.r;
}
set fadeOpacity(v) {
this.i.r = +v;
}
/**
* Gets or sets if highlighting was handled, and whether internal highlighting logic should be skipped.
*/
get highlightingHandled() {
return this.i.c;
}
set highlightingHandled(v) {
this.i.c = ensureBool(v);
}
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("TreemapNodeStyle");
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;
}
}