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

Function createScaleByModel

src/coord/axisHelper.ts:82–133  ·  view source on GitHub ↗
(
    model:
        Model<
            // Expect `Pick<AxisBaseOptionCommon, 'type'>`,
            // but be lenient for user's invalid input.
            {type?: string}
            & Pick<LogAxisBaseOption, 'logBase'>
            & Pick<AxisBaseOptionCommon, 'breaks'>
        >
        & Partial<Pick<
            AxisModelExtendedInCreator,
            'getOrdinalMeta' | 'getCategories'
        >>,
    type: OptionAxisType,
    coordSysSupportAxisBreaks: boolean,
)

Source from the content-addressed store, hash-verified

80}
81
82export function createScaleByModel(
83 model:
84 Model<
85 // Expect `Pick<AxisBaseOptionCommon, 'type'>`,
86 // but be lenient for user's invalid input.
87 {type?: string}
88 & Pick<LogAxisBaseOption, 'logBase'>
89 & Pick<AxisBaseOptionCommon, 'breaks'>
90 >
91 & Partial<Pick<
92 AxisModelExtendedInCreator,
93 'getOrdinalMeta' | 'getCategories'
94 >>,
95 type: OptionAxisType,
96 coordSysSupportAxisBreaks: boolean,
97): Scale {
98
99 const breakHelper = getScaleBreakHelper();
100 let breakOption;
101 if (breakHelper) {
102 breakOption = retrieveAxisBreaksOption(model, type, coordSysSupportAxisBreaks);
103 }
104
105 switch (type) {
106 case 'category':
107 return new OrdinalScale({
108 ordinalMeta: model.getOrdinalMeta
109 ? model.getOrdinalMeta()
110 : model.getCategories(),
111 extent: initExtentForUnion(),
112 });
113 case 'time':
114 return new TimeScale({
115 locale: model.ecModel.getLocaleModel(),
116 useUTC: model.ecModel.get('useUTC'),
117 breakOption,
118 });
119 case 'log':
120 // See also #3749
121 return new LogScale({
122 logBase: model.get('logBase'),
123 breakOption,
124 });
125 case 'value':
126 return new IntervalScale({
127 breakOption
128 });
129 default:
130 // case others.
131 return new (Scale.getClass(type) || IntervalScale)({});
132 }
133}
134
135/**
136 * Check if the axis cross a specific value.

Callers 3

_createAxisMethod · 0.90
createAxisCreatorMethod · 0.90
setAxisFunction · 0.90

Calls 7

getScaleBreakHelperFunction · 0.90
initExtentForUnionFunction · 0.90
retrieveAxisBreaksOptionFunction · 0.85
getLocaleModelMethod · 0.80
getOrdinalMetaMethod · 0.65
getCategoriesMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…