This commit is contained in:
parent
04a05284ed
commit
043d81b823
1 changed files with 21 additions and 1 deletions
|
@ -36,8 +36,10 @@ type PieIntValue struct {
|
|||
Value int
|
||||
}
|
||||
|
||||
func generatePie(name string, data []opts.PieData) ChartData {
|
||||
const SUCCESS_CHART_COLOR = "#7cffb2"
|
||||
const FAILED_CHART_COLOR = "#ff6e76"
|
||||
|
||||
func generatePie(name string, data []opts.PieData) ChartData {
|
||||
pie := charts.NewPie()
|
||||
pie.SetGlobalOptions(
|
||||
charts.WithInitializationOpts(opts.Initialization{
|
||||
|
@ -48,6 +50,18 @@ func generatePie(name string, data []opts.PieData) ChartData {
|
|||
Title: name,
|
||||
}))
|
||||
|
||||
for i := range data {
|
||||
if data[i].Name == "Success" {
|
||||
data[i].ItemStyle = &opts.ItemStyle{
|
||||
Color: SUCCESS_CHART_COLOR,
|
||||
}
|
||||
} else if data[i].Name == "Failed" {
|
||||
data[i].ItemStyle = &opts.ItemStyle{
|
||||
Color: FAILED_CHART_COLOR,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pie.AddSeries(name, data).SetSeriesOptions(
|
||||
charts.WithLabelOpts(
|
||||
opts.Label{
|
||||
|
@ -228,10 +242,16 @@ func generateStats(ctx context.Context) ([]ChartData, error) {
|
|||
if v.Status == constants.TASK_STATUS_SUCCESS {
|
||||
successBarData = append(successBarData, opts.BarData{
|
||||
Value: v.Count,
|
||||
ItemStyle: &opts.ItemStyle{
|
||||
Color: SUCCESS_CHART_COLOR,
|
||||
},
|
||||
})
|
||||
} else if v.Status == constants.TASK_STATUS_FAILED {
|
||||
failedBarData = append(failedBarData, opts.BarData{
|
||||
Value: v.Count,
|
||||
ItemStyle: &opts.ItemStyle{
|
||||
Color: FAILED_CHART_COLOR,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue