ImGui.NET icon indicating copy to clipboard operation
ImGui.NET copied to clipboard

PlotLine and PlotHistogram cannot be called with float[] array

Open abc013 opened this issue 4 years ago • 2 comments

The current implementation only allows a single float:

PlotHistogram(string label, ref float values, int values_count)
PlotHistogram(string label, ref float values, int values_count, int values_offset)
[...]
PlotLines(string label, ref float values, int values_count)
PlotLines(string label, ref float values, int values_count, int values_offset)
[...]

However, those functions can be called with an array of floats in the original library. For example, this c++ code cannot be implemented in c#:

static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr));

abc013 avatar Dec 03 '20 14:12 abc013

Pass the array like this: PlotLines(label, ref arr[0], count) It should work

bootzin avatar Dec 03 '20 19:12 bootzin

Yes, it works! Thank you!

I'll leave this issue open because it's still confusing for newcomers and there should be at least a hint about how to pass the array imo (or I missed something...).

If you don't agree with that, feel free to close the issue. :)

abc013 avatar Dec 03 '20 20:12 abc013