@visactor/vrender-components 1.0.25 → 1.0.26-alpha.0

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
@@ -17391,6 +17391,7 @@ var AXIS_ELEMENT_NAME;
17391
17391
  AXIS_ELEMENT_NAME["subTick"] = "axis-sub-tick";
17392
17392
  AXIS_ELEMENT_NAME["label"] = "axis-label";
17393
17393
  AXIS_ELEMENT_NAME["title"] = "axis-title";
17394
+ AXIS_ELEMENT_NAME["labelHoverOnAxis"] = "axis-label-hover-on-axis";
17394
17395
  AXIS_ELEMENT_NAME["gridContainer"] = "axis-grid-container";
17395
17396
  AXIS_ELEMENT_NAME["grid"] = "axis-grid";
17396
17397
  AXIS_ELEMENT_NAME["gridRegion"] = "axis-grid-region";
@@ -17438,6 +17439,25 @@ const DEFAULT_AXIS_THEME = {
17438
17439
  fillOpacity: 1
17439
17440
  }
17440
17441
  },
17442
+ labelHoverOnAxis: {
17443
+ visible: false,
17444
+ space: 4,
17445
+ position: 0,
17446
+ autoRotate: false,
17447
+ textStyle: {
17448
+ fontSize: 12,
17449
+ fill: 'white',
17450
+ fontWeight: 'normal',
17451
+ fillOpacity: 1
17452
+ },
17453
+ background: {
17454
+ visible: true,
17455
+ style: {
17456
+ cornerRadius: 2,
17457
+ fill: 'black'
17458
+ }
17459
+ }
17460
+ },
17441
17461
  tick: {
17442
17462
  visible: true,
17443
17463
  inside: false,
@@ -20273,7 +20293,13 @@ function loadCircleAxisGridComponent() {
20273
20293
  loadLineAxisComponent();
20274
20294
  class LineAxis extends AxisBase {
20275
20295
  constructor(attributes, options) {
20296
+ var _a;
20297
+ if (attributes.labelHoverOnAxis) {
20298
+ attributes.labelHoverOnAxis.textStyle = Object.assign({}, attributes.label.style, attributes.labelHoverOnAxis.textStyle);
20299
+ attributes.labelHoverOnAxis.space = (_a = attributes.labelHoverOnAxis.space) !== null && _a !== void 0 ? _a : attributes.label.space;
20300
+ }
20276
20301
  super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, LineAxis.defaultAttributes, attributes), options);
20302
+ this.labelHoverOnAxisGroup = null;
20277
20303
  }
20278
20304
  _renderInner(container) {
20279
20305
  var _a;
@@ -20325,6 +20351,18 @@ class LineAxis extends AxisBase {
20325
20351
  bgRect.states = merge({}, DEFAULT_STATES$1, (_a = panel.state) !== null && _a !== void 0 ? _a : {});
20326
20352
  axisContainer.insertBefore(bgRect, axisContainer.firstChild);
20327
20353
  }
20354
+ const { labelHoverOnAxis } = this.attribute;
20355
+ if (labelHoverOnAxis && labelHoverOnAxis.visible) {
20356
+ this.renderLabelHoverOnAxis();
20357
+ }
20358
+ }
20359
+ renderLabelHoverOnAxis() {
20360
+ const hoverOnLabelAttributes = this.getLabelHoverOnAxisAttribute();
20361
+ const hoverOnLabel = new Tag(Object.assign({}, hoverOnLabelAttributes));
20362
+ hoverOnLabel.name = AXIS_ELEMENT_NAME.title;
20363
+ hoverOnLabel.id = this._getNodeId('hover-on-label');
20364
+ this.labelHoverOnAxisGroup = hoverOnLabel;
20365
+ this.axisContainer.add(hoverOnLabel);
20328
20366
  }
20329
20367
  renderLine(container) {
20330
20368
  const { start, end, line } = this.attribute;
@@ -20519,6 +20557,84 @@ class LineAxis extends AxisBase {
20519
20557
  }
20520
20558
  return attrs;
20521
20559
  }
20560
+ getLabelHoverOnAxisAttribute() {
20561
+ var _a, _b;
20562
+ const { orient } = this.attribute;
20563
+ const _c = this.attribute.labelHoverOnAxis, { position = 0, space = 4, autoRotate = true, textStyle = {}, background = {}, formatMethod, text: textContent = '', maxWidth } = _c, restAttrs = __rest(_c, ["position", "space", "autoRotate", "textStyle", "background", "formatMethod", "text", "maxWidth"]);
20564
+ const point = this.getTickCoord(0);
20565
+ if (orient === 'bottom' || orient === 'top') {
20566
+ point.x = position;
20567
+ }
20568
+ else {
20569
+ point.y = position;
20570
+ }
20571
+ let tickLength = 0;
20572
+ if (((_a = this.attribute.tick) === null || _a === void 0 ? void 0 : _a.visible) && this.attribute.tick.inside === false) {
20573
+ tickLength = this.attribute.tick.length || 4;
20574
+ }
20575
+ if (((_b = this.attribute.subTick) === null || _b === void 0 ? void 0 : _b.visible) && this.attribute.subTick.inside === false) {
20576
+ tickLength = Math.max(tickLength, this.attribute.subTick.length || 2);
20577
+ }
20578
+ const labelLength = 0;
20579
+ const offset = tickLength + labelLength + space;
20580
+ const labelPoint = this.getVerticalCoord(point, offset, false);
20581
+ const vector = this.getVerticalVector(offset, false, { x: 0, y: 0 });
20582
+ let { angle } = restAttrs;
20583
+ let textAlign = 'center';
20584
+ let textBaseline;
20585
+ if (isNil(angle) && autoRotate) {
20586
+ const axisVector = this.getRelativeVector();
20587
+ const v1 = [1, 0];
20588
+ const radian = angleTo(axisVector, v1, true);
20589
+ angle = radian;
20590
+ const { verticalFactor = 1 } = this.attribute;
20591
+ const factor = -1 * verticalFactor;
20592
+ if (factor === 1) {
20593
+ textBaseline = 'bottom';
20594
+ }
20595
+ else {
20596
+ textBaseline = 'top';
20597
+ }
20598
+ }
20599
+ else {
20600
+ textAlign = this.getTextAlign(vector);
20601
+ textBaseline = this.getTextBaseline(vector, false);
20602
+ }
20603
+ let maxTagWidth = maxWidth;
20604
+ if (isNil(maxTagWidth)) {
20605
+ const { verticalLimitSize, verticalMinSize, orient } = this.attribute;
20606
+ const limitSize = Math.min(verticalLimitSize || Infinity, verticalMinSize || Infinity);
20607
+ if (isValidNumber(limitSize)) {
20608
+ const isX = orient === 'bottom' || orient === 'top';
20609
+ if (isX) {
20610
+ if (angle !== Math.PI / 2) {
20611
+ const cosValue = Math.abs(Math.cos(angle !== null && angle !== void 0 ? angle : 0));
20612
+ maxTagWidth = cosValue < 1e-6 ? Infinity : this.attribute.end.x / cosValue;
20613
+ }
20614
+ else {
20615
+ maxTagWidth = limitSize - offset;
20616
+ }
20617
+ }
20618
+ else {
20619
+ if (angle && angle !== 0) {
20620
+ const sinValue = Math.abs(Math.sin(angle));
20621
+ maxTagWidth = sinValue < 1e-6 ? Infinity : this.attribute.end.y / sinValue;
20622
+ }
20623
+ else {
20624
+ maxTagWidth = limitSize - offset;
20625
+ }
20626
+ }
20627
+ }
20628
+ }
20629
+ const text = formatMethod ? formatMethod(textContent) : textContent;
20630
+ const attrs = Object.assign(Object.assign(Object.assign({}, labelPoint), restAttrs), { maxWidth: maxTagWidth, textStyle: Object.assign({ textAlign,
20631
+ textBaseline }, textStyle), text });
20632
+ attrs.angle = angle;
20633
+ if (background && background.visible) {
20634
+ attrs.panel = Object.assign(Object.assign({ visible: true }, restAttrs.panel), background.style);
20635
+ }
20636
+ return attrs;
20637
+ }
20522
20638
  getTextBaseline(vector, inside) {
20523
20639
  let base = 'middle';
20524
20640
  const { verticalFactor = 1 } = this.attribute;
@@ -20751,8 +20867,8 @@ class LineAxis extends AxisBase {
20751
20867
  let limitLength = limitSize;
20752
20868
  let titleHeight = 0;
20753
20869
  let titleSpacing = 0;
20754
- const axisLineWidth = line && line.visible ? ((_b = line.style.lineWidth) !== null && _b !== void 0 ? _b : 1) : 0;
20755
- const tickLength = tick && tick.visible ? ((_c = tick.length) !== null && _c !== void 0 ? _c : 4) : 0;
20870
+ const axisLineWidth = line && line.visible ? (_b = line.style.lineWidth) !== null && _b !== void 0 ? _b : 1 : 0;
20871
+ const tickLength = tick && tick.visible ? (_c = tick.length) !== null && _c !== void 0 ? _c : 4 : 0;
20756
20872
  if (title && title.visible && typeof title.text === 'string') {
20757
20873
  titleHeight = measureTextSize(title.text, title.textStyle, (_e = (_d = this.stage) === null || _d === void 0 ? void 0 : _d.getTheme()) === null || _e === void 0 ? void 0 : _e.text).height;
20758
20874
  const padding = normalizePadding(title.padding);
@@ -20763,6 +20879,41 @@ class LineAxis extends AxisBase {
20763
20879
  }
20764
20880
  return limitLength;
20765
20881
  }
20882
+ showLabelHoverOnAxis(position, text) {
20883
+ if (this.attribute.labelHoverOnAxis) {
20884
+ if (this.labelHoverOnAxisGroup) {
20885
+ const { formatMethod } = this.attribute.labelHoverOnAxis;
20886
+ const textStr = formatMethod ? formatMethod(text) : text;
20887
+ this.labelHoverOnAxisGroup.setAttribute('text', textStr);
20888
+ this.labelHoverOnAxisGroup.setAttribute('visible', true);
20889
+ this.labelHoverOnAxisGroup.setAttribute('visibleAll', true);
20890
+ if (this.attribute.orient === 'left' || this.attribute.orient === 'right') {
20891
+ this.labelHoverOnAxisGroup.setAttributes({
20892
+ y: position
20893
+ });
20894
+ }
20895
+ else {
20896
+ this.labelHoverOnAxisGroup.setAttributes({
20897
+ x: position
20898
+ });
20899
+ }
20900
+ }
20901
+ else {
20902
+ this.attribute.labelHoverOnAxis.visible = true;
20903
+ this.attribute.labelHoverOnAxis.position = position;
20904
+ this.attribute.labelHoverOnAxis.text = text;
20905
+ this.renderLabelHoverOnAxis();
20906
+ }
20907
+ }
20908
+ }
20909
+ hideLabelHoverOnAxis() {
20910
+ if (this.attribute.labelHoverOnAxis && this.labelHoverOnAxisGroup) {
20911
+ this.labelHoverOnAxisGroup.setAttributes({
20912
+ visible: false,
20913
+ visibleAll: false
20914
+ });
20915
+ }
20916
+ }
20766
20917
  release() {
20767
20918
  super.release();
20768
20919
  this._breaks = null;
@@ -22718,25 +22869,12 @@ class LabelBase extends AnimateComponent {
22718
22869
  else {
22719
22870
  labels = this._layout(labels);
22720
22871
  }
22721
- const filteredLabels = [];
22722
- const overlapLabels = labels;
22723
- if (!isBoolean(overlap) && isFunction(overlap.filterBeforeOverlap)) {
22724
- const getRelatedGraphic = this.getRelatedGraphic.bind(this);
22725
- labels.forEach(label => {
22726
- if (overlap.filterBeforeOverlap(label, getRelatedGraphic, this)) {
22727
- overlapLabels.push(label);
22728
- }
22729
- else {
22730
- filteredLabels.push(label);
22731
- }
22732
- });
22733
- }
22734
22872
  if (isFunction(customOverlapFunc)) {
22735
- labels = customOverlapFunc(overlapLabels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? (d) => this._idToPoint.get(d.id) : null, this).concat(filteredLabels);
22873
+ labels = customOverlapFunc(labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? (d) => this._idToPoint.get(d.id) : null, this);
22736
22874
  }
22737
22875
  else {
22738
22876
  if (overlap !== false) {
22739
- labels = this._overlapping(overlapLabels).concat(filteredLabels);
22877
+ labels = this._overlapping(labels);
22740
22878
  }
22741
22879
  }
22742
22880
  if (isFunction(this.attribute.onAfterOverlapping)) {
@@ -34583,6 +34721,6 @@ TableSeriesNumber.defaultAttributes = {
34583
34721
  select: true
34584
34722
  };
34585
34723
 
34586
- const version = "1.0.25";
34724
+ const version = "1.0.26-alpha.0";
34587
34725
 
34588
34726
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, 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, GroupTransition, IDataZoomEvent, IDataZoomInteractiveEvent, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PolygonSectorCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SeriesNumberCellStateValue, SeriesNumberEvent, SizeContinuousLegend, Slider, StoryLabelItem, Switch, SymbolLabel, TableSeriesNumber, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, WeatherBox, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, scrollbarModule, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
@@ -30,6 +30,25 @@ export declare class CircleAxis extends AxisBase<CircleAxisAttributes> {
30
30
  fillOpacity: number;
31
31
  };
32
32
  };
33
+ labelHoverOnAxis: {
34
+ visible: boolean;
35
+ space: number;
36
+ position: number;
37
+ autoRotate: boolean;
38
+ textStyle: {
39
+ fontSize: number;
40
+ fill: string;
41
+ fontWeight: string;
42
+ fillOpacity: number;
43
+ };
44
+ background: {
45
+ visible: boolean;
46
+ style: {
47
+ cornerRadius: number;
48
+ fill: string;
49
+ };
50
+ };
51
+ };
33
52
  tick: {
34
53
  visible: boolean;
35
54
  inside: boolean;
@@ -21,6 +21,25 @@ export declare const DEFAULT_AXIS_THEME: {
21
21
  fillOpacity: number;
22
22
  };
23
23
  };
24
+ labelHoverOnAxis: {
25
+ visible: boolean;
26
+ space: number;
27
+ position: number;
28
+ autoRotate: boolean;
29
+ textStyle: {
30
+ fontSize: number;
31
+ fill: string;
32
+ fontWeight: string;
33
+ fillOpacity: number;
34
+ };
35
+ background: {
36
+ visible: boolean;
37
+ style: {
38
+ cornerRadius: number;
39
+ fill: string;
40
+ };
41
+ };
42
+ };
24
43
  tick: {
25
44
  visible: boolean;
26
45
  inside: boolean;
package/es/axis/config.js CHANGED
@@ -21,6 +21,25 @@ export const DEFAULT_AXIS_THEME = {
21
21
  fillOpacity: 1
22
22
  }
23
23
  },
24
+ labelHoverOnAxis: {
25
+ visible: !1,
26
+ space: 4,
27
+ position: 0,
28
+ autoRotate: !1,
29
+ textStyle: {
30
+ fontSize: 12,
31
+ fill: "white",
32
+ fontWeight: "normal",
33
+ fillOpacity: 1
34
+ },
35
+ background: {
36
+ visible: !0,
37
+ style: {
38
+ cornerRadius: 2,
39
+ fill: "black"
40
+ }
41
+ }
42
+ },
24
43
  tick: {
25
44
  visible: !0,
26
45
  inside: !1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE;QACL,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,CAAC;SACf;KACF;IACD,KAAK,EAAE;QACL,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,CAAC;SACf;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,KAAK;QACb,cAAc,EAAE,IAAI;QACpB,MAAM,EAAE,CAAC;QACT,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;SACjB;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;SACjB;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;SACjB;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC;CACV,CAAC","file":"config.js","sourcesContent":["export const DEFAULT_AXIS_THEME = {\n title: {\n space: 4,\n padding: 0,\n textStyle: {\n fontSize: 12,\n fill: '#333333',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n },\n label: {\n visible: true,\n inside: false,\n space: 4,\n padding: 0,\n style: {\n fontSize: 12,\n fill: '#333',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n },\n tick: {\n visible: true,\n inside: false,\n alignWithLabel: true,\n length: 4,\n style: {\n lineWidth: 1,\n stroke: '#000',\n strokeOpacity: 1\n }\n },\n subTick: {\n visible: false,\n inside: false,\n count: 4,\n length: 2,\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1\n }\n },\n line: {\n visible: true,\n style: {\n lineWidth: 1,\n stroke: '#000',\n strokeOpacity: 1\n }\n }\n};\n\nexport const DEFAULT_AXIS_BREAK_SYMBOL_STYLE = {\n size: 8,\n stroke: '#000',\n lineWidth: 1,\n zIndex: 1\n};\n"]}
1
+ {"version":3,"sources":["../src/axis/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE;QACL,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,CAAC;SACf;KACF;IACD,KAAK,EAAE;QACL,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,CAAC;SACf;KACF;IACD,gBAAgB,EAAE;QAChB,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,CAAC;QACX,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,OAAO;YACb,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,CAAC;SACf;QACD,UAAU,EAAE;YACV,OAAO,EAAE,IAAI;YACb,KAAK,EAAE;gBACL,YAAY,EAAE,CAAC;gBACf,IAAI,EAAE,OAAO;aACd;SACF;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,KAAK;QACb,cAAc,EAAE,IAAI;QACpB,MAAM,EAAE,CAAC;QACT,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;SACjB;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;SACjB;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE,CAAC;SACjB;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC;CACV,CAAC","file":"config.js","sourcesContent":["export const DEFAULT_AXIS_THEME = {\n title: {\n space: 4,\n padding: 0,\n textStyle: {\n fontSize: 12,\n fill: '#333333',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n },\n label: {\n visible: true,\n inside: false,\n space: 4,\n padding: 0,\n style: {\n fontSize: 12,\n fill: '#333',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n },\n labelHoverOnAxis: {\n visible: false,\n space: 4,\n position: 0,\n autoRotate: false,\n textStyle: {\n fontSize: 12,\n fill: 'white',\n fontWeight: 'normal',\n fillOpacity: 1\n },\n background: {\n visible: true,\n style: {\n cornerRadius: 2,\n fill: 'black'\n }\n }\n },\n tick: {\n visible: true,\n inside: false,\n alignWithLabel: true,\n length: 4,\n style: {\n lineWidth: 1,\n stroke: '#000',\n strokeOpacity: 1\n }\n },\n subTick: {\n visible: false,\n inside: false,\n count: 4,\n length: 2,\n style: {\n lineWidth: 1,\n stroke: '#999',\n strokeOpacity: 1\n }\n },\n line: {\n visible: true,\n style: {\n lineWidth: 1,\n stroke: '#000',\n strokeOpacity: 1\n }\n }\n};\n\nexport const DEFAULT_AXIS_BREAK_SYMBOL_STYLE = {\n size: 8,\n stroke: '#000',\n lineWidth: 1,\n zIndex: 1\n};\n"]}
@@ -7,6 +7,7 @@ export declare enum AXIS_ELEMENT_NAME {
7
7
  subTick = "axis-sub-tick",
8
8
  label = "axis-label",
9
9
  title = "axis-title",
10
+ labelHoverOnAxis = "axis-label-hover-on-axis",
10
11
  gridContainer = "axis-grid-container",
11
12
  grid = "axis-grid",
12
13
  gridRegion = "axis-grid-region",
@@ -5,10 +5,11 @@ export var AXIS_ELEMENT_NAME;
5
5
  AXIS_ELEMENT_NAME.labelContainer = "axis-label-container", AXIS_ELEMENT_NAME.tickContainer = "axis-tick-container",
6
6
  AXIS_ELEMENT_NAME.tick = "axis-tick", AXIS_ELEMENT_NAME.subTick = "axis-sub-tick",
7
7
  AXIS_ELEMENT_NAME.label = "axis-label", AXIS_ELEMENT_NAME.title = "axis-title",
8
- AXIS_ELEMENT_NAME.gridContainer = "axis-grid-container", AXIS_ELEMENT_NAME.grid = "axis-grid",
9
- AXIS_ELEMENT_NAME.gridRegion = "axis-grid-region", AXIS_ELEMENT_NAME.line = "axis-line",
10
- AXIS_ELEMENT_NAME.background = "axis-background", AXIS_ELEMENT_NAME.axisLabelBackground = "axis-label-background",
11
- AXIS_ELEMENT_NAME.axisBreak = "axis-break", AXIS_ELEMENT_NAME.axisBreakSymbol = "axis-break-symbol";
8
+ AXIS_ELEMENT_NAME.labelHoverOnAxis = "axis-label-hover-on-axis", AXIS_ELEMENT_NAME.gridContainer = "axis-grid-container",
9
+ AXIS_ELEMENT_NAME.grid = "axis-grid", AXIS_ELEMENT_NAME.gridRegion = "axis-grid-region",
10
+ AXIS_ELEMENT_NAME.line = "axis-line", AXIS_ELEMENT_NAME.background = "axis-background",
11
+ AXIS_ELEMENT_NAME.axisLabelBackground = "axis-label-background", AXIS_ELEMENT_NAME.axisBreak = "axis-break",
12
+ AXIS_ELEMENT_NAME.axisBreakSymbol = "axis-break-symbol";
12
13
  }(AXIS_ELEMENT_NAME || (AXIS_ELEMENT_NAME = {}));
13
14
 
14
15
  export var AxisStateValue;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/constant.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,iBAiBX;AAjBD,WAAY,iBAAiB;IAC3B,6CAAwB,CAAA;IACxB,qDAAgC,CAAA;IAChC,4DAAuC,CAAA;IACvC,0DAAqC,CAAA;IACrC,uCAAkB,CAAA;IAClB,8CAAyB,CAAA;IACzB,yCAAoB,CAAA;IACpB,yCAAoB,CAAA;IACpB,0DAAqC,CAAA;IACrC,uCAAkB,CAAA;IAClB,oDAA+B,CAAA;IAC/B,uCAAkB,CAAA;IAClB,mDAA8B,CAAA;IAC9B,kEAA6C,CAAA;IAC7C,6CAAwB,CAAA;IACxB,0DAAqC,CAAA;AACvC,CAAC,EAjBW,iBAAiB,KAAjB,iBAAiB,QAiB5B;AAED,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,sDAAoC,CAAA;IACpC,iCAAe,CAAA;IACf,gDAA8B,CAAA;AAChC,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,EAAE;IACpC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE;IAC7B,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,EAAE;IAC1B,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,EAAE;CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC","file":"constant.js","sourcesContent":["export enum AXIS_ELEMENT_NAME {\n innerView = 'inner-view',\n axisContainer = 'axis-container',\n labelContainer = 'axis-label-container',\n tickContainer = 'axis-tick-container',\n tick = 'axis-tick',\n subTick = 'axis-sub-tick',\n label = 'axis-label',\n title = 'axis-title',\n gridContainer = 'axis-grid-container',\n grid = 'axis-grid',\n gridRegion = 'axis-grid-region',\n line = 'axis-line',\n background = 'axis-background',\n axisLabelBackground = 'axis-label-background',\n axisBreak = 'axis-break',\n axisBreakSymbol = 'axis-break-symbol'\n}\n\nexport enum AxisStateValue {\n selected = 'selected',\n selectedReverse = 'selected_reverse',\n hover = 'hover',\n hoverReverse = 'hover_reverse'\n}\n\nexport const DEFAULT_STATES = {\n [AxisStateValue.selectedReverse]: {},\n [AxisStateValue.selected]: {},\n [AxisStateValue.hover]: {},\n [AxisStateValue.hoverReverse]: {}\n};\n\nexport const TopZIndex = 999;\n"]}
1
+ {"version":3,"sources":["../src/axis/constant.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,iBAkBX;AAlBD,WAAY,iBAAiB;IAC3B,6CAAwB,CAAA;IACxB,qDAAgC,CAAA;IAChC,4DAAuC,CAAA;IACvC,0DAAqC,CAAA;IACrC,uCAAkB,CAAA;IAClB,8CAAyB,CAAA;IACzB,yCAAoB,CAAA;IACpB,yCAAoB,CAAA;IACpB,kEAA6C,CAAA;IAC7C,0DAAqC,CAAA;IACrC,uCAAkB,CAAA;IAClB,oDAA+B,CAAA;IAC/B,uCAAkB,CAAA;IAClB,mDAA8B,CAAA;IAC9B,kEAA6C,CAAA;IAC7C,6CAAwB,CAAA;IACxB,0DAAqC,CAAA;AACvC,CAAC,EAlBW,iBAAiB,KAAjB,iBAAiB,QAkB5B;AAED,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,sDAAoC,CAAA;IACpC,iCAAe,CAAA;IACf,gDAA8B,CAAA;AAChC,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,EAAE;IACpC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE;IAC7B,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,EAAE;IAC1B,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,EAAE;CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC","file":"constant.js","sourcesContent":["export enum AXIS_ELEMENT_NAME {\n innerView = 'inner-view',\n axisContainer = 'axis-container',\n labelContainer = 'axis-label-container',\n tickContainer = 'axis-tick-container',\n tick = 'axis-tick',\n subTick = 'axis-sub-tick',\n label = 'axis-label',\n title = 'axis-title',\n labelHoverOnAxis = 'axis-label-hover-on-axis',\n gridContainer = 'axis-grid-container',\n grid = 'axis-grid',\n gridRegion = 'axis-grid-region',\n line = 'axis-line',\n background = 'axis-background',\n axisLabelBackground = 'axis-label-background',\n axisBreak = 'axis-break',\n axisBreakSymbol = 'axis-break-symbol'\n}\n\nexport enum AxisStateValue {\n selected = 'selected',\n selectedReverse = 'selected_reverse',\n hover = 'hover',\n hoverReverse = 'hover_reverse'\n}\n\nexport const DEFAULT_STATES = {\n [AxisStateValue.selectedReverse]: {},\n [AxisStateValue.selected]: {},\n [AxisStateValue.hover]: {},\n [AxisStateValue.hoverReverse]: {}\n};\n\nexport const TopZIndex = 999;\n"]}
package/es/axis/line.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { TextAlignType, IGroup, IText, TextBaselineType } from '@visactor/vrender-core';
2
- import type { TagAttributes } from '../tag';
2
+ import { type TagAttributes } from '../tag';
3
3
  import type { LineAxisAttributes, AxisItem } from './type';
4
4
  import { AxisBase } from './base';
5
5
  import { LineAxisMixin } from './mixin/line';
@@ -30,6 +30,25 @@ export declare class LineAxis extends AxisBase<LineAxisAttributes> {
30
30
  fillOpacity: number;
31
31
  };
32
32
  };
33
+ labelHoverOnAxis: {
34
+ visible: boolean;
35
+ space: number;
36
+ position: number;
37
+ autoRotate: boolean;
38
+ textStyle: {
39
+ fontSize: number;
40
+ fill: string;
41
+ fontWeight: string;
42
+ fillOpacity: number;
43
+ };
44
+ background: {
45
+ visible: boolean;
46
+ style: {
47
+ cornerRadius: number;
48
+ fill: string;
49
+ };
50
+ };
51
+ };
33
52
  tick: {
34
53
  visible: boolean;
35
54
  inside: boolean;
@@ -61,12 +80,15 @@ export declare class LineAxis extends AxisBase<LineAxisAttributes> {
61
80
  };
62
81
  };
63
82
  };
64
- constructor(attributes: LineAxisAttributes, options?: ComponentOptions);
65
83
  private _breaks;
84
+ private labelHoverOnAxisGroup;
85
+ constructor(attributes: LineAxisAttributes, options?: ComponentOptions);
66
86
  protected _renderInner(container: IGroup): void;
87
+ protected renderLabelHoverOnAxis(): void;
67
88
  protected renderLine(container: IGroup): void;
68
89
  protected getTextAlign(vector: number[]): TextAlignType;
69
90
  protected getTitleAttribute(): TagAttributes;
91
+ protected getLabelHoverOnAxisAttribute(): TagAttributes;
70
92
  protected getTextBaseline(vector: number[], inside?: boolean): TextBaselineType;
71
93
  protected getLabelAlign(vector: [number, number], inside?: boolean, angle?: number): {
72
94
  textAlign: TextAlignType;
@@ -76,5 +98,7 @@ export declare class LineAxis extends AxisBase<LineAxisAttributes> {
76
98
  protected handleLabelsOverlap(labelShapes: IText[], labelData: AxisItem[], labelContainer: IGroup, layer: number, layerCount: number): void;
77
99
  protected afterLabelsOverlap(labelShapes: IText[], labelData: AxisItem[], labelContainer: IGroup, layer: number, layerCount: number): void;
78
100
  private _getAxisLabelLimitLength;
101
+ showLabelHoverOnAxis(position: number, text: string): void;
102
+ hideLabelHoverOnAxis(): void;
79
103
  release(): void;
80
104
  }
package/es/axis/line.js CHANGED
@@ -16,6 +16,8 @@ import { Segment } from "../segment";
16
16
 
17
17
  import { angleTo } from "../util/matrix";
18
18
 
19
+ import { Tag } from "../tag";
20
+
19
21
  import { AxisBase } from "./base";
20
22
 
21
23
  import { DEFAULT_AXIS_THEME } from "./config";
@@ -44,7 +46,11 @@ loadLineAxisComponent();
44
46
 
45
47
  export class LineAxis extends AxisBase {
46
48
  constructor(attributes, options) {
47
- super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, LineAxis.defaultAttributes, attributes), options);
49
+ var _a;
50
+ attributes.labelHoverOnAxis && (attributes.labelHoverOnAxis.textStyle = Object.assign({}, attributes.label.style, attributes.labelHoverOnAxis.textStyle),
51
+ attributes.labelHoverOnAxis.space = null !== (_a = attributes.labelHoverOnAxis.space) && void 0 !== _a ? _a : attributes.label.space),
52
+ super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, LineAxis.defaultAttributes, attributes), options),
53
+ this.labelHoverOnAxisGroup = null;
48
54
  }
49
55
  _renderInner(container) {
50
56
  var _a;
@@ -95,6 +101,13 @@ export class LineAxis extends AxisBase {
95
101
  bgRect.states = merge({}, DEFAULT_STATES, null !== (_a = panel.state) && void 0 !== _a ? _a : {}),
96
102
  axisContainer.insertBefore(bgRect, axisContainer.firstChild);
97
103
  }
104
+ const {labelHoverOnAxis: labelHoverOnAxis} = this.attribute;
105
+ labelHoverOnAxis && labelHoverOnAxis.visible && this.renderLabelHoverOnAxis();
106
+ }
107
+ renderLabelHoverOnAxis() {
108
+ const hoverOnLabelAttributes = this.getLabelHoverOnAxisAttribute(), hoverOnLabel = new Tag(Object.assign({}, hoverOnLabelAttributes));
109
+ hoverOnLabel.name = AXIS_ELEMENT_NAME.title, hoverOnLabel.id = this._getNodeId("hover-on-label"),
110
+ this.labelHoverOnAxisGroup = hoverOnLabel, this.axisContainer.add(hoverOnLabel);
98
111
  }
99
112
  renderLine(container) {
100
113
  const {start: start, end: end, line: line} = this.attribute, _a = line, {startSymbol: startSymbol, endSymbol: endSymbol, style: style, state: state} = _a, restLineAttrs = __rest(_a, [ "startSymbol", "endSymbol", "style", "state" ]), lineAttrs = Object.assign({
@@ -189,6 +202,49 @@ export class LineAxis extends AxisBase {
189
202
  visible: !0
190
203
  }, background.style)), attrs;
191
204
  }
205
+ getLabelHoverOnAxisAttribute() {
206
+ var _a, _b;
207
+ const {orient: orient} = this.attribute, _c = this.attribute.labelHoverOnAxis, {position: position = 0, space: space = 4, autoRotate: autoRotate = !0, textStyle: textStyle = {}, background: background = {}, formatMethod: formatMethod, text: textContent = "", maxWidth: maxWidth} = _c, restAttrs = __rest(_c, [ "position", "space", "autoRotate", "textStyle", "background", "formatMethod", "text", "maxWidth" ]), point = this.getTickCoord(0);
208
+ "bottom" === orient || "top" === orient ? point.x = position : point.y = position;
209
+ let tickLength = 0;
210
+ (null === (_a = this.attribute.tick) || void 0 === _a ? void 0 : _a.visible) && !1 === this.attribute.tick.inside && (tickLength = this.attribute.tick.length || 4),
211
+ (null === (_b = this.attribute.subTick) || void 0 === _b ? void 0 : _b.visible) && !1 === this.attribute.subTick.inside && (tickLength = Math.max(tickLength, this.attribute.subTick.length || 2));
212
+ const offset = tickLength + 0 + space, labelPoint = this.getVerticalCoord(point, offset, !1), vector = this.getVerticalVector(offset, !1, {
213
+ x: 0,
214
+ y: 0
215
+ });
216
+ let textBaseline, {angle: angle} = restAttrs, textAlign = "center";
217
+ if (isNil(angle) && autoRotate) {
218
+ const axisVector = this.getRelativeVector();
219
+ angle = angleTo(axisVector, [ 1, 0 ], !0);
220
+ const {verticalFactor: verticalFactor = 1} = this.attribute;
221
+ textBaseline = 1 === -1 * verticalFactor ? "bottom" : "top";
222
+ } else textAlign = this.getTextAlign(vector), textBaseline = this.getTextBaseline(vector, !1);
223
+ let maxTagWidth = maxWidth;
224
+ if (isNil(maxTagWidth)) {
225
+ const {verticalLimitSize: verticalLimitSize, verticalMinSize: verticalMinSize, orient: orient} = this.attribute, limitSize = Math.min(verticalLimitSize || 1 / 0, verticalMinSize || 1 / 0);
226
+ if (isValidNumber(limitSize)) {
227
+ if ("bottom" === orient || "top" === orient) if (angle !== Math.PI / 2) {
228
+ const cosValue = Math.abs(Math.cos(null != angle ? angle : 0));
229
+ maxTagWidth = cosValue < 1e-6 ? 1 / 0 : this.attribute.end.x / cosValue;
230
+ } else maxTagWidth = limitSize - offset; else if (angle && 0 !== angle) {
231
+ const sinValue = Math.abs(Math.sin(angle));
232
+ maxTagWidth = sinValue < 1e-6 ? 1 / 0 : this.attribute.end.y / sinValue;
233
+ } else maxTagWidth = limitSize - offset;
234
+ }
235
+ }
236
+ const text = formatMethod ? formatMethod(textContent) : textContent, attrs = Object.assign(Object.assign(Object.assign({}, labelPoint), restAttrs), {
237
+ maxWidth: maxTagWidth,
238
+ textStyle: Object.assign({
239
+ textAlign: textAlign,
240
+ textBaseline: textBaseline
241
+ }, textStyle),
242
+ text: text
243
+ });
244
+ return attrs.angle = angle, background && background.visible && (attrs.panel = Object.assign(Object.assign({
245
+ visible: !0
246
+ }, restAttrs.panel), background.style)), attrs;
247
+ }
192
248
  getTextBaseline(vector, inside) {
193
249
  let base = "middle";
194
250
  const {verticalFactor: verticalFactor = 1} = this.attribute, factor = (inside ? 1 : -1) * verticalFactor;
@@ -327,6 +383,24 @@ export class LineAxis extends AxisBase {
327
383
  return limitLength && (limitLength = (limitLength - labelSpace - titleSpacing - titleHeight - axisLineWidth - tickLength) / layerCount),
328
384
  limitLength;
329
385
  }
386
+ showLabelHoverOnAxis(position, text) {
387
+ if (this.attribute.labelHoverOnAxis) if (this.labelHoverOnAxisGroup) {
388
+ const {formatMethod: formatMethod} = this.attribute.labelHoverOnAxis, textStr = formatMethod ? formatMethod(text) : text;
389
+ this.labelHoverOnAxisGroup.setAttribute("text", textStr), this.labelHoverOnAxisGroup.setAttribute("visible", !0),
390
+ this.labelHoverOnAxisGroup.setAttribute("visibleAll", !0), "left" === this.attribute.orient || "right" === this.attribute.orient ? this.labelHoverOnAxisGroup.setAttributes({
391
+ y: position
392
+ }) : this.labelHoverOnAxisGroup.setAttributes({
393
+ x: position
394
+ });
395
+ } else this.attribute.labelHoverOnAxis.visible = !0, this.attribute.labelHoverOnAxis.position = position,
396
+ this.attribute.labelHoverOnAxis.text = text, this.renderLabelHoverOnAxis();
397
+ }
398
+ hideLabelHoverOnAxis() {
399
+ this.attribute.labelHoverOnAxis && this.labelHoverOnAxisGroup && this.labelHoverOnAxisGroup.setAttributes({
400
+ visible: !1,
401
+ visibleAll: !1
402
+ });
403
+ }
330
404
  release() {
331
405
  super.release(), this._breaks = null;
332
406
  }