UNPKG

igniteui-react-charts

Version:

Ignite UI React charting components for building rich data visualizations using TypeScript APIs.

615 lines (611 loc) 18.1 kB
import * as React from 'react'; import { ZoomSliderOrientation_$type } from './ZoomSliderOrientation'; import { IgrZoomSliderResolvingAxisValueEventArgs } from './igr-zoom-slider-resolving-axis-value-event-args'; import { IgrRectChangedEventArgs } from "igniteui-react-core"; import { ZoomSlider } from "./ZoomSlider"; import { fromRect, toRect, ensureEnum, brushToString, stringToBrush, ensureBool, initializePropertiesFromCss, NamePatcher, isValidProp, toSpinal, getModifiedProps } from "igniteui-react-core"; import { FontInfo } from "igniteui-react-core"; import { ReactRenderer } from "igniteui-react-core"; import { delegateCombine, delegateRemove } from "igniteui-react-core"; const ZoomSliderStylingDefaults = {}; export class IgrZoomSlider extends React.Component { set height(value) { this._height = value; if (this._elRef) { this._elRef.style.height = value; this._zoomSlider.notifySizeChanged(); } } get height() { return this._height; } set width(value) { this._width = value; if (this._elRef) { this._elRef.style.height = value; this._zoomSlider.notifySizeChanged(); } } get width() { return this._width; } _getMainRef(ref) { this._elRef = ref; } render() { let div = React.createElement("div", { className: "ig-zoom-slider igr-zoom-slider", ref: this._getMainRef }); //} return div; } constructor(props) { super(props); this._wrapper = null; this._implementation = null; this.__p = null; this._hasUserValues = new Set(); this._stylingContainer = null; this._stylingParent = null; this._inStyling = false; this._resolvingAxisValue = null; this._resolvingAxisValue_wrapped = null; this._windowRectChanged = null; this._windowRectChanged_wrapped = null; if (this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this)); } this._getMainRef = this._getMainRef.bind(this); this._implementation = this.createImplementation(); if (document) { this._container = document.createElement("div"); this._container.style.display = "block"; this._container.style.width = "100%"; this._container.style.height = "100%"; } var root; root = this._container; if (this._container != null) { root = this._container; } var ren = new ReactRenderer(root, document, true, ZoomSliderStylingDefaults); this._wrapper = ren; var zoomSlider = this.i; this._zoomSlider = zoomSlider; zoomSlider.provideContainer(ren); zoomSlider.notifySizeChanged(); if (props) { this.initializeProperties(); } ren.addSizeWatcher(() => { this._zoomSlider.notifySizeChanged(); }); } 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; } initializeProperties() { for (const p of Object.keys(this.props)) { if (isValidProp(this, p)) { this[p] = this.props[p]; } } } // supports angular themes or custom properties set in CSS updateStyle() { this._styling(this._elRef, this); } /** * Release any resources held by the ZoomSlider. */ destroy() { this.i.destroy(); this._zoomSlider.destroy(); this._wrapper.destroy(); } componentWillUnmount() { } componentDidMount() { this._elRef.style.width = this._width ? this._width : ""; this._elRef.style.height = this._height ? this._height : ""; this._elRef.appendChild(this._container); this._zoomSlider.notifySizeChanged(); this.initializeContent(); } initializeContent() { this.updateStyle(); } createImplementation() { return new ZoomSlider(); } get i() { return this._implementation; } static _staticStyling(container, component, parent) { let genericPrefix = ""; let typeName = (component.i ? component.i : component).$type.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } genericPrefix = toSpinal("ZoomSlider"); let additionalPrefixes = []; let prefix = toSpinal(typeName); additionalPrefixes.push(prefix + "-"); let b = (component.i ? component.i : component).$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, component, genericPrefix + "-", new Set(), false, additionalPrefixes); } get panTransitionDuration() { return this.i.bl; } set panTransitionDuration(v) { this.i.bl = +v; } get maxZoomWidth() { return this.i.bg; } set maxZoomWidth(v) { this.i.bg = +v; } /** * Gets or sets the scaling value used to affect the pixel density of the control. * A higher scaling ratio will produce crisper visuals at the expense of memory. Lower values will cause the control * to appear blurry. */ get pixelScalingRatio() { return this.i.bi; } set pixelScalingRatio(v) { this.i.bi = +v; } get actualPixelScalingRatio() { return this.i.a4; } set actualPixelScalingRatio(v) { this.i.a4 = +v; } get windowRect() { return fromRect(this.i.windowRect); } set windowRect(v) { this.i.windowRect = toRect(v); } get minZoomWidth() { return this.i.bh; } set minZoomWidth(v) { this.i.bh = +v; } get startInset() { return this.i.startInset; } set startInset(v) { this.i.startInset = +v; } get endInset() { return this.i.endInset; } set endInset(v) { this.i.endInset = +v; } get trackStartInset() { return this.i.trackStartInset; } set trackStartInset(v) { this.i.trackStartInset = +v; } get trackEndInset() { return this.i.trackEndInset; } set trackEndInset(v) { this.i.trackEndInset = +v; } get barExtent() { return this.i.barExtent; } set barExtent(v) { this.i.barExtent = +v; } get orientation() { return this.i.e; } set orientation(v) { this.i.e = ensureEnum(ZoomSliderOrientation_$type, v); } get lowerThumbBrush() { return brushToString(this.i.e8); } set lowerThumbBrush(v) { this.i.e8 = stringToBrush(v); } get lowerThumbStrokeThickness() { return this.i.be; } set lowerThumbStrokeThickness(v) { this.i.be = +v; } get higherThumbStrokeThickness() { return this.i.a9; } set higherThumbStrokeThickness(v) { this.i.a9 = +v; } get higherThumbBrush() { return brushToString(this.i.e0); } set higherThumbBrush(v) { this.i.e0 = stringToBrush(v); } get lowerThumbOutline() { return brushToString(this.i.e9); } set lowerThumbOutline(v) { this.i.e9 = stringToBrush(v); } get higherThumbOutline() { return brushToString(this.i.e1); } set higherThumbOutline(v) { this.i.e1 = stringToBrush(v); } get lowerThumbRidgesBrush() { return brushToString(this.i.fa); } set lowerThumbRidgesBrush(v) { this.i.fa = stringToBrush(v); } get higherThumbRidgesBrush() { return brushToString(this.i.e2); } set higherThumbRidgesBrush(v) { this.i.e2 = stringToBrush(v); } get lowerThumbWidth() { return this.i.bf; } set lowerThumbWidth(v) { this.i.bf = +v; } get higherThumbWidth() { return this.i.ba; } set higherThumbWidth(v) { this.i.ba = +v; } get lowerThumbHeight() { return this.i.bd; } set lowerThumbHeight(v) { this.i.bd = +v; } get higherThumbHeight() { return this.i.a8; } set higherThumbHeight(v) { this.i.a8 = +v; } get lowerShadeBrush() { return brushToString(this.i.e6); } set lowerShadeBrush(v) { this.i.e6 = stringToBrush(v); } get lowerShadeOutline() { return brushToString(this.i.e7); } set lowerShadeOutline(v) { this.i.e7 = stringToBrush(v); } get lowerShadeStrokeThickness() { return this.i.bc; } set lowerShadeStrokeThickness(v) { this.i.bc = +v; } get higherShadeBrush() { return brushToString(this.i.ey); } set higherShadeBrush(v) { this.i.ey = stringToBrush(v); } get higherShadeOutline() { return brushToString(this.i.ez); } set higherShadeOutline(v) { this.i.ez = stringToBrush(v); } get higherShadeStrokeThickness() { return this.i.a7; } set higherShadeStrokeThickness(v) { this.i.a7 = +v; } get barBrush() { return brushToString(this.i.et); } set barBrush(v) { this.i.et = stringToBrush(v); } get barOutline() { return brushToString(this.i.eu); } set barOutline(v) { this.i.eu = stringToBrush(v); } get barStrokeThickness() { return this.i.a5; } set barStrokeThickness(v) { this.i.a5 = +v; } get rangeThumbBrush() { return brushToString(this.i.fb); } set rangeThumbBrush(v) { this.i.fb = stringToBrush(v); } get rangeThumbOutline() { return brushToString(this.i.fc); } set rangeThumbOutline(v) { this.i.fc = stringToBrush(v); } get rangeThumbStrokeThickness() { return this.i.bj; } set rangeThumbStrokeThickness(v) { this.i.bj = +v; } get rangeThumbRidgesBrush() { return brushToString(this.i.fd); } set rangeThumbRidgesBrush(v) { this.i.fd = stringToBrush(v); } get lowerCalloutBrush() { return brushToString(this.i.e3); } set lowerCalloutBrush(v) { this.i.e3 = stringToBrush(v); } get lowerCalloutTextColor() { return brushToString(this.i.e5); } set lowerCalloutTextColor(v) { this.i.e5 = stringToBrush(v); } get lowerCalloutOutline() { return brushToString(this.i.e4); } set lowerCalloutOutline(v) { this.i.e4 = stringToBrush(v); } get lowerCalloutStrokeThickness() { return this.i.bb; } set lowerCalloutStrokeThickness(v) { this.i.bb = +v; } get higherCalloutBrush() { return brushToString(this.i.ev); } set higherCalloutBrush(v) { this.i.ev = stringToBrush(v); } get higherCalloutTextColor() { return brushToString(this.i.ex); } set higherCalloutTextColor(v) { this.i.ex = stringToBrush(v); } get higherCalloutOutline() { return brushToString(this.i.ew); } set higherCalloutOutline(v) { this.i.ew = stringToBrush(v); } get higherCalloutStrokeThickness() { return this.i.a6; } set higherCalloutStrokeThickness(v) { this.i.a6 = +v; } get isCustomThumbProvided() { return this.i.ab; } get isCustomRangeThumbProvided() { return this.i.z; } get isCustomBarProvided() { return this.i.y; } get isCustomShadeProvided() { return this.i.aa; } get areThumbCalloutsEnabled() { return this.i.q; } set areThumbCalloutsEnabled(v) { this.i.q = ensureBool(v); } get thumbCalloutTextStyle() { if (this.i.o == null) { return null; } return this.i.o.fontString; } set thumbCalloutTextStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.o = fi; } 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("ZoomSlider"); 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; } onDetachedFromUI() { this.i.onDetachedFromUI(); } onAttachedToUI() { this.i.onAttachedToUI(); } /** * Called by the UI framework to provide a UI container for rendering this control. * @param container * The UI container element. */ provideContainer(container) { this.i.provideContainer(container); } flush() { this.i.c3(); } trackDirty() { this.i.trackDirty(); } /** * Shows the ZoomSlider. */ show() { this.i.show(); } /** * Hides the ZoomSlider. */ hide() { this.i.hide(); } get resolvingAxisValue() { return this._resolvingAxisValue; } set resolvingAxisValue(ev) { if (this._resolvingAxisValue_wrapped !== null) { this.i.resolvingAxisValue = delegateRemove(this.i.resolvingAxisValue, this._resolvingAxisValue_wrapped); this._resolvingAxisValue_wrapped = null; this._resolvingAxisValue = null; } this._resolvingAxisValue = ev; this._resolvingAxisValue_wrapped = (o, e) => { let outerArgs = new IgrZoomSliderResolvingAxisValueEventArgs(); outerArgs._provideImplementation(e); if (this.beforeResolvingAxisValue) { this.beforeResolvingAxisValue(this, outerArgs); } if (this._resolvingAxisValue) { this._resolvingAxisValue(this, outerArgs); } }; this.i.resolvingAxisValue = delegateCombine(this.i.resolvingAxisValue, this._resolvingAxisValue_wrapped); ; } /** * Occurs just after the current ZoomSlider's window rectangle is changed. */ get windowRectChanged() { return this._windowRectChanged; } set windowRectChanged(ev) { if (this._windowRectChanged_wrapped !== null) { this.i.windowRectChanged = delegateRemove(this.i.windowRectChanged, this._windowRectChanged_wrapped); this._windowRectChanged_wrapped = null; this._windowRectChanged = null; } this._windowRectChanged = ev; this._windowRectChanged_wrapped = (o, e) => { let outerArgs = new IgrRectChangedEventArgs(); outerArgs._provideImplementation(e); if (this.beforeWindowRectChanged) { this.beforeWindowRectChanged(this, outerArgs); } if (this._windowRectChanged) { this._windowRectChanged(this, outerArgs); } }; this.i.windowRectChanged = delegateCombine(this.i.windowRectChanged, this._windowRectChanged_wrapped); ; } }