Skip to content

feat(err): enhance sparkline component#30236

Merged
hpouillot merged 15 commits intomasterfrom
err/sparkline-refresh
Mar 25, 2025
Merged

feat(err): enhance sparkline component#30236
hpouillot merged 15 commits intomasterfrom
err/sparkline-refresh

Conversation

@hpouillot
Copy link
Contributor

Changes

  • Update sparkline component to:
    - display X axis as timeserie
    - add hover state on data
    - ability to customize tooltip label
  • Use those features for occurence sparklines

@hpouillot hpouillot requested review from a team, daibhin and oliverb123 March 20, 2025 16:21
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR enhances the sparkline visualization component with timeseries support, hover states, and customizable tooltips, while consolidating sparkline functionality across error tracking features.

Key changes:

  • Introduces new OccurenceSparkline component replacing SparklinePanel with improved timeseries visualization
  • Adds dark mode support and proper time unit formatting in sparkline tooltips
  • Implements useSparklineData hook for centralized data handling and aggregation
  • Refactors scale configuration into separate objects for better maintainability
  • Simplifies sparklineLabels utility to allow flexible date formatting at UI layer

The changes appear well-structured and improve code organization while adding valuable features to the sparkline visualization system.

7 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2025

Size Change: -21 B (0%)

Total Size: 9.75 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 9.75 MB -21 B (0%)

compressed-size-action

Copy link
Contributor

@oliverb123 oliverb123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Contributor

@daibhin daibhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a PR to fix some small hiccups and the typing of ScaleOptions. Left a couple of questions that we can go through tomorrow if you like

return useMemo(() => {
return {
color: isDarkModeOn ? 'primitive-neutral-200' : 'primitive-neutral-800',
hoverColor: 'primary-3000',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the transition from the dark grey to the orange. It's very noticeable and looks laggy because it's going across the colour wheel. What do you think about a lighter grey that transitions to a darker grey for the highlighted line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it with only few data points, it might be too eye-catching with more. Let's try with variant of gray

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image


export const Metadata = (): JSX.Element => {
const { issue, issueLoading } = useValues(errorTrackingIssueSceneLogic)
const [values, unit, interval] = useSparklineData(issue?.aggregations)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useSparklineData relies on the sparklineSelectedPeriod hook internally, which is configured on the list page. This means the sparkline could appear different for different customers on the issue page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The date range on the issue page comes from the listing, so in any case the sparkline will be different for two users, right? (if one comes from listing and the other one directly from issue url).

}, [isDarkModeOn])
}

export function useSparklineData(aggregations?: ErrorTrackingIssueAggregations): [number[], TimeUnit, number] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be taking an optional type? I think it's making the implementation of the component more complicated and causing us to do checks to see if there are any returned values in other components

Suggested change
export function useSparklineData(aggregations?: ErrorTrackingIssueAggregations): [number[], TimeUnit, number] {
export function useSparklineData(aggregations: ErrorTrackingIssueAggregations): [number[], TimeUnit, number] {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keeping this arg optional will make component implementation easier because you don't have to check if aggregation is populated before using this hook. Values should always be valid for sparkline component, no need to check, I removed the condition here

@daibhin
Copy link
Contributor

daibhin commented Mar 20, 2025

Oh, one other thing. I can be good to include a gif / screenshot for visual changes like this. It can help to review without needing to pull the branch sometimes

hoverColor?: string
}

export type AnyScaleOptions = ScaleOptions<'linear' | 'logarithmic' | 'time' | 'timeseries' | 'category'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@hpouillot hpouillot enabled auto-merge (squash) March 24, 2025 10:46
@hpouillot hpouillot force-pushed the err/sparkline-refresh branch from 167ec48 to c0ac413 Compare March 24, 2025 17:24
@hpouillot hpouillot disabled auto-merge March 24, 2025 21:28
@hpouillot hpouillot merged commit 8b869e3 into master Mar 25, 2025
112 checks passed
@hpouillot hpouillot deleted the err/sparkline-refresh branch March 25, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants