aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/gizak/termui/example/sparklines.go
blob: f04baf57068e3ebe646590c132a6c784ef035b82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2015 Zack Guo <gizak@icloud.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.

// +build ignore

package main

import "github.com/gizak/termui"

func main() {
    err := termui.Init()
    if err != nil {
        panic(err)
    }
    defer termui.Close()

    termui.UseTheme("helloworld")

    data := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6}
    spl0 := termui.NewSparkline()
    spl0.Data = data[3:]
    spl0.Title = "Sparkline 0"
    spl0.LineColor = termui.ColorGreen

    // single
    spls0 := termui.NewSparklines(spl0)
    spls0.Height = 2
    spls0.Width = 20
    spls0.HasBorder = false

    spl1 := termui.NewSparkline()
    spl1.Data = data
    spl1.Title = "Sparkline 1"
    spl1.LineColor = termui.ColorRed

    spl2 := termui.NewSparkline()
    spl2.Data = data[5:]
    spl2.Title = "Sparkline 2"
    spl2.LineColor = termui.ColorMagenta

    // group
    spls1 := termui.NewSparklines(spl0, spl1, spl2)
    spls1.Height = 8
    spls1.Width = 20
    spls1.Y = 3
    spls1.Border.Label = "Group Sparklines"

    spl3 := termui.NewSparkline()
    spl3.Data = data
    spl3.Title = "Enlarged Sparkline"
    spl3.Height = 8
    spl3.LineColor = termui.ColorYellow

    spls2 := termui.NewSparklines(spl3)
    spls2.Height = 11
    spls2.Width = 30
    spls2.Border.FgColor = termui.ColorCyan
    spls2.X = 21
    spls2.Border.Label = "Tweeked Sparkline"

    termui.Render(spls0, spls1, spls2)

    <-termui.EventCh()
}