當前位置: 首頁>>代碼示例>>Golang>>正文


Golang plot.DrawArea類代碼示例

本文整理匯總了Golang中code/google/com/p/plotinum/plot.DrawArea的典型用法代碼示例。如果您正苦於以下問題:Golang DrawArea類的具體用法?Golang DrawArea怎麽用?Golang DrawArea使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DrawArea類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Plot

// Plot implements the plot.Plotter interface.
func (g *Grid) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, trY := plt.Transforms(&da)

	if g.Vertical.Color == nil {
		goto horiz
	}
	for _, tk := range plt.X.Tick.Marker(plt.X.Min, plt.X.Max) {
		if tk.IsMinor() {
			continue
		}
		x := trX(tk.Value)
		da.StrokeLine2(g.Vertical, x, da.Min.Y, x, da.Min.Y+da.Size.Y)
	}

horiz:
	if g.Horizontal.Color == nil {
		return
	}
	for _, tk := range plt.Y.Tick.Marker(plt.Y.Min, plt.Y.Max) {
		if tk.IsMinor() {
			continue
		}
		y := trY(tk.Value)
		da.StrokeLine2(g.Horizontal, da.Min.X, y, da.Min.X+da.Size.X, y)
	}
}
開發者ID:jen6,項目名稱:plotinum,代碼行數:27,代碼來源:grid.go

示例2: Plot

// Plot implements the plot.Plotter interface.
func (b *BarChart) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, trY := plt.Transforms(&da)

	for i, ht := range b.Values {
		x := b.XMin + float64(i)
		xmin := trX(float64(x))
		if !da.ContainsX(xmin) {
			continue
		}
		xmin = xmin - b.Width/2 + b.Offset
		xmax := xmin + b.Width
		bottom := b.stackedOn.BarHeight(i)
		ymin := trY(bottom)
		ymax := trY(bottom + ht)

		pts := []plot.Point{
			{xmin, ymin},
			{xmin, ymax},
			{xmax, ymax},
			{xmax, ymin},
		}
		poly := da.ClipPolygonY(pts)
		da.FillPolygon(b.Color, poly)

		pts = append(pts, plot.Pt(xmin, ymin))
		outline := da.ClipLinesY(pts)
		da.StrokeLines(b.LineStyle, outline...)
	}
}
開發者ID:jen6,項目名稱:plotinum,代碼行數:30,代碼來源:barchart.go

示例3: Plot

func (pt *Dots) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, trY := plt.Transforms(&da)

	da.SetColor(pt.Color)

	for i := range pt.Y {
		// Transform the data x, y coordinate of this bubble
		// to the corresponding drawing coordinate.
		x := trX(pt.X[i])
		y := trY(pt.Y[i])

		// Get the radius of this bubble.  The radius
		// is specified in drawing units (i.e., its size
		// is given as the final size at which it will
		// be drawn) so it does not need to be transformed.
		rad := vg.Length(2)

		// Fill a circle centered at x,y on the draw area.
		var p vg.Path
		p.Move(x+rad, y)
		p.Arc(x, y, rad, 0, 2*math.Pi)
		p.Close()
		da.Fill(p)
	}
}
開發者ID:knodos,項目名稱:kmodel,代碼行數:25,代碼來源:dots.go

示例4: Plot

// Plot draws the Line, implementing the plot.Plotter interface.
func (rp *ResponsePlotter) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, trY := plt.Transforms(&da)

	start := float64(rp.Response.GetStartTime())
	step := float64(rp.Response.GetStepTime())
	absent := rp.Response.IsAbsent

	lines := make([][]plot.Point, 1)
	lines[0] = make([]plot.Point, 0, len(rp.Response.Values))

	/* ikruglov
	 * swithing between lineMode and looping inside
	 * is more branch-prediction friendly i.e. potentially faster */
	switch rp.lineMode {
	case "slope":
		currentLine := 0
		lastAbsent := false
		for i, v := range rp.Response.Values {
			if absent[i] {
				lastAbsent = true
			} else if lastAbsent {
				currentLine++
				lines = append(lines, make([]plot.Point, 1))
				lines[currentLine][0] = plot.Point{X: trX(start + float64(i)*step), Y: trY(v)}
				lastAbsent = false
			} else {
				lines[currentLine] = append(lines[currentLine], plot.Point{X: trX(start + float64(i)*step), Y: trY(v)})
			}
		}

	case "connected":
		for i, v := range rp.Response.Values {
			if absent[i] {
				continue
			}

			lines[0] = append(lines[0], plot.Point{X: trX(start + float64(i)*step), Y: trY(v)})
		}

	case "drawAsInfinite":
		for i, v := range rp.Response.Values {
			if !absent[i] && v > 0 {
				infiniteLine := []plot.Point{
					plot.Point{X: trX(start + float64(i)*step), Y: da.Y(1)},
					plot.Point{X: trX(start + float64(i)*step), Y: da.Y(0)},
				}
				lines = append(lines, infiniteLine)
			}
		}

	//case "staircase": // TODO
	default:
		panic("Unimplemented " + rp.lineMode)
	}

	da.StrokeLines(rp.LineStyle, lines...)
}
開發者ID:markocelan,項目名稱:carbonapi,代碼行數:58,代碼來源:png.go

示例5: Plot

// Plot draws the Line, implementing the plot.Plotter
// interface.
func (pts *Line) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, trY := plt.Transforms(&da)
	ps := make([]plot.Point, len(pts.XYs))
	for i, p := range pts.XYs {
		ps[i].X = trX(p.X)
		ps[i].Y = trY(p.Y)
	}
	da.StrokeLines(pts.LineStyle, da.ClipLinesXY(ps)...)
}
開發者ID:jackielii,項目名稱:go-plotinum,代碼行數:11,代碼來源:line.go

示例6: Plot

// Plot implements the Plotter interface, drawing a line
// that connects each point in the Line.
func (f *Function) Plot(da plot.DrawArea, p *plot.Plot) {
	trX, trY := p.Transforms(&da)

	d := (p.X.Max - p.X.Min) / float64(f.Samples-1)
	line := make([]plot.Point, f.Samples)
	for i := range line {
		x := p.X.Min + float64(i)*d
		line[i].X = trX(x)
		line[i].Y = trY(f.F(x))
	}
	da.StrokeLines(f.LineStyle, da.ClipLinesXY(line)...)
}
開發者ID:jen6,項目名稱:plotinum,代碼行數:14,代碼來源:functions.go

示例7: Plot

// Plot implements the Plotter interface, drawing labels.
func (l *Labels) Plot(da plot.DrawArea, p *plot.Plot) {
	trX, trY := p.Transforms(&da)
	for i, label := range l.Labels {
		x := trX(l.XYs[i].X)
		y := trY(l.XYs[i].Y)
		if !da.Contains(plot.Pt(x, y)) {
			continue
		}
		x += l.XOffset
		y += l.YOffset
		da.FillText(l.TextStyle, x, y, l.XAlign, l.YAlign, label)
	}
}
開發者ID:venliong,項目名稱:plotinum,代碼行數:14,代碼來源:labels.go

示例8: Plot

// Plot implements the Plotter interface, drawing labels.
func (e *YErrorBars) Plot(da plot.DrawArea, p *plot.Plot) {
	trX, trY := p.Transforms(&da)
	for i, err := range e.YErrors {
		x := trX(e.XYs[i].X)
		ylow := trY(e.XYs[i].Y - math.Abs(err.Low))
		yhigh := trY(e.XYs[i].Y + math.Abs(err.High))

		bar := da.ClipLinesY([]plot.Point{{x, ylow}, {x, yhigh}})
		da.StrokeLines(e.LineStyle, bar...)
		e.drawCap(&da, x, ylow)
		e.drawCap(&da, x, yhigh)
	}
}
開發者ID:jen6,項目名稱:plotinum,代碼行數:14,代碼來源:errbars.go

示例9: Plot

// Plot implements the plot.Plotter interface.
func (cg *ColorGrid) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, trY := plt.Transforms(&da)
	for i, d := range cg.XYZs {
		if i%cg.Ny != cg.Ny-1 && i < cg.Nx*cg.Ny-cg.Ny {
			pts := []plot.Point{
				{trX(d.X), trY(d.Y)},
				{trX(cg.XYZs[i+cg.Ny].X), trY(cg.XYZs[i+cg.Ny].Y)},
				{trX(cg.XYZs[i+cg.Ny+1].X), trY(cg.XYZs[i+cg.Ny+1].Y)},
				{trX(cg.XYZs[i+1].X), trY(cg.XYZs[i+1].Y)},
			}
			da.FillPolygon(color.Gray{uint8((d.Z - cg.MinZ) / math.Abs(cg.MaxZ-cg.MinZ) * 255.0)}, pts)
		}
	}
}
開發者ID:akonneker,項目名稱:scicomp,代碼行數:15,代碼來源:test.go

示例10: Plot

func (s *SparkLines) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, trY := plt.Transforms(&da)

	w := vg.Length(1)

	da.SetLineWidth(w)

	_, _, ymin, ymax := s.DataRange()

	for _, d := range s.XYs {
		perc := float64(d.Y-ymin) / float64(ymax-ymin)
		c := BrightColorGradient.GetInterpolatedColorFor((perc*-1+1)*0.5 + 0.6)
		da.SetColor(c)

		// Transform the data x, y coordinate of this bubble
		// to the corresponding drawing coordinate.
		x := trX(d.X)
		y := trY(d.Y * 0.9)

		//rad := vg.Length(10)
		var p vg.Path
		p.Move(x-w, y)
		p.Line(x-w, 0)
		//p.Close()
		da.Stroke(p)

		//da.StrokeLine2(*sty, x, 0, x, y)
	}
}
開發者ID:raff,項目名稱:go-sparkline,代碼行數:29,代碼來源:plot.go

示例11: Plot

func (b *QuartPlot) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, trY := plt.Transforms(&da)
	x := trX(b.Location)
	if !da.ContainsX(x) {
		return
	}

	med := plot.Pt(x, trY(b.Median))
	q1 := trY(b.Quartile1)
	q3 := trY(b.Quartile3)
	aLow := trY(b.AdjLow)
	aHigh := trY(b.AdjHigh)

	da.StrokeLine2(b.WhiskerStyle, x, aHigh, x, q3)
	da.DrawGlyph(b.MedianStyle, med)
	da.StrokeLine2(b.WhiskerStyle, x, aLow, x, q1)

	ostyle := b.MedianStyle
	ostyle.Radius = b.MedianStyle.Radius / 2
	for _, out := range b.Outside {
		y := trY(b.Value(out))
		da.DrawGlyph(ostyle, plot.Pt(x, y))
	}
}
開發者ID:venliong,項目名稱:plotinum,代碼行數:24,代碼來源:quartile.go

示例12: Plot

// Plot implements the Plotter interface, drawing a line
// that connects each point in the Line.
func (h *Histogram) Plot(da plot.DrawArea, p *plot.Plot) {
	trX, trY := p.Transforms(&da)

	for _, bin := range h.Bins {
		pts := []plot.Point{
			{trX(bin.Min), trY(0)},
			{trX(bin.Max), trY(0)},
			{trX(bin.Max), trY(bin.Weight)},
			{trX(bin.Min), trY(bin.Weight)},
		}
		if h.FillColor != nil {
			da.FillPolygon(h.FillColor, da.ClipPolygonXY(pts))
		}
		pts = append(pts, plot.Pt(trX(bin.Min), trY(0)))
		da.StrokeLines(h.LineStyle, da.ClipLinesXY(pts)...)
	}
}
開發者ID:jen6,項目名稱:plotinum,代碼行數:19,代碼來源:histogram.go

示例13: Plot

func (pts *VerticalLine) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, _ := plt.Transforms(&da)
	ps := make([]plot.Point, 2)
	ps[0].X = trX(pts.X)
	ps[1].X = ps[0].X

	ps[0].Y = da.Min.Y
	ps[1].Y = da.Max().Y

	da.StrokeLines(pts.LineStyle, da.ClipLinesXY(ps)...)
}
開發者ID:ematpl,項目名稱:analyzer,代碼行數:11,代碼來源:vertical_line.go

示例14: Plot

func (pts *HorizontalLine) Plot(da plot.DrawArea, plt *plot.Plot) {
	_, trY := plt.Transforms(&da)
	ps := make([]plot.Point, 2)

	ps[0].X = da.Min.X
	ps[1].X = da.Max().X

	ps[0].Y = trY(pts.Y)
	ps[1].Y = ps[0].Y

	da.StrokeLines(pts.LineStyle, da.ClipLinesXY(ps)...)
}
開發者ID:onsi,項目名稱:analyzer,代碼行數:12,代碼來源:horizontal_line.go

示例15: Plot

func (g GlyphBoxes) Plot(da plot.DrawArea, plt *plot.Plot) {
	for _, b := range plt.GlyphBoxes(plt) {
		x := da.X(b.X) + b.Rect.Min.X
		y := da.Y(b.Y) + b.Rect.Min.Y
		da.StrokeLines(g.LineStyle, []plot.Point{
			{x, y},
			{x + b.Rect.Size.X, y},
			{x + b.Rect.Size.X, y + b.Rect.Size.Y},
			{x, y + b.Rect.Size.Y},
			{x, y},
		})
	}
}
開發者ID:aquarat,項目名稱:plotinum,代碼行數:13,代碼來源:glyphbox.go


注:本文中的code/google/com/p/plotinum/plot.DrawArea類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。