Documentation
¶
Index ¶
- func Legend(c *Chart, userDefaults ...render.Style) render.Renderable
- func LegendLeft(c *Chart, userDefaults ...render.Style) render.Renderable
- func LegendThin(c *Chart, userDefaults ...render.Style) render.Renderable
- type Axis
- type BarChart
- func (bc *BarChart) DPI() float64
- func (bc *BarChart) GetBarSpacing() int
- func (bc *BarChart) GetBarWidth() int
- func (bc *BarChart) GetColorPalette() render.ColorPalette
- func (bc *BarChart) GetFont() render.Font
- func (bc *BarChart) Height() int
- func (bc *BarChart) Render(rp render.RendererProvider, w io.Writer) error
- func (bc *BarChart) SetDPI(dpi float64)
- func (bc *BarChart) SetHeight(height int)
- func (bc *BarChart) SetWidth(width int)
- func (bc *BarChart) Width() int
- type Chart
- func (c *Chart) Box() render.Box
- func (c *Chart) DPI(defaults ...float64) float64
- func (c *Chart) GetColorPalette() render.ColorPalette
- func (c *Chart) GetFont() render.Font
- func (c *Chart) Height() int
- func (c *Chart) Render(rp render.RendererProvider, w io.Writer) error
- func (c *Chart) SetDPI(dpi float64)
- func (c *Chart) SetHeight(height int)
- func (c *Chart) SetWidth(width int)
- func (c *Chart) Width() int
- type CircularProgressBar
- func (cp *CircularProgressBar) DPI() float64
- func (cp *CircularProgressBar) GetColorPalette() render.ColorPalette
- func (cp *CircularProgressBar) GetLabel() string
- func (cp *CircularProgressBar) GetProgress() float64
- func (cp *CircularProgressBar) Height() int
- func (cp *CircularProgressBar) Render(rp render.RendererProvider, w io.Writer) error
- func (cp *CircularProgressBar) SetDPI(dpi float64)
- func (cp *CircularProgressBar) SetHeight(height int)
- func (cp *CircularProgressBar) SetLabel(label string)
- func (cp *CircularProgressBar) SetProgress(progress float64)
- func (cp *CircularProgressBar) SetSize(size int)
- func (cp *CircularProgressBar) SetWidth(width int)
- func (cp *CircularProgressBar) Size() int
- func (cp *CircularProgressBar) Width() int
- type DonutChart
- func (pc *DonutChart) Box() render.Box
- func (pc *DonutChart) DPI(defaults ...float64) float64
- func (pc *DonutChart) GetColorPalette() render.ColorPalette
- func (pc *DonutChart) GetFont() render.Font
- func (pc *DonutChart) Height() int
- func (pc *DonutChart) Render(rp render.RendererProvider, w io.Writer) error
- func (pc *DonutChart) SetDPI(dpi float64)
- func (pc *DonutChart) SetHeight(height int)
- func (pc *DonutChart) SetWidth(width int)
- func (pc *DonutChart) Width() int
- type GridLine
- type GridLineProvider
- type LinearProgressBar
- func (lp *LinearProgressBar) DPI() float64
- func (lp *LinearProgressBar) GetColorPalette() render.ColorPalette
- func (lp *LinearProgressBar) GetLabel() string
- func (lp *LinearProgressBar) GetProgress() float64
- func (lp *LinearProgressBar) Height() int
- func (lp *LinearProgressBar) Render(rp render.RendererProvider, w io.Writer) error
- func (lp *LinearProgressBar) SetDPI(dpi float64)
- func (lp *LinearProgressBar) SetHeight(height int)
- func (lp *LinearProgressBar) SetLabel(label string)
- func (lp *LinearProgressBar) SetProgress(progress float64)
- func (lp *LinearProgressBar) SetWidth(width int)
- func (lp *LinearProgressBar) Width() int
- type PieChart
- func (pc *PieChart) Box() render.Box
- func (pc *PieChart) DPI(defaults ...float64) float64
- func (pc *PieChart) GetColorPalette() render.ColorPalette
- func (pc *PieChart) GetFont() render.Font
- func (pc *PieChart) Height() int
- func (pc *PieChart) Render(rp render.RendererProvider, w io.Writer) error
- func (pc *PieChart) SetDPI(dpi float64)
- func (pc *PieChart) SetHeight(height int)
- func (pc *PieChart) SetWidth(width int)
- func (pc *PieChart) Width() int
- type StackedBar
- type StackedBarChart
- func (sbc StackedBarChart) Box() render.Box
- func (sbc StackedBarChart) DPI(defaults ...float64) float64
- func (sbc StackedBarChart) GetBarSpacing() int
- func (sbc StackedBarChart) GetColorPalette() render.ColorPalette
- func (sbc StackedBarChart) GetFont() render.Font
- func (sbc StackedBarChart) Height() int
- func (sbc StackedBarChart) Render(rp render.RendererProvider, w io.Writer) error
- func (sbc *StackedBarChart) SetDPI(dpi float64)
- func (sbc *StackedBarChart) SetHeight(height int)
- func (sbc *StackedBarChart) SetWidth(width int)
- func (sbc StackedBarChart) Width() int
- type Tick
- type TickPosition
- type TicksProvider
- type XAxis
- func (xa XAxis) GetGridLines(ticks []Tick) []GridLine
- func (xa XAxis) GetName() string
- func (xa XAxis) GetStyle() render.Style
- func (xa XAxis) GetTickPosition(defaults ...TickPosition) TickPosition
- func (xa XAxis) GetTicks(r render.Renderer, ra sequence.Range, defaults render.Style, ...) []Tick
- func (xa XAxis) GetValueFormatter() dataset.ValueFormatter
- func (xa XAxis) Measure(r render.Renderer, canvasBox render.Box, ra sequence.Range, ...) render.Box
- func (xa XAxis) Render(r render.Renderer, canvasBox render.Box, ra sequence.Range, ...)
- type YAxis
- func (ya YAxis) GetGridLines(ticks []Tick) []GridLine
- func (ya YAxis) GetName() string
- func (ya YAxis) GetNameStyle() render.Style
- func (ya YAxis) GetStyle() render.Style
- func (ya YAxis) GetTickStyle() render.Style
- func (ya YAxis) GetTicks(r render.Renderer, ra sequence.Range, defaults render.Style, ...) []Tick
- func (ya YAxis) GetValueFormatter() dataset.ValueFormatter
- func (ya YAxis) Measure(r render.Renderer, canvasBox render.Box, ra sequence.Range, ...) render.Box
- func (ya YAxis) Render(r render.Renderer, canvasBox render.Box, ra sequence.Range, ...)
- func (ya YAxis) RenderAxisLine(r render.Renderer, canvasBox render.Box, ra sequence.Range, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Legend ¶
func Legend(c *Chart, userDefaults ...render.Style) render.Renderable
Legend returns a legend renderable function.
func LegendLeft ¶
func LegendLeft(c *Chart, userDefaults ...render.Style) render.Renderable
LegendLeft is a legend that is designed for longer series lists.
func LegendThin ¶
func LegendThin(c *Chart, userDefaults ...render.Style) render.Renderable
LegendThin is a legend that doesn't obscure the chart area.
Types ¶
type Axis ¶
type Axis interface { GetName() string SetName(name string) GetStyle() render.Style SetStyle(style render.Style) GetTicks() []Tick GenerateTicks(r render.Renderer, ra sequence.Range, vf dataset.ValueFormatter) []Tick // GenerateGridLines returns the gridlines for the axis. 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 render.Renderer, canvasBox render.Box, ra sequence.Range, style render.Style, ticks []Tick) render.Box // Render renders the axis. Render(r render.Renderer, canvasBox render.Box, ra sequence.Range, style render.Style, ticks []Tick) }
Axis is a chart feature detailing what values happen where.
type BarChart ¶
type BarChart struct { Title string TitleStyle render.Style Font render.Font Background render.Style Canvas render.Style ColorPalette render.ColorPalette XAxis render.Style YAxis YAxis BarWidth int BarSpacing int IsHorizontal bool UseBaseValue bool BaseValue float64 Bars []dataset.Value Elements []render.Renderable // contains filtered or unexported fields }
BarChart is a chart that draws bars on a range.
func (*BarChart) GetBarSpacing ¶
GetBarSpacing returns the spacing between bars.
func (*BarChart) GetBarWidth ¶
GetBarWidth returns the default bar width.
func (*BarChart) GetColorPalette ¶
func (bc *BarChart) GetColorPalette() render.ColorPalette
GetColorPalette returns the color palette for the chart.
type Chart ¶
type Chart struct { Title string TitleStyle render.Style Font render.Font Background render.Style Canvas render.Style ColorPalette render.ColorPalette XAxis XAxis YAxis YAxis YAxisSecondary YAxis Series []dataset.Series Elements []render.Renderable // contains filtered or unexported fields }
Chart represents a line, curve or histogram chart.
func (*Chart) GetColorPalette ¶
func (c *Chart) GetColorPalette() render.ColorPalette
GetColorPalette returns the color palette for the chart.
type CircularProgressBar ¶ added in v0.2.0
type CircularProgressBar struct { // BackgroundStyle is the style for the background bar. BackgroundStyle render.Style // ForegroundStyle is the style for the foreground bar. ForegroundStyle render.Style // LabelStyle is the style for the label that will displayed in the center of the progress bar. LabelStyle render.Style // ColorPalette is the color pallete that could be used to add colors in this progress bar ColorPalette render.ColorPalette // Reversed is a flag where if the value is true then the progress bar would rendered counter clockwise. Reversed bool // contains filtered or unexported fields }
CircularProgressBar is a component that will render circular progress bar component.
func (*CircularProgressBar) DPI ¶ added in v0.2.0
func (cp *CircularProgressBar) DPI() float64
DPI returns the DPI of the progress bar.
func (*CircularProgressBar) GetColorPalette ¶ added in v0.2.0
func (cp *CircularProgressBar) GetColorPalette() render.ColorPalette
GetColorPalette returns the color palette for the chart.
func (*CircularProgressBar) GetLabel ¶ added in v0.2.0
func (cp *CircularProgressBar) GetLabel() string
GetLabel returns the label displayed in the center of the progress bar.
func (*CircularProgressBar) GetProgress ¶ added in v0.2.0
func (cp *CircularProgressBar) GetProgress() float64
GetProgress returns the progress represented by this chart. Returned value should be a float number between 0.0 - 1.0.
func (*CircularProgressBar) Height ¶ added in v0.2.0
func (cp *CircularProgressBar) Height() int
Height returns the chart height.
func (*CircularProgressBar) Render ¶ added in v0.2.0
func (cp *CircularProgressBar) Render(rp render.RendererProvider, w io.Writer) error
Render renders the progress bar with the given renderer to the given io.Writer.
func (*CircularProgressBar) SetDPI ¶ added in v0.2.0
func (cp *CircularProgressBar) SetDPI(dpi float64)
SetDPI sets the DPI for the progress bar.
func (*CircularProgressBar) SetHeight ¶ added in v0.2.0
func (cp *CircularProgressBar) SetHeight(height int)
SetHeight method is exists to fuifill the requirements of render.ChartRenderable interface. To set width or height of this circular progress bar, use SetSize instead.
func (*CircularProgressBar) SetLabel ¶ added in v0.2.0
func (cp *CircularProgressBar) SetLabel(label string)
SetLabel sets the label that would be displayed in the center of the progress bar.
func (*CircularProgressBar) SetProgress ¶ added in v0.2.0
func (cp *CircularProgressBar) SetProgress(progress float64)
SetProgress set the progress that will represented by this chart. Expected value should be float number between 0.0 - 1.0.
func (*CircularProgressBar) SetSize ¶ added in v0.2.0
func (cp *CircularProgressBar) SetSize(size int)
SetSize sets the chart size.
func (*CircularProgressBar) SetWidth ¶ added in v0.2.0
func (cp *CircularProgressBar) SetWidth(width int)
SetWidth method is exists to fuifill the requirements of render.ChartRenderable interface. To set width or height of this circular progress bar, use SetSize instead.
func (*CircularProgressBar) Size ¶ added in v0.2.0
func (cp *CircularProgressBar) Size() int
Size returns the chart size or the default value.
func (*CircularProgressBar) Width ¶ added in v0.2.0
func (cp *CircularProgressBar) Width() int
Width returns the chart width.
type DonutChart ¶
type DonutChart struct { Title string TitleStyle render.Style Font render.Font Background render.Style Canvas render.Style SliceStyle render.Style ColorPalette render.ColorPalette Values []dataset.Value Elements []render.Renderable // contains filtered or unexported fields }
DonutChart is a chart that draws sections of a circle based on percentages with an hole.
func (*DonutChart) Box ¶
func (pc *DonutChart) Box() render.Box
Box returns the chart bounds as a box.
func (*DonutChart) DPI ¶
func (pc *DonutChart) DPI(defaults ...float64) float64
DPI returns the DPI for the chart.
func (*DonutChart) GetColorPalette ¶
func (pc *DonutChart) GetColorPalette() render.ColorPalette
GetColorPalette returns the color palette for the chart.
func (*DonutChart) GetFont ¶
func (pc *DonutChart) GetFont() render.Font
GetFont returns the text font.
func (*DonutChart) Height ¶
func (pc *DonutChart) Height() int
Height returns the chart height or the default value.
func (*DonutChart) Render ¶
func (pc *DonutChart) Render(rp render.RendererProvider, w io.Writer) error
Render renders the chart with the given renderer to the given io.Writer.
func (*DonutChart) SetDPI ¶
func (pc *DonutChart) SetDPI(dpi float64)
SetDPI sets the DPI for the chart.
func (*DonutChart) SetHeight ¶
func (pc *DonutChart) SetHeight(height int)
SetHeight sets the chart height.
func (*DonutChart) SetWidth ¶
func (pc *DonutChart) SetWidth(width int)
SetWidth sets the chart width.
func (*DonutChart) Width ¶
func (pc *DonutChart) Width() int
Width returns the chart width or the default value.
type GridLine ¶
GridLine is a line on a graph canvas.
func GenerateGridLines ¶
GenerateGridLines generates grid lines.
type GridLineProvider ¶
type GridLineProvider interface {
GetGridLines(ticks []Tick, isVertical bool, majorStyle, minorStyle render.Style) []GridLine
}
GridLineProvider is a type that provides grid lines.
type LinearProgressBar ¶ added in v0.2.0
type LinearProgressBar struct { // BackgroundStyle is the style for the background bar. BackgroundStyle render.Style // ForegroundStyle is the style for the foreground bar. ForegroundStyle render.Style // LabelStyle is the style for the label that will displayed on the progress bar. LabelStyle render.Style // ColorPalette is the color pallete that could be used to add colors in this progress bar ColorPalette render.ColorPalette // RoundedEdgeStart is a flag to enable rounded edge at the start of the bar. RoundedEdgeStart bool // RoundedEdgeEnd us a flag to enable rounded edge at the end of the bar. RoundedEdgeEnd bool // CustomTopInfo defines a user provided function to draw a custom info above the progress bar. // The callback function should return the height occupied by the top info, which would be used // to shift down the progress bar position. CustomTopInfo func(r render.Renderer, x int) int // CustomBottomInfo defines a user provided function to draw a custom info under the progress bar. // The callback function should return the height occupied by the bottom info, which would be used // to calculate this progress bar total height. CustomBottomInfo func(r render.Renderer, x int) int // contains filtered or unexported fields }
LinearProgressBar is a component that will render progress bar component.
func (*LinearProgressBar) DPI ¶ added in v0.2.0
func (lp *LinearProgressBar) DPI() float64
DPI returns the DPI of the progress bar.
func (*LinearProgressBar) GetColorPalette ¶ added in v0.2.0
func (lp *LinearProgressBar) GetColorPalette() render.ColorPalette
GetColorPalette returns the color palette for the chart.
func (*LinearProgressBar) GetLabel ¶ added in v0.2.0
func (lp *LinearProgressBar) GetLabel() string
GetLabel would returns label that rendered on the progress bar.
func (*LinearProgressBar) GetProgress ¶ added in v0.2.0
func (lp *LinearProgressBar) GetProgress() float64
GetProgress returns the progress represented by this chart. Returned value should be a float number between 0.0 - 1.0.
func (*LinearProgressBar) Height ¶ added in v0.2.0
func (lp *LinearProgressBar) Height() int
Height returns the chart height or the default value.
func (*LinearProgressBar) Render ¶ added in v0.2.0
func (lp *LinearProgressBar) Render(rp render.RendererProvider, w io.Writer) error
Render renders the progrss bar with the given renderer to the given io.Writer.
func (*LinearProgressBar) SetDPI ¶ added in v0.2.0
func (lp *LinearProgressBar) SetDPI(dpi float64)
SetDPI sets the DPI for the progrss bar.
func (*LinearProgressBar) SetHeight ¶ added in v0.2.0
func (lp *LinearProgressBar) SetHeight(height int)
SetHeight sets the chart height.
func (*LinearProgressBar) SetLabel ¶ added in v0.2.0
func (lp *LinearProgressBar) SetLabel(label string)
SetLabel sets the labe that would be rendered on the progress bar.
func (*LinearProgressBar) SetProgress ¶ added in v0.2.0
func (lp *LinearProgressBar) SetProgress(progress float64)
SetProgress set the progress that will represented by this chart. Expected value should be float number between 0.0 - 1.0.
func (*LinearProgressBar) SetWidth ¶ added in v0.2.0
func (lp *LinearProgressBar) SetWidth(width int)
SetWidth sets the chart width.
func (*LinearProgressBar) Width ¶ added in v0.2.0
func (lp *LinearProgressBar) Width() int
Width returns the chart width or the default value.
type PieChart ¶
type PieChart struct { Title string TitleStyle render.Style Font render.Font Background render.Style Canvas render.Style SliceStyle render.Style ColorPalette render.ColorPalette Values []dataset.Value Elements []render.Renderable // contains filtered or unexported fields }
PieChart is a chart that draws sections of a circle based on percentages.
func (*PieChart) GetColorPalette ¶
func (pc *PieChart) GetColorPalette() render.ColorPalette
GetColorPalette returns the color palette for the chart.
type StackedBar ¶
StackedBar is a bar within a StackedBarChart.
func (StackedBar) GetWidth ¶
func (sb StackedBar) GetWidth() int
GetWidth returns the width of the bar.
type StackedBarChart ¶
type StackedBarChart struct { Title string TitleStyle render.Style Font render.Font Background render.Style Canvas render.Style ColorPalette render.ColorPalette XAxis render.Style YAxis render.Style BarSpacing int IsHorizontal bool Bars []StackedBar Elements []render.Renderable // contains filtered or unexported fields }
StackedBarChart is a chart that draws sections of a bar based on percentages.
func (StackedBarChart) Box ¶
func (sbc StackedBarChart) Box() render.Box
Box returns the chart bounds as a box.
func (StackedBarChart) DPI ¶
func (sbc StackedBarChart) DPI(defaults ...float64) float64
DPI returns the DPI for the chart.
func (StackedBarChart) GetBarSpacing ¶
func (sbc StackedBarChart) GetBarSpacing() int
GetBarSpacing returns the spacing between bars.
func (StackedBarChart) GetColorPalette ¶
func (sbc StackedBarChart) GetColorPalette() render.ColorPalette
GetColorPalette returns the color palette for the chart.
func (StackedBarChart) GetFont ¶
func (sbc StackedBarChart) GetFont() render.Font
GetFont returns the text font.
func (StackedBarChart) Height ¶
func (sbc StackedBarChart) Height() int
Height returns the chart height or the default value.
func (StackedBarChart) Render ¶
func (sbc StackedBarChart) Render(rp render.RendererProvider, w io.Writer) error
Render renders the chart with the given renderer to the given io.Writer.
func (*StackedBarChart) SetDPI ¶
func (sbc *StackedBarChart) SetDPI(dpi float64)
SetDPI sets the DPI for the chart.
func (*StackedBarChart) SetHeight ¶
func (sbc *StackedBarChart) SetHeight(height int)
SetHeight sets the chart height.
func (*StackedBarChart) SetWidth ¶
func (sbc *StackedBarChart) SetWidth(width int)
SetWidth sets the chart width.
func (StackedBarChart) Width ¶
func (sbc StackedBarChart) Width() int
Width returns the chart width or the default value.
type TickPosition ¶
type TickPosition int
TickPosition is an enumeration of possible tick drawing positions.
const ( // TickPositionUnset means to use the default tick position. TickPositionUnset TickPosition = 0 // TickPositionBetweenTicks draws the labels for a tick between the previous and current tick. TickPositionBetweenTicks TickPosition = 1 // TickPositionUnderTick draws the tick below the tick. TickPositionUnderTick TickPosition = 2 )
type TicksProvider ¶
type TicksProvider interface {
GetTicks(r render.Renderer, defaults render.Style, vf dataset.ValueFormatter) []Tick
}
TicksProvider is a type that provides ticks.
type XAxis ¶
type XAxis struct { Name string NameStyle render.Style Style render.Style ValueFormatter dataset.ValueFormatter Range sequence.Range TickStyle render.Style Ticks []Tick TickPosition TickPosition GridLines []GridLine GridMajorStyle render.Style GridMinorStyle render.Style }
XAxis represents the horizontal axis.
func (XAxis) GetGridLines ¶
GetGridLines returns the gridlines for the axis.
func (XAxis) GetTickPosition ¶
func (xa XAxis) GetTickPosition(defaults ...TickPosition) TickPosition
GetTickPosition returns the tick position option for the axis.
func (XAxis) GetTicks ¶
func (xa XAxis) GetTicks(r render.Renderer, ra sequence.Range, defaults render.Style, vf dataset.ValueFormatter) []Tick
GetTicks returns the ticks for a series. The coalesce priority is:
- User Supplied Ticks (i.e. Ticks array on the axis itself).
- Range ticks (i.e. if the range provides ticks).
- Generating continuous ticks based on minimum spacing and canvas width.
func (XAxis) GetValueFormatter ¶
func (xa XAxis) GetValueFormatter() dataset.ValueFormatter
GetValueFormatter returns the value formatter for the axis.
type YAxis ¶
type YAxis struct { Name string NameStyle render.Style Style render.Style Zero GridLine AxisType dataset.YAxisType Ascending bool ValueFormatter dataset.ValueFormatter Range sequence.Range TickStyle render.Style Ticks []Tick GridLines []GridLine GridMajorStyle render.Style GridMinorStyle render.Style }
YAxis is a veritcal rule of the range. There can be (2) y-axes; a primary and secondary.
func (YAxis) GetGridLines ¶
GetGridLines returns the gridlines for the axis.
func (YAxis) GetNameStyle ¶
GetNameStyle returns the name style.
func (YAxis) GetTickStyle ¶
GetTickStyle returns the tick style.
func (YAxis) GetTicks ¶
func (ya YAxis) GetTicks(r render.Renderer, ra sequence.Range, defaults render.Style, vf dataset.ValueFormatter) []Tick
GetTicks returns the ticks for a series. The coalesce priority is:
- User Supplied Ticks (i.e. Ticks array on the axis itself).
- Range ticks (i.e. if the range provides ticks).
- Generating continuous ticks based on minimum spacing and canvas width.
func (YAxis) GetValueFormatter ¶
func (ya YAxis) GetValueFormatter() dataset.ValueFormatter
GetValueFormatter returns the value formatter for the axis.
func (YAxis) Measure ¶
func (ya YAxis) Measure(r render.Renderer, canvasBox render.Box, ra sequence.Range, defaults render.Style, ticks []Tick) render.Box
Measure returns the bounds of the axis.