@gooddata/react-components
Version:
GoodData.UI - A powerful JavaScript library for building analytical applications
44 lines • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../../utils/common");
var axisLabel_1 = require("../../../../constants/axisLabel");
function getLabelOptions(index, aligns) {
var isOppositeAxis = index === 1;
var align = aligns[index];
var y = isOppositeAxis ? undefined : axisLabel_1.BOTTOM_AXIS_MARGIN;
return {
labels: {
align: align,
y: y,
},
};
}
function getAxisLabelConfigurationForDualBarChart(chartOptions) {
var type = chartOptions.type, _a = chartOptions.yAxes, yAxes = _a === void 0 ? [] : _a;
var isBar = common_1.isBarChart(type);
var isDualAxis = yAxes.length === 2;
var isDualAxisBarChart = isBar && isDualAxis;
if (!isDualAxisBarChart) {
return {};
}
var yAxisProps = chartOptions.yAxisProps, secondary_yAxisProps = chartOptions.secondary_yAxisProps;
var yAxesConfig = [yAxisProps, secondary_yAxisProps].map(function (axis, index) {
if (axis === void 0) { axis = {}; }
var rotation = axis.rotation;
switch (rotation) {
case axisLabel_1.ROTATE_60_DEGREES:
case axisLabel_1.ROTATE_90_DEGREES:
return getLabelOptions(index, [axisLabel_1.ALIGN_RIGHT, axisLabel_1.ALIGN_LEFT]);
case axisLabel_1.ROTATE_NEGATIVE_60_DEGREES:
case axisLabel_1.ROTATE_NEGATIVE_90_DEGREES:
return getLabelOptions(index, [axisLabel_1.ALIGN_LEFT, axisLabel_1.ALIGN_RIGHT]);
default:
return undefined;
}
});
return {
yAxis: yAxesConfig,
};
}
exports.getAxisLabelConfigurationForDualBarChart = getAxisLabelConfigurationForDualBarChart;
//# sourceMappingURL=getAxisLabelConfigurationForDualBarChart.js.map