(
scale: Scale,
model: AxisBaseModel,
// Typically: data extent from all series on this axis.
dataExtent: number[],
requireStartValue: boolean,
requireContainShape: boolean
)
| 178 | |
| 179 | |
| 180 | constructor( |
| 181 | scale: Scale, |
| 182 | model: AxisBaseModel, |
| 183 | // Typically: data extent from all series on this axis. |
| 184 | dataExtent: number[], |
| 185 | requireStartValue: boolean, |
| 186 | requireContainShape: boolean |
| 187 | ) { |
| 188 | const isOrdinal = isOrdinalScale(scale); |
| 189 | |
| 190 | const axisDataLen = isOrdinal |
| 191 | // FIXME: there is a flaw here: if there is no "block" data processor like `dataZoom`, |
| 192 | // and progressive rendering is using, here the category result might just only contain |
| 193 | // the processed chunk rather than the entire result. |
| 194 | ? model.getCategories().length |
| 195 | : null; |
| 196 | |
| 197 | // [CATEGORY_AXIS_MODEL_DATA_IS_EMPTY_ARRAY]: |
| 198 | // This is only for backward compatibility - `xxxAxis: {data: []}` can declare this axis as |
| 199 | // a "category" axis and use `series.data` to determine its extent but the axis is blank - only |
| 200 | // axis line is displayed. This is a conincidence, but it is used in some cases. |
| 201 | let categoryAxisModelDataIsEmptyArray: boolean; |
| 202 | if (isOrdinal) { |
| 203 | const axisModelDataArray = model.getCategories(true); |
| 204 | categoryAxisModelDataIsEmptyArray = axisModelDataArray && !axisModelDataArray.length; |
| 205 | } |
| 206 | |
| 207 | // NOTE: also considered the input dataExtent may be still in the initialized state `[Infinity, -Infinity]`. |
| 208 | const dataMM = dataExtent.slice(); |
| 209 | // custom dataMin/dataMax. |
| 210 | // Also considered `modelDataMinMax[0] > modelDataMinMax[1]` may occur. |
| 211 | if (isIntervalScale(scale) || isLogScale(scale) || isTimeScale(scale)) { |
| 212 | unionExtentStartFromNumber( |
| 213 | dataMM, |
| 214 | parseAxisModelMinMax(scale, (model as AxisBaseModel<NumericAxisBaseOptionCommon>).get('dataMin', true)) |
| 215 | ); |
| 216 | unionExtentEndFromNumber( |
| 217 | dataMM, |
| 218 | parseAxisModelMinMax(scale, (model as AxisBaseModel<NumericAxisBaseOptionCommon>).get('dataMax', true)) |
| 219 | ); |
| 220 | } |
| 221 | if (!extentHasValue(dataMM)) { |
| 222 | // dataMM may be still `[Infinity, -Infinity]`, we use `NaN` on the subsequent calculations |
| 223 | // to force the `noZoomEffMM` to be `[NaN, NaN]` if needed. |
| 224 | dataMM[0] = dataMM[1] = NaN; |
| 225 | } |
| 226 | |
| 227 | const noZoomEffMM: number[] = []; |
| 228 | const fixMM: boolean[] = [false, false]; |
| 229 | |
| 230 | // Notice: When min/max is not set (that is, when there are null/undefined, |
| 231 | // which is the most common case), these cases should be ensured: |
| 232 | // (1) For 'ordinal', show all axis.data. |
| 233 | // (2) For others: |
| 234 | // + `boundaryGap` is applied (if min/max set, boundaryGap is |
| 235 | // disabled). |
| 236 | // + If `needIncludeZero`, min/max should be zero, otherwise, min/max should |
| 237 | // be the result that originalExtent enlarged by boundaryGap. |
nothing calls this directly
no test coverage detected