-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Improve time scale ticks behavior #38911
Improve time scale ticks behavior #38911
Conversation
🚨 Visual Regression Tests failed. Get the report artifact |
🚨 Visual Regression Tests failed. Get the report artifact |
8eab0b4
to
7b8b778
Compare
🚨 Visual Regression Tests failed. Get the report artifact |
🚨 Visual Regression Tests failed. Get the report artifact |
7310730
to
1d57fb1
Compare
🚨 Visual Regression Tests failed. Get the report artifact |
Snapshots have been updated |
{ interval: "year", count: 50, testFn: d => d.year() % 50 }, // (20) 50 year | ||
{ interval: "year", count: 100, testFn: d => d.year() % 100 }, // (21) 100 year | ||
export const TIMESERIES_INTERVALS = [ | ||
{ unit: "ms", count: 1, testFn: d => 0 }, // (0) millisecond |
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.
I removed a few old dc.js files with dead code since they relied on this objects with the old name
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.
Let's move this to a .ts
file in the echarts
directory
Snapshots have been updated |
🚨 Visual Regression Tests failed. Get the report artifact |
|
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.
Timeseries waterfall charts are no longer working in app (but they do in static viz), for example http://localhost:3000/question/133-waterfall-timeseries-uk-car-accidents
@EmmadUsmani can you please share more details about the waterfall question that is not working? I don't use this database due to huge delays which makes it unusable for me locally |
🚨 Visual Regression Tests failed. Get the report artifact |
Snapshots have been updated |
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.
Let's resolve the above issue regarding the first date, I think it's a big regression.
@EmmadUsmani there is no actual regression in storybook or the app but Loki for some reason flakes and drop them, I'll investigate:
I think this spec has relative date time x-axis but due to formatting issues it includes current date which is wrong. I'll check & fix, maybe in a separate PR since this is related to actual time scale x-axis |
{ interval: "year", count: 50, testFn: d => d.year() % 50 }, // (20) 50 year | ||
{ interval: "year", count: 100, testFn: d => d.year() % 100 }, // (21) 100 year | ||
export const TIMESERIES_INTERVALS = [ | ||
{ unit: "ms", count: 1, testFn: d => 0 }, // (0) millisecond |
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.
Let's move this to a .ts
file in the echarts
directory
frontend/src/metabase/visualizations/echarts/cartesian/model/axis.ts
Outdated
Show resolved
Hide resolved
frontend/src/metabase/visualizations/echarts/cartesian/model/axis.ts
Outdated
Show resolved
Hide resolved
frontend/src/metabase/visualizations/echarts/cartesian/option/series.ts
Outdated
Show resolved
Hide resolved
frontend/src/metabase/visualizations/echarts/cartesian/waterfall/model/axis.ts
Outdated
Show resolved
Hide resolved
30ba05b
to
12b1e51
Compare
12b1e51
to
5f5c06f
Compare
@EmmadUsmani the issue with missing ticks is caused by timezones. Since this PR has grown a lot, I moved the timezone issue in a separate task #39322 |
Fixed this, thanks |
* handle time series ticks in ECharts * fix waterfall total tick * cleanup * specs * Update Loki Snapshots * review * compensate ticks timezone * update snapshots * spec --------- Co-authored-by: Metabase bot <metabase-bot@metabase.com>
* handle time series ticks in ECharts * fix waterfall total tick * cleanup * specs * Update Loki Snapshots * review * compensate ticks timezone * update snapshots * spec --------- Co-authored-by: Metabase bot <metabase-bot@metabase.com>
* handle time series ticks in ECharts * fix waterfall total tick * cleanup * specs * Update Loki Snapshots * review * compensate ticks timezone * update snapshots * spec --------- Co-authored-by: Metabase bot <metabase-bot@metabase.com>
* handle time series ticks in ECharts * fix waterfall total tick * cleanup * specs * Update Loki Snapshots * review * compensate ticks timezone * update snapshots * spec --------- Co-authored-by: Metabase bot <metabase-bot@metabase.com>
* handle time series ticks in ECharts * fix waterfall total tick * cleanup * specs * Update Loki Snapshots * review * compensate ticks timezone * update snapshots * spec --------- Co-authored-by: Metabase bot <metabase-bot@metabase.com>
Closes
Description
The default ECharts tick selection behavior was confusing on weekly and quarterly data because the ticks did not match the actual data:
This PR fixes these cases and overall improves time scale ticks behavior.
Handle weeks and quarters
For these units we force ECharts to render ticks with smaller granularity and then in the formatter function we select desired ticks only.
Weeks: we select daily ticks that have the same day of week as the underlying data.
Quarters: we select monthly ticks that are start of quarters.
Handle long durations
To render long durations relatively to the unit we use the largest possible unit for ticks that exists 3 times within the data which guarantees at least two ticks on the chart.
For example, given the dataset has weekly data but the range of the dataset is 4 years. If we render weekly ticks, they will have some random values that will match start of some weeks of the data. It will be harder to comprehend than just evenly spaced yearly ticks.
The example below demonstrates why it is needed. It has weekly data over a few years.
Without switching to a larger unit for ticks
After switching to a larger unit for ticks