Giter VIP home page Giter VIP logo

Comments (10)

EzzPress avatar EzzPress commented on May 28, 2024

Screenshot_20221027_0008461

from vico.

 avatar commented on May 28, 2024

Hello! The HorizontalAxis.TickPosition.Center constructor has a spacing parameter. The default value is 1. Once you change the value to n, ticks, vertical grid lines, and labels will be displayed every n entries. This is demonstrated in the second sample chart. See here for the relevant code. You appear to be using an AxisValueFormatter to display a label every 10 entries, which is why unwanted vertical grid lines can be seen. Please note that this approach is no longer recommended.

from vico.

EzzPress avatar EzzPress commented on May 28, 2024

Thank you for your tip! It works for me
image
But my case is show upcoming data (1-10 dots per sec).
In case when x-values of chart entry are Ints, grid is ok, when I use Floats the grid is gone and blinks sometimes.
image
Maybe I missed some initial settings?

private val entries: MutableList<FloatEntry> = MutableList(0) { FloatEntry(0f, 0f) }
    val producer = ChartEntryModelProducer(entries)

from vico.

 avatar commented on May 28, 2024

I’m glad to hear that the spacing parameter did the trick. Regarding the grid issue, would you be able to provide a minimal reproducible example?

from vico.

EzzPress avatar EzzPress commented on May 28, 2024

I’m glad to hear that the spacing parameter did the trick. Regarding the grid issue, would you be able to provide a minimal reproducible example?

https://github.com/EzzPress/VicoExample

check the viewmodel comments in init function

from vico.

 avatar commented on May 28, 2024

Cheers!

from vico.

EzzPress avatar EzzPress commented on May 28, 2024

I’m glad to hear that the spacing parameter did the trick. Regarding the grid issue, would you be able to provide a minimal reproducible example?

Some updates - grid disappears when the new x value is not a divisor to the grid range.
For example:

  • 1f step for new chart values - ok
  • 0.5f step for new chart values - ok
  • 0.51f step for new chart values - grid fails

from vico.

 avatar commented on May 28, 2024

Thanks for the update! At the moment, Vico doesn’t support entirely arbitrary distances between the x values of entries, which is why the grid is misbehaving. x values can be skipped, but a level of consistency is expected. For example, (0, 1, 2, 4) works, but (0, 0.49, 1.23, 5.34) causes issues. If you’d like to display entries with arbitrary x values in an equidistant manner, you can use an AxisValueFormatter implementation (see here). We plan on adding support for arbitrarily spaced entries in the future (#112). In order to make things clearer, we’ll be looking into having an exception thrown when the differences between the x values in a data set aren’t consistent enough for charts to behave properly.

from vico.

patrickmichalik avatar patrickmichalik commented on May 28, 2024

I’ve taken a closer look at the function responsible for calculating the x step, and it would appear that instead of calculating the greatest common denominator of the x values, it finds the pair of values with the smallest difference and treats said difference as the step, the assumption being that the smallest difference divides all other differences. It’d be preferable if the greatest common denominator were used, so I’ll be updating the function accordingly. Once this is done, the issue you’ve described will no longer occur. However, it’s worth noting that the greatest common denominator of 0.5 and 0.51 is 0.01, so if the set of x values is (0, 0.5, 0.51), the grid will be correctly drawn, but there will be a large number of empty segments between the entry with an x value of 0 and the entry with an x value of 0.5. Therefore, a custom AxisValueFormatter implementation will still be the way to go as far as displaying entries with arbitrary x values in an equidistant manner is concerned.

from vico.

patrickmichalik avatar patrickmichalik commented on May 28, 2024

Vico 1.6.1, which is now rolling out, introduces the changes described in my last comment. As it turns out, the direct cause of the issue with the bottom axis was that HorizontalAxis handled fractional x values improperly. That too has been resolved. Consequently, I’ll be closing this issue. Thanks for your feedback!

from vico.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.