Skip to content

Commit

Permalink
plot: fix code (examples/plot works now
Browse files Browse the repository at this point in the history
  • Loading branch information
gucio321 committed Sep 14, 2023
1 parent 1a7e8c5 commit 63cd282
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Plot.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
}
}

Expand Down

0 comments on commit 63cd282

Please sign in to comment.