(
// Component or series
model: ComponentModel,
printError?: boolean
)
| 184 | | typeof COORD_SYS_USAGE_KIND_BOX; |
| 185 | |
| 186 | export function decideCoordSysUsageKind( |
| 187 | // Component or series |
| 188 | model: ComponentModel, |
| 189 | printError?: boolean |
| 190 | ): { |
| 191 | kind: CoordinateSystemUsageKind; |
| 192 | coordSysType: string | NullUndefined; |
| 193 | } { |
| 194 | // For backward compat, still not use `true` in model.get. |
| 195 | const coordSysType = model.getShallow('coordinateSystem'); |
| 196 | let coordSysUsageOption = model.getShallow('coordinateSystemUsage', true); |
| 197 | const isDeclaredExplicitly = coordSysUsageOption != null; |
| 198 | let kind: CoordinateSystemUsageKind = COORD_SYS_USAGE_KIND_NONE; |
| 199 | |
| 200 | if (coordSysType) { |
| 201 | const isSeries = model.mainType === 'series'; |
| 202 | if (coordSysUsageOption == null) { |
| 203 | coordSysUsageOption = isSeries ? 'data' : 'box'; |
| 204 | } |
| 205 | |
| 206 | if (coordSysUsageOption === 'data') { |
| 207 | kind = COORD_SYS_USAGE_KIND_DATA; |
| 208 | if (!isSeries) { |
| 209 | if (__DEV__) { |
| 210 | if (isDeclaredExplicitly && printError) { |
| 211 | error('coordinateSystemUsage "data" is not supported in non-series components.'); |
| 212 | } |
| 213 | } |
| 214 | kind = COORD_SYS_USAGE_KIND_NONE; |
| 215 | } |
| 216 | } |
| 217 | else if (coordSysUsageOption === 'box') { |
| 218 | kind = COORD_SYS_USAGE_KIND_BOX; |
| 219 | if (!isSeries && !canBeNonSeriesBoxCoordSys(coordSysType)) { |
| 220 | if (__DEV__) { |
| 221 | if (isDeclaredExplicitly && printError) { |
| 222 | error(`coordinateSystem "${coordSysType}" cannot be used` |
| 223 | + ` as coordinateSystemUsage "box" for "${model.type}" yet.` |
| 224 | ); |
| 225 | } |
| 226 | } |
| 227 | kind = COORD_SYS_USAGE_KIND_NONE; |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | return {coordSysType, kind}; |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * These cases are considered: |
no test coverage detected
searching dependent graphs…