aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/gizak/termui/example/barchart.go
blob: 83947f580d6aaed4057d2738ca582557599f9019 (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
// 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")

    bc := termui.NewBarChart()
    data := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6}
    bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"}
    bc.Border.Label = "Bar Chart"
    bc.Data = data
    bc.Width = 26
    bc.Height = 10
    bc.DataLabels = bclabels
    bc.TextColor = termui.ColorGreen
    bc.BarColor = termui.ColorRed
    bc.NumColor = termui.ColorYellow

    termui.Render(bc)

    <-termui.EventCh()
}