Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getPathString(d?: SymbolDatum) {
return d ? this.symbol(d) : this.symbol();
}
}
const sym = new Symbolizer(100, 'square');
pathStringMaybe = sym.getPathString();
pathStringMaybe = sym.getPathString({ size: 10, type: 'circle' });
// Test pre-fab symbols ===============================================================
const symbolArray: d3Shape.SymbolType[] = d3Shape.symbols;
customSymbol = d3Shape.symbolCircle;
customSymbol = d3Shape.symbolCross;
customSymbol = d3Shape.symbolDiamond;
customSymbol = d3Shape.symbolSquare;
customSymbol = d3Shape.symbolStar;
customSymbol = d3Shape.symbolTriangle;
customSymbol = d3Shape.symbolWye;
// -----------------------------------------------------------------------------------
// Test Stacks
// -----------------------------------------------------------------------------------
interface StackDatum {
values: { [name: string]: number; };
}
let seriesDatum: StackDatum;
svgSymbol = svgSymbol.type(d => {
let t: d3Shape.SymbolType;
switch (d.type) { // datum type is SymbolDatum
case 'circle':
t = d3Shape.symbolCircle;
break;
case 'square':
t = d3Shape.symbolSquare;
break;
default:
t = d3Shape.symbolCircle;
break;
}
return t;
});
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()
.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;
.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;
});
}
.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;
});
}
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()
.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) {
() => {
console.log(symbol)
if(symbol === 'circle') {
return D3Shape.symbolCircle
}else if(symbol === 'cross') {
return D3Shape.symbolCross
}else if(symbol === 'diamond') {
return D3Shape.symbolDiamond
}else if(symbol === 'square') {
return D3Shape.symbolSquare
}else if(symbol === 'star') {
return D3Shape.symbolStar
}else if(symbol === 'triangle') {
return D3Shape.symbolTriangle
}else if(symbol === 'wye') {
return D3Shape.symbolWye
}else {
console.error('Symbol is not support ' + symbol + '.')
}
}
};
var nodeShapeOptions = {
squareDiamond: {
symbol: d3_shape_1.symbolSquare,
rotation: 45
},
square: {
symbol: d3_shape_1.symbolSquare,
rotation: 0
},
diamond: {
symbol: d3_shape_1.symbolDiamond,
rotation: 0
},
circle: {
symbol: d3_shape_1.symbolCircle,
rotation: 0
}
};
var Nodes = /** @class */ (function (_super) {
__extends(Nodes, _super);
function Nodes() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = "node";
_this.focusElementAccessor = "path.node." + styles.border;
return _this;
}
Nodes.prototype.updateDraw = function () {
var nodeGroups = this.el
.select("g.nodes-group")
.selectAll("g.node-group")
.data(this.data, function (node) { return node.id(); });
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _ReactUtils = require('../util/ReactUtils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var SYMBOL_FACTORIES = {
symbolCircle: _d3Shape.symbolCircle, symbolCross: _d3Shape.symbolCross, symbolDiamond: _d3Shape.symbolDiamond,
symbolSquare: _d3Shape.symbolSquare, symbolStar: _d3Shape.symbolStar, symbolTriangle: _d3Shape.symbolTriangle, symbolWye: _d3Shape.symbolWye
};
var RADIAN = Math.PI / 180;
var getSymbolFactory = function getSymbolFactory(type) {
var name = 'symbol' + type.slice(0, 1).toUpperCase() + type.slice(1);
return SYMBOL_FACTORIES[name] || _d3Shape.symbolCircle;
};
var calculateAreaSize = function calculateAreaSize(size, sizeType, type) {
if (sizeType === 'area') {
return size;
}
switch (type) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fp_1 = require("lodash/fp");
var styles = require("./styles");
var d3_shape_1 = require("d3-shape");
var defaultAccessors = {
fill: function (series, d) { return "#fff"; },
size: function (series, d) { return 50; },
stroke: function (series, d) { return series.legendColor(); },
symbol: function (series, d) { return "circle"; },
};
var symbolOptions = {
circle: {
symbol: d3_shape_1.symbolCircle,
},
cross: {
symbol: d3_shape_1.symbolCross,
},
diamond: {
symbol: d3_shape_1.symbolDiamond,
},
square: {
symbol: d3_shape_1.symbolSquare,
},
squareDiamond: {
symbol: d3_shape_1.symbolSquare,
rotation: 45,
},
star: {
symbol: d3_shape_1.symbolStar,