Skip to content

Commit

Permalink
Use variable for inline to enable multi-series
Browse files Browse the repository at this point in the history
  • Loading branch information
technicianted committed Oct 29, 2019
1 parent 9d16a8b commit 7fb5fb2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions gnuplot.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,22 @@ func gnuplotAction(c *cli.Context) error {

buf := bytes.NewBufferString(header)

for i, result := range results {
plot := fmt.Sprintf("plot '-' using 1:%d with lines lw 1 title '%s'\n", i+2, escapeMetricName(result.Metric))
buf.WriteString(plot)
}

buf.WriteString("$DATA << EOD\n")
if err := csvWriter(buf, results); err != nil {
return err
}
buf.WriteString("EOD\n")

for i, result := range results {
if i == 0 {
buf.WriteString("plot ")
} else {
buf.WriteString(", ")
}
plot := fmt.Sprintf("$DATA using 1:%d with lines lw 1 title '%s'", i+2, escapeMetricName(result.Metric))
buf.WriteString(plot)
}
buf.WriteString("\n")

fmt.Printf("%s\n", buf.String())

Expand Down

0 comments on commit 7fb5fb2

Please sign in to comment.