本文整理汇总了TypeScript中d3-shape.symbol函数的典型用法代码示例。如果您正苦于以下问题:TypeScript symbol函数的具体用法?TypeScript symbol怎么用?TypeScript symbol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了symbol函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(size: number, type: 'circle' | 'square') {
this.size = size;
switch (type) {
case 'circle':
this.type = d3Shape.symbolCircle;
break;
case 'square':
this.type = d3Shape.symbolSquare;
break;
default:
this.type = d3Shape.symbolCircle;
break;
}
this.symbol = d3Shape.symbol<Symbolizer, SymbolDatum>()
.size(function(this: Symbolizer, d?: SymbolDatum) {
return d ? d.size : this.size;
})
.type(function(this: Symbolizer, d?: SymbolDatum) {
let type = this.type;
if (d && d.type) {
switch (d.type) {
case 'circle':
type = d3Shape.symbolCircle;
break;
case 'square':
type = d3Shape.symbolSquare;
break;
default:
type = d3Shape.symbolSquare;
}
}
return type;
});
}
示例2: draw
let customSymbol: d3Shape.SymbolType;
customSymbol = {
draw(context: CanvasPathMethods, size: number): void {
// draw custom symbol using canvas path methods
}
};
// Symbol() create Symbol Generator ===================================================
let canvasSymbol: d3Shape.Symbol<any, any>;
let svgSymbol: d3Shape.Symbol<SVGPathElement, SymbolDatum>;
canvasSymbol = d3Shape.symbol();
svgSymbol = d3Shape.symbol<SymbolDatum>();
// Configure Symbol Generator =========================================================
// context() --------------------------------------------------------------------------
if (context !== null) {
canvasSymbol = canvasSymbol.context(context); // draw to canvas
}
context = canvasSymbol.context();
svgSymbol = svgSymbol.context(null); // use as path string generator for SVG
// size() ----------------------------------------------------------------------------
示例3: symbol
export const dSymbol = (
{ size }: ScatterSeries.PointOptions,
) => symbol().size(size ** 2).type(symbolCircle)()!;