Coder Social home page Coder Social logo

Comments (4)

mellinoe avatar mellinoe commented on May 19, 2024

The final parameter is actually a stride in bytes, rather than elements. So if you change 1 to 1 * sizeof(float) and 2 to 2 * sizeof(float), then you will get more reasonable results.

Additionally, the third parameter is actually supposed to be an "offset" for the data points. It turns out that the native code will wrap around if it reaches the end of the data (actually, it will trigger an assertion, but those are disabled in the version of cimgui being used). Since you're using the length of the array, it's just wrapping back around to the beginning.

Aside from that, there is actually a genuine issue with the current wrapper method, because there's no way to specify the number of elements to plot yourself -- the full array size is always used. There should probably be an overload where you can pass in the length yourself, in addition to the "start index" (that's effectively the third parameter in the current version). If you wanted to use a stride of 2-floats, then you'd want to only draw half as many elements, otherwise it'll end up reading values past the end of the array.

@se5a Let me know if that makes sense.

from imgui.net.

se5a avatar se5a commented on May 19, 2024

size in bytes... ok that.. that would make more sense.
yeah I think I understand the offset, it's just most examples I saw appeared to use the length of the array for some odd reason.
off to try this size in bytes now!

from imgui.net.

mellinoe avatar mellinoe commented on May 19, 2024

@se5a I pushed a commit with a new PlotHistogram overload:

void PlotHistogram(
    string label,
    float[] values,
    int startIndex,
    int count,
    string overlayText = null,
    float scaleMin = float.MaxValue,
    float scaleMax = float.MaxValue,
    Vector2 graphSize = default(Vector2),
    int elementStride = 1)

This one should be easier to understand, and has default parameter values that match the native API.

from imgui.net.

se5a avatar se5a commented on May 19, 2024

My histograms are now with 100% less giberish. thanks!

cool, that should help future confused people.
/// xml comments could go a long way to helping make things less confusing too, but I guess that'd be a lot of work to go through and do everything.

from imgui.net.

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.