123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- var graphic = require("../../util/graphic");
- var _number = require("../../util/number");
- var round = _number.round;
- function createGridClipPath(cartesian, hasAnimation, seriesModel) {
- var rect = cartesian.getArea();
- var isHorizontal = cartesian.getBaseAxis().isHorizontal();
- var x = rect.x;
- var y = rect.y;
- var width = rect.width;
- var height = rect.height;
- var lineWidth = seriesModel.get('lineStyle.width') || 2;
- x -= lineWidth / 2;
- y -= lineWidth / 2;
- width += lineWidth;
- height += lineWidth;
- x = Math.floor(x);
- width = Math.round(width);
- var clipPath = new graphic.Rect({
- shape: {
- x: x,
- y: y,
- width: width,
- height: height
- }
- });
- if (hasAnimation) {
- clipPath.shape[isHorizontal ? 'width' : 'height'] = 0;
- graphic.initProps(clipPath, {
- shape: {
- width: width,
- height: height
- }
- }, seriesModel);
- }
- return clipPath;
- }
- function createPolarClipPath(polar, hasAnimation, seriesModel) {
- var sectorArea = polar.getArea();
- var clipPath = new graphic.Sector({
- shape: {
- cx: round(polar.cx, 1),
- cy: round(polar.cy, 1),
- r0: round(sectorArea.r0, 1),
- r: round(sectorArea.r, 1),
- startAngle: sectorArea.startAngle,
- endAngle: sectorArea.endAngle,
- clockwise: sectorArea.clockwise
- }
- });
- if (hasAnimation) {
- clipPath.shape.endAngle = sectorArea.startAngle;
- graphic.initProps(clipPath, {
- shape: {
- endAngle: sectorArea.endAngle
- }
- }, seriesModel);
- }
- return clipPath;
- }
- function createClipPath(coordSys, hasAnimation, seriesModel) {
- if (!coordSys) {
- return null;
- } else if (coordSys.type === 'polar') {
- return createPolarClipPath(coordSys, hasAnimation, seriesModel);
- } else if (coordSys.type === 'cartesian2d') {
- return createGridClipPath(coordSys, hasAnimation, seriesModel);
- }
- return null;
- }
- exports.createGridClipPath = createGridClipPath;
- exports.createPolarClipPath = createPolarClipPath;
- exports.createClipPath = createClipPath;
|