Skip to content

Commit

Permalink
add sans serif font, adjust legend padding
Browse files Browse the repository at this point in the history
  • Loading branch information
myshkins committed Jan 17, 2024
1 parent c4aad58 commit 300b014
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tsplot/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ func WithFontSize(size float64) PlotOption {
}
}

// WithFontSize configures the font variant as Sans-Serif
func WithSansFont() PlotOption {
return func(p *plot.Plot) {
p.Title.TextStyle.Font.Variant = "Sans"
p.X.Label.TextStyle.Font.Variant = "Sans"
p.Y.Label.TextStyle.Font.Variant = "Sans"
p.Legend.TextStyle.Font.Variant = "Sans"
}
}

// ApplyDefaultHighContrast applies the default high contrast color scheme to the *plot.Plot.
func ApplyDefaultHighContrast(p *plot.Plot) {
opts := []PlotOption{
Expand Down
2 changes: 2 additions & 0 deletions tsplot/plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
monitoring "cloud.google.com/go/monitoring/apiv3/v2"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
"google.golang.org/api/iterator"
"google.golang.org/genproto/googleapis/api/metric"
monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
Expand Down Expand Up @@ -108,6 +109,7 @@ func NewPlotFromTimeSeriesIterator(tsi *monitoring.TimeSeriesIterator, legendKey
legendEntry.Color = lineColor
p.Legend.Left = true
p.Legend.Top = true
p.Legend.Padding = vg.Points(2)
p.Legend.Add(timeSeries.GetMetric().GetLabels()[legendKey], legendEntry)
}
}
Expand Down

0 comments on commit 300b014

Please sign in to comment.