diff --git a/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx b/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx index a33e4e6a33069..0ea62da9299ad 100644 --- a/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx +++ b/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx @@ -50,7 +50,7 @@ export function ActionsLineGraph({ const labels = (indexedResults.length === 2 && indexedResults.every((x) => x.compare) && - indexedResults.find((x) => x.compare_label === 'current')?.days) || + indexedResults.find((x) => x.compare_label === 'current')?.labels) || (indexedResults[0] && indexedResults[0].labels) || [] diff --git a/posthog/hogql_queries/insights/trends/test/test_trends.py b/posthog/hogql_queries/insights/trends/test/test_trends.py index fdfa854d75862..5fe2bc58cc261 100644 --- a/posthog/hogql_queries/insights/trends/test/test_trends.py +++ b/posthog/hogql_queries/insights/trends/test/test_trends.py @@ -2141,9 +2141,9 @@ def test_trends_compare_day_interval_relative_range(self): ) self.assertEqual(response[0]["label"], "sign up") - self.assertEqual(response[0]["labels"][4], "day 4") + self.assertEqual(response[0]["labels"][4], "1-Jan-2020") self.assertEqual(response[0]["data"][4], 3.0) - self.assertEqual(response[0]["labels"][5], "day 5") + self.assertEqual(response[0]["labels"][5], "2-Jan-2020") self.assertEqual(response[0]["data"][5], 1.0) self.assertEqual( response[0]["days"], @@ -2173,9 +2173,9 @@ def test_trends_compare_day_interval_relative_range(self): ], ) self.assertEqual(response[1]["label"], "sign up") - self.assertEqual(response[1]["labels"][3], "day 3") + self.assertEqual(response[1]["labels"][3], "24-Dec-2019") self.assertEqual(response[1]["data"][3], 1.0) - self.assertEqual(response[1]["labels"][4], "day 4") + self.assertEqual(response[1]["labels"][4], "25-Dec-2019") self.assertEqual(response[1]["data"][4], 0.0) with freeze_time("2020-01-04T13:00:01Z"): diff --git a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py index f9dcd0d3c89dd..a5463e34fd74d 100644 --- a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py +++ b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py @@ -1044,8 +1044,15 @@ def test_trends_compare(self): response.results[1]["days"], ) - self.assertEqual(["day 0", "day 1", "day 2", "day 3", "day 4"], response.results[0]["labels"]) - self.assertEqual(["day 0", "day 1", "day 2", "day 3", "day 4"], response.results[1]["labels"]) + self.assertEqual( + ["15-Jan-2020", "16-Jan-2020", "17-Jan-2020", "18-Jan-2020", "19-Jan-2020"], + response.results[0]["labels"], + ) + + self.assertEqual( + ["10-Jan-2020", "11-Jan-2020", "12-Jan-2020", "13-Jan-2020", "14-Jan-2020"], + response.results[1]["labels"], + ) def test_trends_compare_weeks(self): self._create_test_events() @@ -1096,10 +1103,31 @@ def test_trends_compare_weeks(self): ) self.assertEqual( - ["day 0", "day 1", "day 2", "day 3", "day 4", "day 5", "day 6", "day 7"], response.results[0]["labels"] + [ + "17-Jan-2020", + "18-Jan-2020", + "19-Jan-2020", + "20-Jan-2020", + "21-Jan-2020", + "22-Jan-2020", + "23-Jan-2020", + "24-Jan-2020", + ], + response.results[0]["labels"], ) + self.assertEqual( - ["day 0", "day 1", "day 2", "day 3", "day 4", "day 5", "day 6", "day 7"], response.results[1]["labels"] + [ + "10-Jan-2020", + "11-Jan-2020", + "12-Jan-2020", + "13-Jan-2020", + "14-Jan-2020", + "15-Jan-2020", + "16-Jan-2020", + "17-Jan-2020", + ], + response.results[1]["labels"], ) def test_trends_breakdowns(self): diff --git a/posthog/hogql_queries/insights/trends/trends_query_runner.py b/posthog/hogql_queries/insights/trends/trends_query_runner.py index 831adda7d5f14..d66695fbac984 100644 --- a/posthog/hogql_queries/insights/trends/trends_query_runner.py +++ b/posthog/hogql_queries/insights/trends/trends_query_runner.py @@ -524,17 +524,8 @@ def get_value(name: str, val: Any): # Modifications for when comparing to previous period if self.query.compareFilter is not None and self.query.compareFilter.compare: - labels = [ - "{} {}".format( - self.query.interval if self.query.interval is not None else "day", - i, - ) - for i in range(len(series_object.get("labels", []))) - ] - series_object["compare"] = True series_object["compare_label"] = "previous" if series.is_previous_period_series else "current" - series_object["labels"] = labels # Modifications for when breakdowns are active if self.breakdown_enabled: