victory-chart
Version:
Chart Component for Victory
47 lines (42 loc) • 2.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _range = require("lodash/range");
var _range2 = _interopRequireDefault(_range);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
circle: function circle(x, y, size) {
return "M " + x + ", " + y + " m " + -size + ", 0\n a " + size + ", " + size + " 0 1,0 " + size * 2 + ",0\n a " + size + ", " + size + " 0 1,0 " + -size * 2 + ",0";
},
square: function square(x, y, size) {
var baseSize = 0.87 * size;
return "M " + (x - baseSize) + ", " + (y + baseSize) + "\n L " + (x + baseSize) + ", " + (y + baseSize) + "\n L " + (x + baseSize) + ", " + (y - baseSize) + "\n L " + (x - baseSize) + ", " + (y - baseSize) + "\n z";
},
diamond: function diamond(x, y, size) {
var baseSize = 0.87 * size;
var length = Math.sqrt(2 * (baseSize * baseSize));
return "M " + x + ", " + (y + length) + "\n L " + (x + length) + ", " + y + "\n L " + x + ", " + (y - length) + "\n L " + (x - length) + ", " + y + "\n z";
},
triangleDown: function triangleDown(x, y, size) {
var height = size / 2 * Math.sqrt(3);
return "M " + (x - size) + ", " + (y - size) + "\n L " + (x + size) + ", " + (y - size) + "\n L " + x + ", " + (y + height) + "\n z";
},
triangleUp: function triangleUp(x, y, size) {
var height = size / 2 * Math.sqrt(3);
return "M " + (x - size) + ", " + (y + size) + "\n L " + (x + size) + ", " + (y + size) + "\n L " + x + ", " + (y - height) + "\n z";
},
plus: function plus(x, y, size) {
var baseSize = 1.1 * size;
return "M " + (x - baseSize / 2.5) + ", " + (y + baseSize) + "\n L " + (x + baseSize / 2.5) + ", " + (y + baseSize) + "\n L " + (x + baseSize / 2.5) + ", " + (y + baseSize / 2.5) + "\n L " + (x + baseSize) + ", " + (y + baseSize / 2.5) + "\n L " + (x + baseSize) + ", " + (y - baseSize / 2.5) + "\n L " + (x + baseSize / 2.5) + ", " + (y - baseSize / 2.5) + "\n L " + (x + baseSize / 2.5) + ", " + (y - baseSize) + "\n L " + (x - baseSize / 2.5) + ", " + (y - baseSize) + "\n L " + (x - baseSize / 2.5) + ", " + (y - baseSize / 2.5) + "\n L " + (x - baseSize) + ", " + (y - baseSize / 2.5) + "\n L " + (x - baseSize) + ", " + (y + baseSize / 2.5) + "\n L " + (x - baseSize / 2.5) + ", " + (y + baseSize / 2.5) + "\n z";
},
star: function star(x, y, size) {
var baseSize = 1.35 * size;
var angle = Math.PI / 5;
var starCoords = (0, _range2.default)(10).map(function (index) {
var length = index % 2 === 0 ? baseSize : baseSize / 2;
return length * Math.sin(angle * (index + 1)) + x + ",\n " + (length * Math.cos(angle * (index + 1)) + y);
});
return "M " + starCoords.join("L") + " z";
}
};