本文整理汇总了TypeScript中d3-shape.stack函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stack函数的具体用法?TypeScript stack怎么用?TypeScript stack使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stack函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
{ name: 'apples', label: 'Apples' },
{ name: 'oranges', label: 'Oranges' }
];
const stackData: StackDatum[] = [
{ values: { bananas: 10, apples: 20, oranges: 10 } },
{ values: { bananas: 10, apples: 25, oranges: 0 } },
{ values: { bananas: 20, apples: 20, oranges: 30 } },
{ values: { bananas: 12, apples: 10, oranges: 50 } }
];
// Create stack generator ==========================================================
let defaultStack: d3Shape.Stack<any, { [key: string]: number }, string>;
defaultStack = d3Shape.stack();
let overlyComplicatedStack: d3Shape.Stack<any, StackDatum, StackKey>;
overlyComplicatedStack = d3Shape.stack<StackDatum, StackKey>();
// Configure stack generator =======================================================
// keys(...) ----------------------------------------------------------------------
defaultStack = defaultStack.keys(['bananas', 'apples', 'oranges']);
overlyComplicatedStack = overlyComplicatedStack.keys((data: StackDatum[], keys: StackKey[]) => {
return keys;
});
示例2: stack
Object.keys(stacksKeys).forEach((stackId) => {
result[stackId] = stack().keys(stacksKeys[stackId])
.order(order as any)
.offset(offset as any)(dataItems as any);
});