Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vislib: Fix position calculation of ticks in non-horizontal axes #62309

Merged
merged 3 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ export class AxisLabels {

selection.selectAll('.tick text').text(function(d) {
const parentNode = d3.select(this.parentNode).node();
const currentTickCenter =
scaleStartPad +
(config.isHorizontal() ? self.axisScale.scale(d) : upperBound - self.axisScale.scale(d));
const currentTickCenter = config.isHorizontal()
? scaleStartPad + self.axisScale.scale(d)
: upperBound - scaleStartPad - self.axisScale.scale(d);
const currentTickSize =
(config.isHorizontal() ? parentNode.getBBox().width : parentNode.getBBox().height) *
padding;
Expand Down
24 changes: 23 additions & 1 deletion test/functional/apps/visualize/_vertical_bar_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,32 @@ export default function({ getService, getPageObjects }) {
await PageObjects.visEditor.selectXAxisPosition('left');
await PageObjects.visEditor.clickGo();

const leftLabels = await PageObjects.visChart.getXAxisLabels();
// the getYAxisLabels helper always returns the labels on the left axis
const leftLabels = await PageObjects.visChart.getYAxisLabels();
log.debug(`${leftLabels.length} tick labels on left x axis`);
expect(leftLabels.length).to.be.greaterThan(bottomLabels.length * (2 / 3));
});

it('should not filter out first label after rotation of the chart', async function() {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVerticalBarChart();
await PageObjects.visualize.clickNewSearch();
await PageObjects.timePicker.setDefaultAbsoluteRange();
await PageObjects.visEditor.clickBucket('X-axis');
await PageObjects.visEditor.selectAggregation('Date Range');
await PageObjects.visEditor.selectField('@timestamp');
await PageObjects.visEditor.clickGo();
const bottomLabels = await PageObjects.visChart.getXAxisLabels();
expect(bottomLabels.length).to.be(1);

await PageObjects.visEditor.clickMetricsAndAxes();
await PageObjects.visEditor.selectXAxisPosition('left');
await PageObjects.visEditor.clickGo();

// the getYAxisLabels helper always returns the labels on the left axis
const leftLabels = await PageObjects.visChart.getYAxisLabels();
expect(leftLabels.length).to.be(1);
});
});

describe('bar charts range on x axis', () => {
Expand Down