本文整理汇总了TypeScript中plywood.TimeRange.fromJS方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TimeRange.fromJS方法的具体用法?TypeScript TimeRange.fromJS怎么用?TypeScript TimeRange.fromJS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plywood.TimeRange
的用法示例。
在下文中一共展示了TimeRange.fromJS方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getPseudoHighlight
getPseudoHighlight(eventX: number): TimeRange {
var { scaleX } = this.props;
var { dragStartPx } = this.state;
var myDOM = React.findDOMNode(this);
var d1 = scaleX.invert(dragStartPx);
var d2 = scaleX.invert(eventX - myDOM.getBoundingClientRect().left);
if (d1 < d2) {
return TimeRange.fromJS({ start: d1, end: d2 });
} else {
return TimeRange.fromJS({ start: d2, end: d1 });
}
}
示例2: globalMouseUpListener
globalMouseUpListener(e: MouseEvent) {
var { clicker, essence, highlightId, duration, timezone, onClose } = this.props;
var { dragStartPx, pseudoHighlight } = this.state;
if (dragStartPx === null) return;
if (!pseudoHighlight) { // There was no mouse move so just quietly cancel out
clicker.dropHighlight();
onClose();
return;
}
pseudoHighlight = this.getPseudoHighlight(e.clientX);
this.setState({
dragStartPx: null,
pseudoHighlight: null
});
var timeRange = TimeRange.fromJS({
start: duration.floor(pseudoHighlight.start, timezone),
end: duration.move(duration.floor(pseudoHighlight.end, timezone), timezone, 1)
});
var timeDimension = essence.getTimeDimension();
clicker.changeHighlight(highlightId, Filter.fromClause(timeDimension.expression.in(timeRange)));
}
示例3: parseIntervalString
function parseIntervalString(str: string): TimeRange {
var parts = str.split('/');
if (parts.length > 2) throw new Error(`Can not parse string ${str}`);
var p0: string = parts[0];
var p1: string = parts.length === 2 ? parts[1] : (new Date()).toISOString();
var start: Date = null;
var end: Date = null;
var duration: Duration = null;
if (p0[0] === 'P') {
duration = Duration.fromJS(p0);
end = new Date(p1);
start = duration.move(end, Timezone.UTC, -1);
} else if (p1[0] === 'P') {
start = new Date(p0);
duration = Duration.fromJS(p1);
end = duration.move(end, Timezone.UTC, 1);
} else {
start = new Date(p0);
end = new Date(p1);
}
return TimeRange.fromJS({ start, end });
}
示例4: fromJS
static fromJS(parameters: TimePresetJS): TimePreset {
return new TimePreset({
name: parameters.name,
timeRange: TimeRange.fromJS(parameters.timeRange)
});
}