diff --git a/src/ui/public/vislib/lib/axis/axis_config.js b/src/ui/public/vislib/lib/axis/axis_config.js index f473567cf43c6..4f69483aa5d3e 100644 --- a/src/ui/public/vislib/lib/axis/axis_config.js +++ b/src/ui/public/vislib/lib/axis/axis_config.js @@ -87,7 +87,7 @@ export default function AxisConfigFactory() { this._values.rootEl = chartConfig.get('el'); this.data = chartConfig.data; - if (this._values.type === 'category') { + if (isCategoryAxis) { if (!this._values.values) { this.values = this.data.xValues(chartConfig.get('orderBucketsBySum', false)); this.ordered = this.data.get('ordered'); @@ -124,6 +124,11 @@ export default function AxisConfigFactory() { } } + if (axisConfigArgs.title == null || axisConfigArgs.title.text == null) { + const label = isCategoryAxis ? 'xAxisLabel' : 'yAxisLabel'; + this.set('title.text', this.data.get(label)); + } + // horizontal axis with ordinal scale should have labels rotated (so we can fit more) // unless explicitly overriden by user if (this.isHorizontal() && this.isOrdinal()) {