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

ohlc: use all coords on given x-axis to compute min coord diff #1066

Merged
merged 4 commits into from
Oct 25, 2016

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Oct 21, 2016

fixes #1065

  • ... instead of using only per-trace coords
  • adding a loop over all traces in calcTransform is unfortunate,
    but is required as transform do not have access to the
    setPostiions step.

cc @alexcjohnson

- instead of using only per-trace coords
- adding a loop over all traces in calcTransform is unfortunate,
  but is required as transform do not have access to the
  setPostiions step.
@etpinard etpinard added bug something broken status: reviewable labels Oct 21, 2016
@etpinard etpinard added this to the v1.19.0 milestone Oct 21, 2016
@alexcjohnson
Copy link
Collaborator

Per our slack chat on Friday (edited bcs you convinced me it's per x-axis, not per subplot):

what would happen if you for example display tickers for two stocks traded on opposite sides of the world, and to indicate that you offset one of them by 10 hours (or whatever) from the other.

you wouldn’t want the minimum difference to drop to 10 hours, it should stay at 24 hours

I feel like within each x axis you should calculate the minimum difference for each trace (ignoring traces with only one x value), then take the smallest of all of those as the winner for all traces on that x axis.

So, to also avoid looping over all traces during calc for each trace, I think we need to do something like:

  • If this is calc for the first OHLC trace on this x axis, do the calculation and stash the result as a private attr in fullData for all the traces.
  • If it's not the first one, just return the previously stashed result
  • The calculation for a given trace should be the same as it was before (though I guess Lib.distinctVals is better because it sorts them... but we shouldn't concatenate into a single array)
  • Then take the smallest nonzero difference for any trace, and that becomes the value for all of them.
  • Can you make a test that works like my example, with a few hours offset between the traces? Jasmine should be fine, wouldn't need to be an image test.


var out = _calc([trace0, trace1]);

expect(out[0].x.map(ms2DateTime)).toEqual([
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcjohnson I think this is what you wanted. Can you confirm?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, looks great. Thanks!

@alexcjohnson
Copy link
Collaborator

💃

@etpinard etpinard merged commit 1fd52c3 into master Oct 25, 2016
@etpinard etpinard deleted the ohlc-global-offset branch October 25, 2016 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OHLC tick offset bug
2 participants