Documentation ¶
Overview ¶
Package chart generates interactive svg or png charts from time series data.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chart ¶
type Chart struct {
// contains filtered or unexported fields
}
Chart is the main chart type used for all operations.
Example ¶
opts := &Options{ Title: "Title on top of the chart", Image: svg.New(), // or png.New() Size: "big", // big is 1440px, small is 720px, auto is size of dataset Height: 300, // Defaults to -1, when size=auto height is set to width/4, otherwise set fixed height Width: 900, // If a width is supplied, height is implied and both are used in stead of size setting Scheme: "white", // or black/random/pink/solarized or hsl:180,0.5,0.25 Theme: "light", // default is dark. Start: time.Now().AddDate(0, 0, -1).Unix(), End: time.Now().Unix(), W: os.Stdout, Axes: []*axis.Axis{ axis.NewTime(axis.Bottom, "01-02 15:04").Duration(4 * time.Hour).Grid(4), axis.NewSI(axis.Left, 1000).Ticks(4).Grid(2), // // - Example custom time format // axis.New(axis.Bottom, func(in float64) string { // return time.Unix(int64(in), 0).Format("01-02 15:04") // return in.(time.Time).Format("2006-01-02") // }).Duration(4 * time.Hour).Grid(), // // - Example other custom format // axis.New(axis.Left, func(in float64) string { // return fmt.Sprintf("%.1f", in/3.14) // }).Ticks(5).Grid(), }, } c, err := NewChart(opts) if err != nil { panic(err) } exdata := make([]float64, 256) for i := 0; i < 255; i++ { exdata[i] = float64(i) } warn := c.AddData(&data.Options{Type: "area", Title: "My Data Description"}, exdata) if err != nil { fmt.Println(warn) } c.Render()
Output:
type Options ¶
type Options struct { Title string // guess what, leave empty to hide Size string // big is 1440px, small is 720px, auto is size of dataset Width, Height int // overrides Size Scheme string // palette colorscheme, default "white" Theme string // if random scheme is used, set to "light" to use light colors, otherwise a dark theme is generated Start, End int64 // start + end epoch of data Image image.Image // the chart image type, chart.SVG{} or chart.PNG{} W io.Writer // output writer to write image to SIBase int // SI Base for auto axis calculation, default is 1000. Axes []*axis.Axis }
Options defines a type used to initialize a Chart using NewChart()
Directories ¶
Path | Synopsis |
---|---|
sysmon
Command sysmon is a basic /proc system monitoring tool storing only the last 15 minutes of data, sampled each second, in memory.
|
Command sysmon is a basic /proc system monitoring tool storing only the last 15 minutes of data, sampled each second, in memory. |
Package svg provides the svg interface for tomarus chart lib.
|
Package svg provides the svg interface for tomarus chart lib. |
Click to show internal directories.
Click to hide internal directories.