Skip to content

Commit

Permalink
Reverted barchart/main.go to original state.
Browse files Browse the repository at this point in the history
  • Loading branch information
anxp committed Jan 25, 2022
1 parent f590146 commit 66ccd69
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 57 deletions.
28 changes: 28 additions & 0 deletions _examples/barchart/barchart_001.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"github.com/pterm/pterm"
)

func main() {
positiveBars := pterm.Bars{
pterm.Bar{
Label: "Bar 1",
Value: 5,
},
pterm.Bar{
Label: "Bar 2",
Value: 3,
},
pterm.Bar{
Label: "Longer Label",
Value: 7,
},
}

fmt.Println("Chart example with positive only values (bars use 100% of chart area)")
_ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
_ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
fmt.Println("=====================================================================")
}
28 changes: 28 additions & 0 deletions _examples/barchart/barchart_002.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"github.com/pterm/pterm"
)

func main() {
negativeBars := pterm.Bars{
pterm.Bar{
Label: "Bar 1",
Value: -5,
},
pterm.Bar{
Label: "Bar 2",
Value: -3,
},
pterm.Bar{
Label: "Longer Label",
Value: -7,
},
}

fmt.Println("Chart example with negative only values (bars use 100% of chart area)")
_ = pterm.DefaultBarChart.WithBars(negativeBars).Render()
_ = pterm.DefaultBarChart.WithHorizontal().WithBars(negativeBars).Render()
fmt.Println("=====================================================================")
}
36 changes: 36 additions & 0 deletions _examples/barchart/barchart_003.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package main

import (
"fmt"
"github.com/pterm/pterm"
)

func main() {
mixedBars := pterm.Bars{
pterm.Bar{
Label: "Bar 1",
Value: 2,
},
pterm.Bar{
Label: "Bar 2",
Value: -3,
},
pterm.Bar{
Label: "Bar 3",
Value: -2,
},
pterm.Bar{
Label: "Bar 4",
Value: 5,
},
pterm.Bar{
Label: "Longer Label",
Value: 7,
},
}

fmt.Println("Chart example with mixed values (note screen space usage in case when ABSOLUTE values of negative and positive parts are differ too much)")
_ = pterm.DefaultBarChart.WithBars(mixedBars).Render()
_ = pterm.DefaultBarChart.WithHorizontal().WithBars(mixedBars).Render()
fmt.Println("=====================================================================")
}
61 changes: 4 additions & 57 deletions _examples/barchart/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package main

import (
"fmt"
"github.com/pterm/pterm"
)
import "github.com/pterm/pterm"

func main() {
positiveBars := pterm.Bars{
bars := pterm.Bars{
pterm.Bar{
Label: "Bar 1",
Value: 5,
Expand All @@ -21,56 +18,6 @@ func main() {
},
}

negativeBars := pterm.Bars{
pterm.Bar{
Label: "Bar 1",
Value: -5,
},
pterm.Bar{
Label: "Bar 2",
Value: -3,
},
pterm.Bar{
Label: "Longer Label",
Value: -7,
},
}

mixedBars := pterm.Bars{
pterm.Bar{
Label: "Bar 1",
Value: 2,
},
pterm.Bar{
Label: "Bar 2",
Value: -3,
},
pterm.Bar{
Label: "Bar 3",
Value: -2,
},
pterm.Bar{
Label: "Bar 4",
Value: 5,
},
pterm.Bar{
Label: "Longer Label",
Value: 7,
},
}

fmt.Println("Chart example with positive only values (bars use 100% of chart area)")
_ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
_ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
fmt.Println("=====================================================================")

fmt.Println("Chart example with negative only values (bars use 100% of chart area)")
_ = pterm.DefaultBarChart.WithBars(negativeBars).Render()
_ = pterm.DefaultBarChart.WithHorizontal().WithBars(negativeBars).Render()
fmt.Println("=====================================================================")

fmt.Println("Chart example with mixed values (note screen space usage in case when ABSOLUTE values of negative and positive parts are differ too much)")
_ = pterm.DefaultBarChart.WithBars(mixedBars).Render()
_ = pterm.DefaultBarChart.WithHorizontal().WithBars(mixedBars).Render()
fmt.Println("=====================================================================")
_ = pterm.DefaultBarChart.WithBars(bars).Render()
_ = pterm.DefaultBarChart.WithHorizontal().WithBars(bars).Render()
}

0 comments on commit 66ccd69

Please sign in to comment.