當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lang.assign函數代碼示例

本文整理匯總了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);
}
開發者ID:novemberborn,項目名稱:dojo2-dataviz,代碼行數:18,代碼來源:axes.ts

示例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;
						});
開發者ID:novemberborn,項目名稱:dojo2-dataviz,代碼行數:9,代碼來源:createGroupedColumnChart.ts

示例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;
			}
開發者ID:kitsonk,項目名稱:widgets,代碼行數:31,代碼來源:projector.ts

示例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;
			}
開發者ID:novemberborn,項目名稱:widgets,代碼行數:31,代碼來源:createFormFieldMixin.ts

示例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'
	});
開發者ID:matt-gadd,項目名稱:dojo2-todo-mvc,代碼行數:31,代碼來源:createCheckboxInput.ts

示例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
						};
					});
開發者ID:novemberborn,項目名稱:dojo2-dataviz,代碼行數:81,代碼來源:createStackedColumnChart.ts


注:本文中的dojo-core/lang.assign函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。