MCPcopy Index your code
hub / github.com/apache/echarts / getDataExtent

Method getDataExtent

src/data/DataStore.ts:1135–1196  ·  view source on GitHub ↗
(
        dim: DimensionIndex,
        filter: DataSanitizationFilter | NullUndefined
    )

Source from the content-addressed store, hash-verified

1133 }
1134
1135 getDataExtent(
1136 dim: DimensionIndex,
1137 filter: DataSanitizationFilter | NullUndefined
1138 ): [number, number] {
1139 // Make sure use concrete dim as cache name.
1140 const dimData = this._chunks[dim];
1141 const initialExtent = initExtentForUnion();
1142
1143 if (!dimData) {
1144 return initialExtent;
1145 }
1146
1147 // Make more strict checkings to ensure hitting cache.
1148 const currEnd = this.count();
1149
1150 // Consider the most cases when using data zoom, `getDataExtent`
1151 // happened before filtering. We cache raw extent, which is not
1152 // necessary to be cleared and recalculated when restore data.
1153 const useRaw = !this._indices && !filter;
1154 if (useRaw) {
1155 return this._rawExtent[dim].slice() as [number, number];
1156 }
1157
1158 // NOTE:
1159 // - In logarithm axis, zero should be excluded, therefore the `extent[0]` should be less or equal
1160 // than the min positive data item, which requires the special handling here.
1161 // - "Filter non-positive values for logarithm axis" can also be implemented in a data processor
1162 // but that requires more complicated code to not break all streams under the current architecture,
1163 // therefore we simply implement it here.
1164 // - Performance is sensitive for large data, therefore inline filters rather than cb is used here.
1165
1166 const thisExtent = this._extent;
1167 const dimExtentRecord = thisExtent[dim] || (thisExtent[dim] = {});
1168
1169 const filterParsed = parseSanitizationFilter(filter);
1170 const filterKey = filterParsed.key;
1171
1172 const dimExtent = dimExtentRecord[filterKey];
1173 if (dimExtent) {
1174 return dimExtent.slice() as [number, number];
1175 }
1176
1177 let min = initialExtent[0];
1178 let max = initialExtent[1];
1179
1180 for (let i = 0; i < currEnd; i++) {
1181 // NOTICE: Manually inline some code for performance of large data.
1182 const rawIdx = this.getRawIndex(i);
1183 const value = dimData[rawIdx] as ParsedValueNumeric;
1184 // NOTE: in most cases, filter does not exist.
1185 if (!filter || passesSanitizationFilter(filterParsed, value)) {
1186 if (value < min) {
1187 min = value;
1188 }
1189 if (value > max) {
1190 max = value;
1191 }
1192 }

Callers 7

SeriesData.test.tsFile · 0.45
graphForceLayoutFunction · 0.45
funnelLayoutFunction · 0.45
pieLayoutFunction · 0.45
numCalculateFunction · 0.45
_createAxisMethod · 0.45
_renderDataShadowMethod · 0.45

Calls 5

countMethod · 0.95
initExtentForUnionFunction · 0.90
parseSanitizationFilterFunction · 0.90
passesSanitizationFilterFunction · 0.90
getRawIndexMethod · 0.65

Tested by

no test coverage detected