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

Time display in Tooltip/ticks is broken for timeseries charts #11435

Closed
ckc4823 opened this issue Dec 3, 2019 · 10 comments · Fixed by #24185
Closed

Time display in Tooltip/ticks is broken for timeseries charts #11435

ckc4823 opened this issue Dec 3, 2019 · 10 comments · Fixed by #24185
Assignees
Labels
Customization/Formatting .Frontend Priority:P2 Average run of the mill bug Querying/Native The SQL/native query editor Type:Bug Product defects
Milestone

Comments

@ckc4823
Copy link

ckc4823 commented Dec 3, 2019

Display of time in tooltips of timeseries charts has been missing/broken since 0.33.1

image

  • Metabase jar file on Win10
  • Postgres 12.1
  • Chrome 78.0.3904.108 (Official Build) (64-bit)

⬇️ Please click the 👍 reaction instead of leaving a +1 or update? comment

@ckc4823 ckc4823 added .Needs Triage Type:Bug Product defects labels Dec 3, 2019
@flamber
Copy link
Contributor

flamber commented Dec 4, 2019

Reproduced on master, but only Native/SQL question. Likely related to #17598.

  • Simple question > Sample Dataset > Orders
  • Filter CreatedAt=2019-12-03
  • Change visualization to Line, set X-axis=CreatedAt, Y-axis=Total
  • Check CreatedAt ⚙️, set time to "HH:MM:SS:MS"
    Screenshot_00000
  • Click Editor (top-right) > SQL-icon (Convert to SQL)
    Screenshot_00001

@jens-totemic
Copy link

Is there any known workaround for this?

@flamber
Copy link
Contributor

flamber commented Nov 12, 2021

@jens-totemic Casting as text is currently the only workaround.

@jens-totemic
Copy link

jens-totemic commented Nov 12, 2021

Thanks @flamber. I applied casting to my sample from #18956 and I still get the same result:

WITH test(ts, v) AS (VALUES
	('2021-11-11 13:00:56Z'::timestamptz, 6),
	('2021-11-11 15:11:43Z'::timestamptz, 5),
	('2021-11-11 17:22:35Z'::timestamptz, 4),
	('2021-11-11 19:33:22Z'::timestamptz, 6),
	('2021-11-11 21:44:19Z'::timestamptz, 5),
	('2021-11-11 23:55:02Z'::timestamptz, 4)
)
SELECT cast(ts as text), v
FROM test

The output in the tooltip is still without time (same also in the x-axis label).

@flamber
Copy link
Contributor

flamber commented Nov 12, 2021

@jens-totemic Sorry, you'll need to format the date yourself, so the frontend does not understand it's a date and tries to do it's magic.

@jens-totemic
Copy link

jens-totemic commented Nov 12, 2021

Ok, got it. The problem unfortunately is that this specific column is the one needed as the x-axis in the visualization. I.e. it cannot be modified to the point that Metabase is not recognizing it as a timestamp. So pretty much any time series display will be affected by this.

@flamber flamber added .Frontend Priority:P2 Average run of the mill bug and removed Priority:P3 Cosmetic bugs, minor bugs with a clear workaround labels Nov 12, 2021
@jens-totemic
Copy link

jens-totemic commented Nov 13, 2021

Using some more info from #12370, here's a somewhat contrived way to display the data at least on a minute level resolution with both the tooltip and x-axis showing proper numbers.

What makes this contrived is that if Metabase sees multiple values for the same exact minute, it will add them up in the graph - which is not what we needed. Our regular dataset will never have more than one value for each timestamp but now that we group all of them together into the same minute, it can happen. To fix this, we are just picking exactly one value to visualize for each given minute (which one to pick depends on the use case). So it might be only a 50% workaround depending on the use case but sharing here since it allowed us to keep going.

WITH test(ts, v) AS (VALUES
	('2021-11-11 13:00:15Z'::timestamptz, 6),
	('2021-11-11 13:00:56Z'::timestamptz, 5),
	('2021-11-11 15:11:43Z'::timestamptz, 5),
	('2021-11-11 17:22:35Z'::timestamptz, 4),
	('2021-11-11 19:33:22Z'::timestamptz, 6),
	('2021-11-11 21:44:19Z'::timestamptz, 5),
	('2021-11-11 23:55:02Z'::timestamptz, 4)
)
SELECT DISTINCT ON (ts) ts, v
FROM (
  SELECT date_trunc('minute', ts) AS ts, v
  FROM test
) AS test2
ORDER BY ts, v DESC

@flamber
Copy link
Contributor

flamber commented Nov 13, 2021

@jens-totemic Metabase has several feature requests open about second-handling. It has not really been the main use-case.
If you define "X-axis scale"=Ordinal, then it won't try to merge things together:
image

@flamber flamber changed the title Time display in Tooltip is broken for timeseries charts Time display in Tooltip/ticks is broken for timeseries charts Nov 13, 2021
@jens-totemic
Copy link

Thanks @flamber When using the Ordinal display each entry is equally spaced apart on the screen, no matter if they are just seconds or hours away from each other. The screenshot above illustrates this well. For actual time series data this is not desirable as the time relationship would need to be kept on the graph.

@ckc4823
Copy link
Author

ckc4823 commented Nov 14, 2021

Thanks @jens-totemic for the DISTINCT ON workaround! This issue has been a thorn in my side for years.

This was referenced Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Customization/Formatting .Frontend Priority:P2 Average run of the mill bug Querying/Native The SQL/native query editor Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants