Skip to content

Commit

Permalink
fix: Fixed inconsistent colors in stickiness graph (#28582)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sriram-bk authored and zlwaterfield committed Feb 13, 2025
1 parent efbf2b4 commit 343068a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 0 additions & 2 deletions frontend/src/scenes/trends/trendsDataLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ export const trendsDataLogic = kea<trendsDataLogicType>([

/** Unique series in the results, determined by `item.label` and `item.action.order`. */
const uniqSeries = Array.from(
// :TRICKY: Stickiness insights don't have an `action` object, despite
// types here not reflecting that.
new Set(
indexedResults.map((item) => `${item.label}_${item.action?.order}_${item?.breakdown_value}`)
)
Expand Down
16 changes: 15 additions & 1 deletion posthog/hogql_queries/insights/stickiness_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@

class SeriesWithExtras:
series: EventsNode | ActionsNode | DataWarehouseNode
series_order: int
is_previous_period_series: Optional[bool]

def __init__(
self,
series: EventsNode | ActionsNode | DataWarehouseNode,
series_order: int,
is_previous_period_series: Optional[bool],
):
self.series = series
self.series_order = series_order
self.is_previous_period_series = is_previous_period_series


Expand Down Expand Up @@ -276,6 +279,14 @@ def calculate(self):
],
}

# Add minimal action data for color consistency with trends
series_object["action"] = {
"order": series_with_extra.series_order,
"type": "events",
"name": series_label or "All events",
"id": series_label,
}

# Modifications for when comparing to previous period
if self.query.compareFilter is not None and self.query.compareFilter.compare:
series_object["compare"] = True
Expand Down Expand Up @@ -385,9 +396,10 @@ def setup_series(self) -> list[SeriesWithExtras]:
series_with_extras = [
SeriesWithExtras(
series,
index,
None,
)
for series in self.query.series
for index, series in enumerate(self.query.series)
]

if self.query.compareFilter is not None and self.query.compareFilter.compare:
Expand All @@ -396,12 +408,14 @@ def setup_series(self) -> list[SeriesWithExtras]:
updated_series.append(
SeriesWithExtras(
series=series.series,
series_order=series.series_order,
is_previous_period_series=False,
)
)
updated_series.append(
SeriesWithExtras(
series=series.series,
series_order=series.series_order,
is_previous_period_series=True,
)
)
Expand Down

0 comments on commit 343068a

Please sign in to comment.