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

Fix rendering X axis in TraceResultsScatterPlot - pass milliseconds to moment.js #274

Merged
merged 2 commits into from
Nov 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { XYPlot, XAxis, YAxis, MarkSeries, Hint } from 'react-vis';
import { compose, withState, withProps } from 'recompose';

import { FALLBACK_TRACE_NAME } from '../../../constants';
import { formatDuration } from '../../../utils/date';
import { ONE_MILLISECOND, formatDuration } from '../../../utils/date';

import './react-vis.css';
import './ScatterPlot.css';
Expand All @@ -36,7 +36,11 @@ function ScatterPlotImpl(props) {
width={containerWidth}
height={200}
>
<XAxis title="Time" tickTotal={4} tickFormat={t => moment(t).format('hh:mm:ss a')} />
<XAxis
title="Time"
tickTotal={4}
tickFormat={t => moment(t / ONE_MILLISECOND).format('hh:mm:ss a')}
Copy link
Member

Choose a reason for hiding this comment

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

what does the moment() function do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moment - is the main function of moment.js framework - https://momentjs.com/

It may accept different inputs (strings, Date objects, timestamps). Here it accepts timestamp (number of milliseconds since 1 January 1970 UTC)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks.

While this may be an OK fix for this specific issue, I think a bigger problem is that we have to do that in the first place. I would expect the UI to have some domain model of the trace and expose the timestamps not in raw microseconds format, but in some structured representation, so that the presentation code wouldn't have to do these conversions all over the place.

/>
<YAxis title="Duration" tickTotal={3} tickFormat={t => formatDuration(t)} />
<MarkSeries
sizeRange={[3, 10]}
Expand Down