(
value: ScaleDataValue,
axis: Axis,
ecModel: GlobalModel,
seriesDataIndices: CommonAxisPointerOption['seriesDataIndices'],
opt?: {
precision?: number | 'auto'
formatter?: CommonAxisPointerOption['label']['formatter']
}
)
| 145 | } |
| 146 | |
| 147 | export function getValueLabel( |
| 148 | value: ScaleDataValue, |
| 149 | axis: Axis, |
| 150 | ecModel: GlobalModel, |
| 151 | seriesDataIndices: CommonAxisPointerOption['seriesDataIndices'], |
| 152 | opt?: { |
| 153 | precision?: number | 'auto' |
| 154 | formatter?: CommonAxisPointerOption['label']['formatter'] |
| 155 | } |
| 156 | ): string { |
| 157 | value = axis.scale.parse(value); |
| 158 | let text = (axis.scale as IntervalScale).getLabel( |
| 159 | { |
| 160 | value |
| 161 | }, { |
| 162 | // If `precision` is set, width can be fixed (like '12.00500'), which |
| 163 | // helps to debounce when when moving label. |
| 164 | precision: opt.precision |
| 165 | } |
| 166 | ); |
| 167 | const formatter = opt.formatter; |
| 168 | |
| 169 | if (formatter) { |
| 170 | const params = { |
| 171 | value: axisHelper.getAxisRawValue(axis, {value}), |
| 172 | axisDimension: axis.dim, |
| 173 | axisIndex: (axis as Axis2D).index, // Only Carteian Axis has index |
| 174 | seriesData: [] as CallbackDataParams[] |
| 175 | }; |
| 176 | zrUtil.each(seriesDataIndices, function (idxItem) { |
| 177 | const series = ecModel.getSeriesByIndex(idxItem.seriesIndex); |
| 178 | const dataIndex = idxItem.dataIndexInside; |
| 179 | const dataParams = series && series.getDataParams(dataIndex); |
| 180 | dataParams && params.seriesData.push(dataParams); |
| 181 | }); |
| 182 | |
| 183 | if (zrUtil.isString(formatter)) { |
| 184 | text = formatter.replace('{value}', text); |
| 185 | } |
| 186 | else if (zrUtil.isFunction(formatter)) { |
| 187 | text = formatter(params); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | return text; |
| 192 | } |
| 193 | |
| 194 | export function getTransformedPosition( |
| 195 | axis: Axis, |
no test coverage detected
searching dependent graphs…