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

[tickers] add milliseconds granularity #777

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

PierrickKoch
Copy link
Contributor

Still needs some tests in auto_tests/tests/date_ticker.js, and maybe cleaner display in src/dygraph-utils.js (don't show milliseconds if granularity > MINUTELY or so).

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 89.636% when pulling 2774071 on pierriko:master into 2d0fdf6 on danvk:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 89.641% when pulling 2648940 on pierriko:master into 2d0fdf6 on danvk:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 89.619% when pulling 2648940 on pierriko:master into 2d0fdf6 on danvk:master.

TEN_MSLY: 3,
FIFTY_MSLY: 4,
HTH_MSLY: 5,
FHTH_MSLY: 6,

Choose a reason for hiding this comment

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

What does HTH mean? At first I though "hundred thousand", but that doesn't make sense here; this is just 100/500.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, you're right :)
Would HUNDRED_MSLY and FIVE_HUNDRED_MSLY be ok for you ?

Choose a reason for hiding this comment

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

Personally, I think there's no harm in spelling out "millisecond" instead of just using "ms". But, it's not my code 😉 (Also, as I mentioned in #776 I think it'd be interesting to explore alternative approaches that make this more customizable.)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 89.619% when pulling c55509e on pierriko:master into 2d0fdf6 on danvk:master.

Copy link
Owner

@danvk danvk left a comment

Choose a reason for hiding this comment

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

Thanks for making this change! I'd like to accept but will need to see a unit test (in auto_tests).

@@ -263,6 +263,7 @@ it('testAllDateTickers', function() {
assert.deepEqual([{"v":1307908020000,"label":"19:47"},{"v":1307908050000,"label":"19:47:30"},{"v":1307908080000,"label":"19:48"},{"v":1307908110000,"label":"19:48:30"},{"v":1307908140000,"label":"19:49"},{"v":1307908170000,"label":"19:49:30"}], ticker(1307908000112, 1307908172259, 800, options));
assert.deepEqual([{"v":1307908020000,"label":"19:47"},{"v":1307908050000,"label":"19:47:30"},{"v":1307908080000,"label":"19:48"},{"v":1307908110000,"label":"19:48:30"},{"v":1307908140000,"label":"19:49"},{"v":1307908170000,"label":"19:49:30"}], ticker(1307908000112, 1307908173260, 800, options));
assert.deepEqual([{"v":978307200000,"label":"Jan 2001"},{"v":986083200000,"label":"Apr 2001"},{"v":993945600000,"label":"Jul 2001"},{"v":1001894400000,"label":"Oct 2001"}], ticker(978307200000, 1001894400000, 400, options));
// TODO add millisecond test ?
Copy link
Owner

Choose a reason for hiding this comment

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

yes please.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@danvk if I write a test for this, would that get this over the line for a merge?

DECADAL: 20,
CENTENNIAL: 21,
NUM_GRANULARITIES: 22
MILLISECONDLY: 0,
Copy link
Owner

Choose a reason for hiding this comment

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

I'd prefer to avoid renumbering existing granularities. You can put MILLISECONDLY first in the list, but make its number 22.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is that wise? Not renumbering breaks less/greater-than relationships in total ordering… I’d go for it, especially as it’s this once only (nothing finer than ms supported in js)…

@@ -1229,6 +1229,11 @@ export function dateAxisLabelFormatter(date, granularity, opts) {
if (frac === 0 || granularity >= DygraphTickers.Granularity.DAILY) {
// e.g. '21 Jan' (%d%b)
return zeropad(day) + ' ' + SHORT_MONTH_NAMES_[month];
} else if (granularity < DygraphTickers.Granularity.SECONDLY) {
var str = "" + millis;
return zeropad(secs) + "." + ('000'+str).substring(str.length);
Copy link
Owner

Choose a reason for hiding this comment

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

Add an example of what this looks like.

cryptoquick added a commit to influxdata/dygraphs that referenced this pull request Oct 17, 2017
…ions taken into account and mergeable with master.
lukevmorris pushed a commit to influxdata/dygraphs that referenced this pull request Dec 7, 2017
…ions taken into account and mergeable with master.
lukevmorris added a commit that referenced this pull request Dec 7, 2017
* Add milliseconds granularity wtih changes from #777 with suggestions taken into account and mergeable with master.

* Fix granularities according to original PR.

* Add assertions for millisecond granularities

* Add an example for labels below SECONDLY granularity
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.

6 participants