Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
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 pointRadial
// -----------------------------------------------------------------------------------
const coordinatates: [number, number] = d3Shape.pointRadial(0, 12);
// -----------------------------------------------------------------------------------
// Test Stacks
// -----------------------------------------------------------------------------------
interface StackDatum {
values: { [name: string]: number; };
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;
() => {
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 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,
},
triangle: {
symbol: d3_shape_1.symbolTriangle,
},
};
var Symbol = /** @class */ (function () {
function Symbol(state, events, el, data, options, series) {
this.type = "symbol";
this.state = state;
this.events = events;
this.series = series;
this.el = this.appendSeriesGroup(el);
y: 0
},
right: {
dy: "0.35em",
textAnchor: "start",
x: 1,
y: 0
}
};
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";
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,
},
triangle: {
symbol: d3_shape_1.symbolTriangle,
},
};
var Symbol = /** @class */ (function () {
function Symbol(state, events, el, data, options, series) {
this.type = "symbol";
this.state = state;
left: {
dy: "0.35em",
textAnchor: "end",
x: -1,
y: 0
},
right: {
dy: "0.35em",
textAnchor: "start",
x: 1,
y: 0
}
};
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) {
var _Element3 = _interopRequireDefault(_Element2);
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 SYMBOLS = {
symbolCircle: _d3Shape.symbolCircle,
symbolCross: _d3Shape.symbolCross,
symbolDiamond: _d3Shape.symbolDiamond,
symbolSquare: _d3Shape.symbolSquare,
symbolStar: _d3Shape.symbolStar,
symbolTriangle: _d3Shape.symbolTriangle,
symbolWye: _d3Shape.symbolWye
};
var SymbolShape = function (_Element) {
_inherits(SymbolShape, _Element);
function SymbolShape() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, SymbolShape);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
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) {
case 'cross':