charts

package module
v0.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 17 Imported by: 4

README

go-analyze/charts

license Build Status

Our library focuses on generating beautiful charts and graphs within Go. Graphs are used to show a lot of different types of data, needing to be represented in a unique in order to convey the meaning behind the data. This Go module attempts to use sophisticated defaults to try and render this data in a simple way, while still offering intuitive options to update the graph rendering as you see fit.

Functionality

Currently supported chart types: line, scatter, bar, horizontal bar, pie, doughnut, radar, funnel and table.

New users should check out the Features Overview on our Wiki to see commonly used features for each chart type, as well as linking to specific examples for the feature.

We also have an extensive catalog of examples. Reference the README within the examples directory to see a list of our example implementations of each chart type and configurations.

Themes

Our library offers a wide range of themes, the examples below are only a small subset of what we offer. See our Themes list in Feature Overview to see our complete theme list.

themes

Line Chart
Line Chart

Line Chart Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#line-charts

import (
	"github.com/go-analyze/charts"
)

func main() {
	// values specified where the first index is for each data series or source, and the second index is for each sample.
	values := [][]float64{
		{	// Email
			120, // Mon
			132, // Tue
			101, // Wed
			134, // Thu
			90,  // Fri
			230, // Sat
			210, // Sun
		},
		{
			// values for 'Search Engine' go here
		},
	}
	opt := charts.NewLineChartOptionWithData(values)
	opt.Title = charts.TitleOption{
		Text: "Line Chart Demo",
	}
	opt.XAxis.Labels = []string{
		// The 7 labels here match to the 7 values above
		"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
	}
	opt.Legend = charts.LegendOption{
		SeriesNames: []string{
			"Email", "Search Engine",
		},
	}
	// other options as desired...

	p := charts.NewPainter(charts.PainterOptions{
		Width:        600,
		Height:       400,
	})
	err := p.LineChart(opt)
	// ... err check
	buf, err := p.Bytes()
	// ...

Top Line Chart Examples:

  • line_chart-1-basic - Basic line chart with some simple styling changes and a demonstration of null values.
  • line_chart-2-symbols - Basic line chart which sets a different symbol for each series item.
  • line_chart-3-smooth - Basic line chart with thick smooth lines drawn.
  • line_chart-4-mark - Line chart with included mark points and mark lines.
  • line_chart-6-stacked - Line chart with "Stacked" series enabled, making each series a layer on the chart and the top line showing the sum.
  • line_chart-8-dual_y_axis - Basic line chart with two series, one rendered to the left axis and one to a second y axis on the right.
Scatter Chart
Scatter Chart

Scatter Chart Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#scatter-charts

import (
	"github.com/go-analyze/charts"
)

func main() {
	opt := charts.NewScatterChartOptionWithData([][]float64{
		{120, 132, 101, charts.GetNullValue(), 90, 230, 210},
		{ /* values for search engine go here */ },
	})
	opt.Title.Text = "Scatter"
	opt.XAxis.Labels = []string{
		// The 7 labels here match to the 7 values above
		"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
	}
	opt.Legend.SeriesNames = []string{"Email", "Search Engine"}
	// set other field options as desired...

	p := charts.NewPainter(charts.PainterOptions{
		Width:        600,
		Height:       400,
	})
	err := p.ScatterChart(opt)
	// ... err check
	buf, err := p.Bytes()
	// ...

Top Scatter Chart Examples:

Bar Chart
Bar Chart

Bar Chart Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#bar-charts

import (
	"github.com/go-analyze/charts"
)

func main() {
	// values specified where the first index is for each data series or source, and the second index is for each sample.
	values := [][]float64{
		{   // Rainfall data
			2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3,
		},
		{
			// 'Evaporation' data goes here
		},
	}
	opt := charts.NewBarChartOptionWithData(values)
	opt.XAxis.Labels = []string{
		// A label for each position in the values above
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
	}
	opt.Legend = charts.LegendOption{
		SeriesNames: []string{
			"Rainfall", "Evaporation",
		},
		Offset:       charts.OffsetRight,
	}
	// Example of adding a mark line across the bars, or mark points for specific values
	opt.SeriesList[0].MarkLine.AddLines(charts.SeriesMarkTypeAverage)
	opt.SeriesList[0].MarkPoint.AddPoints(charts.SeriesMarkTypeMax, charts.SeriesMarkTypeMin)
	// other options as desired...

	p := charts.NewPainter(charts.PainterOptions{
		Width:        600,
		Height:       400,
	})
	err := p.BarChart(opt)
	// ... err check
	buf, err := p.Bytes()
	// ...

Top Bar Chart Examples:

Horizontal Bar Chart
Horizontal Bar Chart

Horizontal Bar Chart Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#horizontal-bar-charts

Top Horizontal Bar Chart Examples:

Pie Chart
Pie Chart

Pie Chart Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#pie-charts

import (
	"github.com/go-analyze/charts"
)

func main() {
	values := []float64{
		1048, // Search Engine
		735,  // Direct
		580,  // Email
		484,  // Union Ads
		300,  // Video Ads
	}
	opt := charts.NewPieChartOptionWithData(values)
	opt.Title = charts.TitleOption{
		Text:             "Pie Chart",
		Offset:           charts.OffsetCenter,
	}
	opt.Legend.SeriesNames = []string{
		"Search Engine", "Direct", "Email", "Union Ads", "Video Ads",
	}
	// other options as desired...

	p := charts.NewPainter(charts.PainterOptions{
		Width:        600,
		Height:       400,
	})
	err := p.PieChart(opt)
	// ... err check
	buf, err := p.Bytes()
	// ...

Top Pie Chart Examples:

  • pie_chart-1-basic - Pie chart with a variety of customization demonstrated including positioning the legend in the bottom right corner.
  • pie_chart-2-radius - Pie chart which varies the series radius by the percentage of the series.
Doughnut Chart
Dougnut Chart

Doughnut Chart Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#doughnut-charts

Top Radar Chart Examples:

Radar Chart
Radar Chart

Radar Chart Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#radar-charts

Top Radar Chart Examples:

Heat Map Chart
Heat Map Chart

Heat Map Chart Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#heat-map-charts

Top Radar Chart Examples:

Table
Table

Table Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#tables

Top Table Examples:

  • table-1 - Table with a variety of table specific configuration and styling demonstrated.
Funnel Chart

Funnel Chart Feature List: https://github.com/go-analyze/charts/wiki/Feature-Overview#funnel-charts

import (
	"github.com/go-analyze/charts"
)

func main() {
	values := []float64{
		100, // Show
		80,  // Click
		60,  // Visit
		40,  // Inquiry
		20,  // Order
	}
	opt := charts.NewFunnelChartOptionWithData(values)
	opt.Title.Text = "Funnel Chart"
	opt.Legend.SeriesNames = []string{
		"Show", "Click", "Visit", "Inquiry", "Order",
	}

	p := charts.NewPainter(charts.PainterOptions{
		Width:        600,
		Height:       400,
	})
	err := p.FunnelChart(opt)
	// ... err check
	buf, err := p.Bytes()

Top Funnel Chart Examples:

ECharts Render
import (
	"github.com/go-analyze/charts"
)

func main() {
	buf, err := charts.RenderEChartsToPNG(`{
		"title": {
			"text": "Line Chart"
		},
		"xAxis": {
			"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
		},
		"series": [
			{
				"data": [150, 230, 224, 218, 135, 147, 260]
			}
		]
	}`)
	// snip...

Current Project Status

Forked from vicanso/go-charts and the archived wcharczuk/go-chart, our project introduces enhancements for rendering challenging datasets. We aim to build upon their solid foundation to offer a more versatile and user-friendly charting solution.

API Stability

We're committed to refining the API, incorporating feedback and new ideas to enhance flexibility and ease of use.

Until the v1.0.0 release, API changes should be anticipated. We detail needed API changes on our wiki Version Migration Guide.

Changes

Notable improvements in our fork include:

  • Expanded Features: We continue to develop and extend this library. Recent additions include scatter charts with trend lines, a wide range of built-in themes, stacked series, improved support for eCharts configurations, and smooth line rendering.
  • Intuitive Configuration: Our goal is to ensure configuration options are clear and easy to use. In addition to refining the Go API, we have expanded our documentation in both GoDocs and the Wiki.
  • Expanded Testing: We are committed to comprehensive test coverage. Increased test coverage has led to significant bug fixes, ensuring better reliability across a wide range of configurations.

Our library is an evolving project, aiming to become a standout choice for Go developers seeking powerful yet easy-to-use charting tools. We welcome contributions and feedback as we continue to enhance our library's functionality, configurability, and reliability.

wcharczuk/go-chart Changes

If you're migrating from wcharczuk/go-chart, you should be able to migrate with minimal modifications. The wcharczuk/go-chart codebase has been integrated into our chartdraw package. Any necessary changes are documented in our wcharczuk/go‐chart Migration Guide.

Documentation

Index

Constants

View Source
const (
	ChartTypeLine          = "line"
	ChartTypeScatter       = "scatter"
	ChartTypeBar           = "bar"
	ChartTypePie           = "pie"
	ChartTypeDoughnut      = "doughnut"
	ChartTypeRadar         = "radar"
	ChartTypeFunnel        = "funnel"
	ChartTypeHorizontalBar = "horizontalBar"
	ChartTypeHeatMap       = "heatMap"
)
View Source
const (
	ChartOutputSVG = "svg"
	ChartOutputPNG = "png"
	ChartOutputJPG = "jpg"
)
View Source
const (
	PositionLeft   = "left"
	PositionRight  = "right"
	PositionCenter = "center"
	PositionTop    = "top"
	PositionBottom = "bottom"
)
View Source
const (
	AlignLeft   = "left"
	AlignRight  = "right"
	AlignCenter = "center"
)
View Source
const (
	SymbolNone    = "none"
	SymbolCircle  = "circle"
	SymbolDot     = "dot"
	SymbolSquare  = "square"
	SymbolDiamond = "diamond"
)
View Source
const (
	SeriesMarkTypeMax      = "max"
	SeriesMarkTypeMin      = "min"
	SeriesMarkTypeAverage  = "average"
	SeriesTrendTypeLinear  = "linear"
	SeriesTrendTypeCubic   = "cubic"
	SeriesTrendTypeAverage = "average"
)
View Source
const (
	// ThemeLight is the default theme used, with series colors from echarts.
	ThemeLight = "light"
	// ThemeDark is a dark alternative to the default theme 'light, with series colors from echarts'.
	ThemeDark = "dark"
	// ThemeVividLight is an alternative light theme that has red, yellow, and other bright colors initially in the series.
	// It can be a good option when you want the first few series items to grab the most attention.
	ThemeVividLight = "vivid-light"
	// ThemeVividDark is a dark alternative to 'ThemeVividLight', with the same bright initial series colors.
	ThemeVividDark = "vivid-dark"
	// ThemeGrafana is a grafana styled theme.
	ThemeGrafana = "grafana"
	// ThemeAnt is an ant styled theme.
	ThemeAnt = "ant"
	// ThemeNatureLight provides earthy color tones.
	ThemeNatureLight = "nature-light"
	// ThemeNatureDark provides earthy color tones with a dark background.
	ThemeNatureDark = "nature-dark"
	// ThemeRetro provides colors from the 50's and 60's, silver, maroon, tan, and other vintage colors.
	ThemeRetro = "retro"
	// ThemeOcean is a light colored theme that focuses on shades of green, blue, and other ocean colors.
	ThemeOcean = "ocean"
	// ThemeSlate is a dark theme with a slate background, and light pastel series colors.
	ThemeSlate = "slate"
	// ThemeGray is a light theme that only contains shades of gray.
	ThemeGray = "gray"
	// ThemeWinter is a light theme with shades of white and blue, some light purple.
	ThemeWinter = "winter"
	// ThemeSpring is a light theme with bright greens, yellows, and blues.
	ThemeSpring = "spring"
	// ThemeSummer is a light theme with red, orange, and yellow shades.
	ThemeSummer = "summer"
	// ThemeFall is a dark theme with shades of yellow, orange and brown.
	ThemeFall = "fall"
)

Variables

View Source
var (
	// ColorTransparent is a fully transparent color.
	ColorTransparent = drawing.ColorTransparent
	// ColorWhite is R: 255, G: 255, B: 255.
	ColorWhite = drawing.ColorWhite
	// ColorBlack is R: 0, G: 0, B: 0.
	ColorBlack = drawing.ColorBlack
	// ColorGray is R: 128, G: 128, B: 128.
	ColorGray = drawing.ColorGray
	// ColorRed is R: 255, G: 0, B: 0.
	ColorRed = drawing.ColorRed
	// ColorGreen is R: 0, G: 128, B: 0.
	ColorGreen = drawing.ColorGreen
	// ColorBlue is R: 0, G: 0, B: 255.
	ColorBlue = drawing.ColorBlue
	// ColorSilver is R: 192, G: 192, B: 192.
	ColorSilver = drawing.ColorSilver
	// ColorMaroon is R: 128, G: 0, B: 0.
	ColorMaroon = drawing.ColorMaroon
	// ColorPurple is R: 128, G: 0, B: 128.
	ColorPurple = drawing.ColorPurple
	// ColorFuchsia is R: 255, G: 0, B: 255.
	ColorFuchsia = drawing.ColorFuchsia
	// ColorLime is R: 0, G: 255, B: 0.
	ColorLime = drawing.ColorLime
	// ColorOlive is R: 128, G: 128, B: 0.
	ColorOlive = drawing.ColorOlive
	// ColorYellow is R: 255, G: 255, B: 0.
	ColorYellow = drawing.ColorYellow
	// ColorNavy is R: 0, G: 0, B: 128.
	ColorNavy = drawing.ColorNavy
	// ColorTeal is R: 0, G: 128, B: 128.
	ColorTeal = drawing.ColorTeal
	// ColorAqua (or Cyan) is R: 0, G: 255, B: 255.
	ColorAqua = drawing.ColorAqua
	// ColorDarkGray is R: 40, G: 40, B: 40.
	ColorDarkGray = Color{R: 40, G: 40, B: 40, A: 255}
	// ColorLightGray is R: 211, G: 211, B: 211.
	ColorLightGray = drawing.ColorLightGray
	// ColorSlateGray is R: 112, G: 128, B: 144.
	ColorSlateGray = drawing.ColorSlateGray
	// ColorLightSlateGray is R: 119, G: 136, B: 211.
	ColorLightSlateGray = drawing.ColorLightSlateGray
	// ColorAzure is R: 240, G: 255, B: 255.
	ColorAzure = drawing.ColorAzure
	// ColorBeige is R: 245, G: 245, B: 220.
	ColorBeige = drawing.ColorBeige
	// ColorBrown is R: 165, G: 42, B: 42.
	ColorBrown = drawing.ColorBrown
	// ColorChocolate is R: 210, G: 105, B: 30.
	ColorChocolate = drawing.ColorChocolate
	// ColorCoral is R: 255, G: 127, B: 80.
	ColorCoral = drawing.ColorCoral
	// ColorLightCoral is R: 240, G: 128, B: 128.
	ColorLightCoral = drawing.ColorLightCoral
	// ColorGold is R: 255, G: 215, B: 0.
	ColorGold = drawing.ColorGold
	// ColorIndigo is R: 75, G: 0, B: 130.
	ColorIndigo = drawing.ColorIndigo
	// ColorIvory is R: 255, G: 255, B: 250.
	ColorIvory = drawing.ColorIvory
	// ColorOrange is R: 255, G: 165, B: 0.
	ColorOrange = drawing.ColorOrange
	// ColorPink is R: 255, G: 192, B: 203.
	ColorPink = drawing.ColorPink
	// ColorPlum is R: 221, G: 160, B: 221.
	ColorPlum = drawing.ColorPlum
	// ColorSalmon is R: 250, G: 128, B: 114.
	ColorSalmon = drawing.ColorSalmon
	// ColorTan is R: 210, G: 180, B: 140.
	ColorTan = drawing.ColorTan
	// ColorKhaki is R: 240, G: 230, B: 140.
	ColorKhaki = drawing.ColorKhaki
	// ColorTurquoise is R: 64, G: 224, B: 208.
	ColorTurquoise = drawing.ColorTurquoise
	// ColorViolet is R: 238, G: 130, B: 238.
	ColorViolet = drawing.ColorViolet
	// ColorSkyBlue is R: 135, G: 206, B: 235.
	ColorSkyBlue = drawing.ColorSkyBlue
	// ColorLavender is R: 230, G: 230, B: 250.
	ColorLavender = drawing.ColorLavender
	// ColorThistle is R: 216, G: 191, B: 216.
	ColorThistle = drawing.ColorThistle

	// ColorBlackAlt1 is slightly lighter shade of black: R: 51, G: 51, B: 51.
	ColorBlackAlt1 = chartdraw.ColorBlack
	// ColorBlueAlt1 is lighter shade of blue: R:0, G: 116, B: 217.
	ColorBlueAlt1 = chartdraw.ColorBlue
	// ColorBlueAlt2 is a sea blue: R: 106, G: 195, B: 203.
	ColorBlueAlt2 = chartdraw.ColorAlternateBlue
	// ColorAquaAlt1 is a lighter aqua: R: 0, G: 217, B: 210.
	ColorAquaAlt1 = chartdraw.ColorCyan
	// ColorSageGreen is a more neutral green, R: 158, G: 188, B: 169.
	ColorSageGreen = Color{R: 156, G: 175, B: 136, A: 255}
	// ColorGreenAlt1 is lighter green: R: 0, G: 217, B: 101.
	ColorGreenAlt1 = chartdraw.ColorGreen
	// ColorGreenAlt2 is R: 42, G: 190, B: 137.
	ColorGreenAlt2 = chartdraw.ColorAlternateGreen
	// ColorGreenAlt3 is darker green: R: 59, G: 162, B: 114.
	ColorGreenAlt3 = Color{R: 59, G: 162, B: 114, A: 255}
	// ColorGreenAlt4 is darker green: R: 80, G: 134, B: 66.
	ColorGreenAlt4 = Color{R: 80, G: 143, B: 66, A: 255}
	// ColorRedAlt1 is slightly purple red: R: 217, G: 0, B: 116.
	ColorRedAlt1 = chartdraw.ColorRed
	// ColorRedAlt2 is darker purple red: R: 226, G: 77, B: 66.
	ColorRedAlt2 = Color{R: 226, G: 77, B: 66, A: 255}
	// ColorOrangeAlt1 is more typical orange: R: 217, G: 101, B: 0.
	ColorOrangeAlt1 = chartdraw.ColorOrange
	// ColorOrangeAlt2 is a lighter orange: R: 250, G: 200, B: 88.
	ColorOrangeAlt2 = Color{R: 250, G: 200, B: 88, A: 255}
	// ColorOrangeAlt3 is a lighter orange: R: 255, G: 152, B: 69.
	ColorOrangeAlt3 = Color{R: 255, G: 152, B: 69, A: 255}
	// ColorYellowAlt1 is a slightly darker yellow: R: 217, G: 210, B: 0.
	ColorYellowAlt1 = chartdraw.ColorYellow
	// ColorMustardYellow is a dark yellow, R: 200, G: 160, B: 60.
	ColorMustardYellow = Color{R: 200, G: 160, B: 60, A: 255}
	// ColorDesertSand is a very light yellow / tan, R: 226, G: 201, B: 175.
	ColorDesertSand = Color{R: 226, G: 201, B: 175, A: 255}
)
View Source
var BoxZero = chartdraw.BoxZero
View Source
var OffsetCenter = OffsetStr{Left: PositionCenter}
View Source
var OffsetLeft = OffsetStr{Left: PositionLeft}
View Source
var OffsetRight = OffsetStr{Left: PositionRight}

Functions

func DegreesToRadians added in v0.4.1

func DegreesToRadians(degrees float64) float64

DegreesToRadians returns degrees as radians.

func FormatValueHumanize added in v0.3.1

func FormatValueHumanize(value float64, decimals int, ensureTrailingZeros bool) string

FormatValueHumanize takes in a value and a specified precision, rounding to the specified precision and returning a human friendly number string including commas.

func FormatValueHumanizeShort added in v0.3.1

func FormatValueHumanizeShort(value float64, decimals int, ensureTrailingZeros bool) string

FormatValueHumanizeShort takes in a value and a specified precision, rounding to the specified precision and returning a human friendly number string including commas. If the value is over 1,000 it will be reduced to a shorter version with the appropriate k, M, G, T suffix.

func GetDefaultFont

func GetDefaultFont() *truetype.Font

GetDefaultFont get default font.

func GetFont

func GetFont(fontFamily string) *truetype.Font

GetFont get the font by font family or the default if the family is not installed.

func GetNullValue

func GetNullValue() float64

GetNullValue gets the null value, allowing you to set a series point with "no" value.

func InstallFont

func InstallFont(fontFamily string, data []byte) error

InstallFont installs the font for charts

func InstallTheme

func InstallTheme(name string, opt ThemeOption)

InstallTheme adds a theme to the catalog which can later be retrieved using GetTheme.

func IntSliceToFloat64 added in v0.5.0

func IntSliceToFloat64(slice []int) []float64

IntSliceToFloat64 converts an int slice to a float64 slice so that it can be used for chart values.

func Ptr added in v0.5.0

func Ptr[T any](val T) *T

Ptr is a helper function to help build config options which reference pointers.

func RadiansToDegrees added in v0.4.1

func RadiansToDegrees(value float64) float64

RadiansToDegrees translates a radian value to a degree value.

func RenderEChartsToJPG added in v0.5.1

func RenderEChartsToJPG(options string) ([]byte, error)

func RenderEChartsToPNG

func RenderEChartsToPNG(options string) ([]byte, error)

func RenderEChartsToSVG

func RenderEChartsToSVG(options string) ([]byte, error)

func SetDefaultChartDimensions added in v0.4.0

func SetDefaultChartDimensions(width, height int)

SetDefaultChartDimensions sets default width and height of charts if not otherwise specified in their configuration.

func SetDefaultFont

func SetDefaultFont(fontFamily string) error

SetDefaultFont set default font by name.

func SetDefaultTheme

func SetDefaultTheme(name string) error

SetDefaultTheme sets default theme by name.

func SliceToFloat64 added in v0.5.0

func SliceToFloat64[T any](slice []T, conversion func(T) float64) []float64

SliceToFloat64 converts a slice of arbitrary types to float64 to be used as chart values.

Types

type BarChartOption

type BarChartOption struct {
	// Theme specifies the colors used for the bar chart.
	Theme ColorPalette
	// Padding specifies the padding of bar chart.
	Padding Box
	// Deprecated: Font is deprecated, instead the font needs to be set on the SeriesLabel, or other specific elements.
	Font *truetype.Font
	// SeriesList provides the data population for the chart, typically constructed using NewSeriesListBar.
	SeriesList BarSeriesList
	// StackSeries if set to *true a single bar with the colored series stacked together will be rendered.
	// This feature will result in some options being ignored, including BarMargin and SeriesLabelPosition.
	// MarkLine is also interpreted differently, only the first Series will have the MarkLine rendered (as it's the
	// base bar, other bars are influenced by prior values). StackSeries will only apply to the first YAxis (index 0).
	StackSeries *bool
	// SeriesLabelPosition specifies the position of the label for the series. Currently supported values are
	// "top" or "bottom".
	SeriesLabelPosition string
	// XAxis are options for the x-axis.
	XAxis XAxisOption
	// YAxis are options for the y-axis (at most two).
	YAxis []YAxisOption
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// BarWidth specifies the width of each bar. Width may be reduced to ensure all series fit on the chart.
	BarWidth int
	// BarMargin specifies the margin between bars grouped together. BarWidth takes priority over the margin.
	BarMargin *float64
	// RoundedBarCaps set to *true to produce a bar graph where the bars have rounded tops.
	RoundedBarCaps *bool
	// ValueFormatter defines how float values should be rendered to strings, notably for numeric axis labels.
	ValueFormatter ValueFormatter
}

BarChartOption defines the options for rendering a bar chart. Render the chart using Painter.BarChart.

func NewBarChartOptionWithData added in v0.4.0

func NewBarChartOptionWithData(data [][]float64) BarChartOption

NewBarChartOptionWithData returns an initialized BarChartOption with the SeriesList set for the provided data slice.

func NewBarChartOptionWithSeries added in v0.5.9

func NewBarChartOptionWithSeries(sl BarSeriesList) BarChartOption

NewBarChartOptionWithSeries returns an initialized BarChartOption with the provided SeriesList.

type BarSeries added in v0.5.0

type BarSeries struct {
	// Values provides the series data values.
	Values []float64
	// YAxisIndex is the index for the axis, it must be 0 or 1.
	YAxisIndex int
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
	// MarkPoint provides a configuration for mark points for this series. If Label is also enabled, the MarkPoint
	// will replace the label where rendered.
	MarkPoint SeriesMarkPoint
	// MarkLine provides a configuration for mark lines for this series. When using a MarkLine, you will want to
	// configure padding to the chart on the right for the values.
	MarkLine SeriesMarkLine
}

BarSeries references a population of data for bar charts.

func (*BarSeries) Summary added in v0.5.0

func (b *BarSeries) Summary() populationSummary

type BarSeriesList added in v0.5.0

type BarSeriesList []BarSeries

BarSeriesList provides the data populations for line charts (BarChartOption).

func NewSeriesListBar added in v0.4.0

func NewSeriesListBar(values [][]float64, opts ...BarSeriesOption) BarSeriesList

NewSeriesListBar builds a SeriesList for a bar chart. The first dimension of the values indicates the population of the data, while the second dimension provides the samples for the population (on the X-Axis).

func (BarSeriesList) SetSeriesLabels added in v0.5.6

func (b BarSeriesList) SetSeriesLabels(label SeriesLabel)

SetSeriesLabels sets the label for all elements in the series.

func (BarSeriesList) SumSeries added in v0.5.0

func (b BarSeriesList) SumSeries() []float64

SumSeries returns a float64 slice with the sum of each series matching in order to the series of the list.

func (BarSeriesList) SumSeriesValues added in v0.5.0

func (b BarSeriesList) SumSeriesValues() []float64

SumSeriesValues returns a float64 slice with each series in the list totaled for the value index.

func (BarSeriesList) ToGenericSeriesList added in v0.5.0

func (b BarSeriesList) ToGenericSeriesList() GenericSeriesList

type BarSeriesOption added in v0.4.0

type BarSeriesOption struct {
	Label     SeriesLabel
	Names     []string
	MarkPoint SeriesMarkPoint
	MarkLine  SeriesMarkLine
}

BarSeriesOption provides series customization for NewSeriesListBar or NewSeriesListHorizontalBar.

type Box

type Box = chartdraw.Box

func NewBox added in v0.4.6

func NewBox(left, top, right, bottom int) Box

NewBox returns a new box with the provided left, top, right, and bottom sizes.

func NewBoxEqual added in v0.4.6

func NewBoxEqual(size int) Box

NewBoxEqual returns a new box with equal sizes to each side.

type ChartOption

type ChartOption struct {
	// OutputFormat specifies the output type of chart, "svg", "png" or "jpg", default value is "png".
	OutputFormat string
	// Width is the width of chart.
	Width int
	// Height is the height of chart.
	Height int
	// Theme specifies the colors used for the chart. Built in themes can be loaded using GetTheme with
	// "light", "dark", "vivid-light", "vivid-dark", "ant" or "grafana".
	Theme ColorPalette
	// Padding specifies the padding for chart, default padding is [20, 20, 20, 20].
	Padding Box
	// XAxis are options for the x-axis.
	XAxis XAxisOption
	// YAxis are options for the y-axis (at most two).
	YAxis []YAxisOption
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// Deprecated: Font is deprecated, instead the font needs to be set on the SeriesLabel, or other specific elements.
	Font *truetype.Font
	// Box specifies the canvas box for the chart.
	Box Box
	// SeriesList provides the population data for the charts, constructed through NewSeriesListGeneric.
	SeriesList GenericSeriesList
	// StackSeries if set to *true the lines will be layered or stacked. This option significantly changes the chart
	// visualization, please see the specific chart docs for full details.
	StackSeries *bool
	// RadarIndicators are radar indicator list for radar charts.
	RadarIndicators []RadarIndicator
	// Symbol specifies the symbols to draw at the data points. Empty (default) will vary based on the dataset.
	// Specify 'none' to enforce no symbol, or specify a desired symbol: 'circle', 'dot', 'square', 'diamond'.
	Symbol Symbol
	// LineStrokeWidth is the stroke width for line charts.
	LineStrokeWidth float64
	// FillArea set to *true to fill the area under the line in line charts
	FillArea *bool
	// FillOpacity is the opacity (alpha) of the area fill in line charts.
	FillOpacity uint8
	// Deprecated: BarWidth is deprecated, instead use BarSize.
	BarWidth int
	// Deprecated: BarHeight is deprecated, instead use BarSize.
	BarHeight int
	// BarSize represents the width of the bar, or if a horizontal bar chart the height.
	BarSize int
	// BarMargin specifies the margin between bars grouped together. BarWidth or BarHeight takes priority over the margin.
	BarMargin *float64
	// Radius default radius for pie and radar charts e.g.: 40%, default is "40%"
	Radius string
	// Children are Child charts to render together.
	Children []ChartOption

	// ValueFormatter to format numeric values into labels.
	ValueFormatter ValueFormatter
	// contains filtered or unexported fields
}

ChartOption represents a generic method of representing a chart. This can be useful when you want to render different chart types with the same data and configuration.

type Color

type Color = drawing.Color

func ColorConvertGo added in v0.4.4

func ColorConvertGo(c color.RGBA) Color

ColorConvertGo converts go's built in colors to our Color struct. This allows easy use of colors defined in image/colornames.

func ColorFromHex added in v0.4.4

func ColorFromHex(hex string) Color

ColorFromHex returns a color from a css hex code.

NOTE: it will trim a leading '#' character if present.

func ColorFromKnown added in v0.4.4

func ColorFromKnown(known string) Color

ColorFromKnown returns an internal color from a known (basic) color name.

func ColorFromRGBA added in v0.4.4

func ColorFromRGBA(color string) Color

ColorFromRGBA returns a color from a `rgb(i,i,i)` or `rgba(i,i,i,f)` css function.

func ColorRGB added in v0.4.4

func ColorRGB(r, g, b uint8) Color

ColorRGB constructs a fully opaque color with the color specified.

func ParseColor added in v0.3.2

func ParseColor(rawColor string) Color

ParseColor parses a color from a string. The color can be specified in hex with a `#` prefix (for example '#313233'), in rgb(i,i,i) or rgba(i,i,i,f) format, or as a common name (for example 'red').

type ColorPalette

type ColorPalette interface {
	IsDark() bool
	GetXAxisStrokeColor() Color
	GetYAxisStrokeColor() Color
	GetAxisSplitLineColor() Color
	GetSeriesColor(int) Color
	GetSeriesTrendColor(int) Color
	GetBackgroundColor() Color
	GetTitleTextColor() Color
	GetMarkTextColor() Color
	GetLabelTextColor() Color
	GetLegendTextColor() Color
	GetXAxisTextColor() Color
	GetYAxisTextColor() Color
	GetTitleBorderColor() Color
	GetLegendBorderColor() Color
	// WithXAxisColor will provide a new ColorPalette that uses the specified color for X axis. To adjust the text
	// color invoke WithXAxisTextColor following this.
	WithXAxisColor(Color) ColorPalette
	// WithYAxisColor will provide a new ColorPalette that uses the specified color for Y axis. To adjust the text
	// color invoke WithYAxisTextColor following this.
	WithYAxisColor(Color) ColorPalette
	// WithYAxisSeriesColor will provide a new ColorPalette that uses the specified series index color for Y axis and values.
	WithYAxisSeriesColor(int) ColorPalette
	// WithTitleTextColor will provide a new ColorPalette that uses the specified color for the title text.
	WithTitleTextColor(Color) ColorPalette
	// WithMarkTextColor will provide a new ColorPalette that uses the specified color for mark point and mark line labels.
	WithMarkTextColor(Color) ColorPalette
	// WithLabelTextColor will provide a new ColorPalette that uses the specified color for value labels.
	WithLabelTextColor(Color) ColorPalette
	// WithLegendTextColor will provide a new ColorPalette that uses the specified color for the legend labels
	WithLegendTextColor(Color) ColorPalette
	// WithXAxisTextColor will provide a new ColorPalette that uses the specified color for the x-axis labels.
	WithXAxisTextColor(Color) ColorPalette
	// WithYAxisTextColor will provide a new ColorPalette that uses the specified color for the y-axis labels.
	WithYAxisTextColor(Color) ColorPalette
	// WithSeriesColors will provide a new ColorPalette that uses the specified series colors. This will default the
	// trend line colors to be related to the series colors provided. If you want to customize them further use
	// WithSeriesTrendColors.
	WithSeriesColors([]Color) ColorPalette
	// WithSeriesTrendColors will provide a new ColorPalette that uses the specified series trend line colors.
	WithSeriesTrendColors([]Color) ColorPalette
	// WithBackgroundColor will provide a new ColorPalette that uses the specified color for the background.
	WithBackgroundColor(Color) ColorPalette
	// WithTitleBorderColor will provide a new ColorPalette that uses the specified color for the title border.
	WithTitleBorderColor(Color) ColorPalette
	// WithLegendBorderColor will provide a new ColorPalette that uses the specified color for the legend border.
	WithLegendBorderColor(Color) ColorPalette
}

ColorPalette provides the theming for the chart.

func GetDefaultTheme

func GetDefaultTheme() ColorPalette

GetDefaultTheme returns the default theme.

func GetTheme

func GetTheme(name string) ColorPalette

GetTheme returns an installed theme by name, or the default if the theme is not installed.

func MakeTheme

func MakeTheme(opt ThemeOption) ColorPalette

MakeTheme constructs a one-off theme without installing it into the catalog.

type DoughnutChartOption added in v0.5.6

type DoughnutChartOption struct {
	// Theme specifies the colors used for the doughnut chart.
	Theme ColorPalette
	// Padding specifies the padding of doughnut chart.
	Padding Box
	// SeriesList provides the data population for the chart, typically constructed using NewSeriesListDoughnut.
	SeriesList DoughnutSeriesList
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// RadiusRing default outer radius for the ring e.g.: 40%, default is "40%"
	RadiusRing string
	// RadiusCenter is the radius for the center hold of the doughnut. Must be smaller than RadiusRing.
	RadiusCenter string
	// CenterValues specifies what should be rendered in the center of the doughnut,
	// current options are "none" (default), "labels", "sum".
	// * labels - Will render the labels on the inside of the circle instead of the outside (more risk of collision).
	// * sum - Will put the sum count of all the series (formatted using ValueFormatter).
	CenterValues string
	// CenterValuesFontStyle provides the styling for center values (series labels prefer their specific series styling).
	CenterValuesFontStyle FontStyle
	// SegmentGap provides a margin between each series section.
	SegmentGap float64
	// ValueFormatter defines how float values should be rendered to strings, notably for series labels.
	ValueFormatter ValueFormatter
}

DoughnutChartOption defines the options for rendering a doughnut chart. Render the chart using Painter.DoughnutChart.

func NewDoughnutChartOptionWithData added in v0.5.6

func NewDoughnutChartOptionWithData(data []float64) DoughnutChartOption

NewDoughnutChartOptionWithData returns an initialized DoughnutChartOption with the SeriesList set from the provided data slice.

type DoughnutSeries added in v0.5.6

type DoughnutSeries struct {
	// Value provides the value for the Doughnut section.
	Value float64
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
	// Radius for Doughnut chart, e.g.: 40%, default is "40%"
	Radius string
}

DoughnutSeries references a population of data for doughnut charts.

type DoughnutSeriesList added in v0.5.6

type DoughnutSeriesList []DoughnutSeries

DoughnutSeriesList provides the data populations for Doughnut charts (DoughnutChartOption).

func NewSeriesListDoughnut added in v0.5.6

func NewSeriesListDoughnut(values []float64, opts ...DoughnutSeriesOption) DoughnutSeriesList

NewSeriesListDoughnut builds a SeriesList for a doughnut chart.

func (DoughnutSeriesList) MaxValue added in v0.5.6

func (d DoughnutSeriesList) MaxValue() float64

MaxValue returns the maximum value within the series, or MinInt64 if no values.

func (DoughnutSeriesList) SetSeriesLabels added in v0.5.6

func (d DoughnutSeriesList) SetSeriesLabels(label SeriesLabel)

SetSeriesLabels sets the label for all elements in the series.

func (DoughnutSeriesList) SumSeries added in v0.5.6

func (d DoughnutSeriesList) SumSeries() float64

func (DoughnutSeriesList) ToGenericSeriesList added in v0.5.6

func (d DoughnutSeriesList) ToGenericSeriesList() GenericSeriesList

type DoughnutSeriesOption added in v0.5.6

type DoughnutSeriesOption struct {
	Label SeriesLabel
	Names []string
}

DoughnutSeriesOption provides series customization for NewSeriesListDoughnut.

type EChartStyle

type EChartStyle struct {
	Color   string   `json:"color"`
	Opacity *float64 `json:"opacity,omitempty"`
}

type EChartsAxisLabel

type EChartsAxisLabel struct {
	Formatter string `json:"formatter,omitempty"`
	Show      *bool  `json:"show,omitempty"`
	Color     string `json:"color,omitempty"`
	FontSize  *int   `json:"fontSize,omitempty"`
}

type EChartsAxisLine added in v0.5.0

type EChartsAxisLine struct {
	Show      *bool `json:"show,omitempty"`
	LineStyle struct {
		Color   string   `json:"color,omitempty"`
		Opacity *float64 `json:"opacity,omitempty"`
		Width   *int     `json:"width,omitempty"` // TODO - add support
	} `json:"lineStyle,omitempty"`
}

type EChartsLabelOption

type EChartsLabelOption struct {
	Show     bool   `json:"show"`
	Distance int    `json:"distance"`
	Color    string `json:"color"`
}

type EChartsLegend

type EChartsLegend struct {
	Show            *bool            `json:"show"`
	Data            []string         `json:"data"`
	Align           string           `json:"align"`
	Orient          string           `json:"orient"`
	Padding         EChartsPadding   `json:"padding,omitempty"`
	Left            EChartsPosition  `json:"left"`
	Top             EChartsPosition  `json:"top"`
	TextStyle       EChartsTextStyle `json:"textStyle"`
	BackgroundColor string           `json:"backgroundColor,omitempty"` // TODO - add support
	BorderColor     string           `json:"borderColor,omitempty"`
}

type EChartsMarkData

type EChartsMarkData struct {
	Type string `json:"type"`
	// TODO - support position values below
	XAxis float64 `json:"xAxis,omitempty"`
	YAxis float64 `json:"yAxis,omitempty"`
}

func (*EChartsMarkData) UnmarshalJSON

func (emd *EChartsMarkData) UnmarshalJSON(data []byte) error

type EChartsMarkLine

type EChartsMarkLine struct {
	Data []EChartsMarkData `json:"data"`
}

func (*EChartsMarkLine) ToSeriesMarkLine

func (eml *EChartsMarkLine) ToSeriesMarkLine() SeriesMarkLine

type EChartsMarkPoint

type EChartsMarkPoint struct {
	SymbolSize int               `json:"symbolSize"`
	Data       []EChartsMarkData `json:"data"`
}

func (*EChartsMarkPoint) ToSeriesMarkPoint

func (emp *EChartsMarkPoint) ToSeriesMarkPoint() SeriesMarkPoint

type EChartsOption

type EChartsOption struct {
	Type       string         `json:"type"`
	Theme      string         `json:"theme"`
	FontFamily string         `json:"fontFamily"`
	Padding    EChartsPadding `json:"padding"`
	Box        Box            `json:"box"`
	Width      int            `json:"width"`
	Height     int            `json:"height"`
	Title      struct {
		Show            *bool            `json:"show,omitempty"`
		Text            string           `json:"text"`
		Subtext         string           `json:"subtext"`
		Left            EChartsPosition  `json:"left"`
		Top             EChartsPosition  `json:"top"`
		TextStyle       EChartsTextStyle `json:"textStyle"`
		SubtextStyle    EChartsTextStyle `json:"subtextStyle"`
		BackgroundColor string           `json:"backgroundColor,omitempty"` // TODO - add support
		BorderColor     string           `json:"borderColor,omitempty"`
	} `json:"title"`
	XAxis  EChartsXAxis  `json:"xAxis"`
	YAxis  EChartsYAxis  `json:"yAxis"`
	Legend EChartsLegend `json:"legend"`
	Radar  struct {
		Indicator []RadarIndicator `json:"indicator"`
	} `json:"radar"`
	Series          EChartsSeriesList `json:"series"`
	BackgroundColor string            `json:"backgroundColor,omitempty"`
	Children        []EChartsOption   `json:"children"`
}

func (*EChartsOption) ToOption

func (eo *EChartsOption) ToOption() ChartOption

type EChartsPadding

type EChartsPadding struct {
	Box Box
}

func (*EChartsPadding) UnmarshalJSON

func (eb *EChartsPadding) UnmarshalJSON(data []byte) error

type EChartsPosition

type EChartsPosition string

func (*EChartsPosition) UnmarshalJSON

func (p *EChartsPosition) UnmarshalJSON(data []byte) error

type EChartsSeries

type EChartsSeries struct {
	Data       []EChartsSeriesData `json:"data"`
	Name       string              `json:"name"`
	Type       string              `json:"type"`
	Radius     string              `json:"radius"`
	YAxisIndex int                 `json:"yAxisIndex"`
	ItemStyle  EChartStyle         `json:"itemStyle,omitempty"` // TODO - add support
	// label configuration
	Label     EChartsLabelOption `json:"label"`
	MarkPoint EChartsMarkPoint   `json:"markPoint"`
	MarkLine  EChartsMarkLine    `json:"markLine"`
	Max       *float64           `json:"max"` // TODO - add support
	Min       *float64           `json:"min"` // TODO - add support
}

type EChartsSeriesData

type EChartsSeriesData struct {
	Value     EChartsSeriesDataValue `json:"value"`
	Name      string                 `json:"name"`
	ItemStyle EChartStyle            `json:"itemStyle,omitempty"` // TODO - add support
}

func (*EChartsSeriesData) UnmarshalJSON

func (es *EChartsSeriesData) UnmarshalJSON(data []byte) error

type EChartsSeriesDataValue

type EChartsSeriesDataValue struct {
	// contains filtered or unexported fields
}

func (*EChartsSeriesDataValue) First

func (value *EChartsSeriesDataValue) First() float64

func (*EChartsSeriesDataValue) UnmarshalJSON

func (value *EChartsSeriesDataValue) UnmarshalJSON(data []byte) error

type EChartsSeriesList

type EChartsSeriesList []EChartsSeries

func (EChartsSeriesList) ToSeriesList

func (esList EChartsSeriesList) ToSeriesList() GenericSeriesList

type EChartsTextStyle

type EChartsTextStyle struct {
	Color      string  `json:"color"`
	FontFamily string  `json:"fontFamily"`
	FontSize   float64 `json:"fontSize"`
}

func (*EChartsTextStyle) ToFontStyle added in v0.5.0

func (et *EChartsTextStyle) ToFontStyle() FontStyle

type EChartsXAxis

type EChartsXAxis struct {
	Data []EChartsXAxisData
}

func (*EChartsXAxis) UnmarshalJSON

func (ex *EChartsXAxis) UnmarshalJSON(data []byte) error

type EChartsXAxisData

type EChartsXAxisData struct {
	BoundaryGap *bool            `json:"boundaryGap,omitempty"`
	SplitNumber int              `json:"splitNumber,omitempty"`
	AxisLabel   EChartsAxisLabel `json:"axisLabel,omitempty"`
	AxisLine    EChartsAxisLine  `json:"axisLine,omitempty"`
	Data        []string         `json:"data"`
	Type        string           `json:"type"`
}

type EChartsYAxis

type EChartsYAxis struct {
	Data []EChartsYAxisData `json:"data"`
}

func (*EChartsYAxis) UnmarshalJSON

func (ey *EChartsYAxis) UnmarshalJSON(data []byte) error

type EChartsYAxisData

type EChartsYAxisData struct {
	Min       *float64         `json:"min,omitempty"`
	Max       *float64         `json:"max,omitempty"`
	AxisLabel EChartsAxisLabel `json:"axisLabel,omitempty"`
	AxisLine  EChartsAxisLine  `json:"axisLine,omitempty"`
	Data      []string         `json:"data"`
}

type FontStyle added in v0.2.0

type FontStyle = chartdraw.FontStyle

func NewFontStyleWithSize added in v0.4.7

func NewFontStyleWithSize(size float64) FontStyle

NewFontStyleWithSize constructs a new FontStyle with the specified font size. If you want to avoid directly constructing the FontStyle struct, you can use this followed by additional `WithX` function calls on the returned FontStyle.

type FunnelChartOption

type FunnelChartOption struct {
	// Theme specifies the colors used for the chart.
	Theme ColorPalette
	// Padding specifies the padding of funnel chart.
	Padding Box
	// Deprecated: Font is deprecated, instead the font needs to be set on the SeriesLabel, or other specific elements.
	Font *truetype.Font
	// SeriesList provides the data population for the chart, typically constructed using NewSeriesListFunnel.
	SeriesList FunnelSeriesList
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// ValueFormatter defines how float values should be rendered to strings, notably for series labels.
	ValueFormatter ValueFormatter
}

FunnelChartOption defines the options for rendering a funnel chart. Render the chart using Painter.FunnelChart.

func NewFunnelChartOptionWithData added in v0.4.0

func NewFunnelChartOptionWithData(data []float64) FunnelChartOption

NewFunnelChartOptionWithData returns an initialized FunnelChartOption with the SeriesList set for the provided data slice.

type FunnelSeries added in v0.5.0

type FunnelSeries struct {
	// Value provides the value for the funnel section.
	Value float64
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
}

FunnelSeries references a population of data for funnel charts.

type FunnelSeriesList added in v0.5.0

type FunnelSeriesList []FunnelSeries

FunnelSeriesList provides the data populations for funnel charts (FunnelChartOption).

func NewSeriesListFunnel added in v0.4.0

func NewSeriesListFunnel(values []float64, opts ...FunnelSeriesOption) FunnelSeriesList

NewSeriesListFunnel builds a series list for funnel charts.

func (FunnelSeriesList) SetSeriesLabels added in v0.5.6

func (f FunnelSeriesList) SetSeriesLabels(label SeriesLabel)

SetSeriesLabels sets the label for all elements in the series.

func (FunnelSeriesList) ToGenericSeriesList added in v0.5.0

func (f FunnelSeriesList) ToGenericSeriesList() GenericSeriesList

type FunnelSeriesOption added in v0.4.0

type FunnelSeriesOption struct {
	Label SeriesLabel
	Names []string
}

FunnelSeriesOption provides series customization for NewSeriesListFunnel.

type GenericSeries added in v0.5.0

type GenericSeries struct {
	// Type is the type of series, it can be "line", "bar" or "pie". Default value is "line".
	Type string
	// Values provides the series data values.
	Values []float64
	// YAxisIndex is the index for the axis, it must be 0 or 1.
	YAxisIndex int
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
	// Radius for Pie chart, e.g.: 40%, default is "40%"
	Radius string
	// MarkPoint provides a configuration for mark points for this series. If Label is also enabled, the MarkPoint
	// will replace the label where rendered.
	MarkPoint SeriesMarkPoint
	// MarkLine provides a configuration for mark lines for this series. When using a MarkLine, you will want to
	// configure padding to the chart on the right for the values.
	MarkLine SeriesMarkLine
}

GenericSeries references a population of data for any type of charts. The chart specific fields will only be active for chart types which support them.

type GenericSeriesList added in v0.5.0

type GenericSeriesList []GenericSeries

GenericSeriesList provides the data populations for any chart type configured through ChartOption.

func NewSeriesListGeneric added in v0.5.0

func NewSeriesListGeneric(values [][]float64, chartType string) GenericSeriesList

NewSeriesListGeneric returns a Generic series list for the given values and chart type (used in ChartOption).

func (GenericSeriesList) SetSeriesLabels added in v0.5.6

func (g GenericSeriesList) SetSeriesLabels(label SeriesLabel)

SetSeriesLabels sets the label for all elements in the series.

type HeatMapAxis added in v0.5.1

type HeatMapAxis struct {
	// Title specifies the title to display next to the axis, if any.
	Title string
	// TitleFontStyle specifies the font style for the axis title.
	TitleFontStyle FontStyle
	// Labels specifies custom labels to display along the axis. If empty or nil, numeric indices are used. Must match the size of Values for the given axis.
	Labels []string
	// LabelFontStyle specifies the font style for the axis labels.
	LabelFontStyle FontStyle
	// LabelRotation are the radians for rotating the label. Convert from degrees using DegreesToRadians(float64).
	LabelRotation float64
	// LabelCount is the number of labels to show on the axis. Specify a smaller number to reduce writing collisions.
	LabelCount int
	// LabelCountAdjustment specifies a relative influence on how many labels should be rendered.
	// Typically, this is negative to result in cleaner graphs, positive values may result in text collisions.
	LabelCountAdjustment int
}

HeatMapAxis contains configuration options for an axis on a heat map chart.

type HeatMapOption added in v0.5.1

type HeatMapOption struct {
	// Theme specifies the color palette used for rendering the heat map.
	Theme ColorPalette
	// BaseColorIndex specifies which color from the theme palette to use as the base for gradients.
	BaseColorIndex int
	// Padding specifies the padding around the heat map chart.
	Padding Box
	// Deprecated: Font is deprecated, instead the font needs to be set on the SeriesLabel, or other specific elements.
	Font *truetype.Font
	// Title options for rendering the chart title, including text and font styling.
	Title TitleOption
	// Values provides the 2D slice of float64 values representing the data for the heat map.
	// The outer slice represents the rows (Y-axis) and the inner slice represents the columns (X-axis).
	Values [][]float64
	// XAxis specifies the configuration options for the X-axis.
	XAxis HeatMapAxis
	// YAxis specifies the configuration options for the Y-axis.
	YAxis HeatMapAxis
	// ScaleMinValue overrides the minimum value used for color gradient calculation. If nil, calculated from data.
	ScaleMinValue *float64
	// ScaleMaxValue overrides the maximum value used for color gradient calculation. If nil, calculated from data.
	ScaleMaxValue *float64
	// ValuesLabel configuration for displaying numeric values on top of heat map cells.
	ValuesLabel SeriesLabel
}

HeatMapOption contains configuration options for a heat map chart. Render the chart using Painter.HeatMapChart.

func NewHeatMapOptionWithData added in v0.5.1

func NewHeatMapOptionWithData(data [][]float64) HeatMapOption

NewHeatMapOptionWithData returns an initialized HeatMapOption with the provided data.

type HorizontalBarChartOption

type HorizontalBarChartOption struct {
	// Theme specifies the colors used for the chart.
	Theme ColorPalette
	// Padding specifies the padding of bar chart.
	Padding Box
	// Deprecated: Font is deprecated, instead the font needs to be set on the SeriesLabel, or other specific elements.
	Font *truetype.Font
	// SeriesList provides the data population for the chart, typically constructed using NewSeriesListHorizontalBar.
	SeriesList HorizontalBarSeriesList
	// StackSeries if set to *true a single bar with the colored series stacked together will be rendered.
	// This feature will result in some options being ignored, including BarMargin and SeriesLabelPosition.
	// MarkLine is also interpreted differently, only the first Series will have the MarkLine rendered (as it's the
	// base bar, other bars are influenced by prior values).
	StackSeries *bool
	// SeriesLabelPosition specifies the position of the label for the series. Currently supported values are
	// "left" or "right".
	SeriesLabelPosition string
	// XAxis are options for the x-axis.
	XAxis XAxisOption
	// YAxis are options for the y-axis.
	YAxis YAxisOption
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// BarHeight specifies the height of each horizontal bar. Height may be reduced to ensure all series fit on the chart.
	BarHeight int
	// BarMargin specifies the margin between bars grouped together. BarHeight takes priority over the margin.
	BarMargin *float64
	// ValueFormatter defines how float values should be rendered to strings, notably for numeric axis labels.
	ValueFormatter ValueFormatter
}

HorizontalBarChartOption defines the options for rendering a horizontal bar chart. Render the chart using Painter.HorizontalBarChart.

func NewHorizontalBarChartOptionWithData added in v0.4.0

func NewHorizontalBarChartOptionWithData(data [][]float64) HorizontalBarChartOption

NewHorizontalBarChartOptionWithData returns an initialized HorizontalBarChartOption with the SeriesList set for the provided data slice.

type HorizontalBarSeries added in v0.5.0

type HorizontalBarSeries struct {
	// Values provides the series data values.
	Values []float64
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
	// MarkLine provides a configuration for mark lines for this series.
	MarkLine SeriesMarkLine
}

HorizontalBarSeries references a population of data for horizontal bar charts.

func (*HorizontalBarSeries) Summary added in v0.5.0

func (h *HorizontalBarSeries) Summary() populationSummary

type HorizontalBarSeriesList added in v0.5.0

type HorizontalBarSeriesList []HorizontalBarSeries

HorizontalBarSeriesList provides the data populations for horizontal bar charts (HorizontalBarChartOption).

func NewSeriesListHorizontalBar added in v0.4.0

func NewSeriesListHorizontalBar(values [][]float64, opts ...BarSeriesOption) HorizontalBarSeriesList

NewSeriesListHorizontalBar builds a SeriesList for a horizontal bar chart. Horizontal bar charts are unique in that these Series can not be combined with any other chart type.

func (HorizontalBarSeriesList) SetSeriesLabels added in v0.5.6

func (h HorizontalBarSeriesList) SetSeriesLabels(label SeriesLabel)

SetSeriesLabels sets the label for all elements in the series.

func (HorizontalBarSeriesList) SumSeries added in v0.5.0

func (h HorizontalBarSeriesList) SumSeries() []float64

SumSeries returns a float64 slice with the sum of each series matching in order to the series of the list.

func (HorizontalBarSeriesList) SumSeriesValues added in v0.5.0

func (h HorizontalBarSeriesList) SumSeriesValues() []float64

SumSeriesValues returns a float64 slice with each series in the list totaled for the value index.

func (HorizontalBarSeriesList) ToGenericSeriesList added in v0.5.0

func (h HorizontalBarSeriesList) ToGenericSeriesList() GenericSeriesList

type LegendOption

type LegendOption struct {
	// Show specifies if the legend should be rendered, set this to *false (through Ptr(false)) to hide the legend.
	Show *bool
	// Theme specifies the colors used for the legend.
	Theme ColorPalette
	// SeriesNames provides text labels for the legend.
	SeriesNames []string
	// FontStyle specifies the font, size, and style for rendering the legend.
	FontStyle FontStyle
	// Padding specifies space padding around the legend.
	Padding Box
	// Offset allows you to specify the position of the legend component relative to the left and top side.
	Offset OffsetStr
	// Align is the legend marker and text alignment, it can be 'left', 'right' or 'center', default is 'left'.
	Align string
	// Vertical can be set to *true to set the legend orientation to be vertical.
	Vertical *bool
	// Symbol defines the icon shape next to the label. Can be 'square', 'dot', or 'diamond'.
	Symbol Symbol
	// OverlayChart can be set to *true to render the legend over the chart. Ignored if Vertical is set to true (always overlapped).
	OverlayChart *bool
	// BorderWidth can be set to a non-zero value to render a box around the legend.
	BorderWidth float64
	// contains filtered or unexported fields
}

func (*LegendOption) IsEmpty

func (opt *LegendOption) IsEmpty() bool

IsEmpty checks legend is empty

type LineChartOption

type LineChartOption struct {
	// Theme specifies the colors used for the line chart.
	Theme ColorPalette
	// Padding specifies the padding of line chart.
	Padding Box
	// Deprecated: Font is deprecated, instead the font needs to be set on the SeriesLabel, or other specific elements.
	Font *truetype.Font
	// SeriesList provides the data population for the chart, typically constructed using NewSeriesListLine.
	SeriesList LineSeriesList
	// StackSeries if set to *true the lines will be layered over each other, with the last series value representing
	// the sum of all the values. Enabling this will also enable FillArea (which until v0.5 can't be disabled).
	// Some options will be ignored when StackedSeries is enabled, this includes StrokeSmoothingTension.
	// MarkLine is also interpreted differently, only the first Series will have the MarkLine rendered (as it's the
	// base bar, other bars are influenced by prior values). Additionally only the 0 index y-axis is stacked,
	// allowing a non-stacked line to also be included on y-axis 1.
	StackSeries *bool
	// XAxis are options for the x-axis.
	XAxis XAxisOption
	// YAxis are options for the y-axis (at most two).
	YAxis []YAxisOption
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// Symbol specifies the symbols to draw at the data points. Empty (default) will vary based on the dataset.
	// Specify 'none' to enforce no symbol, or specify a desired symbol: 'circle', 'dot', 'square', 'diamond'. This can
	// also be set on each series specifically.
	Symbol Symbol
	// LineStrokeWidth is the width of the rendered line.
	LineStrokeWidth float64
	// StrokeSmoothingTension should be between 0 and 1. At 0 perfectly straight lines will be used with 1 providing
	// smoother lines. Because the tension smooths out the line, the line will no longer hit the data points exactly.
	// The more variable the points, and the higher the tension, the more the line will be moved from the points.
	StrokeSmoothingTension float64
	// FillArea set this to true to fill the area below the line.
	FillArea *bool
	// FillOpacity is the opacity (alpha) of the area fill.
	FillOpacity uint8
	// ValueFormatter defines how float values should be rendered to strings, notably for numeric axis labels.
	ValueFormatter ValueFormatter
}

LineChartOption defines the options for rendering a line chart. Render the chart using Painter.LineChart.

func NewLineChartOptionWithData added in v0.4.0

func NewLineChartOptionWithData(data [][]float64) LineChartOption

NewLineChartOptionWithData returns an initialized LineChartOption with the SeriesList set for the provided data slice.

func NewLineChartOptionWithSeries added in v0.5.9

func NewLineChartOptionWithSeries(sl LineSeriesList) LineChartOption

NewLineChartOptionWithSeries returns an initialized LineChartOption with the provided SeriesList.

type LineSeries added in v0.5.0

type LineSeries struct {
	// Values provides the series data values.
	Values []float64
	// YAxisIndex is the index for the axis, it must be 0 or 1.
	YAxisIndex int
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
	// MarkPoint provides a configuration for mark points for this series. If Label is also enabled, the MarkPoint
	// will replace the label where rendered.
	MarkPoint SeriesMarkPoint
	// MarkLine provides a configuration for mark lines for this series. When using a MarkLine, you will want to
	// configure padding to the chart on the right for the values.
	MarkLine SeriesMarkLine
	// Symbol specifies a custom symbol for the series.
	Symbol Symbol
}

LineSeries references a population of data for line charts.

func (*LineSeries) Summary added in v0.5.0

func (l *LineSeries) Summary() populationSummary

type LineSeriesList added in v0.5.0

type LineSeriesList []LineSeries

LineSeriesList provides the data populations for line charts (LineChartOption).

func NewSeriesListLine added in v0.4.0

func NewSeriesListLine(values [][]float64, opts ...LineSeriesOption) LineSeriesList

NewSeriesListLine builds a SeriesList for a line chart. The first dimension of the values indicates the population of the data, while the second dimension provides the samples for the population.

func (LineSeriesList) SetSeriesLabels added in v0.5.6

func (l LineSeriesList) SetSeriesLabels(label SeriesLabel)

SetSeriesLabels sets the label for all elements in the series.

func (LineSeriesList) SumSeries added in v0.5.0

func (l LineSeriesList) SumSeries() []float64

SumSeries returns a float64 slice with the sum of each series matching in order to the series of the list.

func (LineSeriesList) SumSeriesValues added in v0.5.0

func (l LineSeriesList) SumSeriesValues() []float64

SumSeriesValues returns a float64 slice with each series in the list totaled for the value index.

func (LineSeriesList) ToGenericSeriesList added in v0.5.0

func (l LineSeriesList) ToGenericSeriesList() GenericSeriesList

type LineSeriesOption added in v0.4.0

type LineSeriesOption struct {
	Label     SeriesLabel
	Names     []string
	MarkPoint SeriesMarkPoint
	MarkLine  SeriesMarkLine
}

LineSeriesOption provides series customization for NewSeriesListLine.

type OffsetInt added in v0.3.0

type OffsetInt struct {
	// Left indicates a vertical spacing adjustment from the top.
	Top int
	// Left indicates a horizontal spacing adjustment from the left.
	Left int
}

OffsetInt provides an ability to configure a shift from the top or left alignments.

func (OffsetInt) WithLeft added in v0.3.0

func (o OffsetInt) WithLeft(val int) OffsetInt

func (OffsetInt) WithTop added in v0.3.0

func (o OffsetInt) WithTop(val int) OffsetInt

type OffsetStr added in v0.3.0

type OffsetStr struct {
	// Left is the distance between the component and the left side of the container.
	// It can be pixel value (20), percentage value (20%), or position description: 'left', 'right', 'center'.
	Left string
	// Top is the distance between the component and the top side of the container.
	// It can be pixel value (20), or percentage value (20%), or position description: 'top', 'bottom'.
	Top string
}

OffsetStr provides an ability to configure a shift from the top or left alignments using flexible string inputs.

func (OffsetStr) WithLeft added in v0.3.0

func (o OffsetStr) WithLeft(val string) OffsetStr

func (OffsetStr) WithLeftI added in v0.3.0

func (o OffsetStr) WithLeftI(val int) OffsetStr

func (OffsetStr) WithTop added in v0.3.0

func (o OffsetStr) WithTop(val string) OffsetStr

func (OffsetStr) WithTopI added in v0.3.0

func (o OffsetStr) WithTopI(val int) OffsetStr

type OptionFunc

type OptionFunc func(opt *ChartOption)

OptionFunc option function.

func ChildOptionFunc

func ChildOptionFunc(child ...ChartOption) OptionFunc

ChildOptionFunc adds a Child chart on top of the current one. Use Padding and Box for positioning.

func DimensionsOptionFunc added in v0.4.0

func DimensionsOptionFunc(width, height int) OptionFunc

DimensionsOptionFunc sets the width and height dimensions of the chart.

func FontOptionFunc deprecated

func FontOptionFunc(font *truetype.Font) OptionFunc

Deprecated: FontOptionFunc is deprecated, fonts should be set on the specific elements (SeriesLabel, Title, etc).

func JPGOutputOptionFunc added in v0.5.1

func JPGOutputOptionFunc() OptionFunc

JPGOutputOptionFunc sets jpg as the image type for the chart's output.

func LegendLabelsOptionFunc

func LegendLabelsOptionFunc(labels []string) OptionFunc

LegendLabelsOptionFunc sets the legend series name labels of the chart.

func LegendOptionFunc

func LegendOptionFunc(legend LegendOption) OptionFunc

LegendOptionFunc sets the legend of the chart.

func MarkLineOptionFunc

func MarkLineOptionFunc(seriesIndex int, markLineTypes ...string) OptionFunc

MarkLineOptionFunc sets the mark line for series of the chart.

func MarkPointOptionFunc

func MarkPointOptionFunc(seriesIndex int, markPointTypes ...string) OptionFunc

MarkPointOptionFunc sets the mark point for series of the chart.

func PNGOutputOptionFunc added in v0.4.0

func PNGOutputOptionFunc() OptionFunc

PNGOutputOptionFunc sets png as the image type for the chart's output.

func PaddingOptionFunc

func PaddingOptionFunc(padding Box) OptionFunc

PaddingOptionFunc sets the padding of the chart.

func RadarIndicatorOptionFunc

func RadarIndicatorOptionFunc(names []string, values []float64) OptionFunc

RadarIndicatorOptionFunc sets the radar indicator of chart

func SVGOutputOptionFunc added in v0.4.0

func SVGOutputOptionFunc() OptionFunc

SVGOutputOptionFunc sets svg as the image type for the chart's output.

func SeriesShowLabel added in v0.4.0

func SeriesShowLabel(show bool) OptionFunc

SeriesShowLabel sets the series show label state for all series.

func ThemeNameOptionFunc

func ThemeNameOptionFunc(theme string) OptionFunc

ThemeNameOptionFunc set them of chart by name.

func ThemeOptionFunc

func ThemeOptionFunc(theme ColorPalette) OptionFunc

ThemeOptionFunc sets the theme of the chart.

func TitleOptionFunc

func TitleOptionFunc(title TitleOption) OptionFunc

TitleOptionFunc sets the title of the chart.

func TitleTextOptionFunc

func TitleTextOptionFunc(text string, subtext ...string) OptionFunc

TitleTextOptionFunc sets the title text of chart.

func XAxisLabelsOptionFunc added in v0.4.9

func XAxisLabelsOptionFunc(labels []string) OptionFunc

XAxisLabelsOptionFunc sets the x-axis labels of the chart.

func XAxisOptionFunc

func XAxisOptionFunc(xAxisOption XAxisOption) OptionFunc

XAxisOptionFunc sets the x-axis of the chart.

func YAxisLabelsOptionFunc added in v0.4.9

func YAxisLabelsOptionFunc(labels []string) OptionFunc

YAxisLabelsOptionFunc sets the y-axis labels of the chart.

func YAxisOptionFunc

func YAxisOptionFunc(yAxisOption ...YAxisOption) OptionFunc

YAxisOptionFunc sets the y-axis of chart, supports up to two y-axis.

type Painter

type Painter struct {
	// contains filtered or unexported fields
}

Painter is the primary struct for drawing charts/graphs.

func BarRender

func BarRender(values [][]float64, opts ...OptionFunc) (*Painter, error)

BarRender renders a bar chart.

func DoughnutRender added in v0.5.6

func DoughnutRender(values []float64, opts ...OptionFunc) (*Painter, error)

DoughnutRender renders a doughnut or ring chart.

func FunnelRender

func FunnelRender(values []float64, opts ...OptionFunc) (*Painter, error)

FunnelRender renders a funnel chart.

func HorizontalBarRender

func HorizontalBarRender(values [][]float64, opts ...OptionFunc) (*Painter, error)

HorizontalBarRender renders a horizontal bar chart.

func LineRender

func LineRender(values [][]float64, opts ...OptionFunc) (*Painter, error)

LineRender renders a line chart.

func NewPainter

func NewPainter(opts PainterOptions, opt ...PainterOptionFunc) *Painter

NewPainter creates a painter which can be used to render charts to (using for example newLineChart).

func PieRender

func PieRender(values []float64, opts ...OptionFunc) (*Painter, error)

PieRender renders a pie chart.

func RadarRender

func RadarRender(values [][]float64, opts ...OptionFunc) (*Painter, error)

RadarRender renders a radar chart.

func Render

func Render(opt ChartOption, opts ...OptionFunc) (*Painter, error)

func ScatterRender added in v0.5.0

func ScatterRender(values [][]float64, opts ...OptionFunc) (*Painter, error)

ScatterRender renders a scatter chart.

func TableOptionRenderDirect added in v0.4.0

func TableOptionRenderDirect(opt TableChartOption) (*Painter, error)

TableOptionRenderDirect table render with the provided options directly to an image. Table options are different from other charts as they include the state for initializing the Painter, where other charts accept the Painter. If you want to write a Table on an existing Painter use TableOptionRender

func TableRenderValues added in v0.4.0

func TableRenderValues(header []string, data [][]string, spanMaps ...map[int]int) (*Painter, error)

TableRenderValues renders a table chart with the simple header and data values provided.

func (*Painter) ArrowDown added in v0.4.0

func (p *Painter) ArrowDown(x, y, width, height int,
	fillColor, strokeColor Color, strokeWidth float64)

ArrowDown draws an arrow at the given point and dimensions pointing down.

func (*Painter) ArrowLeft

func (p *Painter) ArrowLeft(x, y, width, height int,
	fillColor, strokeColor Color, strokeWidth float64)

ArrowLeft draws an arrow at the given point and dimensions pointing left.

func (*Painter) ArrowRight

func (p *Painter) ArrowRight(x, y, width, height int,
	fillColor, strokeColor Color, strokeWidth float64)

ArrowRight draws an arrow at the given point and dimensions pointing right.

func (*Painter) ArrowUp added in v0.4.0

func (p *Painter) ArrowUp(x, y, width, height int,
	fillColor, strokeColor Color, strokeWidth float64)

ArrowUp draws an arrow at the given point and dimensions pointing up.

func (*Painter) BarChart added in v0.4.0

func (p *Painter) BarChart(opt BarChartOption) error

BarChart renders a bar chart with the provided configuration to the painter.

func (*Painter) Bytes

func (p *Painter) Bytes() ([]byte, error)

Bytes returns the final rendered data as a byte slice.

func (*Painter) Child

func (p *Painter) Child(opt ...PainterOptionFunc) *Painter

Child returns a painter with the passed-in options applied to it. Useful when you want to render relative to only a portion of the canvas via PainterBoxOption.

func (*Painter) Circle

func (p *Painter) Circle(radius float64, x, y int, fillColor, strokeColor Color, strokeWidth float64)

Circle draws a circle at the given coords with a given radius.

func (*Painter) Dots

func (p *Painter) Dots(points []Point, fillColor, strokeColor Color, strokeWidth float64, dotRadius float64)

Dots prints filled circles for the given points.

func (*Painter) DoughnutChart added in v0.5.6

func (p *Painter) DoughnutChart(opt DoughnutChartOption) error

DoughnutChart renders a doughnut or ring chart with the provided configuration to the painter.

func (*Painter) FillArea

func (p *Painter) FillArea(points []Point, fillColor Color)

FillArea draws a filled polygon through the given points, skipping "null" (MaxInt32) break values (filling the area flat between them).

func (*Painter) FilledDiamond added in v0.4.9

func (p *Painter) FilledDiamond(cx, cy, width, height int, fillColor, strokeColor Color, strokeWidth float64)

FilledDiamond will draw a filled diamond centered at (cx, cy) with the given width and height.

func (*Painter) FilledRect added in v0.4.3

func (p *Painter) FilledRect(x1, y1, x2, y2 int, fillColor, strokeColor Color, strokeWidth float64)

FilledRect will draw a filled box with the given coordinates.

func (*Painter) FunnelChart added in v0.4.0

func (p *Painter) FunnelChart(opt FunnelChartOption) error

FunnelChart renders a funnel chart with the provided configuration to the painter.

func (*Painter) HeatMapChart added in v0.5.1

func (p *Painter) HeatMapChart(opt HeatMapOption) error

HeatMapChart renders a heat map with the provided configuration to the painter.

func (*Painter) Height

func (p *Painter) Height() int

Height returns the drawable height of the painter's box.

func (*Painter) HorizontalBarChart added in v0.4.0

func (p *Painter) HorizontalBarChart(opt HorizontalBarChartOption) error

HorizontalBarChart renders a horizontal bar chart with the provided configuration to the painter.

func (*Painter) HorizontalMarkLine added in v0.4.10

func (p *Painter) HorizontalMarkLine(x, y, width int, fillColor, strokeColor Color, strokeWidth float64, strokeDashArray []float64)

HorizontalMarkLine draws a horizontal line with a small circle and arrow at the right.

func (*Painter) LineChart added in v0.4.0

func (p *Painter) LineChart(opt LineChartOption) error

LineChart renders a line chart with the provided configuration to the painter.

func (*Painter) LineStroke

func (p *Painter) LineStroke(points []Point, strokeColor Color, strokeWidth float64)

LineStroke draws a line in the graph from point to point with the specified stroke color/width. Points with values of math.MaxInt32 will be skipped, resulting in a gap. Single or isolated points will result in just a dot being drawn at the point.

func (*Painter) MeasureText

func (p *Painter) MeasureText(text string, textRotation float64, fontStyle FontStyle) Box

MeasureText will provide the rendered size of the text for the provided font style.

func (*Painter) PieChart added in v0.4.0

func (p *Painter) PieChart(opt PieChartOption) error

PieChart renders a pie chart with the provided configuration to the painter.

func (*Painter) Pin

func (p *Painter) Pin(x, y, width int, fillColor, strokeColor Color, strokeWidth float64)

Pin draws a pin shape (circle + curved tail).

func (*Painter) Polygon

func (p *Painter) Polygon(center Point, radius float64, sides int, strokeColor Color, strokeWidth float64)

Polygon draws a polygon with the specified center, radius, and number of sides.

func (*Painter) RadarChart added in v0.4.0

func (p *Painter) RadarChart(opt RadarChartOption) error

RadarChart renders a radar chart with the provided configuration to the painter.

func (*Painter) ScatterChart added in v0.5.0

func (p *Painter) ScatterChart(opt ScatterChartOption) error

ScatterChart renders a scatter chart with the provided configuration to the painter.

func (*Painter) SmoothLineStroke

func (p *Painter) SmoothLineStroke(points []Point, tension float64, strokeColor Color, strokeWidth float64)

SmoothLineStroke draws a smooth curve through the given points using Quadratic Bézier segments and a `tension` parameter in [0..1] with 0 providing straight lines between midpoints and 1 providing a smoother line. Because the tension smooths out the line, the line will no longer hit the provided points exactly. The more variable the points, and the higher the tension, the more the line will be.

func (*Painter) TableChart added in v0.4.0

func (p *Painter) TableChart(opt TableChartOption) error

TableChart renders a table with the provided configuration to the painter.

func (*Painter) Text

func (p *Painter) Text(body string, x, y int, radians float64, fontStyle FontStyle)

Text draws the given string at the position specified, using the given font style. Specifying radians will rotate the text.

func (*Painter) TextFit

func (p *Painter) TextFit(body string, x, y, width int, fontStyle FontStyle, textAligns ...string) Box

TextFit draws multi-line text constrained to a given width.

func (*Painter) VerticalMarkLine added in v0.4.10

func (p *Painter) VerticalMarkLine(x, y, height int, fillColor, strokeColor Color, strokeWidth float64, strokeDashArray []float64)

VerticalMarkLine draws a vertical line with a small dot at the bottom and an arrow at the top.

func (*Painter) Width

func (p *Painter) Width() int

Width returns the drawable width of the painter's box.

type PainterOptionFunc added in v0.4.0

type PainterOptionFunc func(*Painter)

PainterOptionFunc defines a function that can modify a Painter after creation.

func PainterBoxOption

func PainterBoxOption(box Box) PainterOptionFunc

PainterBoxOption sets a specific box for the Painter to draw within.

func PainterFontOption

func PainterFontOption(font *truetype.Font) PainterOptionFunc

PainterFontOption sets the default font face for the Painter. This font is used if the FontStyle specified in chart configs does not specify another face.

func PainterPaddingOption

func PainterPaddingOption(padding Box) PainterOptionFunc

PainterPaddingOption sets the padding of the draw painter.

func PainterThemeOption

func PainterThemeOption(theme ColorPalette) PainterOptionFunc

PainterThemeOption sets a color palette theme default for the Painter. This theme is used if the specific chart options don't have a theme set.

type PainterOptions

type PainterOptions struct {
	// OutputFormat specifies the output type, "svg" or "png", default is "png".
	OutputFormat string
	// Width is the width of the draw painter.
	Width int
	// Height is the height of the draw painter.
	Height int
	// Font is the default font used for rendering text.
	Font *truetype.Font
	// Theme is the default theme to be used if the chart does not specify a theme.
	Theme ColorPalette
}

PainterOptions contains parameters for creating a new Painter.

type PieChartOption

type PieChartOption struct {
	// Theme specifies the colors used for the pie chart.
	Theme ColorPalette
	// Padding specifies the padding of pie chart.
	Padding Box
	// Deprecated: Font is deprecated, instead the font needs to be set on the SeriesLabel, or other specific elements.
	Font *truetype.Font
	// SeriesList provides the data population for the chart, typically constructed using NewSeriesListPie.
	SeriesList PieSeriesList
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// Radius default radius for pie e.g.: 40%, default is "40%"
	Radius string
	// SegmentGap provides a gap between each pie slice.
	SegmentGap float64
	// ValueFormatter defines how float values should be rendered to strings, notably for series labels.
	ValueFormatter ValueFormatter
}

PieChartOption defines the options for rendering a pie chart. Render the chart using Painter.PieChart.

func NewPieChartOptionWithData added in v0.4.0

func NewPieChartOptionWithData(data []float64) PieChartOption

NewPieChartOptionWithData returns an initialized PieChartOption with the SeriesList set from the provided data slice.

type PieSeries added in v0.5.0

type PieSeries struct {
	// Value provides the value for the pie section.
	Value float64
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
	// Radius for Pie chart, e.g.: 40%, default is "40%"
	Radius string
}

PieSeries references a population of data for pie charts.

type PieSeriesList added in v0.5.0

type PieSeriesList []PieSeries

PieSeriesList provides the data populations for pie charts (PieChartOption).

func NewSeriesListPie added in v0.4.0

func NewSeriesListPie(values []float64, opts ...PieSeriesOption) PieSeriesList

NewSeriesListPie builds a SeriesList for a pie chart.

func (PieSeriesList) MaxValue added in v0.5.0

func (p PieSeriesList) MaxValue() float64

MaxValue returns the maximum value within the series, or MinInt64 if no values.

func (PieSeriesList) SetSeriesLabels added in v0.5.6

func (p PieSeriesList) SetSeriesLabels(label SeriesLabel)

SetSeriesLabels sets the label for all elements in the series.

func (PieSeriesList) SumSeries added in v0.5.0

func (p PieSeriesList) SumSeries() float64

func (PieSeriesList) ToGenericSeriesList added in v0.5.0

func (p PieSeriesList) ToGenericSeriesList() GenericSeriesList

type PieSeriesOption

type PieSeriesOption struct {
	Label SeriesLabel
	Names []string
}

PieSeriesOption provides series customization for NewSeriesListPie.

type Point

type Point = chartdraw.Point

type RadarChartOption

type RadarChartOption struct {
	// Theme specifies the colors used for the pie chart.
	Theme ColorPalette
	// Padding specifies the padding of pie chart.
	Padding Box
	// Font is the font used to render the chart.
	Font *truetype.Font
	// SeriesList provides the data population for the chart, typically constructed using NewSeriesListRadar.
	SeriesList RadarSeriesList
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// RadarIndicators provides the radar indicator list.
	RadarIndicators []RadarIndicator
	// Radius for radar e.g.: 40%, default is "40%"
	Radius string
	// ValueFormatter defines how float values should be rendered to strings, notably for series labels.
	ValueFormatter ValueFormatter
}

RadarChartOption defines the options for rendering a radar chart. Render the chart using Painter.RadarChart.

func NewRadarChartOptionWithData added in v0.4.0

func NewRadarChartOptionWithData(data [][]float64, names []string, values []float64) RadarChartOption

NewRadarChartOptionWithData returns an initialized RadarChartOption with the SeriesList set for the provided data slice.

type RadarIndicator

type RadarIndicator struct {
	// Name specifies a name for the iIndicator.
	Name string
	// Max is the maximum value of indicator.
	Max float64
	// Min is the minimum value of indicator.
	Min float64
}

func NewRadarIndicators

func NewRadarIndicators(names []string, values []float64) []RadarIndicator

NewRadarIndicators returns a radar indicator list

type RadarSeries added in v0.5.0

type RadarSeries struct {
	// Values provides the series data list.
	Values []float64
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
}

RadarSeries references a population of data for radar charts.

type RadarSeriesList added in v0.5.0

type RadarSeriesList []RadarSeries

RadarSeriesList provides the data populations for line charts (RadarChartOption).

func NewSeriesListRadar added in v0.4.0

func NewSeriesListRadar(values [][]float64, opts ...RadarSeriesOption) RadarSeriesList

NewSeriesListRadar builds a SeriesList for a Radar chart.

func (RadarSeriesList) SetSeriesLabels added in v0.5.6

func (r RadarSeriesList) SetSeriesLabels(label SeriesLabel)

SetSeriesLabels sets the label for all elements in the series.

func (RadarSeriesList) ToGenericSeriesList added in v0.5.0

func (r RadarSeriesList) ToGenericSeriesList() GenericSeriesList

type RadarSeriesOption added in v0.4.0

type RadarSeriesOption struct {
	Label SeriesLabel
	Names []string
}

RadarSeriesOption provides series customization for NewSeriesListRadar.

type ScatterChartOption added in v0.5.0

type ScatterChartOption struct {
	// Theme specifies the colors used for the scatter chart.
	Theme ColorPalette
	// Padding specifies the padding of scatter chart.
	Padding Box
	// Deprecated: Font is deprecated, instead the font needs to be set on the SeriesLabel, or other specific elements.
	Font *truetype.Font
	// SeriesList provides the data population for the chart, typically constructed using NewSeriesListScatter or
	// NewSeriesListScatterMultiValue.
	SeriesList ScatterSeriesList
	// XAxis are options for the x-axis.
	XAxis XAxisOption
	// YAxis are options for the y-axis (at most two).
	YAxis []YAxisOption
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// Symbol specifies the default symbols to draw the data points with. Default is 'dot', additional options are:
	// 'circle', 'dot', 'square', 'diamond'. This can also be set on a per-series level.
	Symbol Symbol
	// SymbolSize specifies the size for each data point, default is 2.0.
	SymbolSize float64
	// ValueFormatter defines how float values should be rendered to strings, notably for numeric axis labels.
	ValueFormatter ValueFormatter
}

ScatterChartOption defines the options for rendering a scatter chart. Render the chart using Painter.ScatterChart.

func NewScatterChartOptionWithData added in v0.5.0

func NewScatterChartOptionWithData(data [][]float64) ScatterChartOption

NewScatterChartOptionWithData returns an initialized ScatterChartOption with the SeriesList set for the provided data slice.

func NewScatterChartOptionWithSeries added in v0.5.9

func NewScatterChartOptionWithSeries(sl ScatterSeriesList) ScatterChartOption

NewScatterChartOptionWithSeries returns an initialized ScatterChartOption with the provided SeriesList.

type ScatterSeries added in v0.5.0

type ScatterSeries struct {
	// Values provides the series data values.
	Values [][]float64
	// YAxisIndex is the index for the axis, it must be 0 or 1.
	YAxisIndex int
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
	// MarkLine provides a configuration for mark lines for this series. When using a MarkLine, you will want to
	// configure padding to the chart on the right for the values.
	MarkLine SeriesMarkLine
	// TrendLine provides configurations for trend lines for this series.
	TrendLine []SeriesTrendLine
	// Symbol specifies a custom symbol for the series.
	Symbol Symbol
}

ScatterSeries references a population of data for scatter charts.

func (*ScatterSeries) Summary added in v0.5.0

func (s *ScatterSeries) Summary() populationSummary

type ScatterSeriesList added in v0.5.0

type ScatterSeriesList []ScatterSeries

ScatterSeriesList provides the data populations for scatter charts (ScatterChartOption).

func NewSeriesListScatter added in v0.5.0

func NewSeriesListScatter(values [][]float64, opts ...ScatterSeriesOption) ScatterSeriesList

NewSeriesListScatter builds a SeriesList for a line chart. The first dimension of the values indicates the population of the data, while the second dimension provides the samples for the population.

func NewSeriesListScatterMultiValue added in v0.5.0

func NewSeriesListScatterMultiValue(values [][][]float64, opts ...ScatterSeriesOption) ScatterSeriesList

NewSeriesListScatterMultiValue builds a SeriesList for a scatter charts. The first dimension of the values indicates the population of the data, while the second dimension provides the samples for the population. Multiple values for a single sample can be provided using the last dimension.

func (ScatterSeriesList) SetSeriesLabels added in v0.5.6

func (s ScatterSeriesList) SetSeriesLabels(label SeriesLabel)

SetSeriesLabels sets the label for all elements in the series.

func (ScatterSeriesList) SumSeries added in v0.5.0

func (s ScatterSeriesList) SumSeries() []float64

SumSeries returns a float64 slice with the sum of each series matching in order to the series of the list.

func (ScatterSeriesList) ToGenericSeriesList added in v0.5.6

func (s ScatterSeriesList) ToGenericSeriesList() GenericSeriesList

type ScatterSeriesOption added in v0.5.0

type ScatterSeriesOption struct {
	Label     SeriesLabel
	Names     []string
	MarkLine  SeriesMarkLine
	TrendLine []SeriesTrendLine
}

ScatterSeriesOption provides series customization for NewSeriesListScatter and NewSeriesListScatterMultiValue.

type SeriesLabel

type SeriesLabel struct {
	// FormatTemplate is a string template for formatting the data label.
	// {b}: the name of a data item.
	// {c}: the value of a data item.
	// {d}: the percent of a data item(pie chart).
	FormatTemplate string
	// ValueFormatter is an alternative method of providing a format for the data label.
	ValueFormatter ValueFormatter
	// FontStyle specifies the font and style for the label.
	FontStyle FontStyle
	// Show flag for label, if unset the behavior will be defaulted based on the chart type.
	Show *bool
	// Distance to the host graphic element.
	Distance int // TODO - do we want to replace with just Offset?
	// Offset specifies an offset from the position.
	Offset OffsetInt
}

SeriesLabel specifies if and how the specific series values should be rendered on the chart.

type SeriesMark added in v0.5.0

type SeriesMark struct {
	// Type is the mark data type, it can be "max", "min", "average". "average" is only for mark line.
	Type string
	// Global specifies the mark reference the sum of all series. This option is only
	// used when the Series is "Stacked" and the mark is on the LAST Series of the SeriesList.
	Global bool
}

type SeriesMarkLine

type SeriesMarkLine struct {
	// ValueFormatter is used to produce the label for the Mark Line.
	ValueFormatter ValueFormatter
	// Lines are the mark lines for the series.
	Lines SeriesMarkList
}

func NewMarkLine

func NewMarkLine(markLineTypes ...string) SeriesMarkLine

NewMarkLine returns a mark line for the provided types, this is set on a specific instance within a Series.

func (*SeriesMarkLine) AddGlobalLines added in v0.5.0

func (m *SeriesMarkLine) AddGlobalLines(markTypes ...string)

AddGlobalLines will add "global" mark lines, which will be referenced to the sum of all the series. These marks are only rendered when the Series is "Stacked" and the mark line is on the LAST Series of the SeriesList.

func (*SeriesMarkLine) AddLines added in v0.5.0

func (m *SeriesMarkLine) AddLines(markTypes ...string)

AddLines will add mark lines for the series.

type SeriesMarkList added in v0.5.0

type SeriesMarkList []SeriesMark

func NewSeriesMarkGlobalList added in v0.5.0

func NewSeriesMarkGlobalList(markTypes ...string) SeriesMarkList

NewSeriesMarkGlobalList returns a slice of SeriesMark initialized for the given types with the global flag set. Global marks reference the sum of all series. This option is only used when the Series is "Stacked" and the mark is on the LAST Series of the SeriesList.

func NewSeriesMarkList added in v0.5.0

func NewSeriesMarkList(markTypes ...string) SeriesMarkList

NewSeriesMarkList returns a SeriesMarkList initialized for the given types.

type SeriesMarkPoint

type SeriesMarkPoint struct {
	// SymbolSize is the width of symbol, default value is 28.
	SymbolSize int
	// ValueFormatter is used to produce the label for the Mark Point.
	ValueFormatter ValueFormatter
	// Points are the mark points for the series.
	Points SeriesMarkList
}

func NewMarkPoint

func NewMarkPoint(markPointTypes ...string) SeriesMarkPoint

NewMarkPoint returns a mark point for the provided types, this is set on a specific instance within a Series.

func (*SeriesMarkPoint) AddGlobalPoints added in v0.5.0

func (m *SeriesMarkPoint) AddGlobalPoints(markTypes ...string)

AddGlobalPoints will add "global" mark points, which will be referenced to the sum of all the series. These marks are only rendered when the Series is "Stacked" and the mark point is on the LAST Series of the SeriesList.

func (*SeriesMarkPoint) AddPoints added in v0.5.0

func (m *SeriesMarkPoint) AddPoints(markTypes ...string)

AddPoints will add mark points for the series.

type SeriesTrendLine added in v0.5.0

type SeriesTrendLine struct {
	// LineStrokeWidth is the width of the rendered line.
	LineStrokeWidth float64
	// StrokeSmoothingTension should be between 0 and 1. At 0 the lines will be sharp and precise, with 1 providing
	// smoother lines.
	StrokeSmoothingTension float64
	// LineColor provides an override of the theme color for this trend line
	LineColor Color
	// Type specifies the trend line type: "linear", "cubic", "average".
	Type string
	// Window is only used for average, defining how many points to consider.
	Window int
}

func NewTrendLine added in v0.5.0

func NewTrendLine(trendType string) []SeriesTrendLine

NewTrendLine returns a trend line for the provided types, this is set on a specific instance within a Series.

type Symbol added in v0.4.9

type Symbol string

type TableCell

type TableCell struct {
	// Text the text of table cell
	Text string
	// FontStyle contains the configuration for the cell text font.
	FontStyle FontStyle
	// FillColor sets a color for this table cell.
	FillColor Color
	// Row the row index of table cell.
	Row int
	// Column the column index of table cell.
	Column int
}

type TableChartOption

type TableChartOption struct {
	// OutputFormat specifies the output type, "svg" or "png".
	OutputFormat string
	// Theme specifies the colors used for the table.
	Theme ColorPalette
	// Padding specifies the padding of table.
	Padding Box
	// Width specifies the width of the table.
	Width int
	// Header provides header data for the top of the table.
	Header []string
	// Data provides the row and column data for the table.
	Data [][]string
	// Spans provide the span for each column on the table.
	Spans []int
	// TextAligns specifies the text alignment for each cell on the table.
	TextAligns []string
	// FontStyle contains the configuration for the table text font.
	FontStyle FontStyle
	// HeaderBackgroundColor provides a background color of header row.
	HeaderBackgroundColor Color
	// HeaderFontColor specifies a text color for the header text.
	HeaderFontColor Color
	// RowBackgroundColors specifies an array of colors for each row.
	RowBackgroundColors []Color
	// BackgroundColor specifies a general background color.
	BackgroundColor Color
	// CellModifier is an optional function to modify the style or content of a specific TableCell before they are rendered.
	CellModifier func(TableCell) TableCell
}

type ThemeOption

type ThemeOption struct {
	IsDarkMode         bool
	AxisStrokeColor    Color
	XAxisStrokeColor   Color
	YAxisStrokeColor   Color
	AxisSplitLineColor Color
	BackgroundColor    Color
	TextColor          Color
	TextColorTitle     Color
	TextColorMark      Color
	TextColorLabel     Color
	TextColorLegend    Color
	TextColorXAxis     Color
	TextColorYAxis     Color
	TitleBorderColor   Color
	LegendBorderColor  Color
	SeriesColors       []Color
	SeriesTrendColors  []Color
}

type TitleOption

type TitleOption struct {
	// Show specifies if the title should be rendered, set this to *false (through Ptr(false)) to hide the title.
	Show *bool
	// Theme specifies the colors used for the title.
	Theme ColorPalette
	// Text specifies the title text, supporting '\n' for new lines.
	Text string
	// Subtext to the title, supporting '\n' for new lines.
	Subtext string
	// Offset allows you to specify the position of the title component relative to the left and top side.
	Offset OffsetStr
	// FontStyle specifies the font, size, and style for rendering the title.
	FontStyle FontStyle
	// SubtextFontStyle specifies the font, size, and style for rendering the subtext.
	SubtextFontStyle FontStyle
	// BorderWidth can be set to a non-zero value to render a box around the title.
	BorderWidth float64
}

type ValueFormatter

type ValueFormatter func(float64) string

ValueFormatter defines a function that can be used to format numeric values.

type XAxisOption

type XAxisOption struct {
	// Show specifies if the x-axis should be rendered, set this to *false (through Ptr(false)) to hide the axis.
	Show *bool
	// Theme specifies the colors used for the x-axis.
	Theme ColorPalette
	// Title specifies a name for the axis, if specified the axis name is rendered below the X-Axis.
	Title string
	// TitleFontStyle provides the font, size, and color for the axis title.
	TitleFontStyle FontStyle
	// Labels provides labels for each value on the x-axis (index matching to the series index).
	Labels []string
	// DataStartIndex specifies what index the Data values should start from.
	DataStartIndex int
	// Deprecated: Position is deprecated. Currently, when set to `bottom` and the labels would render on the top
	// side of the axis line. However, the line would remain at the bottom of the chart. This seems confusing, and
	// attempts to actually move the axis line to the top of the chart are currently very messy looking. For that
	// reason this is currently deprecated. If a top X-Axis is valuable to you, please open a feature request.
	Position string
	// BoundaryGap specifies that the chart should have additional space on the left and right, with data points being
	// centered between two axis ticks. Default is set based on the dataset density / size to produce an easy-to-read
	// graph. Specify a *bool (through charts.Ptr(false) or charts.Ptr(true)) to enforce a spacing.
	BoundaryGap *bool
	// Deprecated: FontStyle is deprecated, use LabelFontStyle.
	FontStyle FontStyle
	// LabelFontStyle specifies the font configuration for each label.
	LabelFontStyle FontStyle
	// LabelRotation are the radians for rotating the label. Convert from degrees using DegreesToRadians(float64).
	LabelRotation float64
	// LabelOffset is the offset of each label.
	LabelOffset OffsetInt
	// ValueFormatter defines how float values should be rendered to strings, notably for numeric axis labels.
	ValueFormatter ValueFormatter
	// Unit is a suggestion for how large the axis step is, this is a recommendation only. Larger numbers result in fewer labels.
	Unit float64
	// LabelCount is the number of labels to show on the axis. Specify a smaller number to reduce writing collisions.
	LabelCount int
	// LabelCountAdjustment specifies a relative influence on how many labels should be rendered.
	// Typically, this is negative to result in cleaner graphs, positive values may result in text collisions.
	LabelCountAdjustment int
}

type YAxisOption

type YAxisOption struct {
	// Show specifies if the y-axis should be rendered, set this to *false (through Ptr(false)) to hide the axis.
	Show *bool
	// Theme specifies the colors used for the x-axis.
	Theme ColorPalette
	// Title specifies a name for the axis, if specified the axis name is rendered on the outside of the Y-Axis.
	Title string
	// TitleFontStyle provides the font, size, and color for the axis title.
	TitleFontStyle FontStyle
	// Min, if set this will force the minimum value of y-axis.
	Min *float64
	// Max, if set this will force the maximum value of y-axis.
	Max *float64
	// RangeValuePaddingScale suggest a scale of padding added to the max and min values.
	RangeValuePaddingScale *float64
	// Labels provides labels for each value on the y-axis.
	Labels []string
	// Position describes the position of y-axis, it can be 'left' or 'right'.
	Position string
	// Deprecated: FontStyle is deprecated, use LabelFontStyle.
	FontStyle FontStyle
	// LabelFontStyle specifies the font configuration for each label.
	LabelFontStyle FontStyle
	// LabelRotation are the radians for rotating the label. Convert from degrees using DegreesToRadians(float64).
	LabelRotation float64
	// Deprecated: Formatter is deprecated, use ValueFormatter instead.
	Formatter string
	// Unit is a suggestion for how large the axis step is, this is a recommendation only. Larger numbers result in fewer labels.
	Unit float64
	// LabelCount is the number of labels to show on the axis. Specify a smaller number to reduce writing collisions.
	LabelCount int
	// LabelCountAdjustment specifies a relative influence on how many labels should be rendered.
	// Typically, this is negative to result in cleaner graphs, positive values may result in text collisions.
	LabelCountAdjustment int
	// LabelSkipCount specifies a number of lines between labels where there will be no label and instead just a horizontal line.
	LabelSkipCount int
	// SplitLineShow for showing axis split line, set this to true to show the horizontal axis split lines.
	SplitLineShow *bool
	// SpineLineShow can be set to enforce if the vertical spine on the axis should be shown or not.
	// By default, not shown unless a category axis.
	SpineLineShow *bool
	// ValueFormatter defines how float values should be rendered to strings, notably for numeric axis labels.
	ValueFormatter ValueFormatter
	// contains filtered or unexported fields
}

Directories

Path Synopsis
examples/axes command
examples/basic command
examples/legend command
examples
demo/themes command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL