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

Candlestick doesn't work when x does not start at 0 #3441

Closed
mannyveloso opened this issue May 3, 2018 · 5 comments
Closed

Candlestick doesn't work when x does not start at 0 #3441

mannyveloso opened this issue May 3, 2018 · 5 comments

Comments

@mannyveloso
Copy link

What did you do?

We're attempting to make a candlestick graph where the x-axis is a date value. We added a datevalueformatter so the x-axis would display DD-MMM-YYYY.

What did you expect to happen?

The date formatter would display the date on the x-axis.

What happened instead?

The graph axis labels were 01-Jan-1970. In addition, the candlestick graph was drawn oddly. The red dot that was normally there was gone.

From a quick look at the code, the renderer seems to assume that x is a monotonically increasing value that starts at 0.

Charts Environment

Charts version/Branch/Commit Number:
Charts 3.1.1
Xcode 9.3
Swift 4.1
iOS 11.3
Mac OS 10.13.4

@liuxuan30
Copy link
Member

liuxuan30 commented May 7, 2018

take a look at the demo. You can workaround by modifying the value formatter to start from 0.

And what number you start with?

I checked the code, no matter what your X val is, when rendering, it should maps to Xbounds starting from 0. So it should be transparent.

I tweaked the Chart demo to

        [yVals1 addObject:[[CandleChartDataEntry alloc] initWithX:i+5 shadowH:val + high shadowL:val - low open:even ? val + open : val - open close:even ? val - close : val + close icon: [UIImage imageNamed:@"icon"]]];

and it sill draws fine.

(lldb) po _xBounds.min
0

(lldb) po _xBounds.max
40

(lldb) po _xBounds.range
40

(lldb) po dataSet.xMin
5.0

(lldb) po dataSet.xMax
45.0

@liuxuan30
Copy link
Member

post more details and images and reopen it.

@mannyveloso
Copy link
Author

mannyveloso commented May 24, 2018

So, this image is when the x coordinate is a straight-up 0-1-2-3-4-5-etc.

img_0148

The next image is when the x-coordinate is the time since 1970. The red bars are missing and it's oddly offset.

img_0149

@mannyveloso
Copy link
Author

Can't reopen the issue. Should I just open a new issue?

@mannyveloso
Copy link
Author

Dup of #1742

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