(
value: ScaleDataValue[],
dims?: typeof dimPermutations[number],
startingAtTick?: boolean
)
| 95 | } |
| 96 | |
| 97 | getMarkerPosition( |
| 98 | value: ScaleDataValue[], |
| 99 | dims?: typeof dimPermutations[number], |
| 100 | startingAtTick?: boolean |
| 101 | ) { |
| 102 | const coordSys = this.coordinateSystem; |
| 103 | if (coordSys && coordSys.clampData) { |
| 104 | // PENDING if clamp ? |
| 105 | const clampData = coordSys.clampData(value); |
| 106 | const pt = coordSys.dataToPoint(clampData); |
| 107 | if (startingAtTick) { |
| 108 | each(coordSys.getAxes(), function (axis: Axis2D, idx: number) { |
| 109 | // If axis type is category, use tick coords instead |
| 110 | if (axis.type === 'category' && dims != null) { |
| 111 | const tickCoords = axis.getTicksCoords(); |
| 112 | const alignTicksWithLabel = (axis.getTickModel() as Model<CategoryAxisBaseOption['axisTick']>) |
| 113 | .get('alignWithLabel'); |
| 114 | |
| 115 | let targetTickId = clampData[idx]; |
| 116 | // The index of rightmost tick of markArea is 1 larger than x1/y1 index |
| 117 | const isEnd = dims[idx] === 'x1' || dims[idx] === 'y1'; |
| 118 | if (isEnd && !alignTicksWithLabel) { |
| 119 | targetTickId += 1; |
| 120 | } |
| 121 | |
| 122 | // The only contains one tick, tickCoords is |
| 123 | // like [{coord: 0, tickValue: 0}, {coord: 0}] |
| 124 | // to the length should always be larger than 1 |
| 125 | if (tickCoords.length < 2) { |
| 126 | return; |
| 127 | } |
| 128 | else if (tickCoords.length === 2) { |
| 129 | // The left value and right value of the axis are |
| 130 | // the same. coord is 0 in both items. Use the max |
| 131 | // value of the axis as the coord |
| 132 | pt[idx] = axis.toGlobalCoord( |
| 133 | axis.getExtent()[isEnd ? 1 : 0] |
| 134 | ); |
| 135 | return; |
| 136 | } |
| 137 | |
| 138 | let leftCoord; |
| 139 | let coord; |
| 140 | let stepTickValue = 1; |
| 141 | for (let i = 0; i < tickCoords.length; i++) { |
| 142 | const tickCoord = tickCoords[i].coord; |
| 143 | // The last item of tickCoords doesn't contain |
| 144 | // tickValue |
| 145 | const tickValue = i === tickCoords.length - 1 |
| 146 | ? tickCoords[i - 1].tickValue + stepTickValue |
| 147 | : tickCoords[i].tickValue; |
| 148 | if (tickValue === targetTickId) { |
| 149 | coord = tickCoord; |
| 150 | break; |
| 151 | } |
| 152 | else if (tickValue < targetTickId) { |
| 153 | leftCoord = tickCoord; |
| 154 | } |
nothing calls this directly
no test coverage detected