From 63cd28222f9d1a84777c482de153315132125d51 Mon Sep 17 00:00:00 2001 From: gucio321 <73652197+gucio321@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:15:04 +0200 Subject: [PATCH] plot: fix code (examples/plot works now --- Plot.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Plot.go b/Plot.go index 84bf4aca..7a77a70a 100644 --- a/Plot.go +++ b/Plot.go @@ -1,9 +1,8 @@ package giu import ( - "image" - "github.com/AllenDang/cimgui-go" + "image" ) // PlotWidget is implemented by all the particular plots, which can be used @@ -168,7 +167,15 @@ func (p *PlotCanvasWidget) Size(width, height int) *PlotCanvasWidget { // Build implements Widget interface. func (p *PlotCanvasWidget) Build() { - if len(p.plots) > 0 { + if len(p.plots) == 0 { + return + } + + if imgui.PlotBeginPlotV( + Context.FontAtlas.RegisterString(p.title), + ToVec2(image.Pt(p.width, p.height)), + imgui.PlotFlags(p.flags), + ) { imgui.PlotSetupAxisLimitsV( imgui.AxisX1, p.xMin, @@ -228,17 +235,11 @@ func (p *PlotCanvasWidget) Build() { imgui.PlotAxisFlags(p.y3Flags), ) - if imgui.PlotBeginPlotV( - Context.FontAtlas.RegisterString(p.title), - ToVec2(image.Pt(p.width, p.height)), - imgui.PlotFlags(p.flags), - ) { - for _, plot := range p.plots { - plot.Plot() - } - - imgui.PlotEndPlot() + for _, plot := range p.plots { + plot.Plot() } + + imgui.PlotEndPlot() } }