func checkTimeSeries(t *testing.T, got *ts.TimeSeries, exp *TestSeries) {
	if got == nil {
		t.Errorf("FAIL(TimeSeries): can't be nil")
		return
	}
	if exp == nil {
		t.Errorf("FAIL(TimeSeries): can't be nil")
		return
	}
	checkKey(t, got.Key(), exp.Key)
	checkStart(t, got.Start(), exp.Start)
	checkEnd(t, got.End(), exp.End)
	checkStep(t, got.Step(), exp.Step)
	checkData(t, got.Data(), exp.Data)
}
Exemplo n.º 2
0
func ChartSingle(ts *ts.TimeSeries) (template.JS, error) {
	if ts == nil {
		return template.JS(""), nil
	}
	t, err := timeString(ts)
	if err != nil {
		return "", err
	}
	s := bytes.NewBufferString(t)
	if err := s.WriteByte(','); err != nil {
		return "", err
	}

	v, err := valueString(ts, ts.Start(), ts.End())
	if err != nil {
		return "", err
	}
	if _, err := s.WriteString(v); err != nil {
		return "", err
	}
	return template.JS(s.String()), nil
}