diff --git a/generator/charts/charts.go b/generator/charts/charts.go index 031976d..995957d 100644 --- a/generator/charts/charts.go +++ b/generator/charts/charts.go @@ -10,6 +10,7 @@ import ( "github.com/wzshiming/profile_stats" "github.com/wzshiming/profile_stats/generator/charts/render" + placeholder_render "github.com/wzshiming/profile_stats/generator/placeholder/render" "github.com/wzshiming/profile_stats/source" "github.com/wzshiming/profile_stats/utils" ) @@ -197,5 +198,12 @@ func (a *Charts) Get(ctx context.Context, w io.Writer, title string, usernames [ }) } + if len(data.Series) == 0 { + return placeholder_render.PlaceHolderRender(w, placeholder_render.PlaceHolderData{ + Width: len(title) * 9, + Height: 30, + Text: title, + }) + } return render.ChartRender(w, data) } diff --git a/generator/generator.go b/generator/generator.go index e6467a3..28afc2e 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -32,7 +32,7 @@ func NewHandler(src *source.Source) *Handler { r.register("now", now.NewNow()) r.register("updatedat", now.NewNow()) - r.register("stats", placeholder.NewPlaceHolder()) + r.register("placeholder", placeholder.NewPlaceHolder()) r.register("activities", activities.NewActivities(src)) r.register("stats", stats.NewStats(src)) r.register("charts", charts.NewCharts(src))