本文整理汇总了TypeScript中d3-shape.pie函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pie函数的具体用法?TypeScript pie怎么用?TypeScript pie使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pie函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
export const getPiePointTransformer: GetPointTransformerFn = ({
argumentScale, valueScale, points,
}) => {
const x = Math.max(...argumentScale.range()) / 2;
const y = Math.max(...valueScale.range()) / 2;
const maxRadius = Math.min(x, y);
const pieData = pie<Point>().sort(null).value(d => d.value)(points as Point[]);
return (point) => {
const { startAngle, endAngle } = pieData[point.index];
return {
...point,
x,
y,
startAngle,
endAngle,
maxRadius,
};
};
};
示例2: valueOf
index: 0,
startAngle: 0,
endAngle: Math.PI / 2,
padAngle: 0
};
const pieDatum: PieDatum = pieArcObject.data;
num = pieArcObject.value;
num = pieArcObject.index;
num = pieArcObject.startAngle;
num = pieArcObject.endAngle;
num = pieArcObject.padAngle;
// pie(...) create Pie generator =====================================================
let defaultPie: d3Shape.Pie<any, number | { valueOf(): number }> = d3Shape.pie();
let pie: d3Shape.Pie<any, PieDatum> = d3Shape.pie<PieDatum>();
// configure Pie(...) generator ======================================================
// value(...) -------------------------------------------------------------------------
let defaultPieValueAccessor: (d: number | { valueOf(): number }, i?: number, data?: Array<number | { valueOf(): number }>) => number;
defaultPie = defaultPie.value(10);
defaultPieValueAccessor = defaultPie.value();
let pieValueAccessor: (d: PieDatum, i?: number, data?: PieDatum[]) => number;
示例3:
export function getPieData<D>(data: any): Array<PieArcDatum<D>> {
return pie<any, D>().value((item: any) => {
return +item.count;
})(data);
}