in src/dataLabel/dataLabelArrangeGrid.ts [63:140]
constructor(size: ISize, elements: any[], layout: ILabelLayout) {
if (size.width === 0 || size.height === 0) {
this.cellSize = size;
this.rowCount = this.colCount = 0;
}
let baseProperties: TextProperties = {
fontFamily: LabelTextProperties.fontFamily,
fontSize: LabelTextProperties.fontSize,
fontWeight: LabelTextProperties.fontWeight,
};
// sets the cell size to be twice of the Max with and Max height of the elements
this.cellSize = { width: 0, height: 0 };
for (let i = 0, len = elements.length; i < len; i++) {
let child = elements[i];
// Fill label field
child.labeltext = layout.labelText(child);
let properties: TextProperties = Prototype.inherit(baseProperties);
properties.text = child.labeltext;
properties.fontSize = child.data
? child.data.labelFontSize
: child.labelFontSize
? child.labelFontSize
: LabelTextProperties.fontSize;
child.size = {
width: textMeasurementService.measureSvgTextWidth(properties),
height: textMeasurementService.estimateSvgTextHeight(properties),
};
let w = child.size.width * 2,
h = child.size.height * 2;
if (w > this.cellSize.width) {
this.cellSize.width = w;
}
if (h > this.cellSize.height) {
this.cellSize.height = h;
}
}
if (this.cellSize.width === 0) {
this.cellSize.width = size.width;
}
if (this.cellSize.height === 0) {
this.cellSize.height = size.height;
}
this.colCount = this.getGridRowColCount(
this.cellSize.width,
size.width,
DataLabelArrangeGrid.ARRANGEGRID_MIN_COUNT,
DataLabelArrangeGrid.ARRANGEGRID_MAX_COUNT);
this.rowCount = this.getGridRowColCount(
this.cellSize.height,
size.height,
DataLabelArrangeGrid.ARRANGEGRID_MIN_COUNT,
DataLabelArrangeGrid.ARRANGEGRID_MAX_COUNT);
this.cellSize.width = size.width / this.colCount;
this.cellSize.height = size.height / this.rowCount;
let grid = this.grid;
for (let x = 0; x < this.colCount; x++) {
grid[x] = [];
for (let y = 0; y < this.rowCount; y++) {
grid[x][y] = [];
}
}
}