Skip to content

Commit

Permalink
Merge pull request #7 from technicianted/technicianted/multi_series
Browse files Browse the repository at this point in the history
Use variable for inline data to enable multi-series
  • Loading branch information
metalmatze committed Nov 6, 2019
2 parents 9d16a8b + 7fb5fb2 commit 1d771aa
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions gnuplot.go
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 1d771aa

Please sign in to comment.