/api/trends prints pie of each of last N months
This commit is contained in:
@@ -35,6 +35,12 @@ func LikeAfter(date string) Like {
|
||||
}
|
||||
}
|
||||
|
||||
func LikeNotName(pattern string) Like {
|
||||
return func(d Delta) bool {
|
||||
return !like(pattern, d.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func LikeName(pattern string) Like {
|
||||
return func(d Delta) bool {
|
||||
return like(pattern, d.Name)
|
||||
|
||||
@@ -23,6 +23,8 @@ func NewChart(name string) Chart {
|
||||
return NewBar()
|
||||
case "stack":
|
||||
return NewStack()
|
||||
case "pie":
|
||||
return NewPie()
|
||||
default:
|
||||
panic("bad chart name " + name)
|
||||
}
|
||||
@@ -107,3 +109,33 @@ func (stack Stack) AddY(name string, v []int) {
|
||||
Stack: "stackA",
|
||||
}))
|
||||
}
|
||||
|
||||
type Pie struct {
|
||||
*charts.Pie
|
||||
series []opts.PieData
|
||||
}
|
||||
|
||||
func NewPie() *Pie {
|
||||
return &Pie{Pie: charts.NewPie()}
|
||||
}
|
||||
|
||||
func (pie *Pie) AddX(v interface{}) {
|
||||
}
|
||||
|
||||
func (pie *Pie) Render(w io.Writer) error {
|
||||
pie.AddSeries("", pie.series)
|
||||
return pie.Pie.Render(w)
|
||||
}
|
||||
|
||||
func (pie *Pie) AddY(name string, v []int) {
|
||||
for _, v := range v {
|
||||
pie.series = append(pie.series, opts.PieData{
|
||||
Name: fmt.Sprintf("%s ($%d)", name, v),
|
||||
Value: v,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (pie *Pie) Overlap(other Chart) {
|
||||
panic("nope")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user