igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
206 lines (204 loc) • 7.46 kB
JavaScript
import { IgrTimeAxisBreakCollection } from "./igr-time-axis-break-collection";
import { TimeAxisLabellingMode_$type } from "./TimeAxisLabellingMode";
import { IgrTimeAxisLabelFormatCollection } from "./igr-time-axis-label-format-collection";
import { IgrTimeAxisIntervalCollection } from "./igr-time-axis-interval-collection";
import { IgrTimeAxisBase } from "./igr-time-axis-base";
import { TimeXAxis } from "./TimeXAxis";
import { ensureEnum } from "igniteui-react-core";
import { TimeAxisBreakCollection as TimeAxisBreakCollection_internal } from "./TimeAxisBreakCollection";
import { TimeAxisBreak } from "./TimeAxisBreak";
import { SyncableObservableCollection$1 } from "igniteui-react-core";
import { TimeAxisLabelFormatCollection as TimeAxisLabelFormatCollection_internal } from "./TimeAxisLabelFormatCollection";
import { TimeAxisLabelFormat } from "./TimeAxisLabelFormat";
import { TimeAxisIntervalCollection as TimeAxisIntervalCollection_internal } from "./TimeAxisIntervalCollection";
import { TimeAxisInterval } from "./TimeAxisInterval";
/**
* A horizontal axis that uses a DateTime scale.
*
* The `TimeXAxis` is a horizontal axis that uses a DateTime scale.
*
* ```ts
* <IgrDataChart
* dataSource={this.state.dataSource}
* width="700px"
* height="500px">
* <IgrTimeXAxis name="xAxis" label="Date"
* dateTimeMemberPath="Date" />
* </IgrDataChart>
* ```
*
* ```ts
* this.timeXAxis = new IgrTimeXAxis({name: "timeXAxis"});
* this.timeXAxis.title = "Time X Axis";
* this.timeXAxis.dataSource = this.financialData;
* this.timeXAxis.dateTimeMemberPath = "Time";
* ```
*/
export class IgrTimeXAxis extends IgrTimeAxisBase {
createImplementation() {
return new TimeXAxis();
}
/**
* @hidden
*/
get i() {
return this._implementation;
}
constructor(props) {
super(props);
this._breaks = null;
this._labelFormats = null;
this._intervals = null;
}
get isPiecewise() {
return this.i.dj;
}
/**
* TimeAxisBreaks to apply to this axis, representing spans of time to omit, such as weekends.
*
* The `Breaks` to apply to this axis, representing spans of time to omit, such as weekends.
*
* ```ts
* <IgrDataChart
* dataSource={this.state.dataSource}
* width="700px"
* height="500px">
* <IgrTimeXAxis name="xAxis" label="Date"
* dateTimeMemberPath="Date" >
* </IgrTimeXAxis>
* </IgrDataChart>
* ```
*/
get breaks() {
if (this._breaks === null) {
let coll = new IgrTimeAxisBreakCollection();
let innerColl = this.i.breaks;
if (!innerColl) {
innerColl = new TimeAxisBreakCollection_internal();
}
this._breaks = coll._fromInner(innerColl);
}
return this._breaks;
}
set breaks(v) {
if (this._breaks !== null) {
this._breaks._setSyncTarget(null);
this._breaks = null;
}
let coll = new IgrTimeAxisBreakCollection();
this._breaks = coll._fromOuter(v);
let syncColl = new SyncableObservableCollection$1(TimeAxisBreak.$type);
let innerColl = this.i.breaks;
if (!innerColl) {
innerColl = new TimeAxisBreakCollection_internal();
}
syncColl._inner = innerColl;
syncColl.clear();
this._breaks._setSyncTarget(syncColl);
}
/**
* Gets or sets the labelling mode to use when the automatic label formats are applied.
*/
get labellingMode() {
return this.i.rr;
}
set labellingMode(v) {
this.i.rr = ensureEnum(TimeAxisLabellingMode_$type, v);
}
/**
* A list of axis label formats to apply, which are selected according to the visible axis range.
* The label format selected will be the one with the largest range smaller than the visible range of the axis.
*/
get labelFormats() {
if (this._labelFormats === null) {
let coll = new IgrTimeAxisLabelFormatCollection();
let innerColl = this.i.labelFormats;
if (!innerColl) {
innerColl = new TimeAxisLabelFormatCollection_internal();
}
this._labelFormats = coll._fromInner(innerColl);
}
return this._labelFormats;
}
set labelFormats(v) {
if (this._labelFormats !== null) {
this._labelFormats._setSyncTarget(null);
this._labelFormats = null;
}
let coll = new IgrTimeAxisLabelFormatCollection();
this._labelFormats = coll._fromOuter(v);
let syncColl = new SyncableObservableCollection$1(TimeAxisLabelFormat.$type);
let innerColl = this.i.labelFormats;
if (!innerColl) {
innerColl = new TimeAxisLabelFormatCollection_internal();
}
syncColl._inner = innerColl;
syncColl.clear();
this._labelFormats._setSyncTarget(syncColl);
}
/**
* A list of axis label intervals to apply, which are selected according to the visible axis range.
* The interval selected will be the one with the largest range smaller than the visible range of the axis.
*/
get intervals() {
if (this._intervals === null) {
let coll = new IgrTimeAxisIntervalCollection();
let innerColl = this.i.intervals;
if (!innerColl) {
innerColl = new TimeAxisIntervalCollection_internal();
}
this._intervals = coll._fromInner(innerColl);
}
return this._intervals;
}
set intervals(v) {
if (this._intervals !== null) {
this._intervals._setSyncTarget(null);
this._intervals = null;
}
let coll = new IgrTimeAxisIntervalCollection();
this._intervals = coll._fromOuter(v);
let syncColl = new SyncableObservableCollection$1(TimeAxisInterval.$type);
let innerColl = this.i.intervals;
if (!innerColl) {
innerColl = new TimeAxisIntervalCollection_internal();
}
syncColl._inner = innerColl;
syncColl.clear();
this._intervals._setSyncTarget(syncColl);
}
/**
* Gets if the current axis is of category date time axis type
*/
get isCategoryDateTime() {
return this.i.c9;
}
findByName(name) {
var baseResult = super.findByName(name);
if (baseResult) {
return baseResult;
}
if (this.breaks != null && this.breaks.findByName && this.breaks.findByName(name)) {
return this.breaks.findByName(name);
}
if (this.labelFormats != null && this.labelFormats.findByName && this.labelFormats.findByName(name)) {
return this.labelFormats.findByName(name);
}
if (this.intervals != null && this.intervals.findByName && this.intervals.findByName(name)) {
return this.intervals.findByName(name);
}
return null;
}
getValueLabel(value) {
let iv = this.i.ih(value);
return (iv);
}
/**
* Gets the index of the data item with the value nearest the given value.
* @param unscaledValue * The value to find a value close to.
*/
getIndexClosestToUnscaledValue(unscaledValue) {
let iv = this.i.i$f(unscaledValue);
return (iv);
}
}