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

The first candlestick in the figure is cut in half #45

Closed
sf-wind opened this issue Jan 17, 2015 · 2 comments
Closed

The first candlestick in the figure is cut in half #45

sf-wind opened this issue Jan 17, 2015 · 2 comments

Comments

@sf-wind
Copy link
Contributor

sf-wind commented Jan 17, 2015

I copied the example from http://bl.ocks.org/andredumas/edf630690c10b89be390
It seems the first candlestick is always cut in half. It only happens when zoom is used. Without zoom functionality, it works fine. The example is cut in half as well, but it is too small to see clearly. In my example, it is much clearer:

screen shot 2015-01-17 at 1 51 49 am

You see the first red bar is only half the size.

Can that be fixed?

Thanks.

@andredumas
Copy link
Owner

Hi @sf-wind

What you're observing is currently by design. If you print out the zoomable state on that plot you will see the right extent is not a whole number, where the left extent is.

console.log(x.zoomable.domain());

// Output is
//  [33, 250.52]

All techanjs plots consider the midpoint of the plot object (such as candlestick) as the mapped x point on the range. So setting zoomable extent to an integer as is done in that example will cut the candle in half. This was a key decision in the early days of the library and has simplified other calculations and render logic. In order to get a full candle you could zoom an additional half index point:

// Cuts candle in half
zoomable.domain([indicatorPreRoll, data.length]); 

// Starts the plot between candles, getting a first full candle
zoomable.domain([indicatorPreRoll-0.5, data.length]); 

Note that on first initialise of the domain, the viewable domain is widened via the financescale.outerPadding variable. When setting a zoom extent, this is no longer applicable as the zoom takes over.

andre

@andredumas
Copy link
Owner

Closing due to no activity.

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

No branches or pull requests

2 participants