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 titles are crazy :) #130

Closed
plblueraven opened this issue Dec 9, 2019 · 7 comments
Closed

The titles are crazy :) #130

plblueraven opened this issue Dec 9, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@plblueraven
Copy link

I’m using fl_chart: 0.5.1.

crazy_titles

I know that fl_chart is not ready yet for animations etc (any milestones for that?). But still I wanted to try. App that I’m developing should draw time based line chart to which a spot is added for every X (let’s say 130) ms. Of course the chart should have some titles. Let’s assume that 0, ~1/2 Xmax, ~Xmax will be sufficient. I wrote some code using titlesData.bottomTitles.interval, basically I set it to floor of Xmax / 2. Sadly, in this configuration bottom titles have very strange values like: 2.9999986785230.
When I add some logs things go worse. It seems that when I set interval it just starts to grow to an expected value instead of immediately getting a proper value.

I/flutter (23926): half: 4.9625, floor: 4, floor double (interval set to): 4
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 9.763, interval: 4
I/flutter (23926): horizontalSeek: 4.0, min: 0.0, max: 9.763, interval: 4
I/flutter (23926): horizontalSeek: 8.0, min: 0.0, max: 9.763, interval: 4
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 9.7992232, interval: 4.0
I/flutter (23926): horizontalSeek: 4.0, min: 0.0, max: 9.7992232, interval: 4.0
I/flutter (23926): horizontalSeek: 8.0, min: 0.0, max: 9.7992232, interval: 4.0
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 9.835447480000001, interval: 4.0
I/flutter (23926): horizontalSeek: 4.0, min: 0.0, max: 9.835447480000001, interval: 4.0
I/flutter (23926): horizontalSeek: 8.0, min: 0.0, max: 9.835447480000001, interval: 4.0
I/flutter (23926): half: 5.0115, floor: 5, floor double (interval set to): 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 9.871670680000001, interval: 4.0
I/flutter (23926): horizontalSeek: 4.0, min: 0.0, max: 9.871670680000001, interval: 4.0
I/flutter (23926): horizontalSeek: 8.0, min: 0.0, max: 9.871670680000001, interval: 4.0
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 9.905508924814134, interval: 4.223606666666667
I/flutter (23926): horizontalSeek: 4.223606666666667, min: 0.0, max: 9.905508924814134, interval: 4.223606666666667
I/flutter (23926): horizontalSeek: 8.447213333333334, min: 0.0, max: 9.905508924814134, interval: 4.223606666666667
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 9.939347169628267, interval: 4.447213333333333
I/flutter (23926): horizontalSeek: 4.447213333333333, min: 0.0, max: 9.939347169628267, interval: 4.447213333333333
I/flutter (23926): horizontalSeek: 8.894426666666666, min: 0.0, max: 9.939347169628267, interval: 4.447213333333333
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 9.9731854144424, interval: 4.67082
I/flutter (23926): horizontalSeek: 4.67082, min: 0.0, max: 9.9731854144424, interval: 4.67082
I/flutter (23926): horizontalSeek: 9.34164, min: 0.0, max: 9.9731854144424, interval: 4.67082
I/flutter (23926): half: 5.0795, floor: 5, floor double (interval set to): 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.007023659256534, interval: 4.894426666666667
I/flutter (23926): horizontalSeek: 4.894426666666667, min: 0.0, max: 10.007023659256534, interval: 4.894426666666667
I/flutter (23926): horizontalSeek: 9.788853333333334, min: 0.0, max: 10.007023659256534, interval: 4.894426666666667
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.057997537117497, interval: 4.929836666488889
I/flutter (23926): horizontalSeek: 4.929836666488889, min: 0.0, max: 10.057997537117497, interval: 4.929836666488889
I/flutter (23926): horizontalSeek: 9.859673332977778, min: 0.0, max: 10.057997537117497, interval: 4.929836666488889
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.091980460083342, interval: 4.953443567644444
I/flutter (23926): horizontalSeek: 4.953443567644444, min: 0.0, max: 10.091980460083342, interval: 4.953443567644444
I/flutter (23926): horizontalSeek: 9.906887135288889, min: 0.0, max: 10.091980460083342, interval: 4.953443567644444
I/flutter (23926): half: 5.1415, floor: 5, floor double (interval set to): 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.125963383049186, interval: 4.9770504688
I/flutter (23926): horizontalSeek: 4.9770504688, min: 0.0, max: 10.125963383049186, interval: 4.9770504688
I/flutter (23926): horizontalSeek: 9.9541009376, min: 0.0, max: 10.125963383049186, interval: 4.9770504688
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.161077817510167, interval: 4.9821821369731945
I/flutter (23926): horizontalSeek: 4.9821821369731945, min: 0.0, max: 10.161077817510167, interval: 4.9821821369731945
I/flutter (23926): horizontalSeek: 9.964364273946389, min: 0.0, max: 10.161077817510167, interval: 4.9821821369731945
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.19619120506037, interval: 4.987313652149514
I/flutter (23926): horizontalSeek: 4.987313652149514, min: 0.0, max: 10.19619120506037, interval: 4.987313652149514
I/flutter (23926): horizontalSeek: 9.974627304299029, min: 0.0, max: 10.19619120506037, interval: 4.987313652149514
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.231304592610572, interval: 4.992445167325835
I/flutter (23926): horizontalSeek: 4.992445167325835, min: 0.0, max: 10.231304592610572, interval: 4.992445167325835
I/flutter (23926): horizontalSeek: 9.98489033465167, min: 0.0, max: 10.231304592610572, interval: 4.992445167325835
I/flutter (23926): half: 5.2065, floor: 5, floor double (interval set to): 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.266419027071553, interval: 4.9975768354990295
I/flutter (23926): horizontalSeek: 4.9975768354990295, min: 0.0, max: 10.266419027071553, interval: 4.9975768354990295
I/flutter (23926): horizontalSeek: 9.995153670998059, min: 0.0, max: 10.266419027071553, interval: 4.9975768354990295
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.31558326259824, interval: 4.998389581027085
I/flutter (23926): horizontalSeek: 4.998389581027085, min: 0.0, max: 10.31558326259824, interval: 4.998389581027085
I/flutter (23926): horizontalSeek: 9.99677916205417, min: 0.0, max: 10.31558326259824, interval: 4.998389581027085
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.364747498124927, interval: 4.999202326555141
I/flutter (23926): horizontalSeek: 4.999202326555141, min: 0.0, max: 10.364747498124927, interval: 4.999202326555141
I/flutter (23926): horizontalSeek: 9.998404653110281, min: 0.0, max: 10.364747498124927, interval: 4.999202326555141
I/flutter (23926): half: 5.2725, floor: 5, floor double (interval set to): 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.39752300367173, interval: 4.999744146137558
I/flutter (23926): horizontalSeek: 4.999744146137558, min: 0.0, max: 10.39752300367173, interval: 4.999744146137558
I/flutter (23926): horizontalSeek: 9.999488292275116, min: 0.0, max: 10.39752300367173, interval: 4.999744146137558
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.446988754600183, interval: 4.999829962934406
I/flutter (23926): horizontalSeek: 4.999829962934406, min: 0.0, max: 10.446988754600183, interval: 4.999829962934406
I/flutter (23926): horizontalSeek: 9.999659925868812, min: 0.0, max: 10.446988754600183, interval: 4.999829962934406
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.479964610979184, interval: 4.999887171858048
I/flutter (23926): horizontalSeek: 4.999887171858048, min: 0.0, max: 10.479964610979184, interval: 4.999887171858048
I/flutter (23926): horizontalSeek: 9.999774343716096, min: 0.0, max: 10.479964610979184, interval: 4.999887171858048
I/flutter (23926): half: 5.3365, floor: 5, floor double (interval set to): 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.512941450538161, interval: 4.999944382487382
I/flutter (23926): horizontalSeek: 4.999944382487382, min: 0.0, max: 10.512941450538161, interval: 4.999944382487382
I/flutter (23926): horizontalSeek: 9.999888764974765, min: 0.0, max: 10.512941450538161, interval: 4.999944382487382
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.548731609254824, interval: 4.999956818933987
I/flutter (23926): horizontalSeek: 4.999956818933987, min: 0.0, max: 10.548731609254824, interval: 4.999956818933987
I/flutter (23926): horizontalSeek: 9.999913637867975, min: 0.0, max: 10.548731609254824, interval: 4.999956818933987
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.584520700914492, interval: 4.999969255009808
I/flutter (23926): horizontalSeek: 4.999969255009808, min: 0.0, max: 10.584520700914492, interval: 4.999969255009808
I/flutter (23926): horizontalSeek: 9.999938510019616, min: 0.0, max: 10.584520700914492, interval: 4.999969255009808
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.61965248546437, interval: 4.999981462683045
I/flutter (23926): horizontalSeek: 4.999981462683045, min: 0.0, max: 10.61965248546437, interval: 4.999981462683045
I/flutter (23926): horizontalSeek: 9.99996292536609, min: 0.0, max: 10.61965248546437, interval: 4.999981462683045
I/flutter (23926): half: 5.4015, floor: 5, floor double (interval set to): 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.655441577124037, interval: 4.9999938987588655
I/flutter (23926): horizontalSeek: 4.9999938987588655, min: 0.0, max: 10.655441577124037, interval: 4.9999938987588655
I/flutter (23926): horizontalSeek: 9.999987797517731, min: 0.0, max: 10.655441577124037, interval: 4.9999938987588655
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.688353991485112, interval: 4.999995259620363
I/flutter (23926): horizontalSeek: 4.999995259620363, min: 0.0, max: 10.688353991485112, interval: 4.999995259620363
I/flutter (23926): horizontalSeek: 9.999990519240725, min: 0.0, max: 10.688353991485112, interval: 4.999995259620363
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.721311657095868, interval: 4.999996622352908
I/flutter (23926): horizontalSeek: 4.999996622352908, min: 0.0, max: 10.721311657095868, interval: 4.999996622352908
I/flutter (23926): horizontalSeek: 9.999993244705816, min: 0.0, max: 10.721311657095868, interval: 4.999996622352908
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.754270306429442, interval: 4.999997985126128
I/flutter (23926): horizontalSeek: 4.999997985126128, min: 0.0, max: 10.754270306429442, interval: 4.999997985126128
I/flutter (23926): horizontalSeek: 9.999995970252256, min: 0.0, max: 10.754270306429442, interval: 4.999997985126128
I/flutter (23926): half: 5.4665, floor: 5, floor double (interval set to): 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.787228955763018, interval: 4.999999347899347
I/flutter (23926): horizontalSeek: 4.999999347899347, min: 0.0, max: 10.787228955763018, interval: 4.999999347899347
I/flutter (23926): horizontalSeek: 9.999998695798695, min: 0.0, max: 10.787228955763018, interval: 4.999999347899347
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.81978837620379, interval: 4.999999493552549
I/flutter (23926): horizontalSeek: 4.999999493552549, min: 0.0, max: 10.81978837620379, interval: 4.999999493552549
I/flutter (23926): horizontalSeek: 9.999998987105098, min: 0.0, max: 10.81978837620379, interval: 4.999999493552549
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.852346824837602, interval: 4.999999639201404
I/flutter (23926): horizontalSeek: 4.999999639201404, min: 0.0, max: 10.852346824837602, interval: 4.999999639201404
I/flutter (23926): horizontalSeek: 9.999999278402807, min: 0.0, max: 10.852346824837602, interval: 4.999999639201404
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.884905273471412, interval: 4.999999784850258
I/flutter (23926): horizontalSeek: 4.999999784850258, min: 0.0, max: 10.884905273471412, interval: 4.999999784850258
I/flutter (23926): horizontalSeek: 9.999999569700517, min: 0.0, max: 10.884905273471412, interval: 4.999999784850258
I/flutter (23926): half: 5.537, floor: 5, floor double (interval set to): 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.933, interval: 5
I/flutter (23926): horizontalSeek: 5.0, min: 0.0, max: 10.933, interval: 5
I/flutter (23926): horizontalSeek: 10.0, min: 0.0, max: 10.933, interval: 5
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.96449376, interval: 5.0
I/flutter (23926): horizontalSeek: 5.0, min: 0.0, max: 10.96449376, interval: 5.0
I/flutter (23926): horizontalSeek: 10.0, min: 0.0, max: 10.96449376, interval: 5.0
I/flutter (23926): horizontalSeek: 0.0, min: 0.0, max: 10.99598658, interval: 5.0
I/flutter (23926): horizontalSeek: 5.0, min: 0.0, max: 10.99598658, interval: 5.0
I/flutter (23926): horizontalSeek: 10.0, min: 0.0, max: 10.99598658, interval: 5.0

It seems that some kind of (3 steps) animation is there (may be connected with some performance problems like #119),? but still I don’t know why when I set interval from 4 to 5, the chart got intervals: 4, 4.223606666666667, 4.447213333333333, 4.67082, […], 4.999999784850258, 5?

If you want to see an example code it is here https://github.com/plblueraven/crazy_titles

BTW. Is there any reason why things like intervals, title values, reservedSize etc are doubles? In my opinion they could be just (Dart built in type) num.

@imaNNeo
Copy link
Owner

imaNNeo commented Dec 9, 2019

They should be double because some people need to draw titles for example in every 0.5 intervals, and other reasons, I know the problem that you've faced.
We should read the target value instead of animated value for the numbers, we interpolate between 4.0 to 5.0 due to animation stuff, but we should show the target always.
Let me fix it :)
Thanks for reporting!

@imaNNeo imaNNeo added the bug Something isn't working label Dec 9, 2019
@plblueraven
Copy link
Author

Yes, totally agree interval could be double. But double is subtype of num and therefore num interval = someDoubleVariable is totally fine for Dart as well as num interval = someIntVariable.

See: https://dartpad.dev/95cbc0f0a7cf41e0c45db20563d88f0b

Thanks for developing this great lib :)

@imaNNeo
Copy link
Owner

imaNNeo commented Dec 10, 2019

I'm not with generic types, they are not type-safe, and here we need type safety because maybe we wanna calculate something that our input should be a double.

imaNNeo added a commit that referenced this issue Dec 10, 2019
@imaNNeo
Copy link
Owner

imaNNeo commented Dec 10, 2019

Hi,
It has been fixed in 0.5.2 (sorry for the delay), check it out.
Thanks for reporting.

@plblueraven
Copy link
Author

No problem :) Thanks for fix it. Indeed 0.5.2 fixed bottom titles, because my minX is constants. But still I have some problems with left titles where minY is variable. Mostly because of double verticalSeek = data.minY;, maybe it should be double verticalSeek = targetData.minY;. In the other hands this kind of animation could be useful for someone. I have to think about it and hopefully offer some pull request.

@imaNNeo
Copy link
Owner

imaNNeo commented Dec 13, 2019

You're welcome, may I ask you to create another issue to follow up the other problem?
I know there is a lack of documentation in this library, we will improve them ASAP,
Thanks for reporting.

1 similar comment
@imaNNeo
Copy link
Owner

imaNNeo commented Dec 13, 2019

You're welcome, may I ask you to create another issue to follow up the other problem?
I know there is a lack of documentation in this library, we will improve them ASAP,
Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants