Skip to content

Commit

Permalink
Export x values as time instead of float.
Browse files Browse the repository at this point in the history
  • Loading branch information
udhos committed Apr 26, 2018
1 parent eaab81a commit 6dbb0f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
10 changes: 2 additions & 8 deletions goben/chart.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"log"
"os"
"time"
Expand Down Expand Up @@ -36,11 +35,6 @@ func chartRender(filename string, input *ChartData, output *ChartData) error {
Show: true, //enables / displays the x-axis
},
TickPosition: chart.TickPositionBetweenTicks,
ValueFormatter: func(v interface{}) string {
typed := v.(float64)
typedDate := util.Time.FromFloat64(typed)
return fmt.Sprintf("%02d:%02d:%02d", typedDate.Hour(), typedDate.Minute(), typedDate.Second())
},
},
YAxis: chart.YAxis{
Name: "Mbps",
Expand All @@ -54,12 +48,12 @@ func chartRender(filename string, input *ChartData, output *ChartData) error {
},
},
Series: []chart.Series{
chart.ContinuousSeries{
chart.TimeSeries{
Name: "Input",
XValues: input.XValues,
YValues: input.YValues,
},
chart.ContinuousSeries{
chart.TimeSeries{
Name: "Output",
YAxis: chart.YAxisSecondary,
XValues: output.XValues,
Expand Down
4 changes: 2 additions & 2 deletions goben/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ type account struct {

// ChartData records data for chart
type ChartData struct {
XValues []float64
XValues []time.Time
YValues []float64
}

Expand All @@ -204,7 +204,7 @@ func (a *account) update(n int, reportInterval time.Duration, conn, label, cpsLa

// save chart data
if stat != nil {
stat.XValues = append(stat.XValues, chartTime(now))
stat.XValues = append(stat.XValues, now)
stat.YValues = append(stat.YValues, mbps)
}
}
Expand Down
4 changes: 2 additions & 2 deletions goben/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func exportCsv(filename string, info *ExportInfo) error {

entry[Dir] = "input"
for i, x := range info.Input.XValues {
entry[Time] = timeFromFloat(x).String()
entry[Time] = x.String()
entry[Rate] = fmt.Sprintf("%v", info.Input.YValues[i])
if err := w.Write(entry); err != nil {
return err
Expand All @@ -39,7 +39,7 @@ func exportCsv(filename string, info *ExportInfo) error {

entry[Dir] = "output"
for i, x := range info.Output.XValues {
entry[Time] = timeFromFloat(x).String()
entry[Time] = x.String()
entry[Rate] = fmt.Sprintf("%v", info.Output.YValues[i])
if err := w.Write(entry); err != nil {
return err
Expand Down

0 comments on commit 6dbb0f4

Please sign in to comment.