gonum / plot

A repository for plotting and visualizing data
BSD 3-Clause "New" or "Revised" License
2.72k stars 202 forks source link

vg/vggio seems broken with current release of gioui #750

Closed lotodore closed 1 year ago

lotodore commented 2 years ago

I'm trying to use gonum plot with gio.

I copied the example at https://github.com/gonum/plot/blob/master/vg/vggio/vggio_example_test.go and tried to run it somehow. The result when building is:

Build Error: go build -o /Users/maygames/Projects/plottest/__debug_bin -gcflags all=-N -l .
# gonum.org/v1/plot/vg/vggio
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/context.go:36:13: undefined: op.StateOp
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/context.go:45:23: undefined: op.Save
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/context.go:63:12: cannot use f32.Pt(float32(x), float32(y)) (value of type "gioui.org/f32".Point) as type image.Point in argument to op.Offset
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/vggio.go:231:15: undefined: clip.Dash
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/vggio.go:241:3: unknown field 'Style' in struct literal of type clip.Stroke
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/vggio.go:241:15: undefined: clip.StrokeStyle
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/vggio.go:243:16: undefined: clip.FlatCap
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/vggio.go:245:3: unknown field 'Dashes' in struct literal of type clip.Stroke
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/vggio.go:260:9: clip.Outline{…}.Op().Add undefined (type clip.Op has no field or method Add)
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/vggio.go:334:8: undefined: unit.Px
../../go/pkg/mod/gonum.org/v1/plot@v0.11.0/vg/vggio/vggio.go:245:3: too many errors (exit status 2)

I ran

go get -u
go mod tidy

but the result stays the same.

Maybe I did not consider certain version dependencies. At the same time, it seems that vggio is not compatible with the current version of gio, or that the above mentioned example file maybe is outdated. Is there any fix available for this?

szaydel commented 2 years ago

I just pulled the master branch and confirmed that I can test and build the package:

$ go test -v
=== RUN   TestCanvas
    vggio_test.go:65: TODO: github actions for darwin with headless setup.
--- SKIP: TestCanvas (0.00s)
=== RUN   TestCollectionName
--- PASS: TestCollectionName (0.00s)
=== RUN   TestLabels
    vggio_test.go:169: TODO: github actions for darwin with headless setup.
--- SKIP: TestLabels (0.00s)
PASS
ok      gonum.org/v1/plot/vg/vggio  0.441s
$ git log | head -1
Thu Jul 14 09:10:44 2022 -0400 c2b6359 (HEAD -> master, origin/master, origin/HEAD) plotutil: fix off-by-one indexing error in MedianAndMinMax  [Scott Kiesel]

$ go build -o test -gcflags all='-N -l' . ; echo $status
0

Presumably you are having problems regardless of flags. What OS are you running on?

I am testing this on Darwin:

Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000
lotodore commented 2 years ago

Thanks for the feedback. Yes it runs fine with the latest master branch, but this branch is using gioui.org v0.0.0-20210308172011-57750fc8a0a6 (according to go.mod) which is very old.

I'm using latest gioui.org, which does not seem to be compatible and causes the above errors. I am also testing on Darwin arm64.

szaydel commented 2 years ago

I think the point here is that the module file is specifying version with which it is compatible. The APIs in the later version(s) of gioui.org presumably changed (basing this assumption on the output you provided), thus creating the problems you are observing. I would assume that someone will have to do whatever necessary work to adopt later version of gioui.org in place of v0.0.0-20210308172011-57750fc8a0a6.

sbinet commented 2 years ago

yes, end of last year I tried to bring the Gio version we were using up to date with Gio's main, but failed b/c of some reproducibility errors (images didn't match, even with fuzzy matching enabled, from on run to another).

I left it at that.

and now, the API differences are even greater :( (when I tried again earlier this year, Gio was missing support for stroked arcs. I believe there is now a way to stroke them again).

PRs to get vg/vggio up to date with Gio are welcomed :)

lotodore commented 2 years ago

I gave it a shot, but I do not know what "Save" was supposed to do in https://github.com/gonum/plot/blob/5eb6bf0ea28ffc1a7f0c33838eaf5f68c37f408d/vg/vggio/context.go#L45. I only know recent gioui, and I don't think that any function like this exists in the current release.

sbinet commented 1 year ago

this will be fixed by https://github.com/gonum/plot/pull/770