(
xyLocator: MatrixXYLocator[],
matrixModel: MatrixModel,
group: Group,
ecModel: GlobalModel,
cellOption: MatrixBaseCellOption | NullUndefined,
parentItemStyleModel: Model<MatrixCellStyleOption['itemStyle']>,
parentLabelModel: Model<MatrixCellStyleOption['label']>,
parentCellModel: Model<MatrixCellStyleOption>,
shape: RectLike,
textValue: unknown,
zrCellDefault: Z2CellDefault,
tooltipOption: MatrixOption['tooltip'],
targetType: MatrixTargetType
)
| 259 | type MatrixTargetType = 'x' | 'y' | 'body' | 'corner'; |
| 260 | |
| 261 | function createMatrixCell( |
| 262 | xyLocator: MatrixXYLocator[], |
| 263 | matrixModel: MatrixModel, |
| 264 | group: Group, |
| 265 | ecModel: GlobalModel, |
| 266 | cellOption: MatrixBaseCellOption | NullUndefined, |
| 267 | parentItemStyleModel: Model<MatrixCellStyleOption['itemStyle']>, |
| 268 | parentLabelModel: Model<MatrixCellStyleOption['label']>, |
| 269 | parentCellModel: Model<MatrixCellStyleOption>, |
| 270 | shape: RectLike, |
| 271 | textValue: unknown, |
| 272 | zrCellDefault: Z2CellDefault, |
| 273 | tooltipOption: MatrixOption['tooltip'], |
| 274 | targetType: MatrixTargetType |
| 275 | ): void { |
| 276 | // Do not use getModel - a quick performance optimization. |
| 277 | _tmpCellItemStyleModel.option = cellOption ? cellOption.itemStyle : null; |
| 278 | _tmpCellItemStyleModel.parentModel = parentItemStyleModel; |
| 279 | _tmpCellModel.option = cellOption; |
| 280 | _tmpCellModel.parentModel = parentCellModel; |
| 281 | |
| 282 | // Use different z2 because special border may be defined in itemStyle. |
| 283 | const z2 = retrieve2( |
| 284 | _tmpCellModel.getShallow('z2'), |
| 285 | (cellOption && cellOption.itemStyle) ? zrCellDefault.special : zrCellDefault.normal |
| 286 | ); |
| 287 | const tooltipOptionShow = tooltipOption && tooltipOption.show; |
| 288 | |
| 289 | const cellRect = createMatrixRect(shape, _tmpCellItemStyleModel.getItemStyle(), z2); |
| 290 | group.add(cellRect); |
| 291 | |
| 292 | const cursorOption = _tmpCellModel.get('cursor'); |
| 293 | if (cursorOption != null) { |
| 294 | cellRect.attr('cursor', cursorOption); |
| 295 | } |
| 296 | let cellText: Text | NullUndefined; |
| 297 | |
| 298 | if (textValue != null) { |
| 299 | let text = textValue + ''; |
| 300 | _tmpCellLabelModel.option = cellOption ? cellOption.label : null; |
| 301 | _tmpCellLabelModel.parentModel = parentLabelModel; |
| 302 | // This is to accept `option.textStyle` as the default. |
| 303 | _tmpCellLabelModel.ecModel = ecModel; |
| 304 | |
| 305 | const formatter = _tmpCellLabelModel.getShallow('formatter'); |
| 306 | if (formatter) { |
| 307 | const params = { |
| 308 | componentType: 'matrix' as const, |
| 309 | componentIndex: matrixModel.componentIndex, |
| 310 | name: text, |
| 311 | value: textValue as unknown, |
| 312 | coord: xyLocator.slice() as MatrixXYLocator[], |
| 313 | $vars: ['name', 'value', 'coord'] as const |
| 314 | }; |
| 315 | if (isString(formatter)) { |
| 316 | text = formatTplSimple(formatter, params); |
| 317 | } |
| 318 | else if (isFunction(formatter)) { |
no test coverage detected
searching dependent graphs…