• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript lang.assign函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript lang.deepAssign函数代码示例发布时间:2022-05-25
下一篇:
TypeScript interfaces.Handle类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap