AllenDang / giu

Cross platform rapid GUI framework for golang based on Dear ImGui.
MIT License
2.11k stars 127 forks source link

Plot: add Scale setting #772

Closed gucio321 closed 2 months ago

gucio321 commented 4 months ago

@gucio321 old code was:

g.Plot("header").
   XAxeFlags(g.PlotAxisFlagsTime).
   YAxeFlags(g.PlotAxisFlagsNoLabel,g.PlotAxisFlagsNoLabel,g.PlotAxisFlagsNoLabel).
   Plots(...),

it switches to time scale for x-axis, looks like this:

image

Originally posted by @francmarx in https://github.com/AllenDang/giu/issues/632#issuecomment-1957732626

francmarx commented 2 months ago

@gucio321 plot.go line 214: "imgui.AxisX," I think it should be "imgui.AxisX1" ?

gucio321 commented 2 months ago

yes...

so cimgui-go is bugged because this shouldn't work now.

        AxisX1    = 0

should be

        AxisX1    PlotAxisEnum = 0
francmarx commented 2 months ago

it appears two times:

in cimplot_enums.go

// original name: ImAxis_
type PlotAxisEnum int32

const (
    AxisX1    = 0
    AxisX2    = 1
    AxisX3    = 2
    AxisY1    = 3
    AxisY2    = 4
    AxisY3    = 5
    AxisCOUNT = 6
)

in cimgui_enums.go

// X/Y enums are fixed to 0/1 so they may be used to index ImVec2
// original name: ImGuiAxis
type Axis int32

const (
    AxisNone = -1
    AxisX    = 0
    AxisY    = 1
)
gucio321 commented 2 months ago

you are deffinitly right. moreover, it shouldn't compile - this is a bug in cimgui-go. It considers these constants "untyped int" and it interpolates its type.

gucio321 commented 2 months ago

ok, let me create an excel template for my physical labs and I'll fix that in cimgui-go :smile:

francmarx commented 2 months ago

you are deffinitly right. moreover, it shouldn't compile - this is a bug in cimgui-go. It considers these constants "untyped int" and it interpolates its type.

it compiles, because they are different AxisX1 and AxisX, and it works because both are 0

gucio321 commented 2 months ago

yep, and now after cimgui-go update it shouldn't compile :smnile: