UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

98 lines (97 loc) 2.72 kB
import { round } from "../../util/number.mjs"; import { isFunction } from "../../../../zrender/lib/core/util.mjs"; import Rect from "../../../../zrender/lib/graphic/shape/Rect.mjs"; import { initProps } from "../../animation/basicTransition.mjs"; import Sector from "../../../../zrender/lib/graphic/shape/Sector.mjs"; function createGridClipPath(cartesian, hasAnimation, seriesModel, done, during) { var rect = cartesian.getArea(); 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 Rect({ shape: { x, y, width, height } }); if (hasAnimation) { var baseAxis = cartesian.getBaseAxis(); var isHorizontal = baseAxis.isHorizontal(); var isAxisInversed = baseAxis.inverse; if (isHorizontal) { if (isAxisInversed) { clipPath.shape.x += width; } clipPath.shape.width = 0; } else { if (!isAxisInversed) { clipPath.shape.y += height; } clipPath.shape.height = 0; } var duringCb = isFunction(during) ? function(percent) { during(percent, clipPath); } : null; initProps(clipPath, { shape: { width, height, x, y } }, seriesModel, null, done, duringCb); } return clipPath; } function createPolarClipPath(polar, hasAnimation, seriesModel) { var sectorArea = polar.getArea(); var r0 = round(sectorArea.r0, 1); var r = round(sectorArea.r, 1); var clipPath = new Sector({ shape: { cx: round(polar.cx, 1), cy: round(polar.cy, 1), r0, r, startAngle: sectorArea.startAngle, endAngle: sectorArea.endAngle, clockwise: sectorArea.clockwise } }); if (hasAnimation) { var isRadial = polar.getBaseAxis().dim === "angle"; if (isRadial) { clipPath.shape.endAngle = sectorArea.startAngle; } else { clipPath.shape.r = r0; } initProps(clipPath, { shape: { endAngle: sectorArea.endAngle, r } }, seriesModel); } return clipPath; } function createClipPath(coordSys, hasAnimation, seriesModel, done, during) { if (!coordSys) { return null; } else if (coordSys.type === "polar") { return createPolarClipPath(coordSys, hasAnimation, seriesModel); } else if (coordSys.type === "cartesian2d") { return createGridClipPath(coordSys, hasAnimation, seriesModel, done, during); } return null; } export { createClipPath, createGridClipPath, createPolarClipPath };