Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
snapshot.
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Charczuk committed Jul 10, 2016
1 parent 7bb82ae commit e9a3627
Show file tree
Hide file tree
Showing 23 changed files with 547 additions and 441 deletions.
26 changes: 26 additions & 0 deletions annotation_series.go
Original file line number Diff line number Diff line change
@@ -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 changes: 59 additions & 0 deletions axis.go
Original file line number Diff line number Diff line change
@@ -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 changes: 1 addition & 1 deletion box.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit e9a3627

Please sign in to comment.