in src/axis/utils.ts [75:143]
export function calculateAxes(
layers: columnChart.IColumnChart[],
viewport: IViewport,
margin: IMargin,
categoryAxisProperties: DataViewObject,
valueAxisProperties: DataViewObject,
scrollbarVisible: boolean,
existingAxisProperties: MekkoChartAxisProperties): MekkoChartAxisProperties {
const visualOptions: MekkoCalculateScaleAndDomainOptions = {
viewport,
margin,
forcedXDomain: [
categoryAxisProperties
? categoryAxisProperties["start"]
: null,
categoryAxisProperties
? categoryAxisProperties["end"]
: null
],
forceMerge: valueAxisProperties && valueAxisProperties["secShow"] === false,
showCategoryAxisLabel: false,
showValueAxisLabel: false,
categoryAxisScaleType: categoryAxisProperties && categoryAxisProperties["axisScale"] != null
? <string>categoryAxisProperties["axisScale"]
: axisScale.linear,
valueAxisScaleType: valueAxisProperties && valueAxisProperties["axisScale"] != null
? <string>valueAxisProperties["axisScale"]
: axisScale.linear,
trimOrdinalDataOnOverflow: false
};
if (valueAxisProperties) {
visualOptions.forcedYDomain = AxisHelper.applyCustomizedDomain(
[
valueAxisProperties["start"],
valueAxisProperties["end"]
],
visualOptions.forcedYDomain);
}
let result: MekkoChartAxisProperties;
for (let layerNumber: number = 0; layerNumber < layers.length; layerNumber++) {
const currentLayer: columnChart.IColumnChart = layers[layerNumber];
visualOptions.showCategoryAxisLabel = !!categoryAxisProperties
&& !!categoryAxisProperties["showAxisTitle"];
visualOptions.showValueAxisLabel = shouldShowYAxisLabel(
layerNumber,
valueAxisProperties,
false);
const axes: IAxisProperties[] = currentLayer.calculateAxesProperties(visualOptions);
if (layerNumber === 0) {
result = {
x: axes[0],
y1: axes[1]
};
}
result.x.willLabelsFit = false;
result.x.willLabelsWordBreak = false;
}
return result;
}