12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- "use strict";
- exports.__esModule = true;
- exports.getClip = getClip;
- exports.isPointInPlot = isPointInPlot;
- var _require = require('../graphic/index'),
- Shape = _require.Shape;
- 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 Shape.Sector({
- attrs: {
- x: center.x,
- y: center.y,
- r: circleRadius,
- r0: 0,
- startAngle: startAngle,
- endAngle: endAngle
- }
- });
- } else {
- clip = new 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;
- }
|