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

Function initBreakOrLinearMapper

src/scale/scaleMapper.ts:293–329  ·  view source on GitHub ↗
(
    // If input `null/undefined`, a mapper will be created.
    mapper: ScaleMapper | NullUndefined,
    breakParsed: AxisBreakParsingResult | NullUndefined,
    initialExtent: number[] | NullUndefined,
)

Source from the content-addressed store, hash-verified

291}
292
293export function initBreakOrLinearMapper(
294 // If input `null/undefined`, a mapper will be created.
295 mapper: ScaleMapper | NullUndefined,
296 breakParsed: AxisBreakParsingResult | NullUndefined,
297 initialExtent: number[] | NullUndefined,
298): {
299 // If breaks are not available, `brk` is `null/undefined`.
300 brk: BreakScaleMapper | NullUndefined;
301 // Never be `null/undefined`.
302 mapper: ScaleMapper;
303} {
304 let brk: BreakScaleMapper | NullUndefined;
305 mapper = mapper || {} as ScaleMapper;
306
307 const scaleBreakHelper = getScaleBreakHelper();
308 if (scaleBreakHelper) {
309
310 const brkMapper = scaleBreakHelper.createBreakScaleMapper(breakParsed, initialExtent);
311
312 if (brkMapper.hasBreaks()) {
313 // Some `ScaleMapper` methods (such as `normalize`) needs to be fast for large data
314 // when no breaks, so mount break methods only when breaks really exist.
315 each(SCALE_MAPPER_METHOD_NAMES, function (methodName) {
316 if (brkMapper[methodName]) {
317 (mapper as any)[methodName] = bind(brkMapper[methodName], brkMapper);
318 }
319 });
320 brk = brkMapper;
321 }
322 }
323
324 if (brk == null) {
325 initLinearScaleMapper(mapper, initialExtent);
326 }
327
328 return {brk, mapper};
329}
330
331export type DecoratedScaleMapperMethods<THost extends ScaleMapper> = Omit<ScaleMapperGeneric<THost>, 'freeze'>;
332

Callers 3

constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90

Calls 4

getScaleBreakHelperFunction · 0.90
initLinearScaleMapperFunction · 0.85
hasBreaksMethod · 0.65
eachFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…