show

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package show opens a plot in a native window.

func main() {
    p := refract.New(refract.Responsive(true), refract.Title("Signal"))
    p.Add(geom.Line(src, geom.X("t"), geom.Y("y")))

    if err := show.Plot(p, window.Title("Signal")); err != nil {
        log.Fatal(err)
    }
}

The window hovers, clicks, zooms about the pointer, pans on a drag, resets the view on a double click and follows the window's size — all of which is refract.Input driving refract.Live, the same state machine the browser uses. What this package adds is the wiring, and nothing else: a caller who wants a different one uses [Window] directly and writes their own.

Why this is not in package window

Because wiring input is not drawing. A backend consumes IR and must not know what a scale or a panel is, and everything here is about scales and panels; package window draws, and this steers. The core makes the same split with Live.Bind, which is in the root package rather than in backend/canvas — and the reason it cannot simply live there too is that the core module depends on nothing, and a window is a dependency. See docs/adr/0021.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Into

func Into(w *window.Window, p *refract.Plot) error

Into runs an already-configured window showing p.

It is Plot with the window handed in, for a caller who wants to hold the window — to close it from elsewhere, to ask it to redraw when their data changes, or to read its size.

func Plot

func Plot(p *refract.Plot, opts ...window.Option) error

Plot opens p in a native window and returns when the window closes.

It must be called from the main goroutine: some platforms will only run a window loop there. Handlers registered with refract.Plot.On fire from that goroutine too, one at a time, so they may touch the plot without a lock.

The window opens at the plot's own size unless window.Size says otherwise, and the chart is laid out again whenever the window is resized. Give the plot refract.Responsive as well and the type and stroke weights follow the size; without it the chart keeps its proportions and gains room, which is what a dashboard usually wants and a poster usually does not.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL