go-chart/axis.go

46 lines
1.3 KiB
Go
Raw Normal View History

2016-07-10 10:11:47 +02:00
package chart
2016-08-01 01:54:09 +02:00
// TickPosition is an enumeration of possible tick drawing positions.
type TickPosition int
2016-07-30 18:12:03 +02:00
const (
// TickPositionUnset means to use the default tick position.
2016-08-01 01:54:09 +02:00
TickPositionUnset TickPosition = 0
2016-07-30 18:12:03 +02:00
// TickPositionBetweenTicks draws the labels for a tick between the previous and current tick.
2016-08-01 01:54:09 +02:00
TickPositionBetweenTicks TickPosition = 1
2016-07-30 18:12:03 +02:00
// TickPositionUnderTick draws the tick below the tick.
2016-08-01 01:54:09 +02:00
TickPositionUnderTick TickPosition = 2
2016-07-30 18:12:03 +02:00
)
2016-07-10 10:11:47 +02:00
// YAxisType is a type of y-axis; it can either be primary or secondary.
2016-08-01 01:54:09 +02:00
type YAxisType int
2016-07-10 10:11:47 +02:00
const (
// YAxisPrimary is the primary axis.
2016-08-01 01:54:09 +02:00
YAxisPrimary YAxisType = 0
2016-07-10 10:11:47 +02:00
// YAxisSecondary is the secondary axis.
2016-08-01 01:54:09 +02:00
YAxisSecondary YAxisType = 1
2016-07-10 10:11:47 +02:00
)
// Axis is a chart feature detailing what values happen where.
type Axis interface {
GetName() string
2017-01-10 02:57:45 +01:00
SetName(name string)
2016-07-10 10:11:47 +02:00
GetStyle() Style
2017-01-10 02:57:45 +01:00
SetStyle(style Style)
GetTicks() []Tick
GenerateTicks(r Renderer, ra Range, vf ValueFormatter) []Tick
2017-01-10 02:57:45 +01:00
// GenerateGridLines returns the gridlines for the axis.
2016-07-13 04:14:14 +02:00
GetGridLines(ticks []Tick) []GridLine
// Measure should return an absolute box for the axis.
// This is used when auto-fitting the canvas to the background.
Measure(r Renderer, canvasBox Box, ra Range, style Style, ticks []Tick) Box
// Render renders the axis.
Render(r Renderer, canvasBox Box, ra Range, style Style, ticks []Tick)
2016-07-10 10:11:47 +02:00
}