* @implement
(axisModel: AxisBaseModel, axisPointerModel: AxisPointerModel, api: ExtensionAPI, forceRender?: boolean)
| 127 | * @implement |
| 128 | */ |
| 129 | render(axisModel: AxisBaseModel, axisPointerModel: AxisPointerModel, api: ExtensionAPI, forceRender?: boolean) { |
| 130 | const value = axisPointerModel.get('value'); |
| 131 | const status = axisPointerModel.get('status'); |
| 132 | |
| 133 | // Bind them to `this`, not in closure, otherwise they will not |
| 134 | // be replaced when user calling setOption in not merge mode. |
| 135 | this._axisModel = axisModel; |
| 136 | this._axisPointerModel = axisPointerModel; |
| 137 | this._api = api; |
| 138 | |
| 139 | // Optimize: `render` will be called repeatedly during mouse move. |
| 140 | // So it is power consuming if performing `render` each time, |
| 141 | // especially on mobile device. |
| 142 | if (!forceRender |
| 143 | && this._lastValue === value |
| 144 | && this._lastStatus === status |
| 145 | ) { |
| 146 | return; |
| 147 | } |
| 148 | this._lastValue = value; |
| 149 | this._lastStatus = status; |
| 150 | |
| 151 | let group = this._group; |
| 152 | const handle = this._handle; |
| 153 | |
| 154 | if (!status || status === 'hide') { |
| 155 | // Do not clear here, for animation better. |
| 156 | group && group.hide(); |
| 157 | handle && handle.hide(); |
| 158 | return; |
| 159 | } |
| 160 | group && group.show(); |
| 161 | handle && handle.show(); |
| 162 | |
| 163 | // Otherwise status is 'show' |
| 164 | const elOption = {} as AxisPointerElementOptions; |
| 165 | this.makeElOption(elOption, value, axisModel, axisPointerModel, api); |
| 166 | |
| 167 | // Enable change axis pointer type. |
| 168 | const graphicKey = elOption.graphicKey; |
| 169 | if (graphicKey !== this._lastGraphicKey) { |
| 170 | this.clear(api); |
| 171 | } |
| 172 | this._lastGraphicKey = graphicKey; |
| 173 | |
| 174 | const moveAnimation = this._moveAnimation = |
| 175 | this.determineAnimation(axisModel, axisPointerModel); |
| 176 | |
| 177 | if (!group) { |
| 178 | group = this._group = new graphic.Group(); |
| 179 | this.createPointerEl(group, elOption, axisModel, axisPointerModel); |
| 180 | this.createLabelEl(group, elOption, axisModel, axisPointerModel); |
| 181 | api.getZr().add(group); |
| 182 | } |
| 183 | else { |
| 184 | const doUpdateProps = zrUtil.curry(updateProps, axisPointerModel, moveAnimation); |
| 185 | this.updatePointerEl(group, elOption, doUpdateProps); |
| 186 | this.updateLabelEl(group, elOption, doUpdateProps, axisPointerModel); |
nothing calls this directly
no test coverage detected