@visactor/vrender-components 0.19.24-alpha.7 → 0.19.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -8092,15 +8092,16 @@ class Wrapper {
8092
8092
  this.frame.lines.push(line), this.frame.actualHeight += line.height, this.y += line.height, this.lineBuffer.length = 0, this.lineWidth = this.maxAscent = this.maxDescent = this.maxAscentForBlank = this.maxDescentForBlank = 0;
8093
8093
  }
8094
8094
  deal(paragraph) {
8095
- paragraph instanceof RichTextIcon ? "horizontal" === this.direction && 0 === this.width || "vertical" === this.direction && 0 === this.height || this.lineWidth + paragraph[this.directionKey.width] <= this[this.directionKey.width] ? this.store(paragraph) : 0 === this.lineBuffer.length ? (this.store(paragraph), this.send()) : (this.send(), this.deal(paragraph)) : "number" != typeof this.width || this.width < 0 || (paragraph.newLine && this.send(), 0 !== paragraph.text.length && ("horizontal" === this.direction && 0 === this.width || "vertical" === this.direction && 0 === this.height || this.lineWidth + paragraph[this.directionKey.width] <= this[this.directionKey.width] ? this.store(paragraph) : this.lineWidth === this[this.directionKey.width] ? (this.send(), this.deal(paragraph)) : this.cut(paragraph)));
8095
+ let singleLine = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
8096
+ paragraph instanceof RichTextIcon ? "horizontal" === this.direction && 0 === this.width || "vertical" === this.direction && 0 === this.height || this.lineWidth + paragraph[this.directionKey.width] <= this[this.directionKey.width] ? this.store(paragraph) : 0 === this.lineBuffer.length ? (this.store(paragraph), this.send()) : (this.send(), this.deal(paragraph)) : "number" != typeof this.width || this.width < 0 || (paragraph.newLine && this.send(), 0 !== paragraph.text.length && ("horizontal" === this.direction && 0 === this.width || "vertical" === this.direction && 0 === this.height || this.lineWidth + paragraph[this.directionKey.width] <= this[this.directionKey.width] ? this.store(paragraph) : this.lineWidth === this[this.directionKey.width] ? (this.send(), this.deal(paragraph)) : this.cut(paragraph, singleLine)));
8096
8097
  }
8097
- cut(paragraph) {
8098
+ cut(paragraph, singleLine) {
8098
8099
  const availableWidth = this[this.directionKey.width] - this.lineWidth || 0,
8099
8100
  guessIndex = Math.ceil(availableWidth / paragraph[this.directionKey.width] * paragraph.length) || 0,
8100
8101
  index = getStrByWithCanvas(paragraph.text, availableWidth, paragraph.character, guessIndex, "break-word" === this.frame.wordBreak);
8101
8102
  if (0 !== index) {
8102
8103
  const [p1, p2] = seperateParagraph(paragraph, index);
8103
- this.store(p1), this.deal(p2);
8104
+ this.store(p1), singleLine ? this.send() : this.deal(p2);
8104
8105
  } else 0 !== this.lineBuffer.length && (this.send(), this.deal(paragraph));
8105
8106
  }
8106
8107
  }
@@ -8277,7 +8278,7 @@ class RichText extends Graphic {
8277
8278
  skip = !1;
8278
8279
  for (let i = 0; i < paragraphs.length; i++) {
8279
8280
  const p = paragraphs[i];
8280
- skip ? (p.overflow = !0, p.left = 1 / 0, p.top = 1 / 0, !p.newLine && frame.lines[frame.lines.length - 1].paragraphs.push(p)) : wrapper.deal(p), frame.lines.length !== lineCount && (lineCount = frame.lines.length, wrapper.lineBuffer.length = 0, p.overflow = !0, p.left = 1e3, p.top = 1e3, frame.lines[frame.lines.length - 1].paragraphs.push(p), skip = !0), p.newLine && (skip = !1, wrapper.lineWidth = 0);
8281
+ skip ? (p.overflow = !0, p.left = 1 / 0, p.top = 1 / 0, !p.newLine && frame.lines[frame.lines.length - 1].paragraphs.push(p)) : wrapper.deal(p, !0), frame.lines.length !== lineCount && (lineCount = frame.lines.length, wrapper.lineBuffer.length = 0, p.overflow = !0, p.left = 1e3, p.top = 1e3, frame.lines[frame.lines.length - 1].paragraphs.push(p), skip = !0), p.newLine && (skip = !1, wrapper.lineWidth = 0), wrapper.send();
8281
8282
  }
8282
8283
  } else for (let i = 0; i < paragraphs.length; i++) wrapper.deal(paragraphs[i]);
8283
8284
  wrapper.send();
@@ -19218,6 +19219,33 @@ function getPolarAngleLabelPosition(angle, center, radius, labelOffset, inside,
19218
19219
  const vector = getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside);
19219
19220
  return getCircleLabelPosition(labelPoint, vector, text, style);
19220
19221
  }
19222
+ function getCirclePoints(center, count, radius, startAngle, endAngle) {
19223
+ const points = [];
19224
+ const range = endAngle - startAngle;
19225
+ for (let i = 0; i < count; i++) {
19226
+ const angle = startAngle + (i * range) / count;
19227
+ points.push(polarToCartesian$1(center, radius, angle));
19228
+ }
19229
+ return points;
19230
+ }
19231
+ function getPolygonPath(points, closed) {
19232
+ let path = '';
19233
+ if (points.length === 0) {
19234
+ return path;
19235
+ }
19236
+ points.forEach((point, index) => {
19237
+ if (index === 0) {
19238
+ path = `M${point.x},${point.y}`;
19239
+ }
19240
+ else {
19241
+ path += `L${point.x},${point.y}`;
19242
+ }
19243
+ });
19244
+ if (closed) {
19245
+ path += 'Z';
19246
+ }
19247
+ return path;
19248
+ }
19221
19249
 
19222
19250
  const dispatchHoverState = (e, container, lastHover) => {
19223
19251
  const target = e.target;
@@ -20532,22 +20560,29 @@ class CircleAxis extends AxisBase {
20532
20560
  super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, CircleAxis.defaultAttributes, attributes));
20533
20561
  }
20534
20562
  renderLine(container) {
20535
- const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, radius, center, innerRadius = 0, line = {}, inside = false } = this.attribute;
20563
+ const { startAngle = POLAR_START_ANGLE, endAngle = POLAR_END_ANGLE, radius, center, innerRadius = 0, line = {}, inside = false, sides } = this.attribute;
20536
20564
  let arcRadius = radius;
20537
20565
  let arcInnerRadius = innerRadius;
20538
20566
  if (inside && innerRadius > 0) {
20539
20567
  arcRadius = innerRadius;
20540
20568
  arcInnerRadius = 0;
20541
20569
  }
20542
- const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), { startAngle,
20543
- endAngle, radius: arcRadius, innerRadius: arcInnerRadius }), line.style);
20544
- const axisLine = graphicCreator.circle(arcAttrs);
20545
- axisLine.name = AXIS_ELEMENT_NAME.line;
20546
- axisLine.id = this._getNodeId('line');
20570
+ let lineGraphic;
20571
+ if (isValidNumber(sides) && sides >= 3) {
20572
+ const gridPoints = getCirclePoints(center, sides, arcRadius, startAngle, endAngle);
20573
+ lineGraphic = graphicCreator.path(Object.assign(Object.assign({}, line.style), { path: getPolygonPath(gridPoints, true) }));
20574
+ }
20575
+ else {
20576
+ const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), { startAngle,
20577
+ endAngle, radius: arcRadius, innerRadius: arcInnerRadius }), line.style);
20578
+ lineGraphic = graphicCreator.circle(arcAttrs);
20579
+ }
20580
+ lineGraphic.name = AXIS_ELEMENT_NAME.line;
20581
+ lineGraphic.id = this._getNodeId('line');
20547
20582
  if (!isEmpty(line.state)) {
20548
- axisLine.states = merge({}, DEFAULT_STATES$1, line.state);
20583
+ lineGraphic.states = merge({}, DEFAULT_STATES$1, line.state);
20549
20584
  }
20550
- container.add(axisLine);
20585
+ container.add(lineGraphic);
20551
20586
  }
20552
20587
  getTitleAttribute() {
20553
20588
  var _a, _b, _c;
@@ -20716,33 +20751,34 @@ class GroupTransition extends ACustomAnimate {
20716
20751
  onStart() {
20717
20752
  let duration = this.duration;
20718
20753
  let easing = this.easing;
20719
- Object.keys(this._newElementAttrMap).forEach(id => {
20720
- var _a;
20721
- const { node, attrs, state } = this._newElementAttrMap[id];
20722
- if (state === 'enter') {
20723
- const { enter = {} } = (_a = this.params) !== null && _a !== void 0 ? _a : {};
20724
- duration = isValidNumber(enter.duration) ? enter.duration : duration;
20725
- easing = enter.easing ? enter.easing : easing;
20726
- }
20727
- if (node.type === 'path') {
20728
- node
20729
- .animate({
20730
- interpolate(key, ratio, from, to, nextAttributes) {
20731
- if (key === 'path') {
20732
- nextAttributes.path = interpolateString(from, to)(ratio);
20733
- return true;
20754
+ this._newElementAttrMap &&
20755
+ Object.keys(this._newElementAttrMap).forEach(id => {
20756
+ var _a;
20757
+ const { node, attrs, state } = this._newElementAttrMap[id];
20758
+ if (state === 'enter') {
20759
+ const { enter = {} } = (_a = this.params) !== null && _a !== void 0 ? _a : {};
20760
+ duration = isValidNumber(enter.duration) ? enter.duration : duration;
20761
+ easing = enter.easing ? enter.easing : easing;
20762
+ }
20763
+ if (node.type === 'path') {
20764
+ node
20765
+ .animate({
20766
+ interpolate(key, ratio, from, to, nextAttributes) {
20767
+ if (key === 'path') {
20768
+ nextAttributes.path = interpolateString(from, to)(ratio);
20769
+ return true;
20770
+ }
20771
+ return false;
20734
20772
  }
20735
- return false;
20736
- }
20737
- })
20738
- .to(attrs, duration, easing);
20739
- }
20740
- else {
20741
- node
20742
- .animate()
20743
- .to(attrs, duration, easing);
20744
- }
20745
- });
20773
+ })
20774
+ .to(attrs, duration, easing);
20775
+ }
20776
+ else {
20777
+ node
20778
+ .animate()
20779
+ .to(attrs, duration, easing);
20780
+ }
20781
+ });
20746
20782
  }
20747
20783
  onUpdate(end, ratio, out) {
20748
20784
  }
@@ -21287,24 +21323,6 @@ const ticks = (scale, op) => {
21287
21323
  return convertDomainToTickData(scale.domain());
21288
21324
  };
21289
21325
 
21290
- function getLinePath(points, closed) {
21291
- let path = '';
21292
- if (points.length === 0) {
21293
- return path;
21294
- }
21295
- points.forEach((point, index) => {
21296
- if (index === 0) {
21297
- path = `M${point.x},${point.y}`;
21298
- }
21299
- else {
21300
- path += `L${point.x},${point.y}`;
21301
- }
21302
- });
21303
- if (closed) {
21304
- path += 'Z';
21305
- }
21306
- return path;
21307
- }
21308
21326
  function getArcPath(center, points, reverse, closed) {
21309
21327
  let path = '';
21310
21328
  if (!center || points.length === 0) {
@@ -21337,8 +21355,8 @@ function getRegionPath(from, to, attribute) {
21337
21355
  const fromStart = from[0];
21338
21356
  const toEnd = reversePoints[0];
21339
21357
  const center = attribute.center;
21340
- regionPath = getLinePath(from, !!closed);
21341
- nextPath = getLinePath(reversePoints, !!closed);
21358
+ regionPath = getPolygonPath(from, !!closed);
21359
+ nextPath = getPolygonPath(reversePoints, !!closed);
21342
21360
  const toEndRadius = PointService.distancePP(toEnd, center);
21343
21361
  const fromStartRadius = PointService.distancePP(fromStart, center);
21344
21362
  regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;
@@ -21350,8 +21368,8 @@ function getRegionPath(from, to, attribute) {
21350
21368
  nextPath = getArcPath(center, reversePoints, true, !!closed);
21351
21369
  }
21352
21370
  else if (type === 'line' || type === 'polygon') {
21353
- regionPath = getLinePath(from, !!closed);
21354
- nextPath = getLinePath(reversePoints, !!closed);
21371
+ regionPath = getPolygonPath(from, !!closed);
21372
+ nextPath = getPolygonPath(reversePoints, !!closed);
21355
21373
  }
21356
21374
  if (closed) {
21357
21375
  regionPath += nextPath;
@@ -21412,7 +21430,7 @@ class BaseGrid extends AbstractComponent {
21412
21430
  const { id, points } = item;
21413
21431
  let path = '';
21414
21432
  if (type === 'line' || type === 'polygon') {
21415
- path = getLinePath(points, !!closed);
21433
+ path = getPolygonPath(points, !!closed);
21416
21434
  }
21417
21435
  else if (type === 'circle') {
21418
21436
  const { center } = this.attribute;
@@ -21434,7 +21452,7 @@ class BaseGrid extends AbstractComponent {
21434
21452
  const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);
21435
21453
  const ratio = depth / dirLen;
21436
21454
  nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });
21437
- const path = getLinePath(nextPoints, !!closed);
21455
+ const path = getPolygonPath(nextPoints, !!closed);
21438
21456
  const deltaX = abs(nextPoints[0].x - nextPoints[1].x);
21439
21457
  const deltaY = abs(nextPoints[0].y - nextPoints[1].y);
21440
21458
  const shape = graphicCreator.path(Object.assign({ path, z: 0, alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * pi) / 2 : 0, beta: deltaX < deltaY ? -pi / 2 : 0, anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y] }, (isFunction(style)
@@ -21490,15 +21508,6 @@ BaseGrid.defaultAttributes = {
21490
21508
  }
21491
21509
  };
21492
21510
 
21493
- function getCirclePoints(center, count, radius, startAngle, endAngle) {
21494
- const points = [];
21495
- const range = endAngle - startAngle;
21496
- for (let i = 0; i < count; i++) {
21497
- const angle = startAngle + (i * range) / count;
21498
- points.push(polarToCartesian$1(center, radius, angle));
21499
- }
21500
- return points;
21501
- }
21502
21511
  loadLineAxisGridComponent();
21503
21512
  class LineAxisGrid extends BaseGrid {
21504
21513
  constructor(attributes, options) {
@@ -29618,6 +29627,6 @@ EmptyTip.defaultAttributes = {
29618
29627
  }
29619
29628
  };
29620
29629
 
29621
- const version = "0.19.24-alpha.7";
29630
+ const version = "0.19.24";
29622
29631
 
29623
- export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AreaLabel, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupFadeIn, GroupFadeOut, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineDataLabel, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, clampRadian, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, direction, fuzzyEqualNumber, getCircleLabelPosition, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, loadPoptip, measureTextSize, normalize, reactAttributeTransform, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
29632
+ export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AreaLabel, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupFadeIn, GroupFadeOut, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineDataLabel, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, clampRadian, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, direction, fuzzyEqualNumber, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, loadPoptip, measureTextSize, normalize, reactAttributeTransform, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
@@ -48,7 +48,7 @@ export class GroupTransition extends ACustomAnimate {
48
48
  }
49
49
  onStart() {
50
50
  let duration = this.duration, easing = this.easing;
51
- Object.keys(this._newElementAttrMap).forEach((id => {
51
+ this._newElementAttrMap && Object.keys(this._newElementAttrMap).forEach((id => {
52
52
  var _a;
53
53
  const {node: node, attrs: attrs, state: state} = this._newElementAttrMap[id];
54
54
  if ("enter" === state) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/animate/group-transition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,OAAO,e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AAC,GAAW,EAAE,KAAa,EAAE,IAAS,EAAE,EAAO,EAAE,cAAmB;wBAC7E,IAAI,GAAG,KAAK,MAAM,EAAE;4BAClB,cAAc,CAAC,IAAI,GAAG,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;4BACzD,OAAO,IAAI,CAAC;yBACb;wBAED,OAAO,KAAK,CAAC;oBACf,CAAC;iBACF,CAAC;qBAED,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAoB,CAAC,CAAC;aAC9C;iBAAM;gBACJ,IAAiB;qBACf,OAAO,EAAE;qBAET,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAoB,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;IAE9D,CAAC;CACF","file":"group-transition.js","sourcesContent":["import type { EasingType, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { ACustomAnimate, AnimateMode } from '@visactor/vrender-core';\nimport type { Dict } from '@visactor/vutils';\nimport { cloneDeep, interpolateString, isEqual, isValidNumber } from '@visactor/vutils';\nimport { traverseGroup } from '../../util';\n\nexport class GroupTransition extends ACustomAnimate<any> {\n declare target: IGroup;\n\n private _newElementAttrMap: Dict<any>;\n mode = AnimateMode.NORMAL; // 组件的群组动画不需要设置走 AnimateMode.SET_ATTR_IMMEDIATELY\n\n onBind(): void {\n // @ts-ignore\n const currentInnerView = this.target.getInnerView();\n // @ts-ignore\n const prevInnerView = this.target.getPrevInnerView();\n if (!prevInnerView) {\n return;\n }\n\n this._newElementAttrMap = {};\n\n // 遍历新的场景树,将新节点属性更新为旧节点\n // TODO: 目前只处理更新场景\n traverseGroup(currentInnerView, (el: IGraphic) => {\n if ((el as IGraphic).type !== 'group' && el.id) {\n const oldEl = prevInnerView[el.id];\n if (oldEl) {\n if (!isEqual((el as IGraphic).attribute, (oldEl as IGraphic).attribute)) {\n // 更新\n const newProps = cloneDeep((el as IGraphic).attribute);\n this._newElementAttrMap[el.id] = {\n state: 'update',\n node: el,\n attrs: {\n ...newProps,\n opacity: newProps.opacity ?? 1,\n fillOpacity: newProps.fillOpacity ?? 1,\n strokeOpacity: newProps.strokeOpacity ?? 1\n }\n };\n\n (el as IGraphic).setAttributes((oldEl as IGraphic).attribute);\n }\n } else {\n // 新入场元素,进行 fadeIn 动画\n const finalOpacityAttrs = {\n opacity: el.attribute.opacity ?? 1,\n fillOpacity: el.attribute.fillOpacity ?? 1,\n strokeOpacity: el.attribute.strokeOpacity ?? 1\n };\n this._newElementAttrMap[el.id] = {\n state: 'enter',\n node: el,\n attrs: finalOpacityAttrs\n };\n (el as IGraphic).setAttributes({\n opacity: 0,\n fillOpacity: 0,\n strokeOpacity: 0\n });\n }\n }\n });\n }\n\n onStart(): void {\n let duration = this.duration;\n let easing = this.easing;\n\n // 新的场景树\n Object.keys(this._newElementAttrMap).forEach(id => {\n const { node, attrs, state } = this._newElementAttrMap[id];\n if (state === 'enter') {\n const { enter = {} } = this.params ?? {};\n duration = isValidNumber(enter.duration) ? enter.duration : duration;\n easing = enter.easing ? enter.easing : easing;\n }\n if ((node as IGraphic).type === 'path') {\n (node as IGraphic)\n .animate({\n interpolate(key: string, ratio: number, from: any, to: any, nextAttributes: any) {\n if (key === 'path') {\n nextAttributes.path = interpolateString(from, to)(ratio);\n return true;\n }\n\n return false;\n }\n })\n // .wait(delay)\n .to(attrs, duration, easing as EasingType);\n } else {\n (node as IGraphic)\n .animate()\n // .wait(delay)\n .to(attrs, duration, easing as EasingType);\n }\n });\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n // do nothing\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/animate/group-transition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,aA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C,CAAC,CAAC,MAAM,CAAC;iBAC/C;gBACD,IAAK,IAAiB,CAAC,IAAI,KAAK,MAAM,EAAE;oBACrC,IAAiB;yBACf,OAAO,CAAC;wBACP,WAAW,CAAC,GAAW,EAAE,KAAa,EAAE,IAAS,EAAE,EAAO,EAAE,cAAmB;4BAC7E,IAAI,GAAG,KAAK,MAAM,EAAE;gCAClB,cAAc,CAAC,IAAI,GAAG,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gCACzD,OAAO,IAAI,CAAC;6BACb;4BAED,OAAO,KAAK,CAAC;wBACf,CAAC;qBACF,CAAC;yBAED,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAoB,CAAC,CAAC;iBAC9C;qBAAM;oBACJ,IAAiB;yBACf,OAAO,EAAE;yBAET,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAoB,CAAC,CAAC;iBAC9C;YACH,CAAC,CAAC,CAAC;IACP,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;IAE9D,CAAC;CACF","file":"group-transition.js","sourcesContent":["import type { EasingType, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { ACustomAnimate, AnimateMode } from '@visactor/vrender-core';\nimport type { Dict } from '@visactor/vutils';\nimport { cloneDeep, interpolateString, isEqual, isValidNumber } from '@visactor/vutils';\nimport { traverseGroup } from '../../util';\n\nexport class GroupTransition extends ACustomAnimate<any> {\n declare target: IGroup;\n\n private _newElementAttrMap: Dict<any>;\n mode = AnimateMode.NORMAL; // 组件的群组动画不需要设置走 AnimateMode.SET_ATTR_IMMEDIATELY\n\n onBind(): void {\n // @ts-ignore\n const currentInnerView = this.target.getInnerView();\n // @ts-ignore\n const prevInnerView = this.target.getPrevInnerView();\n if (!prevInnerView) {\n return;\n }\n\n this._newElementAttrMap = {};\n\n // 遍历新的场景树,将新节点属性更新为旧节点\n // TODO: 目前只处理更新场景\n traverseGroup(currentInnerView, (el: IGraphic) => {\n if ((el as IGraphic).type !== 'group' && el.id) {\n const oldEl = prevInnerView[el.id];\n if (oldEl) {\n if (!isEqual((el as IGraphic).attribute, (oldEl as IGraphic).attribute)) {\n // 更新\n const newProps = cloneDeep((el as IGraphic).attribute);\n this._newElementAttrMap[el.id] = {\n state: 'update',\n node: el,\n attrs: {\n ...newProps,\n opacity: newProps.opacity ?? 1,\n fillOpacity: newProps.fillOpacity ?? 1,\n strokeOpacity: newProps.strokeOpacity ?? 1\n }\n };\n\n (el as IGraphic).setAttributes((oldEl as IGraphic).attribute);\n }\n } else {\n // 新入场元素,进行 fadeIn 动画\n const finalOpacityAttrs = {\n opacity: el.attribute.opacity ?? 1,\n fillOpacity: el.attribute.fillOpacity ?? 1,\n strokeOpacity: el.attribute.strokeOpacity ?? 1\n };\n this._newElementAttrMap[el.id] = {\n state: 'enter',\n node: el,\n attrs: finalOpacityAttrs\n };\n (el as IGraphic).setAttributes({\n opacity: 0,\n fillOpacity: 0,\n strokeOpacity: 0\n });\n }\n }\n });\n }\n\n onStart(): void {\n let duration = this.duration;\n let easing = this.easing;\n\n // 新的场景树\n this._newElementAttrMap &&\n Object.keys(this._newElementAttrMap).forEach(id => {\n const { node, attrs, state } = this._newElementAttrMap[id];\n if (state === 'enter') {\n const { enter = {} } = this.params ?? {};\n duration = isValidNumber(enter.duration) ? enter.duration : duration;\n easing = enter.easing ? enter.easing : easing;\n }\n if ((node as IGraphic).type === 'path') {\n (node as IGraphic)\n .animate({\n interpolate(key: string, ratio: number, from: any, to: any, nextAttributes: any) {\n if (key === 'path') {\n nextAttributes.path = interpolateString(from, to)(ratio);\n return true;\n }\n\n return false;\n }\n })\n // .wait(delay)\n .to(attrs, duration, easing as EasingType);\n } else {\n (node as IGraphic)\n .animate()\n // .wait(delay)\n .to(attrs, duration, easing as EasingType);\n }\n });\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n // do nothing\n }\n}\n"]}
package/es/axis/circle.js CHANGED
@@ -10,7 +10,7 @@ var __rest = this && this.__rest || function(s, e) {
10
10
 
11
11
  import { graphicCreator } from "@visactor/vrender-core";
12
12
 
13
- import { isNil, get, merge, isNumberClose, isEmpty, mixin } from "@visactor/vutils";
13
+ import { isNil, get, merge, isNumberClose, isEmpty, mixin, isValidNumber } from "@visactor/vutils";
14
14
 
15
15
  import { POLAR_END_ANGLE, POLAR_START_ANGLE } from "../constant";
16
16
 
@@ -22,7 +22,7 @@ import { AXIS_ELEMENT_NAME, DEFAULT_STATES } from "./constant";
22
22
 
23
23
  import { CircleAxisMixin } from "./mixin/circle";
24
24
 
25
- import { getCircleLabelPosition } from "./util";
25
+ import { getCircleLabelPosition, getCirclePoints, getPolygonPath } from "./util";
26
26
 
27
27
  import { loadCircleAxisComponent } from "./register";
28
28
 
@@ -33,17 +33,26 @@ export class CircleAxis extends AxisBase {
33
33
  super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, CircleAxis.defaultAttributes, attributes));
34
34
  }
35
35
  renderLine(container) {
36
- const {startAngle: startAngle = POLAR_START_ANGLE, endAngle: endAngle = POLAR_END_ANGLE, radius: radius, center: center, innerRadius: innerRadius = 0, line: line = {}, inside: inside = !1} = this.attribute;
37
- let arcRadius = radius, arcInnerRadius = innerRadius;
38
- inside && innerRadius > 0 && (arcRadius = innerRadius, arcInnerRadius = 0);
39
- const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), {
40
- startAngle: startAngle,
41
- endAngle: endAngle,
42
- radius: arcRadius,
43
- innerRadius: arcInnerRadius
44
- }), line.style), axisLine = graphicCreator.circle(arcAttrs);
45
- axisLine.name = AXIS_ELEMENT_NAME.line, axisLine.id = this._getNodeId("line"), isEmpty(line.state) || (axisLine.states = merge({}, DEFAULT_STATES, line.state)),
46
- container.add(axisLine);
36
+ const {startAngle: startAngle = POLAR_START_ANGLE, endAngle: endAngle = POLAR_END_ANGLE, radius: radius, center: center, innerRadius: innerRadius = 0, line: line = {}, inside: inside = !1, sides: sides} = this.attribute;
37
+ let lineGraphic, arcRadius = radius, arcInnerRadius = innerRadius;
38
+ if (inside && innerRadius > 0 && (arcRadius = innerRadius, arcInnerRadius = 0),
39
+ isValidNumber(sides) && sides >= 3) {
40
+ const gridPoints = getCirclePoints(center, sides, arcRadius, startAngle, endAngle);
41
+ lineGraphic = graphicCreator.path(Object.assign(Object.assign({}, line.style), {
42
+ path: getPolygonPath(gridPoints, !0)
43
+ }));
44
+ } else {
45
+ const arcAttrs = Object.assign(Object.assign(Object.assign({}, center), {
46
+ startAngle: startAngle,
47
+ endAngle: endAngle,
48
+ radius: arcRadius,
49
+ innerRadius: arcInnerRadius
50
+ }), line.style);
51
+ lineGraphic = graphicCreator.circle(arcAttrs);
52
+ }
53
+ lineGraphic.name = AXIS_ELEMENT_NAME.line, lineGraphic.id = this._getNodeId("line"),
54
+ isEmpty(line.state) || (lineGraphic.states = merge({}, DEFAULT_STATES, line.state)),
55
+ container.add(lineGraphic);
47
56
  }
48
57
  getTitleAttribute() {
49
58
  var _a, _b, _c;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/circle.ts"],"names":[],"mappings":";;;;;;;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,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CAAC,EAAE;YACrE,IAAI,GAAG,QAAQ,CAAC;SACjB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAES,mBAAmB,CAC3B,WAAoB,EACpB,SAAqB,EACrB,cAAsB,EACtB,KAAa,EACb,UAAkB;QAElB,OAAO;IACT,CAAC;IACS,mBAAmB,CAC3B,WAAoB,EACpB,SAAqB,EACrB,cAAsB,EACtB,KAAa,EACb,UAAkB;QAGlB,OAAO;IACT,CAAC;IACS,kBAAkB,CAC1B,WAAoB,EACpB,SAAqB,EACrB,cAAsB,EACtB,KAAa,EACb,UAAkB;QAElB,OAAO;IACT,CAAC;IAES,aAAa,CACrB,MAAwB,EACxB,MAAgB,EAChB,KAAc;QAEd,OAAO;YACL,SAAS,EAAE,QAAQ;YACnB,YAAY,EAAE,QAAQ;SACvB,CAAC;IACJ,CAAC;IAES,gBAAgB,CACxB,KAAY,EACZ,MAAwB,EACxB,IAAqB,EACrB,KAAqC;QAErC,OAAO,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;;AApNM,4BAAiB,GAAG,kBAAkB,CAAC;AAuNhD,KAAK,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC","file":"circle.js","sourcesContent":["/**\n * @description 圆弧型坐标轴\n */\nimport type { IGroup, IText, ITextGraphicAttribute, TextAlignType, TextBaselineType } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport type { Point } from '@visactor/vutils';\nimport { isNil, get, merge, isNumberClose, isEmpty, mixin } from '@visactor/vutils';\nimport { POLAR_END_ANGLE, POLAR_START_ANGLE } from '../constant';\nimport type { CircleAxisAttributes, TitleAttributes, SubTickAttributes, TickLineItem, AxisItem } from './type';\nimport { AxisBase } from './base';\nimport { DEFAULT_AXIS_THEME } from './config';\nimport { AXIS_ELEMENT_NAME, DEFAULT_STATES } from './constant';\nimport { CircleAxisMixin } from './mixin/circle';\nimport { getCircleLabelPosition } from './util';\nimport type { ComponentOptions } from '../interface';\nimport { loadCircleAxisComponent } from './register';\n\nloadCircleAxisComponent();\nexport interface CircleAxis\n extends Pick<CircleAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector' | 'getRelativeVector'>,\n AxisBase<CircleAxisAttributes> {}\n\nexport class CircleAxis extends AxisBase<CircleAxisAttributes> {\n static defaultAttributes = DEFAULT_AXIS_THEME;\n\n constructor(attributes: CircleAxisAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, CircleAxis.defaultAttributes, attributes));\n }\n\n protected renderLine(container: IGroup): void {\n const {\n startAngle = POLAR_START_ANGLE,\n endAngle = POLAR_END_ANGLE,\n radius,\n center,\n innerRadius = 0,\n line = {},\n inside = false\n } = this.attribute as CircleAxisAttributes;\n\n let arcRadius = radius;\n let arcInnerRadius = innerRadius;\n if (inside && innerRadius > 0) {\n arcRadius = innerRadius;\n arcInnerRadius = 0;\n }\n\n const arcAttrs = {\n ...center,\n startAngle,\n endAngle,\n radius: arcRadius,\n innerRadius: arcInnerRadius,\n ...line.style\n };\n const axisLine = graphicCreator.circle(arcAttrs);\n axisLine.name = AXIS_ELEMENT_NAME.line;\n axisLine.id = this._getNodeId('line');\n\n if (!isEmpty(line.state)) {\n axisLine.states = merge({}, DEFAULT_STATES, line.state);\n }\n container.add(axisLine);\n }\n\n protected getTitleAttribute() {\n const { center, radius, innerRadius = 0 } = this.attribute as CircleAxisAttributes;\n const {\n space = 4,\n textStyle = {},\n shape,\n background,\n state = {},\n ...restAttrs\n } = this.attribute.title as TitleAttributes;\n let titlePoint = center;\n let labelHeight = 0;\n if (this.attribute.label?.visible && this.attribute.label.inside === false) {\n // 这里取 label 的最大长度\n labelHeight = get(this.attribute.label, 'style.fontSize', 12) + get(this.attribute.label, 'space', 4);\n }\n let tickLength = 0;\n if (this.attribute.tick?.visible && this.attribute.tick.inside === false) {\n tickLength = this.attribute.tick.length || 4;\n }\n if (this.attribute.subTick?.visible && this.attribute.subTick.inside === false) {\n tickLength = Math.max(tickLength, this.attribute.subTick.length || 2);\n }\n const offset = radius + tickLength + labelHeight + space;\n let textBaseline: TextBaselineType = 'middle';\n let { position } = this.attribute.title as TitleAttributes;\n if (isNil(position)) {\n position = innerRadius === 0 ? 'end' : 'middle';\n }\n if (position === 'start') {\n textBaseline = 'bottom';\n titlePoint = {\n x: center.x,\n y: center.y - offset\n };\n } else if (position === 'end') {\n textBaseline = 'top';\n titlePoint = {\n x: center.x,\n y: center.y + offset\n };\n }\n const attrs: any = {\n ...titlePoint,\n ...restAttrs,\n textStyle: {\n textBaseline,\n textAlign: 'center',\n ...textStyle\n },\n state: {\n text: merge({}, DEFAULT_STATES, state.text),\n shape: merge({}, DEFAULT_STATES, state.shape),\n panel: merge({}, DEFAULT_STATES, state.background)\n }\n };\n\n const { angle } = restAttrs; // 用户设置的是角度\n attrs.angle = angle;\n\n if (shape && shape.visible) {\n attrs.shape = {\n visible: true,\n ...shape.style\n };\n if (shape.space) {\n attrs.space = shape.space;\n }\n }\n\n if (background && background.visible) {\n attrs.panel = {\n visible: true,\n ...background.style\n };\n }\n\n return attrs;\n }\n\n protected getSubTickLineItems() {\n const { subTick } = this.attribute as CircleAxisAttributes;\n const subTickLineItems: TickLineItem[] = [];\n const { count: subCount = 4, inside = false, length = 2 } = subTick as SubTickAttributes;\n const tickLineItems = this.tickLineItems;\n const tickLineCount = tickLineItems.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n if (tickLineCount >= 2) {\n const tickSegment = this.data[1].value - this.data[0].value;\n const isAlignWithLable = this.attribute?.tick?.alignWithLabel;\n for (let i = 0; i < tickLineCount; i++) {\n const pre = tickLineItems[i];\n const next = tickLineItems[i + 1];\n for (let j = 0; j < subCount; j++) {\n const percent = (j + 1) / (subCount + 1);\n const value =\n (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);\n const point = this.getTickCoord(value);\n const endPoint = this.getVerticalCoord(point, length, inside);\n subTickLineItems.push({\n start: point,\n end: endPoint,\n value\n });\n }\n }\n }\n\n return subTickLineItems;\n }\n\n protected getTextBaseline(vector: number[]): TextBaselineType {\n let base: TextBaselineType = 'middle';\n if (isNumberClose(vector[1], 0)) {\n base = 'middle';\n } else if (vector[1] > 0 && vector[1] > Math.abs(vector[0])) {\n base = 'top';\n } else if (vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0])) {\n base = 'bottom';\n }\n return base;\n }\n\n protected beforeLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n return;\n }\n protected handleLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n // 暂不支持\n return;\n }\n protected afterLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n return;\n }\n\n protected getLabelAlign(\n vector: [number, number],\n inside?: boolean,\n angle?: number\n ): { textAlign: TextAlignType; textBaseline: TextBaselineType } {\n return {\n textAlign: 'center', //'left',\n textBaseline: 'middle' //'top'\n };\n }\n\n protected getLabelPosition(\n point: Point,\n vector: [number, number],\n text: string | number,\n style: Partial<ITextGraphicAttribute>\n ) {\n return getCircleLabelPosition(point, vector, text, style);\n }\n}\n\nmixin(CircleAxis, CircleAxisMixin);\n"]}
1
+ {"version":3,"sources":["../src/axis/circle.ts"],"names":[],"mappings":";;;;;;;;;;;AAYA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjE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IAAqB,EACrB,KAAqC;QAErC,OAAO,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;;AAhOM,4BAAiB,GAAG,kBAAkB,CAAC;AAmOhD,KAAK,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC","file":"circle.js","sourcesContent":["/**\n * @description 圆弧型坐标轴\n */\nimport type {\n IGraphic,\n IGroup,\n IText,\n ITextGraphicAttribute,\n TextAlignType,\n TextBaselineType\n} from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport type { Point } from '@visactor/vutils';\nimport { isNil, get, merge, isNumberClose, isEmpty, mixin, isValidNumber } from '@visactor/vutils';\nimport { POLAR_END_ANGLE, POLAR_START_ANGLE } from '../constant';\nimport type { CircleAxisAttributes, TitleAttributes, SubTickAttributes, TickLineItem, AxisItem } from './type';\nimport { AxisBase } from './base';\nimport { DEFAULT_AXIS_THEME } from './config';\nimport { AXIS_ELEMENT_NAME, DEFAULT_STATES } from './constant';\nimport { CircleAxisMixin } from './mixin/circle';\nimport { getCircleLabelPosition, getCirclePoints, getPolygonPath } from './util';\nimport type { ComponentOptions } from '../interface';\nimport { loadCircleAxisComponent } from './register';\n\nloadCircleAxisComponent();\nexport interface CircleAxis\n extends Pick<CircleAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector' | 'getRelativeVector'>,\n AxisBase<CircleAxisAttributes> {}\n\nexport class CircleAxis extends AxisBase<CircleAxisAttributes> {\n static defaultAttributes = DEFAULT_AXIS_THEME;\n\n constructor(attributes: CircleAxisAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, CircleAxis.defaultAttributes, attributes));\n }\n\n protected renderLine(container: IGroup): void {\n const {\n startAngle = POLAR_START_ANGLE,\n endAngle = POLAR_END_ANGLE,\n radius,\n center,\n innerRadius = 0,\n line = {},\n inside = false,\n sides\n } = this.attribute as CircleAxisAttributes;\n\n let arcRadius = radius;\n let arcInnerRadius = innerRadius;\n if (inside && innerRadius > 0) {\n arcRadius = innerRadius;\n arcInnerRadius = 0;\n }\n\n let lineGraphic: IGraphic;\n if (isValidNumber(sides) && sides >= 3) {\n const gridPoints = getCirclePoints(center as Point, sides as number, arcRadius, startAngle, endAngle);\n\n lineGraphic = graphicCreator.path({\n ...line.style,\n path: getPolygonPath(gridPoints, true)\n });\n } else {\n const arcAttrs = {\n ...center,\n startAngle,\n endAngle,\n radius: arcRadius,\n innerRadius: arcInnerRadius,\n ...line.style\n };\n lineGraphic = graphicCreator.circle(arcAttrs);\n }\n\n lineGraphic.name = AXIS_ELEMENT_NAME.line;\n lineGraphic.id = this._getNodeId('line');\n\n if (!isEmpty(line.state)) {\n lineGraphic.states = merge({}, DEFAULT_STATES, line.state);\n }\n container.add(lineGraphic);\n }\n\n protected getTitleAttribute() {\n const { center, radius, innerRadius = 0 } = this.attribute as CircleAxisAttributes;\n const {\n space = 4,\n textStyle = {},\n shape,\n background,\n state = {},\n ...restAttrs\n } = this.attribute.title as TitleAttributes;\n let titlePoint = center;\n let labelHeight = 0;\n if (this.attribute.label?.visible && this.attribute.label.inside === false) {\n // 这里取 label 的最大长度\n labelHeight = get(this.attribute.label, 'style.fontSize', 12) + get(this.attribute.label, 'space', 4);\n }\n let tickLength = 0;\n if (this.attribute.tick?.visible && this.attribute.tick.inside === false) {\n tickLength = this.attribute.tick.length || 4;\n }\n if (this.attribute.subTick?.visible && this.attribute.subTick.inside === false) {\n tickLength = Math.max(tickLength, this.attribute.subTick.length || 2);\n }\n const offset = radius + tickLength + labelHeight + space;\n let textBaseline: TextBaselineType = 'middle';\n let { position } = this.attribute.title as TitleAttributes;\n if (isNil(position)) {\n position = innerRadius === 0 ? 'end' : 'middle';\n }\n if (position === 'start') {\n textBaseline = 'bottom';\n titlePoint = {\n x: center.x,\n y: center.y - offset\n };\n } else if (position === 'end') {\n textBaseline = 'top';\n titlePoint = {\n x: center.x,\n y: center.y + offset\n };\n }\n const attrs: any = {\n ...titlePoint,\n ...restAttrs,\n textStyle: {\n textBaseline,\n textAlign: 'center',\n ...textStyle\n },\n state: {\n text: merge({}, DEFAULT_STATES, state.text),\n shape: merge({}, DEFAULT_STATES, state.shape),\n panel: merge({}, DEFAULT_STATES, state.background)\n }\n };\n\n const { angle } = restAttrs; // 用户设置的是角度\n attrs.angle = angle;\n\n if (shape && shape.visible) {\n attrs.shape = {\n visible: true,\n ...shape.style\n };\n if (shape.space) {\n attrs.space = shape.space;\n }\n }\n\n if (background && background.visible) {\n attrs.panel = {\n visible: true,\n ...background.style\n };\n }\n\n return attrs;\n }\n\n protected getSubTickLineItems() {\n const { subTick } = this.attribute as CircleAxisAttributes;\n const subTickLineItems: TickLineItem[] = [];\n const { count: subCount = 4, inside = false, length = 2 } = subTick as SubTickAttributes;\n const tickLineItems = this.tickLineItems;\n const tickLineCount = tickLineItems.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n if (tickLineCount >= 2) {\n const tickSegment = this.data[1].value - this.data[0].value;\n const isAlignWithLable = this.attribute?.tick?.alignWithLabel;\n for (let i = 0; i < tickLineCount; i++) {\n const pre = tickLineItems[i];\n const next = tickLineItems[i + 1];\n for (let j = 0; j < subCount; j++) {\n const percent = (j + 1) / (subCount + 1);\n const value =\n (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);\n const point = this.getTickCoord(value);\n const endPoint = this.getVerticalCoord(point, length, inside);\n subTickLineItems.push({\n start: point,\n end: endPoint,\n value\n });\n }\n }\n }\n\n return subTickLineItems;\n }\n\n protected getTextBaseline(vector: number[]): TextBaselineType {\n let base: TextBaselineType = 'middle';\n if (isNumberClose(vector[1], 0)) {\n base = 'middle';\n } else if (vector[1] > 0 && vector[1] > Math.abs(vector[0])) {\n base = 'top';\n } else if (vector[1] < 0 && Math.abs(vector[1]) > Math.abs(vector[0])) {\n base = 'bottom';\n }\n return base;\n }\n\n protected beforeLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n return;\n }\n protected handleLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n // 暂不支持\n return;\n }\n protected afterLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n return;\n }\n\n protected getLabelAlign(\n vector: [number, number],\n inside?: boolean,\n angle?: number\n ): { textAlign: TextAlignType; textBaseline: TextBaselineType } {\n return {\n textAlign: 'center', //'left',\n textBaseline: 'middle' //'top'\n };\n }\n\n protected getLabelPosition(\n point: Point,\n vector: [number, number],\n text: string | number,\n style: Partial<ITextGraphicAttribute>\n ) {\n return getCircleLabelPosition(point, vector, text, style);\n }\n}\n\nmixin(CircleAxis, CircleAxisMixin);\n"]}
@@ -6,14 +6,7 @@ import { AbstractComponent } from "../../core/base";
6
6
 
7
7
  import { AXIS_ELEMENT_NAME } from "../constant";
8
8
 
9
- import { getElMap, getVerticalCoord } from "../util";
10
-
11
- function getLinePath(points, closed) {
12
- let path = "";
13
- return 0 === points.length || (points.forEach(((point, index) => {
14
- 0 === index ? path = `M${point.x},${point.y}` : path += `L${point.x},${point.y}`;
15
- })), closed && (path += "Z")), path;
16
- }
9
+ import { getElMap, getPolygonPath, getVerticalCoord } from "../util";
17
10
 
18
11
  function getArcPath(center, points, reverse, closed) {
19
12
  let path = "";
@@ -29,15 +22,15 @@ function getRegionPath(from, to, attribute) {
29
22
  let regionPath = "", nextPath = "";
30
23
  if ("line" === type && attribute.smoothLink && attribute.center) {
31
24
  const fromStart = from[0], toEnd = reversePoints[0], center = attribute.center;
32
- regionPath = getLinePath(from, !!closed), nextPath = getLinePath(reversePoints, !!closed);
25
+ regionPath = getPolygonPath(from, !!closed), nextPath = getPolygonPath(reversePoints, !!closed);
33
26
  const toEndRadius = PointService.distancePP(toEnd, center), fromStartRadius = PointService.distancePP(fromStart, center);
34
27
  regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`,
35
28
  nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;
36
29
  } else if ("circle" === type) {
37
30
  const {center: center} = attribute;
38
31
  regionPath = getArcPath(center, from, !1, !!closed), nextPath = getArcPath(center, reversePoints, !0, !!closed);
39
- } else "line" !== type && "polygon" !== type || (regionPath = getLinePath(from, !!closed),
40
- nextPath = getLinePath(reversePoints, !!closed));
32
+ } else "line" !== type && "polygon" !== type || (regionPath = getPolygonPath(from, !!closed),
33
+ nextPath = getPolygonPath(reversePoints, !!closed));
41
34
  return closed ? regionPath += nextPath : (nextPath = "L" + nextPath.substring(1),
42
35
  regionPath += nextPath, regionPath += "Z"), regionPath;
43
36
  }
@@ -85,7 +78,7 @@ export class BaseGrid extends AbstractComponent {
85
78
  if (items.forEach(((item, index) => {
86
79
  const {id: id, points: points} = item;
87
80
  let path = "";
88
- if ("line" === type || "polygon" === type) path = getLinePath(points, !!closed); else if ("circle" === type) {
81
+ if ("line" === type || "polygon" === type) path = getPolygonPath(points, !!closed); else if ("circle" === type) {
89
82
  const {center: center} = this.attribute;
90
83
  path = getArcPath(center, points, !1, !!closed);
91
84
  }
@@ -102,7 +95,7 @@ export class BaseGrid extends AbstractComponent {
102
95
  x: points[0].x + dir_x * ratio,
103
96
  y: points[0].y + dir_y * ratio
104
97
  });
105
- const path = getLinePath(nextPoints, !!closed), deltaX = abs(nextPoints[0].x - nextPoints[1].x), deltaY = abs(nextPoints[0].y - nextPoints[1].y), shape = graphicCreator.path(Object.assign({
98
+ const path = getPolygonPath(nextPoints, !!closed), deltaX = abs(nextPoints[0].x - nextPoints[1].x), deltaY = abs(nextPoints[0].y - nextPoints[1].y), shape = graphicCreator.path(Object.assign({
106
99
  path: path,
107
100
  z: 0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AAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACjB;KACF;CACF,CAAC","file":"base.js","sourcesContent":["/**\n * @description 网格线\n */\nimport { isFunction, isArray, merge, PointService, abs, pi } from '@visactor/vutils';\nimport type { IGraphic, IGroup, Path } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../../core/base';\nimport type { Point } from '../../core/type';\nimport type { GridItem, CircleGridAttributes, GridBaseAttributes, GridAttributes, LineGridAttributes } from './type';\nimport type { AxisItem, TransformedAxisItem } from '../type';\nimport { AXIS_ELEMENT_NAME } from '../constant';\nimport { getElMap, getVerticalCoord } from '../util';\n\nfunction getLinePath(points: Point[], closed: boolean) {\n let path = '';\n if (points.length === 0) {\n return path;\n }\n points.forEach((point, index) => {\n if (index === 0) {\n path = `M${point.x},${point.y}`;\n } else {\n path += `L${point.x},${point.y}`;\n }\n });\n if (closed) {\n path += 'Z';\n }\n\n return path;\n}\n\nfunction getArcPath(center: Point, points: Point[], reverse: boolean, closed: boolean) {\n let path = '';\n if (!center || points.length === 0) {\n return path;\n }\n const firstPoint = points[0];\n const radius = PointService.distancePP(center, firstPoint);\n const sweepFlag = reverse ? 0 : 1; // 顺时针还是逆时针\n if (closed) {\n // 封闭时,绘制整个圆\n path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${\n center.y + radius\n }A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;\n } else {\n points.forEach((point, index) => {\n if (index === 0) {\n path = `M${point.x},${point.y}`;\n } else {\n path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;\n }\n });\n }\n\n return path;\n}\n\nfunction getRegionPath(from: Point[], to: Point[], attribute: GridAttributes) {\n const { type, closed } = attribute;\n const reversePoints = to.slice(0).reverse();\n\n let regionPath = '';\n let nextPath = '';\n\n if (type === 'line' && (attribute as LineGridAttributes).smoothLink && (attribute as LineGridAttributes).center) {\n const fromStart = from[0];\n const toEnd = reversePoints[0];\n const center = (attribute as LineGridAttributes).center as Point;\n\n regionPath = getLinePath(from, !!closed);\n nextPath = getLinePath(reversePoints, !!closed);\n const toEndRadius = PointService.distancePP(toEnd, center);\n const fromStartRadius = PointService.distancePP(fromStart, center);\n regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;\n nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;\n } else if (type === 'circle') {\n const { center } = attribute as CircleGridAttributes;\n regionPath = getArcPath(center, from, false, !!closed);\n nextPath = getArcPath(center, reversePoints, true, !!closed);\n } else if (type === 'line' || type === 'polygon') {\n regionPath = getLinePath(from, !!closed);\n nextPath = getLinePath(reversePoints, !!closed);\n }\n\n if (closed) {\n regionPath += nextPath;\n } else {\n nextPath = 'L' + nextPath.substring(1); // 更新第一个节点\n regionPath += nextPath;\n regionPath += 'Z';\n }\n return regionPath;\n}\n\nexport abstract class BaseGrid<T extends GridBaseAttributes> extends AbstractComponent<Required<T>> {\n name = 'axis-grid';\n\n static defaultAttributes: Partial<GridBaseAttributes> = {\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n },\n subGrid: {\n visible: false,\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n }\n }\n };\n\n protected _innerView: IGroup;\n getInnerView() {\n return this._innerView;\n }\n\n protected _prevInnerView: { [key: string]: IGraphic }; // 缓存旧场景树,用于自定义动画\n /**\n * 获取更新前的旧场景树\n * @returns 返回更新前的旧场景树\n */\n getPrevInnerView() {\n return this._prevInnerView;\n }\n\n // 经过处理后的坐标轴点数据\n protected data: TransformedAxisItem[] = [];\n abstract getTickCoord(value: number): Point;\n abstract isInValidValue(value: number): boolean;\n abstract getVerticalVector(offset: number, inside: boolean, point: Point): [number, number];\n protected abstract getGridAttribute(isSubGrid: boolean): T;\n\n protected render(): void {\n this._prevInnerView = this._innerView && getElMap(this._innerView);\n\n this.removeAllChild(true);\n this._innerView = graphicCreator.group({ x: 0, y: 0, pickable: false });\n this.add(this._innerView);\n\n const { items, visible } = this.attribute;\n if (items && items.length && visible !== false) {\n this.data = this._transformItems(items);\n this._renderGrid(this._innerView);\n }\n }\n\n protected getVerticalCoord(point: Point, offset: number, inside: boolean): Point {\n return getVerticalCoord(point, this.getVerticalVector(offset, inside, point));\n }\n\n private _transformItems(items: AxisItem[]) {\n const data: TransformedAxisItem[] = [];\n items.forEach((item: AxisItem) => {\n data.push({\n ...item,\n point: this.getTickCoord(item.value),\n id: item.id ?? item.label\n });\n });\n return data;\n }\n private _renderGrid(container: any) {\n // 渲染 subGrid\n const { visible } = this.attribute.subGrid || {};\n if (visible) {\n this._renderGridByType(true, container);\n }\n\n // 渲染 Grid,Grid 需要在 subGrid 上层渲染\n this._renderGridByType(false, container);\n }\n\n private _renderGridByType(isSubGrid: boolean, container: IGroup) {\n const gridAttrs = merge({}, this.attribute, this.getGridAttribute(isSubGrid));\n\n const { type, items, style, closed, alternateColor, depth = 0 } = gridAttrs;\n const name = isSubGrid ? `${AXIS_ELEMENT_NAME.grid}-sub` : `${AXIS_ELEMENT_NAME.grid}`;\n\n // 绘制网格线\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n let path = '';\n if (type === 'line' || type === 'polygon') {\n path = getLinePath(points, !!closed);\n } else if (type === 'circle') {\n const { center } = this.attribute as unknown as CircleGridAttributes;\n path = getArcPath(center, points, false, !!closed);\n }\n const shape = graphicCreator.path({\n path,\n z: depth,\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n\n // 添加额外的3d线段\n if (depth && type === 'line') {\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n // 重新计算points,使其长度为depth\n const nextPoints = [];\n nextPoints.push(points[0]);\n const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };\n const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);\n const ratio = depth / dirLen;\n nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });\n const path = getLinePath(nextPoints, !!closed);\n const deltaX = abs(nextPoints[0].x - nextPoints[1].x);\n const deltaY = abs(nextPoints[0].y - nextPoints[1].y);\n const shape = graphicCreator.path({\n path,\n z: 0,\n alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * pi) / 2 : 0,\n beta: deltaX < deltaY ? -pi / 2 : 0,\n anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y],\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n }\n\n // 绘制填充区域\n if (items.length > 1 && alternateColor) {\n const colors: string[] = isArray(alternateColor)\n ? (alternateColor as string[])\n : [alternateColor as string, 'transparent'];\n const getColor = (index: number) => colors[index % colors.length];\n\n // const regions: any[] = [];\n for (let index = 0; index < items.length - 1; index++) {\n const [prev, curr] = [items[index].points, items[index + 1].points];\n const path = getRegionPath(prev, curr, gridAttrs);\n const shape = graphicCreator.path({\n path,\n fill: getColor(index)\n }) as Path;\n shape.name = `${name}-region`;\n shape.id = this._getNodeId(`${name}-region-${index}`);\n container.add(shape);\n }\n }\n }\n\n /**\n * @override 覆写\n * @param id\n * @returns\n */\n protected _getNodeId(id: string) {\n return `${this.id}-${id}`;\n }\n\n release(): void {\n super.release();\n this._prevInnerView = null;\n this._innerView = null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/grid/base.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE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,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aACtB;SACF;IACH,CAAC;IAOS,UAAU,CAAC,EAAU;QAC7B,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;;AA5KM,0BAAiB,GAAgC;IACtD,KAAK,EAAE;QACL,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;QACd,aAAa,EAAE,CAAC;QAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KACjB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACjB;KACF;CACF,CAAC","file":"base.js","sourcesContent":["/**\n * @description 网格线\n */\nimport { isFunction, isArray, merge, PointService, abs, pi } from '@visactor/vutils';\nimport type { IGraphic, IGroup, Path } from '@visactor/vrender-core';\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../../core/base';\nimport type { Point } from '../../core/type';\nimport type { GridItem, CircleGridAttributes, GridBaseAttributes, GridAttributes, LineGridAttributes } from './type';\nimport type { AxisItem, TransformedAxisItem } from '../type';\nimport { AXIS_ELEMENT_NAME } from '../constant';\nimport { getElMap, getPolygonPath, getVerticalCoord } from '../util';\n\nfunction getArcPath(center: Point, points: Point[], reverse: boolean, closed: boolean) {\n let path = '';\n if (!center || points.length === 0) {\n return path;\n }\n const firstPoint = points[0];\n const radius = PointService.distancePP(center, firstPoint);\n const sweepFlag = reverse ? 0 : 1; // 顺时针还是逆时针\n if (closed) {\n // 封闭时,绘制整个圆\n path += `M${center.x},${center.y - radius}A${radius},${radius},0,0,${sweepFlag},${center.x},${\n center.y + radius\n }A${radius},${radius},0,0,${sweepFlag},${center.x},${center.y - radius}Z`;\n } else {\n points.forEach((point, index) => {\n if (index === 0) {\n path = `M${point.x},${point.y}`;\n } else {\n path += `A${radius},${radius},0,0,${sweepFlag},${point.x},${point.y}`;\n }\n });\n }\n\n return path;\n}\n\nfunction getRegionPath(from: Point[], to: Point[], attribute: GridAttributes) {\n const { type, closed } = attribute;\n const reversePoints = to.slice(0).reverse();\n\n let regionPath = '';\n let nextPath = '';\n\n if (type === 'line' && (attribute as LineGridAttributes).smoothLink && (attribute as LineGridAttributes).center) {\n const fromStart = from[0];\n const toEnd = reversePoints[0];\n const center = (attribute as LineGridAttributes).center as Point;\n\n regionPath = getPolygonPath(from, !!closed);\n nextPath = getPolygonPath(reversePoints, !!closed);\n const toEndRadius = PointService.distancePP(toEnd, center);\n const fromStartRadius = PointService.distancePP(fromStart, center);\n regionPath += `A${toEndRadius},${toEndRadius},0,0,1,${toEnd.x},${toEnd.y}L${toEnd.x},${toEnd.y}`;\n nextPath += `A${fromStartRadius},${fromStartRadius},0,0,0,${fromStart.x},${fromStart.y}`;\n } else if (type === 'circle') {\n const { center } = attribute as CircleGridAttributes;\n regionPath = getArcPath(center, from, false, !!closed);\n nextPath = getArcPath(center, reversePoints, true, !!closed);\n } else if (type === 'line' || type === 'polygon') {\n regionPath = getPolygonPath(from, !!closed);\n nextPath = getPolygonPath(reversePoints, !!closed);\n }\n\n if (closed) {\n regionPath += nextPath;\n } else {\n nextPath = 'L' + nextPath.substring(1); // 更新第一个节点\n regionPath += nextPath;\n regionPath += 'Z';\n }\n return regionPath;\n}\n\nexport abstract class BaseGrid<T extends GridBaseAttributes> extends AbstractComponent<Required<T>> {\n name = 'axis-grid';\n\n static defaultAttributes: Partial<GridBaseAttributes> = {\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n },\n subGrid: {\n visible: false,\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1,\n lineDash: [4, 4]\n }\n }\n };\n\n protected _innerView: IGroup;\n getInnerView() {\n return this._innerView;\n }\n\n protected _prevInnerView: { [key: string]: IGraphic }; // 缓存旧场景树,用于自定义动画\n /**\n * 获取更新前的旧场景树\n * @returns 返回更新前的旧场景树\n */\n getPrevInnerView() {\n return this._prevInnerView;\n }\n\n // 经过处理后的坐标轴点数据\n protected data: TransformedAxisItem[] = [];\n abstract getTickCoord(value: number): Point;\n abstract isInValidValue(value: number): boolean;\n abstract getVerticalVector(offset: number, inside: boolean, point: Point): [number, number];\n protected abstract getGridAttribute(isSubGrid: boolean): T;\n\n protected render(): void {\n this._prevInnerView = this._innerView && getElMap(this._innerView);\n\n this.removeAllChild(true);\n this._innerView = graphicCreator.group({ x: 0, y: 0, pickable: false });\n this.add(this._innerView);\n\n const { items, visible } = this.attribute;\n if (items && items.length && visible !== false) {\n this.data = this._transformItems(items);\n this._renderGrid(this._innerView);\n }\n }\n\n protected getVerticalCoord(point: Point, offset: number, inside: boolean): Point {\n return getVerticalCoord(point, this.getVerticalVector(offset, inside, point));\n }\n\n private _transformItems(items: AxisItem[]) {\n const data: TransformedAxisItem[] = [];\n items.forEach((item: AxisItem) => {\n data.push({\n ...item,\n point: this.getTickCoord(item.value),\n id: item.id ?? item.label\n });\n });\n return data;\n }\n private _renderGrid(container: any) {\n // 渲染 subGrid\n const { visible } = this.attribute.subGrid || {};\n if (visible) {\n this._renderGridByType(true, container);\n }\n\n // 渲染 Grid,Grid 需要在 subGrid 上层渲染\n this._renderGridByType(false, container);\n }\n\n private _renderGridByType(isSubGrid: boolean, container: IGroup) {\n const gridAttrs = merge({}, this.attribute, this.getGridAttribute(isSubGrid));\n\n const { type, items, style, closed, alternateColor, depth = 0 } = gridAttrs;\n const name = isSubGrid ? `${AXIS_ELEMENT_NAME.grid}-sub` : `${AXIS_ELEMENT_NAME.grid}`;\n\n // 绘制网格线\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n let path = '';\n if (type === 'line' || type === 'polygon') {\n path = getPolygonPath(points, !!closed);\n } else if (type === 'circle') {\n const { center } = this.attribute as unknown as CircleGridAttributes;\n path = getArcPath(center, points, false, !!closed);\n }\n const shape = graphicCreator.path({\n path,\n z: depth,\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n\n // 添加额外的3d线段\n if (depth && type === 'line') {\n items.forEach((item: GridItem, index: number) => {\n const { id, points } = item;\n // 重新计算points,使其长度为depth\n const nextPoints = [];\n nextPoints.push(points[0]);\n const dir = { x: points[1].x - points[0].x, y: points[1].y - points[0].y };\n const dirLen = Math.sqrt(dir.x * dir.x + dir.y * dir.y);\n const ratio = depth / dirLen;\n nextPoints.push({ x: points[0].x + dir.x * ratio, y: points[0].y + dir.y * ratio });\n const path = getPolygonPath(nextPoints, !!closed);\n const deltaX = abs(nextPoints[0].x - nextPoints[1].x);\n const deltaY = abs(nextPoints[0].y - nextPoints[1].y);\n const shape = graphicCreator.path({\n path,\n z: 0,\n alpha: deltaX > deltaY ? ((points[1].x - points[0].x > 0 ? -1 : 1) * pi) / 2 : 0,\n beta: deltaX < deltaY ? -pi / 2 : 0,\n anchor3d: deltaX > deltaY ? [nextPoints[0].x, 0] : [0, nextPoints[0].y],\n ...(isFunction(style)\n ? merge({}, this.skipDefault ? null : BaseGrid.defaultAttributes.style, style(item, index))\n : style)\n }) as Path;\n shape.name = `${name}-line`;\n shape.id = this._getNodeId(`${name}-path-${id}`);\n container.add(shape);\n });\n }\n\n // 绘制填充区域\n if (items.length > 1 && alternateColor) {\n const colors: string[] = isArray(alternateColor)\n ? (alternateColor as string[])\n : [alternateColor as string, 'transparent'];\n const getColor = (index: number) => colors[index % colors.length];\n\n // const regions: any[] = [];\n for (let index = 0; index < items.length - 1; index++) {\n const [prev, curr] = [items[index].points, items[index + 1].points];\n const path = getRegionPath(prev, curr, gridAttrs);\n const shape = graphicCreator.path({\n path,\n fill: getColor(index)\n }) as Path;\n shape.name = `${name}-region`;\n shape.id = this._getNodeId(`${name}-region-${index}`);\n container.add(shape);\n }\n }\n }\n\n /**\n * @override 覆写\n * @param id\n * @returns\n */\n protected _getNodeId(id: string) {\n return `${this.id}-${id}`;\n }\n\n release(): void {\n super.release();\n this._prevInnerView = null;\n this._innerView = null;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { PointService, merge, polarToCartesian, mixin } from "@visactor/vutils";
1
+ import { PointService, merge, mixin } from "@visactor/vutils";
2
2
 
3
3
  import { BaseGrid } from "./base";
4
4
 
@@ -8,14 +8,7 @@ import { LineAxisMixin } from "../mixin/line";
8
8
 
9
9
  import { loadLineAxisGridComponent } from "../register";
10
10
 
11
- function getCirclePoints(center, count, radius, startAngle, endAngle) {
12
- const points = [], range = endAngle - startAngle;
13
- for (let i = 0; i < count; i++) {
14
- const angle = startAngle + i * range / count;
15
- points.push(polarToCartesian(center, radius, angle));
16
- }
17
- return points;
18
- }
11
+ import { getCirclePoints } from "../util";
19
12
 
20
13
  loadLineAxisGridComponent();
21
14
 
@@ -29,8 +22,8 @@ export class LineAxisGrid extends BaseGrid {
29
22
  const {length: length} = this.attribute;
30
23
  gridPoints = [ point, this.getVerticalCoord(point, length, !0) ];
31
24
  } else if ("circle" === gridType || "polygon" === gridType) {
32
- const {center: center, sides: sides = 6, startAngle: startAngle = POLAR_START_ANGLE, endAngle: endAngle = POLAR_END_ANGLE} = this.attribute;
33
- gridPoints = getCirclePoints(center, sides, PointService.distancePP(center, point), startAngle, endAngle);
25
+ const {center: center, sides: sides = 6, startAngle: startAngle = POLAR_START_ANGLE, endAngle: endAngle = POLAR_END_ANGLE} = this.attribute, distance = PointService.distancePP(center, point);
26
+ gridPoints = getCirclePoints(center, sides, distance, startAngle, endAngle);
34
27
  }
35
28
  return gridPoints;
36
29
  }