-
Notifications
You must be signed in to change notification settings - Fork 12
feat (analytics): better sparkline management [MA-4441] #2561
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
Conversation
87583a5
to
fcf7757
Compare
fcf7757
to
c1c66db
Compare
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.
Everything looks good. The only thing I recommend, which I think is a blocker is to at least have a cleanup function to unregister the chart from the global state onUnMount or onBeforeUnmount
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.
hmm, yeah that's probably fair. That also would help with the state getting polluted in long running sessions.
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.
fixed. 3d8f6e6
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.
Just one comment/concern
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.
Could datasets be empty?
Should guard against allTimestamps reducing to [] -> actualMinStamp = 0 -> actualMaxStamp = 0
I'm having trouble tracing in the code if that might cause any trouble down stream may be have a test around empty datasets?
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.
yeah, it could return 0 in that case. But if your dataset is empty then it won't be rendering anything anyways. I'm not sure I can prove that without a test though, so I'll add one.
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.
ah, this one is a little tricky and I had handled this already, but it's not at all obvious. I added a test 3d8f6e6.
The trick is that syncedMinStamp
is doing this logic:
const syncedMinStamp = computed<number>(() => {
return Object.values(state.minStamps)
.reduce((min, stamp): number => {
return min === 0 ? stamp : Math.min(min, stamp)
}, 0)
})
To be clear, return min === 0 ? stamp : Math.min(min, stamp)
means if we ever encounter a 0 we ignore it in favor of the first actual timestamp we find. Granted, this means I'm disqualifying Wed Dec 31 1969 19:00:00 GMT-0500
as a start time, but... I think that's okay.
Uh oh!
There was an error while loading. Please reload this page.
Satisfies MA-4441
Related PR in konnect: https://github.com/Kong/konnect-ui-apps/pull/8846
Description
Previously I exposed a
@max
event which was supposed to communicate the local manipulation of the passed in data. With that event the parent was supposed to feed that value back in given a maximum 'max' value across all sparklines rendered. This required the developer to understand and think about how sparklines work far more than was useful. This change allows users to render sparklines at any scale and by simply providing agroupKey
and achartKey
the sparkline itself can manage keeping scales in sync. Simpler development and more consistent usage should be the result.