CImGui.PlotLines and CImGui.PlotHistogram problems

I have a problem with these CImGui functions.
It should plot my Array, but it take every second second value from my Array, and every second value from “I don’t know?” I checked my array values and there’s any problem with that. Even on the image which I uploaded the maximum value of Bplane array is equal 29.17 A/m and some of these bars are even order of 7 or more for example this 3.117e+007 which is seen on this image.
It looks like that:


And some brief code:

@cstatic X=Cfloat[-10.0, 0.20, 10.0] Y=Cfloat[-10, 0.20, 10.0] Yplane=Cint(1) Unit=Cint(0)  begin
              if @isdefined B
                if @c CImGui.VSliderInt("##v", ImVec2(bar_width,img_height), &Yplane, 1, length(y), @sprintf("%g m",y[Yplane]))
                        global plane=Yplane
                end
                Bplane=B[:,plane]*coefficient 
                CImGui.SameLine()
                # CImGui.Text("$Bplane")
             
                @c CImGui.PlotHistogram("Histogram", Bplane, length(Bplane), 0, C_NULL, 0.0, maximum(Bplane), ImVec2(img_width,img_height))

B is created in button:

if CImGui.Button("Generate plot")
x=X[1]:X[2]:X[3]
y=Y[1]:Y[2]:Y[3]
...
global B=...
...
end

did you convert those values passed to CImGui to Cfloat?

1 Like

I added Bplane=Cfloat.(B[:,plane)) and all works. Thank you.

I have one more question. Is any way to display a tooltip text in this CImGui.PlotLines in different format. It means for example I have two tables. One is this value table(Bplane) and second is x table(coordinate table). So I want to display instead this what is showed on this uploaded image(24: 3.117e+007) in format (-5.2: 3.117e+007) or even better(X=-5.2 m B=3.117e+007 A/m). That -5.2 is taken from x=-10:0.2:10 steprange eventually x=collect(-10:0.2:10) Array/List. Now this tooltip show something like values for every i point hovered in format: ("$i: $(Bplane[i])") and I want it in format: ("$(x[i]): $(Bplane[i])") or better ("X=$(x[i]) m: B=$(Bplane[i]) A/m").

It looks like PlotHistogram accepts an argument called “overlay_text” which is likely for custom tooltip format.

I know this, but that’s need this extra CImGui.ItemHovered statement and this build-in tooltip with PlotLines/PlotHistogram is almost completed. And if I would use this overlay as a tooltip I would have to clear this PlotLines/PlotHistogram Tooltip.

currently there is no workaround, the tooltip format is hard-coded to "%d: %8.4g":

related issue: https://github.com/ocornut/imgui/pull/201

1 Like

Ok, I used this SetTooltip instead of beginTooltip which I usually use and it works.

if CImGui.IsItemHovered()
    region_x = Cint(div(length(x)*(io.MousePos.x - pos.x),img_width)+1)
    CImGui.SetTooltip(@sprintf("X = %g m \n B = %.2f", x[region_x], Bplane[region_x]))
end

Thank you. Still have problem with Greek characters, if you could help, here’s my other problem CImGui Greek Characters.

I’m not familiar with those font-related stuff too(and I can’t even distinguish Greek and Latin characters :stuck_out_tongue: ). As this is a question about Dear IMGUI itself, I guess you would get more help if you post this to Dear IMGUI’s discourse forum.

1 Like