forked from wcharczuk/go-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Will Charczuk
committed
Jul 10, 2016
1 parent
7bb82ae
commit e9a3627
Showing
23 changed files
with
547 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.