Skip to content
Permalink
Browse files

snapshot.

  • Loading branch information...
wcharczuk committed Jul 10, 2016
1 parent 7bb82ae commit e9a36274acfc8ddb50427d6f200502c7ee9abd33
Showing with 547 additions and 441 deletions.
  1. +26 −0 annotation_series.go
  2. +59 −0 axis.go
  3. +1 −1 box.go
  4. +134 −187 chart.go
  5. +7 −39 continuous_series.go
  6. +95 −0 drawing_helpers.go
  7. +0 −4 formatter.go
  8. +4 −22 range.go
  9. +5 −0 raster_renderer.go
  10. +6 −0 renderable.go
  11. +3 −3 renderer.go
  12. +4 −0 renderer_provider.go
  13. +3 −113 series.go
  14. +0 −30 series_test.go
  15. +45 −7 style.go
  16. +25 −0 tick.go
  17. +14 −33 time_series.go
  18. +6 −2 util.go
  19. +43 −0 value_formatter.go
  20. +7 −0 value_provider.go
  21. +5 −0 vector_renderer.go
  22. +27 −0 xaxis.go
  23. +28 −0 yaxis.go
@@ -0,0 +1,26 @@
package chart

// Annotation is a label on the chart.
type Annotation struct {
X, Y float64
Label string
}

// AnnotationSeries is a series of labels on the chart.
type AnnotationSeries struct {
Name string
Style Style
YAxis YAxisType
Annotations []Annotation
}

// Render draws the series.
func (as AnnotationSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range) {
if as.Style.Show {
for _, a := range as.Annotations {
lx := xrange.Translate(a.X) + canvasBox.Left
ly := yrange.Translate(a.Y) + canvasBox.Top
DrawAnnotation(r, canvasBox, xrange, yrange, as.Style, lx, ly, a.Label)
}
}
}
59 axis.go
@@ -0,0 +1,59 @@
package chart

// YAxisType is a type of y-axis; it can either be primary or secondary.
type YAxisType int

const (
// YAxisPrimary is the primary axis.
YAxisPrimary YAxisType = 0
// YAxisSecondary is the secondary axis.
YAxisSecondary YAxisType = 1
)

// Axis is a chart feature detailing what values happen where.
type Axis interface {
GetName() string
GetStyle() Style
Render(c *Chart, r Renderer, canvasBox Box, ra Range)
}

// axis represents the basics of an axis implementation.
type axis struct {
Name string
Style Style
ValueFormatter ValueFormatter
Range Range
Ticks []Tick
}

func (a axis) GetName() string {
return a.Name
}

func (a axis) GetStyle() Style {
return a.Style
}

func (a axis) getTicks(ra Range) []Tick {
if len(a.Ticks) > 0 {
return a.Ticks
}
return a.generateTicks(ra)
}

func (a axis) generateTicks(ra Range) []Tick {
step := a.getTickStep(ra)
return a.generateTicksWithStep(ra, step)
}

func (a axis) getTickCount(ra Range) int {
return 0
}

func (a axis) getTickStep(ra Range) float64 {
return 0.0
}

func (a axis) generateTicksWithStep(ra Range, step float64) []Tick {
return []Tick{}
}
2 box.go
@@ -20,7 +20,7 @@ func (b Box) IsZero() bool {

// String returns a string representation of the box.
func (b Box) String() string {
return fmt.Sprintf("Box(%d,%d,%d,%d)", b.Top, b.Left, b.Right, b.Bottom)
return fmt.Sprintf("box(%d,%d,%d,%d)", b.Top, b.Left, b.Right, b.Bottom)
}

// GetTop returns a coalesced value with a default.

0 comments on commit e9a3627

Please sign in to comment.
You can’t perform that action at this time.