本文整理汇总了TypeScript中dojo-core/lang.assign函数的典型用法代码示例。如果您正苦于以下问题:TypeScript assign函数的具体用法?TypeScript assign怎么用?TypeScript assign使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assign函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createAxesConfiguration
function createAxesConfiguration(shared: AxisConfiguration<Datum<number>>, chartOptions: any): any {
const config: any = {};
for (const side of ['bottomAxis', 'leftAxis', 'rightAxis', 'topAxis']) {
config[side] = deepAssign({}, shared);
if (side === 'leftAxis' || side === 'rightAxis') {
config[side].labels = assign({
anchor: 'end'
}, config[side].labels);
}
if (side === 'bottomAxis' || side === 'topAxis') {
config[side].labels = assign({
dominantBaseline: 'middle',
rotation: 90
}, config[side].labels);
}
}
return assign(config, chartOptions);
}
示例2: assign
const columnPoints = originalPoints.map((original) => {
const dx = original.x2 - original.x1;
const x1 = prev.x2;
const x2 = x1 + dx;
const point = assign({}, original, { x1, x2 }) as ColumnPoint<T>;
prev = point;
return point;
});
示例3: getNodeAttributes
export const createProjector: ProjectorFactory = compose<any, ProjectorOptions>({
getNodeAttributes(overrides?: VNodeProperties): VNodeProperties {
/* TODO: This is the same logic as createCachedRenderMixin, merge somehow */
const projector: Projector = this;
const props: VNodeProperties = {};
for (let key in projector.listeners) {
props[key] = projector.listeners[key];
}
const classes: { [index: string]: boolean; } = {};
if (projector.classes) {
projector.classes.forEach((c) => classes[c] = true);
}
props.classes = classes;
props.styles = projector.styles || {};
if (overrides) {
assign(props, overrides);
}
return props;
},
render(): VNode {
const projector: Projector = this;
const childVNodes: VNode[] = [];
projector.children.forEach((child) => childVNodes.push(child.render()));
return h(projector.tagName || 'div', projector.getNodeAttributes(), childVNodes);
},
attach(append?: boolean): Handle {
const projector: Projector = this;
const projectorData = projectorDataMap.get(projector);
if (projectorData.state === ProjectorState.Attached) {
return projectorData.attachHandle;
}
示例4: compose
<V>(options?: FormFieldMixinOptions<V, FormFieldMixinState<V>>): FormFieldMixin<V, FormFieldMixinState<V>>;
}
const createFormMixin: FormMixinFactory = compose({
get value(): string {
const formfield: FormFieldMixin<any, FormFieldMixinState<any>> = this;
return valueToString(formfield.state.value);
},
set value(value: string) {
const formfield: FormFieldMixin<any, FormFieldMixinState<any>> = this;
if (value !== formfield.state.value) {
const event = assign(createCancelableEvent({
type: 'valuechange',
target: formfield
}), {
oldValue: valueToString(formfield.state.value),
value
});
formfield.emit(event);
if (!event.defaultPrevented) {
formfield.setState({ value: stringToValue(event.value) });
}
}
}
}, (instance: FormField<any>, options: FormFieldMixinOptions<any, FormFieldMixinState<any>>) => {
if (options) {
const { type } = options;
if (type) {
instance.type = type;
}
示例5: assign
} = this;
const overrides: VNodeProperties = {};
if (formfield.state.checked !== undefined) {
overrides.checked = formfield.state.checked;
}
// this is a hack, it should go into the formfield mixin
if (formfield.state.placeholder !== undefined) {
overrides.placeholder = formfield.state.placeholder;
}
if (!args[0]) {
args[0] = {};
}
assign(args[0], overrides);
return args;
}
}
},
initialize(instance) {
instance.own(instance.on('input', (event: TypedTargetEvent<HTMLInputElement>) => {
instance.value = event.target.value;
}));
}
})
.extend({
type: 'checkbox',
tagName: 'input'
});
示例6: assign
>(stacks.entries(), (entry, index) => {
const [ stack, signed ] = entry;
const value = signed[0].value + signed[1].value;
const columns = signed[0].columns.concat(signed[1].columns);
const columnPoints: ColumnPoint<T>[] = [];
// Spend half the spacing ahead of each stack, and half after.
const x1 = chartWidth;
// Assume each column's displayWidth is indeed the columnWidth
const x2 = x1 + columnWidth + columnSpacing;
chartWidth = x2;
let maxY2 = 0;
let minY1 = Infinity;
for (const { originalPoints, isNegative, relativeValue } of signed) {
if (originalPoints.length === 0) {
continue;
}
const availableHeight = isNegative ? positiveHeight - columnHeight : positiveHeight;
const correction = isNegative ? negativeStackHeightCorrection : positiveStackHeightCorrection;
const stackHeight = availableHeight * relativeValue * correction;
let prev = { displayHeight: 0, y1: positiveHeight, y2: negativeOffset };
const [ firstPoint ] = originalPoints;
for (const original of originalPoints) {
// Ensure each column within the stack has the correct size relative to the other
// columns.
let displayHeight = stackHeight * original.datum.relativeValue / relativeValue;
// Place above/below the previous column.
let y2 = isNegative ? prev.y2 + displayHeight : prev.y1;
let y1 = isNegative ? prev.y2 : y2 - displayHeight;
// Column spacing eats into the height of the column farthest from the zero line.
// TODO: Support spacing around the zero line? Would need to track whether there was
// a negative stack, and the first point in that stack (issue #8).
if (original !== firstPoint) {
displayHeight -= stackSpacing;
if (isNegative) {
y1 += stackSpacing;
}
else {
y2 -= stackSpacing;
}
}
if (y1 < minY1) {
minY1 = y1;
}
if (y2 > maxY2) {
maxY2 = y2;
}
const point = assign({}, original, {
displayHeight,
x1,
x2,
y1,
y2
}) as ColumnPoint<T>;
columnPoints.push(point);
prev = point;
}
}
return {
columnPoints,
datum: {
input: stack,
columns,
value
},
x1,
x2,
y1: minY1,
y2: maxY2
};
});