igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
108 lines (107 loc) • 3.17 kB
JavaScript
import { IgrAxis } from "./igr-axis";
import { IgrAxisMatcher } from "./igr-axis-matcher";
import { IgrUserBaseAnnotation } from "./igr-user-base-annotation";
import { UserAxisAnnotation as UserAxisAnnotation_internal } from "./UserAxisAnnotation";
/**
* Represents an user annotation for rendering annotation of axis label
*/
export class IgrUserAxisAnnotation extends IgrUserBaseAnnotation {
createImplementation() {
return new UserAxisAnnotation_internal();
}
/**
* @hidden
*/
get i() {
return this._implementation;
}
constructor() {
super();
this._targetAxisName = null;
}
/**
* Gets or sets the target axis that will display the annotation.
*/
get targetAxis() {
const r = this.i.targetAxis;
if (r == null) {
return null;
}
if (!r.externalObject) {
let e = IgrAxis._createFromInternal(r);
if (e) {
e._implementation = r;
}
r.externalObject = e;
}
return r.externalObject;
}
set targetAxis(v) {
v == null ? this.i.targetAxis = null : this.i.targetAxis = v.i;
}
/**
* Gets or sets the name to use to resolve targetAxis from markup.
*/
get targetAxisName() {
return this._targetAxisName;
}
set targetAxisName(v) {
this._targetAxisName = v;
}
/**
* Gets or sets a matcher for matching an axis that will display the annotation.
*/
get targetAxisMatcher() {
const r = this.i.targetAxisMatcher;
if (r == null) {
return null;
}
if (!r.externalObject) {
let e = new IgrAxisMatcher();
if (r.$type) {
e._implementation = r;
}
else {
if (e.i.setNativeElement) {
e.i.setNativeElement(r);
}
}
r.externalObject = e;
}
return r.externalObject;
}
set targetAxisMatcher(v) {
v == null ? this.i.targetAxisMatcher = null : this.i.targetAxisMatcher = v.i;
}
/**
* Gets or sets the value that determines location of annotation on axis.
*/
get value() {
return this.i.value;
}
set value(v) {
this.i.value = +v;
}
bindAxes(axes) {
super.bindAxes(axes);
for (let i = 0; i < axes.length; i++) {
if (this.targetAxisName && this.targetAxisName.length > 0 &&
axes[i].name == this.targetAxisName) {
this.targetAxis = axes[i];
}
}
}
findByName(name) {
var baseResult = super.findByName(name);
if (baseResult) {
return baseResult;
}
if (this.targetAxis && this.targetAxis.name && this.targetAxis.name == name) {
return this.targetAxis;
}
if (this.targetAxisMatcher && this.targetAxisMatcher.name && this.targetAxisMatcher.name == name) {
return this.targetAxisMatcher;
}
return null;
}
}