|
| 1 | +//// [controlFlowCaching.ts] |
| 2 | + |
| 3 | +// Repro for #8401 |
| 4 | + |
| 5 | +function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { |
| 6 | + var isRtl = this._isRtl(); // chart mirroring |
| 7 | + // prepare variable |
| 8 | + var o = this.opt, ta = this.chart.theme.axis, position = o.position, |
| 9 | + leftBottom = position !== "rightOrTop", rotation = o.rotation % 360, |
| 10 | + start, stop, titlePos, titleRotation = 0, titleOffset, axisVector, tickVector, anchorOffset, labelOffset, labelAlign, |
| 11 | + labelGap = this.chart.theme.axis.tick.labelGap, |
| 12 | + taFont = o.font || (ta.majorTick && ta.majorTick.font) || (ta.tick && ta.tick.font), |
| 13 | + taTitleFont = o.titleFont || (ta.title && ta.title.font), |
| 14 | + taFontColor = o.fontColor || (ta.majorTick && ta.majorTick.fontColor) || (ta.tick && ta.tick.fontColor) || "black", |
| 15 | + taTitleFontColor = o.titleFontColor || (ta.title && ta.title.fontColor) || "black", |
| 16 | + taTitleGap = (o.titleGap == 0) ? 0 : o.titleGap || (ta.title && ta.title.gap) || 15, |
| 17 | + taTitleOrientation = o.titleOrientation || (ta.title && ta.title.orientation) || "axis", |
| 18 | + taMajorTick = this.chart.theme.getTick("major", o), |
| 19 | + taMinorTick = this.chart.theme.getTick("minor", o), |
| 20 | + taMicroTick = this.chart.theme.getTick("micro", o), |
| 21 | + |
| 22 | + taStroke = "stroke" in o ? o.stroke : ta.stroke, |
| 23 | + size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0, |
| 24 | + cosr = Math.abs(Math.cos(rotation * Math.PI / 180)), |
| 25 | + sinr = Math.abs(Math.sin(rotation * Math.PI / 180)), |
| 26 | + tsize = taTitleFont ? g.normalizedLength(g.splitFontString(taTitleFont).size) : 0; |
| 27 | + if (rotation < 0) { |
| 28 | + rotation += 360; |
| 29 | + } |
| 30 | + var cachedLabelW = this._getMaxLabelSize(); |
| 31 | + cachedLabelW = cachedLabelW && cachedLabelW.majLabelW; |
| 32 | + titleOffset = size * cosr + (cachedLabelW || 0) * sinr + labelGap + Math.max(taMajorTick.length > 0 ? taMajorTick.length : 0, |
| 33 | + taMinorTick.length > 0 ? taMinorTick.length : 0) + |
| 34 | + tsize + taTitleGap; |
| 35 | + axisVector = { x: isRtl ? -1 : 1, y: 0 }; // chart mirroring |
| 36 | + switch (rotation) { |
| 37 | + default: |
| 38 | + if (rotation < (90 - centerAnchorLimit)) { |
| 39 | + labelOffset.y = leftBottom ? size : 0; |
| 40 | + } else if (rotation < (90 + centerAnchorLimit)) { |
| 41 | + labelOffset.x = -size * 0.4; |
| 42 | + } else if (rotation < 180) { |
| 43 | + labelOffset.y = leftBottom ? 0 : -size; |
| 44 | + } else if (rotation < (270 - centerAnchorLimit)) { |
| 45 | + labelOffset.y = leftBottom ? 0 : -size; |
| 46 | + } else if (rotation < (270 + centerAnchorLimit)) { |
| 47 | + labelOffset.y = leftBottom ? size * 0.4 : 0; |
| 48 | + } else { |
| 49 | + labelOffset.y = leftBottom ? size : 0; |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0; |
| 54 | + titlePos.y = offsets.t - titleOffset + (titleRotation ? 0 : tsize); |
| 55 | + switch (labelAlign) { |
| 56 | + case "start": |
| 57 | + labelAlign = "end"; |
| 58 | + break; |
| 59 | + case "end": |
| 60 | + labelAlign = "start"; |
| 61 | + break; |
| 62 | + case "middle": |
| 63 | + labelOffset.y -= size; |
| 64 | + break; |
| 65 | + } |
| 66 | + |
| 67 | + let _ = rotation; |
| 68 | +} |
| 69 | + |
| 70 | + |
| 71 | +//// [controlFlowCaching.js] |
| 72 | +// Repro for #8401 |
| 73 | +function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { |
| 74 | + var isRtl = this._isRtl(); // chart mirroring |
| 75 | + // prepare variable |
| 76 | + var o = this.opt, ta = this.chart.theme.axis, position = o.position, leftBottom = position !== "rightOrTop", rotation = o.rotation % 360, start, stop, titlePos, titleRotation = 0, titleOffset, axisVector, tickVector, anchorOffset, labelOffset, labelAlign, labelGap = this.chart.theme.axis.tick.labelGap, taFont = o.font || (ta.majorTick && ta.majorTick.font) || (ta.tick && ta.tick.font), taTitleFont = o.titleFont || (ta.title && ta.title.font), taFontColor = o.fontColor || (ta.majorTick && ta.majorTick.fontColor) || (ta.tick && ta.tick.fontColor) || "black", taTitleFontColor = o.titleFontColor || (ta.title && ta.title.fontColor) || "black", taTitleGap = (o.titleGap == 0) ? 0 : o.titleGap || (ta.title && ta.title.gap) || 15, taTitleOrientation = o.titleOrientation || (ta.title && ta.title.orientation) || "axis", taMajorTick = this.chart.theme.getTick("major", o), taMinorTick = this.chart.theme.getTick("minor", o), taMicroTick = this.chart.theme.getTick("micro", o), taStroke = "stroke" in o ? o.stroke : ta.stroke, size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0, cosr = Math.abs(Math.cos(rotation * Math.PI / 180)), sinr = Math.abs(Math.sin(rotation * Math.PI / 180)), tsize = taTitleFont ? g.normalizedLength(g.splitFontString(taTitleFont).size) : 0; |
| 77 | + if (rotation < 0) { |
| 78 | + rotation += 360; |
| 79 | + } |
| 80 | + var cachedLabelW = this._getMaxLabelSize(); |
| 81 | + cachedLabelW = cachedLabelW && cachedLabelW.majLabelW; |
| 82 | + titleOffset = size * cosr + (cachedLabelW || 0) * sinr + labelGap + Math.max(taMajorTick.length > 0 ? taMajorTick.length : 0, taMinorTick.length > 0 ? taMinorTick.length : 0) + |
| 83 | + tsize + taTitleGap; |
| 84 | + axisVector = { x: isRtl ? -1 : 1, y: 0 }; // chart mirroring |
| 85 | + switch (rotation) { |
| 86 | + default: |
| 87 | + if (rotation < (90 - centerAnchorLimit)) { |
| 88 | + labelOffset.y = leftBottom ? size : 0; |
| 89 | + } |
| 90 | + else if (rotation < (90 + centerAnchorLimit)) { |
| 91 | + labelOffset.x = -size * 0.4; |
| 92 | + } |
| 93 | + else if (rotation < 180) { |
| 94 | + labelOffset.y = leftBottom ? 0 : -size; |
| 95 | + } |
| 96 | + else if (rotation < (270 - centerAnchorLimit)) { |
| 97 | + labelOffset.y = leftBottom ? 0 : -size; |
| 98 | + } |
| 99 | + else if (rotation < (270 + centerAnchorLimit)) { |
| 100 | + labelOffset.y = leftBottom ? size * 0.4 : 0; |
| 101 | + } |
| 102 | + else { |
| 103 | + labelOffset.y = leftBottom ? size : 0; |
| 104 | + } |
| 105 | + } |
| 106 | + titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0; |
| 107 | + titlePos.y = offsets.t - titleOffset + (titleRotation ? 0 : tsize); |
| 108 | + switch (labelAlign) { |
| 109 | + case "start": |
| 110 | + labelAlign = "end"; |
| 111 | + break; |
| 112 | + case "end": |
| 113 | + labelAlign = "start"; |
| 114 | + break; |
| 115 | + case "middle": |
| 116 | + labelOffset.y -= size; |
| 117 | + break; |
| 118 | + } |
| 119 | + var _ = rotation; |
| 120 | +} |
0 commit comments