本文整理汇总了Golang中github.com/vdobler/chart.ScatterChart.AddData方法的典型用法代码示例。如果您正苦于以下问题:Golang ScatterChart.AddData方法的具体用法?Golang ScatterChart.AddData怎么用?Golang ScatterChart.AddData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vdobler/chart.ScatterChart
的用法示例。
在下文中一共展示了ScatterChart.AddData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExprGraph
func (s *Schedule) ExprGraph(t miniprofiler.Timer, unit string, res []*expr.Result) (chart.Chart, error) {
c := chart.ScatterChart{
Key: chart.Key{Pos: "itl"},
YRange: chart.Range{Label: unit},
}
c.XRange.Time = true
for ri, r := range res {
rv := r.Value.(expr.Series)
pts := make([]chart.EPoint, len(rv))
idx := 0
for k, v := range rv {
pts[idx].X = float64(k.Unix())
pts[idx].Y = v
idx++
}
slice.Sort(pts, func(i, j int) bool {
return pts[i].X < pts[j].X
})
c.AddData(r.Group.String(), pts, chart.PlotStyleLinesPoints, Autostyle(ri))
}
return &c, nil
}
示例2: Graph
//.........这里部分代码省略.........
if meta.Unit != "" {
m_units[q.Metric] = meta.Unit
}
if meta.Rate != "" {
switch meta.Rate {
case metadata.Gauge:
// ignore
case metadata.Rate:
q.Rate = true
case metadata.Counter:
q.Rate = true
q.RateOptions = opentsdb.RateOptions{
Counter: true,
ResetValue: 1,
}
default:
return nil, fmt.Errorf("unknown metadata rate: %s", meta.Rate)
}
}
}
queries[i] = fmt.Sprintf(`q("%v", "%v", "%v")`, q, start, end)
if !schedule.SystemConf.GetTSDBContext().Version().FilterSupport() {
if err := schedule.Search.Expand(q); err != nil {
return nil, err
}
}
}
var tr opentsdb.ResponseSet
b, _ := json.MarshalIndent(oreq, "", " ")
t.StepCustomTiming("tsdb", "query", string(b), func() {
h := schedule.SystemConf.GetTSDBHost()
if h == "" {
err = fmt.Errorf("tsdbHost not set")
return
}
tr, err = oreq.Query(h)
})
if err != nil {
return nil, err
}
cs, err := makeChart(tr, m_units)
if err != nil {
return nil, err
}
if _, present := r.Form["png"]; present {
c := chart.ScatterChart{
Title: fmt.Sprintf("%v - %v", oreq.Start, queries),
}
c.XRange.Time = true
if min, err := strconv.ParseFloat(r.FormValue("min"), 64); err == nil {
c.YRange.MinMode.Fixed = true
c.YRange.MinMode.Value = min
}
if max, err := strconv.ParseFloat(r.FormValue("max"), 64); err == nil {
c.YRange.MaxMode.Fixed = true
c.YRange.MaxMode.Value = max
}
for ri, r := range cs {
pts := make([]chart.EPoint, len(r.Data))
for idx, v := range r.Data {
pts[idx].X = v[0]
pts[idx].Y = v[1]
}
slice.Sort(pts, func(i, j int) bool {
return pts[i].X < pts[j].X
})
c.AddData(r.Name, pts, chart.PlotStyleLinesPoints, sched.Autostyle(ri))
}
w.Header().Set("Content-Type", "image/svg+xml")
white := color.RGBA{0xff, 0xff, 0xff, 0xff}
const width = 800
const height = 600
s := svg.New(w)
s.Start(width, height)
s.Rect(0, 0, width, height, "fill: #ffffff")
sgr := svgg.AddTo(s, 0, 0, width, height, "", 12, white)
c.Plot(sgr)
s.End()
return nil, nil
}
var a []annotate.Annotation
warnings := []string{}
if schedule.SystemConf.AnnotateEnabled() {
a, err = annotateBackend.GetAnnotations(&startT, &endT)
if err != nil {
warnings = append(warnings, fmt.Sprintf("unable to get annotations: %v", err))
}
}
return struct {
Queries []string
Series []*chartSeries
Annotations []annotate.Annotation
Warnings []string
}{
queries,
cs,
a,
warnings,
}, nil
}