(
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,
)
| 80 | } |
| 81 | |
| 82 | export 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. |
no test coverage detected
searching dependent graphs…