MCPcopy
hub / github.com/apache/echarts / formatLabel

Function formatLabel

src/component/dataZoom/SliderZoomView.ts:1130–1161  ·  view source on GitHub ↗
(
    dataZoomModel: SliderZoomModel,
    extentIdx: 0 | 1,
    window: AxisProxyWindow,
    scale: Scale
)

Source from the content-addressed store, hash-verified

1128}
1129
1130function formatLabel(
1131 dataZoomModel: SliderZoomModel,
1132 extentIdx: 0 | 1,
1133 window: AxisProxyWindow,
1134 scale: Scale
1135): string {
1136 const labelFormatter = dataZoomModel.get('labelFormatter');
1137
1138 let labelPrecision = dataZoomModel.get('labelPrecision');
1139 if (labelPrecision == null || labelPrecision === 'auto') {
1140 labelPrecision = window.valuePrecision;
1141 }
1142
1143 // Do not display values out of `SCALE_EXTENT_KIND_EFFECTIVE` - generally they are meaningless.
1144 // For example, `scaleExtent[0]` is often `0`, and negative values are unlikely to be meaningful.
1145 // That is, "nice" expansion and `SCALE_EXTENT_KIND_MAPPING` expansion are always not display in labels.
1146 const value = window.value[extentIdx];
1147
1148 const valueStr = (value == null || isNaN(value))
1149 ? ''
1150 : (isOrdinalScale(scale) || isTimeScale(scale))
1151 ? scale.getLabel({value: Math.round(value)})
1152 : isFinite(labelPrecision)
1153 ? round(value, labelPrecision, true)
1154 : value + '';
1155
1156 return isFunction(labelFormatter)
1157 ? labelFormatter(value, valueStr)
1158 : isString(labelFormatter)
1159 ? labelFormatter.replace('{value}', valueStr)
1160 : valueStr;
1161}
1162
1163function getOtherDim(thisDim: 'x' | 'y' | 'radius' | 'angle' | 'single' | 'z') {
1164 // FIXME

Callers 1

_updateDataInfoMethod · 0.70

Calls 6

isOrdinalScaleFunction · 0.90
isTimeScaleFunction · 0.90
roundFunction · 0.90
isFunctionFunction · 0.50
getMethod · 0.45
getLabelMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…