Skip to content

Commit

Permalink
pie chart: show label with percent
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Mar 27, 2024
1 parent 5bbf026 commit 742a8d4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ func renderPieChart(f *os.File, title string, d distrib) error {
ItemStyle: &opts.ItemStyle{Color: "#fff8de"},
Value: d.unstaked.Quo(d.supply).Mul(oneHundred).MustFloat64(),
}
pie.AddSeries("pie", data)
pie.AddSeries("pie", data).
SetSeriesOptions(charts.WithLabelOpts(opts.Label{
Show: true,
Formatter: opts.FuncOpts("function(params){ return params.name+': '+params.value.toFixed(2)+'%'}"),
}))
return pie.Render(f)
}

0 comments on commit 742a8d4

Please sign in to comment.