Skip to content

Commit

Permalink
fix: add more significant digits to y axis
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuss committed Jan 30, 2024
1 parent 0cfb53a commit 2db2cb1
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ it('draggable annotation rescales axis in positive direction', () => {
cy.get('g.axis.y-axis > g.tick').should('have.length', 17);
cy.get('g.axis.y-axis > g.tick > text')
.eq(16)
.should('have.text', '8.0k');
.should('have.text', '8k');
cy.get('g.axis.y-axis > g.tick > text')
.eq(0)
.should('have.text', '0.0');
.should('have.text', '0');
});

it('draggable annotation rescales axis in negative direction', () => {
Expand All @@ -91,10 +91,10 @@ it('draggable annotation rescales axis in negative direction', () => {
cy.get('g.axis.y-axis > g.tick').should('have.length', 9);
cy.get('g.axis.y-axis > g.tick > text')
.eq(8)
.should('have.text', '3.0k');
.should('have.text', '3k');
cy.get('g.axis.y-axis > g.tick > text')
.eq(0)
.should('have.text', '−5.0k');
.should('have.text', '−5k');
});

it('non-Editable annotation is not draggable', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ it('draggable annotation rescales axis in positive direction', () => {
cy.get('g.axis.y-axis > g.tick').should('have.length', 17);
cy.get('g.axis.y-axis > g.tick > text')
.eq(16)
.should('have.text', '9.0k');
.should('have.text', '9k');
cy.get('g.axis.y-axis > g.tick > text')
.eq(0)
.should('have.text', '1.0k');
.should('have.text', '1k');
});

it('draggable annotation rescales axis in negative direction', () => {
Expand All @@ -241,10 +241,10 @@ it('draggable annotation rescales axis in negative direction', () => {
cy.get('g.axis.y-axis > g.tick').should('have.length', 10);
cy.get('g.axis.y-axis > g.tick > text')
.eq(9)
.should('have.text', '5.0k');
.should('have.text', '5k');
cy.get('g.axis.y-axis > g.tick > text')
.eq(0)
.should('have.text', '−4.0k');
.should('have.text', '−4k');
});

it('non-Editable annotation is not draggable', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ it('draggable annotation rescales axis in positive direction', () => {
cy.get('g.axis.y-axis > g.tick').should('have.length', 17);
cy.get('g.axis.y-axis > g.tick > text')
.eq(16)
.should('have.text', '9.0k');
.should('have.text', '9k');
cy.get('g.axis.y-axis > g.tick > text')
.eq(0)
.should('have.text', '1.0k');
.should('have.text', '1k');
});

it('draggable annotation rescales axis in negative direction', () => {
Expand All @@ -125,10 +125,10 @@ it('draggable annotation rescales axis in negative direction', () => {
cy.get('g.axis.y-axis > g.tick').should('have.length', 10);
cy.get('g.axis.y-axis > g.tick > text')
.eq(9)
.should('have.text', '5.0k');
.should('have.text', '5k');
cy.get('g.axis.y-axis > g.tick > text')
.eq(0)
.should('have.text', '−4.0k');
.should('have.text', '−4k');
});

it('non-Editable annotation is not draggable', () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { addChartCommands } from './chartCommands';
addChartCommands();

addMatchImageSnapshotCommand({
failureThresholdType: 'pixel',
failureThreshold: 2,
failureThresholdType: 'percent',
failureThreshold: 0.01,
customDiffConfig: { threshold: 0.2 },
});
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ const yAxisConstructor = (size: SizeConfig, viewport: ViewPort) => {
const { yTickCount } = tickCount(size);
const { yScale } = scales(size, viewport);

// format: https://d3js.org/d3-format#locale_format
return axisLeft(yScale)
.ticks(yTickCount)
.tickFormat(format('.2s'))
.tickFormat(format('.4~s'))
.tickSize(-size.width)
.tickPadding(TICK_PADDING);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ describe('initial render', () => {

it('has expected y axis value labels', async () => {
const { axis } = await axisSpecPage();
expect(axis.innerHTML).toContain('3.0k');
expect(axis.innerHTML).toContain('3k');
expect(axis.innerHTML).toContain('3.05k');
expect(axis.innerHTML).toContain('3.1k');
expect(axis.innerHTML).not.toContain('3.00k');
});
Expand Down Expand Up @@ -248,9 +249,9 @@ describe('updated correctly', () => {
expect(axis.innerHTML).not.toContain('3.10k');

// Does contain new y labels
expect(axis.innerHTML).toContain('4.0k');
expect(axis.innerHTML).toContain('4k');
expect(axis.innerHTML).toContain('4.5k');
expect(axis.innerHTML).toContain('5.0k');
expect(axis.innerHTML).toContain('5k');
});

it('updates the y-axis label', async () => {
Expand Down

0 comments on commit 2db2cb1

Please sign in to comment.