Documentation
¶
Index ¶
- Constants
- Variables
- func DegreesToRadians(degrees float64) float64
- func FormatValueHumanize(value float64, decimals int, ensureTrailingZeros bool) string
- func FormatValueHumanizeShort(value float64, decimals int, ensureTrailingZeros bool) string
- func GetDefaultFont() *truetype.Font
- func GetFont(fontFamily string) *truetype.Font
- func GetNullValue() float64
- func InstallFont(fontFamily string, data []byte) error
- func InstallTheme(name string, opt ThemeOption)
- func IntSliceToFloat64(slice []int) []float64
- func Ptr[T any](val T) *T
- func RadiansToDegrees(value float64) float64
- func RenderEChartsToJPG(options string) ([]byte, error)
- func RenderEChartsToPNG(options string) ([]byte, error)
- func RenderEChartsToSVG(options string) ([]byte, error)
- func SetDefaultChartDimensions(width, height int)
- func SetDefaultFont(fontFamily string) error
- func SetDefaultTheme(name string) error
- func SliceToFloat64[T any](slice []T, conversion func(T) float64) []float64
- type BarChartOption
- type BarSeries
- type BarSeriesList
- type BarSeriesOption
- type Box
- type ChartOption
- type Color
- type ColorPalette
- type DoughnutChartOption
- type DoughnutSeries
- type DoughnutSeriesList
- type DoughnutSeriesOption
- type EChartStyle
- type EChartsAxisLabel
- type EChartsAxisLine
- type EChartsLabelOption
- type EChartsLegend
- type EChartsMarkData
- type EChartsMarkLine
- type EChartsMarkPoint
- type EChartsOption
- type EChartsPadding
- type EChartsPosition
- type EChartsSeries
- type EChartsSeriesData
- type EChartsSeriesDataValue
- type EChartsSeriesList
- type EChartsTextStyle
- type EChartsXAxis
- type EChartsXAxisData
- type EChartsYAxis
- type EChartsYAxisData
- type FontStyle
- type FunnelChartOption
- type FunnelSeries
- type FunnelSeriesList
- type FunnelSeriesOption
- type GenericSeries
- type GenericSeriesList
- type HeatMapAxis
- type HeatMapOption
- type HorizontalBarChartOption
- type HorizontalBarSeries
- type HorizontalBarSeriesList
- type LegendOption
- type LineChartOption
- type LineSeries
- type LineSeriesList
- type LineSeriesOption
- type OffsetInt
- type OffsetStr
- type OptionFunc
- func ChildOptionFunc(child ...ChartOption) OptionFunc
- func DimensionsOptionFunc(width, height int) OptionFunc
- func FontOptionFunc(font *truetype.Font) OptionFuncdeprecated
- func JPGOutputOptionFunc() OptionFunc
- func LegendLabelsOptionFunc(labels []string) OptionFunc
- func LegendOptionFunc(legend LegendOption) OptionFunc
- func MarkLineOptionFunc(seriesIndex int, markLineTypes ...string) OptionFunc
- func MarkPointOptionFunc(seriesIndex int, markPointTypes ...string) OptionFunc
- func PNGOutputOptionFunc() OptionFunc
- func PaddingOptionFunc(padding Box) OptionFunc
- func RadarIndicatorOptionFunc(names []string, values []float64) OptionFunc
- func SVGOutputOptionFunc() OptionFunc
- func SeriesShowLabel(show bool) OptionFunc
- func ThemeNameOptionFunc(theme string) OptionFunc
- func ThemeOptionFunc(theme ColorPalette) OptionFunc
- func TitleOptionFunc(title TitleOption) OptionFunc
- func TitleTextOptionFunc(text string, subtext ...string) OptionFunc
- func XAxisLabelsOptionFunc(labels []string) OptionFunc
- func XAxisOptionFunc(xAxisOption XAxisOption) OptionFunc
- func YAxisLabelsOptionFunc(labels []string) OptionFunc
- func YAxisOptionFunc(yAxisOption ...YAxisOption) OptionFunc
- type Painter
- func BarRender(values [][]float64, opts ...OptionFunc) (*Painter, error)
- func DoughnutRender(values []float64, opts ...OptionFunc) (*Painter, error)
- func FunnelRender(values []float64, opts ...OptionFunc) (*Painter, error)
- func HorizontalBarRender(values [][]float64, opts ...OptionFunc) (*Painter, error)
- func LineRender(values [][]float64, opts ...OptionFunc) (*Painter, error)
- func NewPainter(opts PainterOptions, opt ...PainterOptionFunc) *Painter
- func PieRender(values []float64, opts ...OptionFunc) (*Painter, error)
- func RadarRender(values [][]float64, opts ...OptionFunc) (*Painter, error)
- func Render(opt ChartOption, opts ...OptionFunc) (*Painter, error)
- func ScatterRender(values [][]float64, opts ...OptionFunc) (*Painter, error)
- func TableOptionRenderDirect(opt TableChartOption) (*Painter, error)
- func TableRenderValues(header []string, data [][]string, spanMaps ...map[int]int) (*Painter, error)
- func (p *Painter) ArrowDown(x, y, width, height int, fillColor, strokeColor Color, strokeWidth float64)
- func (p *Painter) ArrowLeft(x, y, width, height int, fillColor, strokeColor Color, strokeWidth float64)
- func (p *Painter) ArrowRight(x, y, width, height int, fillColor, strokeColor Color, strokeWidth float64)
- func (p *Painter) ArrowUp(x, y, width, height int, fillColor, strokeColor Color, strokeWidth float64)
- func (p *Painter) BarChart(opt BarChartOption) error
- func (p *Painter) Bytes() ([]byte, error)
- func (p *Painter) Child(opt ...PainterOptionFunc) *Painter
- func (p *Painter) Circle(radius float64, x, y int, fillColor, strokeColor Color, strokeWidth float64)
- func (p *Painter) Dots(points []Point, fillColor, strokeColor Color, strokeWidth float64, ...)
- func (p *Painter) DoughnutChart(opt DoughnutChartOption) error
- func (p *Painter) FillArea(points []Point, fillColor Color)
- func (p *Painter) FilledDiamond(cx, cy, width, height int, fillColor, strokeColor Color, strokeWidth float64)
- func (p *Painter) FilledRect(x1, y1, x2, y2 int, fillColor, strokeColor Color, strokeWidth float64)
- func (p *Painter) FunnelChart(opt FunnelChartOption) error
- func (p *Painter) HeatMapChart(opt HeatMapOption) error
- func (p *Painter) Height() int
- func (p *Painter) HorizontalBarChart(opt HorizontalBarChartOption) error
- func (p *Painter) HorizontalMarkLine(x, y, width int, fillColor, strokeColor Color, strokeWidth float64, ...)
- func (p *Painter) LineChart(opt LineChartOption) error
- func (p *Painter) LineStroke(points []Point, strokeColor Color, strokeWidth float64)
- func (p *Painter) MeasureText(text string, textRotation float64, fontStyle FontStyle) Box
- func (p *Painter) PieChart(opt PieChartOption) error
- func (p *Painter) Pin(x, y, width int, fillColor, strokeColor Color, strokeWidth float64)
- func (p *Painter) Polygon(center Point, radius float64, sides int, strokeColor Color, ...)
- func (p *Painter) RadarChart(opt RadarChartOption) error
- func (p *Painter) ScatterChart(opt ScatterChartOption) error
- func (p *Painter) SmoothLineStroke(points []Point, tension float64, strokeColor Color, strokeWidth float64)
- func (p *Painter) TableChart(opt TableChartOption) error
- func (p *Painter) Text(body string, x, y int, radians float64, fontStyle FontStyle)
- func (p *Painter) TextFit(body string, x, y, width int, fontStyle FontStyle, textAligns ...string) Box
- func (p *Painter) VerticalMarkLine(x, y, height int, fillColor, strokeColor Color, strokeWidth float64, ...)
- func (p *Painter) Width() int
- type PainterOptionFunc
- type PainterOptions
- type PieChartOption
- type PieSeries
- type PieSeriesList
- type PieSeriesOption
- type Point
- type RadarChartOption
- type RadarIndicator
- type RadarSeries
- type RadarSeriesList
- type RadarSeriesOption
- type ScatterChartOption
- type ScatterSeries
- type ScatterSeriesList
- type ScatterSeriesOption
- type SeriesLabel
- type SeriesMark
- type SeriesMarkLine
- type SeriesMarkList
- type SeriesMarkPoint
- type SeriesTrendLine
- type Symbol
- type TableCell
- type TableChartOption
- type ThemeOption
- type TitleOption
- type ValueFormatter
- type XAxisOption
- type YAxisOption
Constants ¶
const ( ChartTypeLine = "line" ChartTypeScatter = "scatter" ChartTypeBar = "bar" ChartTypePie = "pie" ChartTypeDoughnut = "doughnut" ChartTypeRadar = "radar" ChartTypeFunnel = "funnel" ChartTypeHorizontalBar = "horizontalBar" ChartTypeHeatMap = "heatMap" )
const ( ChartOutputSVG = "svg" ChartOutputPNG = "png" ChartOutputJPG = "jpg" )
const ( PositionLeft = "left" PositionRight = "right" PositionCenter = "center" PositionTop = "top" PositionBottom = "bottom" )
const ( AlignLeft = "left" AlignRight = "right" AlignCenter = "center" )
const ( SymbolNone = "none" SymbolCircle = "circle" SymbolDot = "dot" SymbolSquare = "square" SymbolDiamond = "diamond" )
const ( SeriesMarkTypeMax = "max" SeriesMarkTypeMin = "min" SeriesMarkTypeAverage = "average" SeriesTrendTypeLinear = "linear" SeriesTrendTypeCubic = "cubic" SeriesTrendTypeAverage = "average" )
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 ¶
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 = 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} )
var BoxZero = chartdraw.BoxZero
BoxZero is an unset Box.
var OffsetCenter = OffsetStr{Left: PositionCenter}
OffsetCenter positions a component in the center.
var OffsetLeft = OffsetStr{Left: PositionLeft}
OffsetLeft positions a component on the left.
var OffsetRight = OffsetStr{Left: PositionRight}
OffsetRight positions a component on the right.
Functions ¶
func DegreesToRadians ¶ added in v0.4.1
DegreesToRadians returns degrees as radians.
func FormatValueHumanize ¶ added in v0.3.1
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
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 GetNullValue ¶
func GetNullValue() float64
GetNullValue gets the null value, allowing you to set a series point with "no" value.
func InstallFont ¶
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
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
RadiansToDegrees translates a radian value to a degree value.
func RenderEChartsToJPG ¶ added in v0.5.1
RenderEChartsToJPG renders an ECharts option JSON string to JPG bytes.
func RenderEChartsToPNG ¶
RenderEChartsToPNG renders an ECharts option JSON string to PNG bytes.
func RenderEChartsToSVG ¶
RenderEChartsToSVG renders an ECharts option JSON string to SVG bytes.
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 ¶
SetDefaultFont set default font by name.
func SetDefaultTheme ¶
SetDefaultTheme sets default theme by name.
func SliceToFloat64 ¶ added in v0.5.0
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 around the 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 true, renders the series stacked within one bar. This causes
// some options, including BarMargin and SeriesLabelPosition, to be ignored.
// MarkLine only renders for the first series and stacking only applies 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, if true, draws bars with rounded top corners.
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.
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 ¶
Box defines spacing boundaries around a component.
func NewBox ¶ added in v0.4.6
NewBox returns a new box with the provided left, top, right, and bottom sizes.
func NewBoxEqual ¶ added in v0.4.6
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 ¶
Color describes a simple RGBA color.
func ColorConvertGo ¶ added in v0.4.4
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
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
ColorFromKnown returns an internal color from a known (basic) color name.
func ColorFromRGBA ¶ added in v0.4.4
ColorFromRGBA returns a color from a `rgb(i,i,i)` or `rgba(i,i,i,f)` css function.
func ParseColor ¶ added in v0.3.2
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 around the 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 sets the outer radius of the ring, for example "40%".
// Default is "40%".
RadiusRing string
// RadiusCenter is the radius for the center hole of the doughnut and 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 ¶
EChartStyle describes color and opacity for ECharts elements.
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"`
}
EChartsAxisLabel configures axis label display for ECharts.
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"`
}
EChartsAxisLine describes the line styling for an axis.
type EChartsLabelOption ¶
type EChartsLabelOption struct {
Show bool `json:"show"`
Distance int `json:"distance"`
Color string `json:"color"`
}
EChartsLabelOption configures data labels.
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"`
}
EChartsLegend holds legend configuration from ECharts JSON.
type EChartsMarkData ¶
type EChartsMarkData struct {
Type string `json:"type"`
// TODO - support position values below
XAxis float64 `json:"xAxis,omitempty"`
YAxis float64 `json:"yAxis,omitempty"`
}
EChartsMarkData represents mark lines or points in ECharts JSON.
func (*EChartsMarkData) UnmarshalJSON ¶
func (emd *EChartsMarkData) UnmarshalJSON(data []byte) error
UnmarshalJSON parses mark definitions provided as an object or array.
type EChartsMarkLine ¶
type EChartsMarkLine struct {
Data []EChartsMarkData `json:"data"`
}
EChartsMarkLine defines mark lines for a series.
func (*EChartsMarkLine) ToSeriesMarkLine ¶
func (eml *EChartsMarkLine) ToSeriesMarkLine() SeriesMarkLine
ToSeriesMarkLine converts the mark line to the internal representation.
type EChartsMarkPoint ¶
type EChartsMarkPoint struct {
SymbolSize int `json:"symbolSize"`
Data []EChartsMarkData `json:"data"`
}
EChartsMarkPoint defines mark points for a series.
func (*EChartsMarkPoint) ToSeriesMarkPoint ¶
func (emp *EChartsMarkPoint) ToSeriesMarkPoint() SeriesMarkPoint
ToSeriesMarkPoint converts the mark point to the internal representation.
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"`
}
EChartsOption mirrors a basic ECharts configuration.
func (*EChartsOption) ToOption ¶
func (eo *EChartsOption) ToOption() ChartOption
ToOption converts the ECharts options into a ChartOption.
type EChartsPadding ¶
type EChartsPadding struct {
Box Box
}
EChartsPadding represents padding values around a component.
func (*EChartsPadding) UnmarshalJSON ¶
func (eb *EChartsPadding) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a padding array into a Box.
type EChartsPosition ¶
type EChartsPosition string
EChartsPosition represents a CSS-like position value that can be either a string (like "center", "left") or a numeric value.
func (*EChartsPosition) UnmarshalJSON ¶
func (p *EChartsPosition) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a position JSON value that may be a string or number.
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
}
EChartsSeries holds data and styling for one chart series.
type EChartsSeriesData ¶
type EChartsSeriesData struct {
Value EChartsSeriesDataValue `json:"value"`
Name string `json:"name"`
ItemStyle EChartStyle `json:"itemStyle,omitempty"` // TODO - add support
}
EChartsSeriesData describes a single data item from ECharts.
func (*EChartsSeriesData) UnmarshalJSON ¶
func (es *EChartsSeriesData) UnmarshalJSON(data []byte) error
UnmarshalJSON parses a series data item that may be a number or object.
type EChartsSeriesDataValue ¶
type EChartsSeriesDataValue struct {
// contains filtered or unexported fields
}
EChartsSeriesDataValue holds numeric values from an ECharts data entry.
func (*EChartsSeriesDataValue) First ¶
func (value *EChartsSeriesDataValue) First() float64
First returns the first value or 0 when empty.
func (*EChartsSeriesDataValue) UnmarshalJSON ¶
func (value *EChartsSeriesDataValue) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a series data value that may be a single number or array.
type EChartsSeriesList ¶
type EChartsSeriesList []EChartsSeries
EChartsSeriesList is a list of EChartsSeries values.
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"`
}
EChartsTextStyle maps text style options from ECharts.
func (*EChartsTextStyle) ToFontStyle ¶ added in v0.5.0
func (et *EChartsTextStyle) ToFontStyle() FontStyle
ToFontStyle converts the text style to a FontStyle.
type EChartsXAxis ¶
type EChartsXAxis struct {
Data []EChartsXAxisData
}
EChartsXAxis holds a list of x-axis options.
func (*EChartsXAxis) UnmarshalJSON ¶
func (ex *EChartsXAxis) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes x-axis options that may be a single object or an array.
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"`
}
EChartsXAxisData holds x-axis configuration extracted from ECharts JSON.
type EChartsYAxis ¶
type EChartsYAxis struct {
Data []EChartsYAxisData `json:"data"`
}
EChartsYAxis represents a list of y-axis definitions.
func (*EChartsYAxis) UnmarshalJSON ¶
func (ey *EChartsYAxis) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes y-axis options that may be a single object or an array.
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"`
}
EChartsYAxisData holds a single y-axis configuration block.
type FontStyle ¶ added in v0.2.0
FontStyle configures font size, color, and family.
func NewFontStyleWithSize ¶ added in v0.4.7
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 around the 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 around the 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 true, renders the series stacked within one bar. This
// causes some options, including BarMargin and SeriesLabelPosition, to be
// ignored. MarkLine only renders for the first series.
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', 'diamond', or 'circle'.
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
}
LegendOption defines the configuration for rendering the chart legend.
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 around the 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 true, layers each series so the last represents the
// cumulative sum. This forces FillArea and ignores options like
// StrokeSmoothingTension. MarkLine only renders for the first series, and
// only the 0 index y-axis is stacked so another line can use the second axis.
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 {
// Top 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.
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
WithLeft returns a copy of the offset with the Left value set.
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 sets the theme of the 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 (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)
Render creates and renders a chart based on the provided options.
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
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) 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 ¶
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
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) 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 ¶
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 ¶
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) 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 ¶
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.
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 around the 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 sets the default pie radius, for example "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 RadarChartOption ¶
type RadarChartOption struct {
// Theme specifies the colors used for the radar chart.
Theme ColorPalette
// Padding specifies the padding around the 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 sets the chart radius, for example "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
}
RadarIndicator defines the dimensions of a radar chart axis.
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 around the 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 shape to draw each point with. The default
// is 'dot'. Valid options are 'circle', 'dot', 'square' and 'diamond'. This
// can also be set per-series.
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 specifies the pixel distance between the label and its associated data point or chart 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
}
SeriesMark describes a single mark line or point type.
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
}
SeriesMarkLine configures mark lines for a series.
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
SeriesMarkList is a slice of SeriesMark values.
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
}
SeriesMarkPoint configures mark points for a series.
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
}
SeriesTrendLine describes the rendered trend line style.
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
Symbol defines the shape used for data points and legends.
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
}
TableCell represents a single cell in a table.
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
}
TableChartOption defines options for rendering a table chart.
type ThemeOption ¶
type ThemeOption struct {
// IsDarkMode indicates whether the theme is designed for dark backgrounds, affecting color adjustments and text visibility.
IsDarkMode bool
// AxisStrokeColor is the default stroke color for both axes.
AxisStrokeColor Color
// XAxisStrokeColor overrides AxisStrokeColor for the x-axis.
XAxisStrokeColor Color
// YAxisStrokeColor overrides AxisStrokeColor for the y-axis.
YAxisStrokeColor Color
// AxisSplitLineColor sets the color of grid lines drawn between ticks.
AxisSplitLineColor Color
// BackgroundColor sets the chart background.
BackgroundColor Color
// TextColor is the default font color applied if specific text colors are unset.
TextColor Color
// TextColorTitle sets the title text color.
TextColorTitle Color
// TextColorMark sets the color of mark line and point labels.
TextColorMark Color
// TextColorLabel defines the color of series labels.
TextColorLabel Color
// TextColorLegend defines the legend text color.
TextColorLegend Color
// TextColorXAxis defines the x-axis label text color.
TextColorXAxis Color
// TextColorYAxis defines the y-axis label text color.
TextColorYAxis Color
// TitleBorderColor draws an optional border around the title.
TitleBorderColor Color
// LegendBorderColor draws an optional border around the legend.
LegendBorderColor Color
// SeriesColors provides the color palette used for series data.
SeriesColors []Color
// SeriesTrendColors provides the palette for rendered trend lines.
SeriesTrendColors []Color
}
ThemeOption defines color options for a theme.
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
}
TitleOption configures rendering of a chart title.
type ValueFormatter ¶
ValueFormatter defines a function that formats numeric values into string representations for display on charts.
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
}
XAxisOption configures the horizontal axis.
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 y-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
}
YAxisOption configures the vertical axis.
Source Files
¶
- alias.go
- axis.go
- bar_chart.go
- chart_option.go
- charts.go
- color.go
- doughnut_chart.go
- echarts.go
- font.go
- funnel_chart.go
- heat_map.go
- horizontal_bar_chart.go
- legend.go
- line_chart.go
- mark_line.go
- mark_point.go
- painter.go
- pie_chart.go
- radar_chart.go
- range.go
- scatter_chart.go
- series.go
- series_label.go
- table.go
- theme.go
- title.go
- trend_line.go
- util.go
- xaxis.go
- yaxis.go