suoqiu-f2
Version:
Charts for mobile visualization.
49 lines (48 loc) • 1.12 kB
JavaScript
;
exports.__esModule = true;
exports.getClip = getClip;
exports.isPointInPlot = isPointInPlot;
var _index = require("../graphic/index");
function getClip(coord) {
var start = coord.start;
var end = coord.end;
var width = end.x - start.x;
var height = Math.abs(end.y - start.y);
var margin = 10;
var clip;
if (coord.isPolar) {
var circleRadius = coord.circleRadius,
center = coord.center,
startAngle = coord.startAngle,
endAngle = coord.endAngle;
clip = new _index.Shape.Sector({
attrs: {
x: center.x,
y: center.y,
r: circleRadius,
r0: 0,
startAngle: startAngle,
endAngle: endAngle
}
});
} else {
clip = new _index.Shape.Rect({
attrs: {
x: start.x,
y: end.y - margin,
width: width,
height: height + 2 * margin
}
});
}
clip.isClip = true;
return clip;
}
function isPointInPlot(point, plot) {
var x = point.x,
y = point.y;
var tl = plot.tl,
tr = plot.tr,
br = plot.br;
return x >= tl.x && x <= tr.x && y >= tl.y && y <= br.y;
}