adding validation.
This commit is contained in:
parent
3ea3c9ac10
commit
e735797037
20 changed files with 285 additions and 7 deletions
72
_examples/twopoint/main.go
Normal file
72
_examples/twopoint/main.go
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"os"
|
||||
//"time"
|
||||
"github.com/wcharczuk/go-chart" //exposes "chart"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
var b float64
|
||||
b = 1000
|
||||
|
||||
ts1 := chart.ContinuousSeries{ //TimeSeries{
|
||||
Name: "Time Series",
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
|
||||
//XValues: []time.Time{time.Unix(3*b,0),time.Unix(4*b,0),time.Unix(5*b,0),time.Unix(6*b,0),time.Unix(7*b,0),time.Unix(8*b,0),time.Unix(9*b,0),time.Unix(10*b,0)},
|
||||
XValues: []float64{10 * b, 20 * b, 30 * b, 40 * b, 50 * b, 60 * b, 70 * b, 80 * b},
|
||||
YValues: []float64{1.0, 2.0, 30.0, 4.0, 50.0, 6.0, 7.0, 88.0},
|
||||
}
|
||||
|
||||
ts2 := chart.ContinuousSeries{ //TimeSeries{
|
||||
Style: chart.Style{
|
||||
Show: true,
|
||||
StrokeColor: chart.GetDefaultColor(1),
|
||||
},
|
||||
|
||||
XValues: []float64{10 * b, 20 * b, 30 * b, 40 * b, 50 * b, 60 * b, 70 * b, 80 * b},
|
||||
YValues: []float64{15.0, 52.0, 30.0, 42.0, 50.0, 26.0, 77.0, 38.0},
|
||||
}
|
||||
|
||||
graph := chart.Chart{
|
||||
|
||||
XAxis: chart.XAxis{
|
||||
Name: "The XAxis",
|
||||
NameStyle: chart.StyleShow(),
|
||||
Style: chart.StyleShow(),
|
||||
ValueFormatter: chart.TimeMinuteValueFormatter, //TimeHourValueFormatter,
|
||||
},
|
||||
|
||||
YAxis: chart.YAxis{
|
||||
Name: "The YAxis",
|
||||
NameStyle: chart.StyleShow(),
|
||||
Style: chart.StyleShow(),
|
||||
},
|
||||
|
||||
Series: []chart.Series{
|
||||
ts1,
|
||||
ts2,
|
||||
},
|
||||
}
|
||||
|
||||
buffer := bytes.NewBuffer([]byte{})
|
||||
err := graph.Render(chart.PNG, buffer)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fo, err := os.Create("output.png")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if _, err := fo.Write(buffer.Bytes()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
BIN
_examples/twopoint/output.png
Normal file
BIN
_examples/twopoint/output.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Loading…
Add table
Add a link
Reference in a new issue