Documentation
¶
Overview ¶
Package plot implements basic plotting functionality that leverages Chrome/Chromium for cross-platform capabilities. It works on Windows, macOS and Linux.
Any plotting package that can write to an io.Writer is compatible.
See: https://github.com/wcharczuk/go-chart and https://github.com/gonum/plot/wiki/Drawing-to-an-Image-or-Writer:-How-to-save-a-plot-to-an-image.Image-or-an-io.Writer,-not-a-file.#writing-a-plot-to-an-iowriter
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoChromeInstalled indicates that chrome is not installed. // Chrome is required to display plots. ErrNoChromeInstalled = errors.New("no chrome installed") // ErrClosed means the plot window has already been closed ErrClosed = errors.New("plot closed") )
Functions ¶
This section is empty.
Types ¶
type Plot ¶
type Plot struct {
// The channel that indicates the plot window has been closed.
// The window can be closed by the user or the Close function.
Closed chan struct{}
// contains filtered or unexported fields
}
Plot represents a plot window.
func Open ¶
Open creates a new plot window. Any plotting package that writes to an io.Writer (such as to file) is compatible. Optional wrappers for various plotting packages are provided in the subpackages.
Example:
import chart "github.com/wcharczuk/go-chart"
graph := chart.Chart{
Series: []chart.Series{
chart.TimeSeries{
XValues: []time.Time{
time.Now().AddDate(0, 0, -2),
time.Now().AddDate(0, 0, -1),
time.Now(),
}
YValues: []float64{9.0, 10.0, 11.0},
},
},
}
plt, _ := plot.Open("Linear", 150, 250)
graph.Render(chart.SVG, plt)
plt.Display(plot.None)
<-plt.Closed