This repository was archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plugin-chart-echarts): default to standard x-axis format (#1043)
- Loading branch information
Showing
7 changed files
with
104 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/superset-ui-core/src/time-format/formatters/smartDateDetailed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import createMultiFormatter from '../factories/createMultiFormatter'; | ||
|
||
const smartDateDetailedFormatter = createMultiFormatter({ | ||
id: 'smart_date_detailed', | ||
label: 'Detailed adaptive formatter', | ||
formats: { | ||
millisecond: '%Y-%m-%d %H:%M:%S.%L', | ||
second: '%Y-%m-%d %H:%M:%S', | ||
minute: '%Y-%m-%d %H:%M', | ||
hour: '%Y-%m-%d %H:%M', | ||
day: '%Y-%m-%d', | ||
week: '%Y-%m-%d', | ||
month: '%Y-%m-%d', | ||
year: '%Y', | ||
}, | ||
}); | ||
|
||
export default smartDateDetailedFormatter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/superset-ui-core/test/time-format/formatters/smartDateDetailed.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import TimeFormatter from '@superset-ui/core/src/time-format/TimeFormatter'; | ||
import smartDateDetailedFormatter from '@superset-ui/core/src/time-format/formatters/smartDateDetailed'; | ||
|
||
describe('smartDateDetailedFormatter', () => { | ||
const formatter = smartDateDetailedFormatter; | ||
|
||
it('is a function', () => { | ||
expect(formatter).toBeInstanceOf(TimeFormatter); | ||
}); | ||
|
||
it('shows only year when 1st day of the year', () => { | ||
expect(formatter(new Date('2020-01-01 0:00:00'))).toBe('2020'); | ||
}); | ||
|
||
it('shows full date when a regular date', () => { | ||
expect(formatter(new Date('2020-03-01 00:00:00'))).toBe('2020-03-01'); | ||
}); | ||
|
||
it('shows full date including time of day without seconds when hour precision', () => { | ||
expect(formatter(new Date('2020-03-01 13:00:00'))).toBe('2020-03-01 13:00'); | ||
}); | ||
|
||
it('shows full date including time of day when minute precision', () => { | ||
expect(formatter(new Date('2020-03-10 13:10:00'))).toBe('2020-03-10 13:10'); | ||
}); | ||
|
||
it('shows full date including time of day when subsecond precision', () => { | ||
expect(formatter(new Date('2020-03-10 13:10:00.1'))).toBe('2020-03-10 13:10:00.100'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2af1119
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: