in src/visual.ts [474:553]
private calculateAxes() {
let effectiveWidth: number = Math.max(0, this.layout.viewportIn.width - LineDotChart.LegendSize - LineDotChart.AxisSize);
let effectiveHeight: number = Math.max(0, this.layout.viewportIn.height - LineDotChart.LegendSize);
const extentDate: [number, number] = d3.extent(
this.data.dateValues,
(dateValue: DateValue) => dateValue.value);
let minDate: number = extentDate[0],
maxDate: number = extentDate[1] + (extentDate[1] - extentDate[0]) * LineDotChart.dateMaxCutter;
this.xAxisProperties = AxisHelper.createAxis({
pixelSpan: effectiveWidth,
dataDomain: !this.data.isOrdinal
? [minDate, maxDate]
: this.data.dateValues.map((dateValue: DateValue, index: number) => { return dateValue.value; }),
metaDataColumn: this.data.dateMetadataColumn,
formatString: null,
outerPadding: LineDotChart.outerPadding,
useRangePoints: true,
isCategoryAxis: true,
isScalar: !this.data.isOrdinal,
isVertical: false,
forcedTickCount: Math.max(this.layout.viewport.width / LineDotChart.forcedTickSize, 0),
useTickIntervalForDisplayUnits: false,
shouldClamp: true,
getValueFn: LineDotChart.getColumnFormattingCallback(this.data)
});
this.xAxisProperties.xLabelMaxWidth = Math.min(
LineDotChart.xLabelMaxWidth,
this.layout.viewportIn.width / LineDotChart.xLabelTickSize
);
this.xAxisProperties.formatter = this.data.dateColumnFormatter;
let yMin = this.data.yMinValue;
let yMax = this.data.yMaxValue;
// Expanding a scope by increasing yMin and yMax to render y-axes
// - if all data values are the same (yMin = yMax) we increasing them all, for floats - increasing by const float, for integers - by 1;
// - if the data has diffrent minimum and maximum values we increasing only yMax
if (yMax === yMin) {
if ((Math.floor(yMin) === yMin) && yMin !== 0) {
yMin = yMin - 1;
yMax = yMax + 1;
} else {
yMin = yMin - LineDotChart.dateMaxCutter;
yMax = yMax + LineDotChart.dateMaxCutter;
}
} else {
yMax = yMax + (yMax - yMin) * LineDotChart.makeSomeSpaceForCounter;
}
this.yAxisProperties = AxisHelper.createAxis({
pixelSpan: effectiveHeight,
dataDomain: [yMin, yMax],
metaDataColumn: this.data.valuesMetadataColumn,
formatString: null,
outerPadding: LineDotChart.outerPadding,
isCategoryAxis: false,
isScalar: true,
isVertical: true,
useTickIntervalForDisplayUnits: true,
getValueFn: LineDotChart.getValueFormattingCallback(this.data)
});
this.yAxis2Properties = AxisHelper.createAxis({
pixelSpan: effectiveHeight,
dataDomain: [yMin, yMax],
metaDataColumn: this.data.valuesMetadataColumn,
formatString: null,
outerPadding: LineDotChart.outerPadding,
isCategoryAxis: false,
isScalar: true,
isVertical: true,
useTickIntervalForDisplayUnits: true,
getValueFn: LineDotChart.getValueFormattingCallback(this.data)
});
this.yAxis2Properties.formatter = this.data.dataValueFormatter;
}