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 LabelStyle
- 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 SeriesLabelFormatter
- func LabelFormatterGradientColor(values []float64, colors ...Color) SeriesLabelFormatter
- func LabelFormatterGradientGreenRed(values []float64) SeriesLabelFormatter
- func LabelFormatterGradientRedGreen(values []float64) SeriesLabelFormatter
- func LabelFormatterThresholdMax(threshold float64) SeriesLabelFormatter
- func LabelFormatterThresholdMin(threshold float64) SeriesLabelFormatter
- func LabelFormatterTopN(values []float64, n int) SeriesLabelFormatter
- 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" )
const FontFamilyNotoSans = "notosans"
FontFamilyNotoSans provides Noto Sans Display Medium, a slightly more condensed Sans variant compared to FontFamilyRoboto. This font offers better internal character and some symbol and emoji support.
const FontFamilyNotoSansBold = "notosans-bold"
FontFamilyNotoSansBold provides Noto Sans Display Extra Bold, a bold version of FontFamilyNotoSans.
const FontFamilyRoboto = "roboto"
FontFamilyRoboto is the default chart font (Roboto Medium), it provides a well spaced Sans style font with good latin character support.
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 ( // LabelFormatterValueShort provides a short value with at most 2 decimal places. LabelFormatterValueShort = func(index int, name string, val float64) (string, *LabelStyle) { return defaultValueFormatter(val), nil } // LabelFormatterNameShortValue puts the series name next to the value with up to 2 decimal places. LabelFormatterNameShortValue = func(index int, name string, val float64) (string, *LabelStyle) { return name + ": " + defaultValueFormatter(val), nil } )
var BoxZero = chartdraw.BoxZero
BoxZero is an unset Box with no dimensions.
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 formats a value with specified precision and comma separators.
func FormatValueHumanizeShort ¶ added in v0.3.1
FormatValueHumanizeShort formats a value with specified precision and comma separators. Values over 1,000 are shortened with k, M, G, T suffixes.
func GetFont ¶
GetFont returns the font by family name, or the default if the family is not installed.
func GetNullValue ¶
func GetNullValue() float64
GetNullValue returns the null value for setting series points with "no" or "unknown" value.
func InstallFont ¶
InstallFont installs a font for chart rendering.
func InstallTheme ¶
func InstallTheme(name string, opt ThemeOption)
InstallTheme adds a theme to the catalog for later retrieval using GetTheme.
func IntSliceToFloat64 ¶ added in v0.5.0
IntSliceToFloat64 converts an int slice to a float64 slice for use in charts.
func Ptr ¶ added in v0.5.0
func Ptr[T any](val T) *T
Ptr is a helper function for building config options that 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 the default chart width and height when not otherwise specified in their configuration.
func SetDefaultFont ¶
SetDefaultFont sets the default font by name.
func SetDefaultTheme ¶
SetDefaultTheme sets the default theme by name.
func SliceToFloat64 ¶ added in v0.5.0
SliceToFloat64 converts a slice of arbitrary types to float64 using the provided conversion function.
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 when *true renders series stacked within one bar.
// This ignores some options including BarMargin and SeriesLabelPosition.
// MarkLine only renders for the first series and stacking only applies to the first y-axis.
StackSeries *bool
// SeriesLabelPosition specifies the label position for the series: "top" or "bottom".
SeriesLabelPosition string
// XAxis contains options for the x-axis.
XAxis XAxisOption
// YAxis contains options for the y-axis. At most two y-axes are supported.
YAxis []YAxisOption
// Title contains options for rendering the chart title.
Title TitleOption
// Legend contains options for the data legend.
Legend LegendOption
// BarWidth specifies the width of each bar. May be reduced to fit all series on the chart.
BarWidth int
// BarMargin specifies the margin between grouped bars. BarWidth takes priority over a set margin.
BarMargin *float64
// RoundedBarCaps when *true draws bars with rounded top corners.
RoundedBarCaps *bool
// ValueFormatter defines how float values are 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 with 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 bar 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.
func (BarSeriesList) SumSeriesValues ¶ added in v0.5.0
func (b BarSeriesList) SumSeriesValues() []float64
SumSeriesValues returns a float64 slice with each series totaled by 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 specified left, top, right, and bottom values to define the position and dimensions.
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 is "png".
OutputFormat string
// Width is the width of the chart.
Width int
// Height is the height of the 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 the chart. Default is [20, 20, 20, 20].
Padding Box
// XAxis contains options for the x-axis.
XAxis XAxisOption
// YAxis contains options for the y-axis. At most two y-axes are supported.
YAxis []YAxisOption
// Title contains options for rendering the chart title.
Title TitleOption
// Legend contains 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 drawing area for the chart.
Box Box
// SeriesList provides the population data for the chart, constructed through NewSeriesListGeneric.
SeriesList GenericSeriesList
// StackSeries when set to *true causes series to be layered or stacked.
// This significantly changes chart visualization; see specific chart godocs for details.
StackSeries *bool
// RadarIndicators is the list of radar indicators for radar charts.
RadarIndicators []RadarIndicator
// Symbol specifies the symbol to draw at data points. Empty (default) varies by chart type.
// 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 when set to *true fills the area under the line in line charts.
FillArea *bool
// FillOpacity is the opacity or alpha channel (0-255) 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 bars, or height for horizontal bar charts.
BarSize int
// BarMargin specifies the margin between grouped bars. BarSize takes priority over margin.
BarMargin *float64
// Radius is the target radius for pie and radar charts. Default is "40%".
Radius string
// Children are child charts to render together.
Children []ChartOption
// ValueFormatter formats 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 represents an RGBA color.
func ColorConvertGo ¶ added in v0.4.4
ColorConvertGo converts Go's built-in colors to our Color struct. 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. Trims 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 CSS 'rgb(i,i,i)' or 'rgba(i,i,i,f)' format.
func ColorRGB ¶ added in v0.4.4
ColorRGB constructs a fully opaque color with the specified RGB values.
func ParseColor ¶ added in v0.3.2
ParseColor parses a color from a string. Supports hex with '#' prefix (e.g. '#313233'), rgb(i,i,i) or rgba(i,i,i,f) format, or common names (e.g. '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 returns a new ColorPalette with the specified x-axis color.
// Use WithXAxisTextColor to adjust the text color.
WithXAxisColor(Color) ColorPalette
// WithYAxisColor returns a new ColorPalette with the specified y-axis color.
// Use WithYAxisTextColor to adjust the text color.
WithYAxisColor(Color) ColorPalette
// WithYAxisSeriesColor returns a new ColorPalette using the specified series color for y-axis and values.
WithYAxisSeriesColor(int) ColorPalette
// WithTitleTextColor returns a new ColorPalette with the specified title text color.
WithTitleTextColor(Color) ColorPalette
// WithMarkTextColor returns a new ColorPalette with the specified mark point and line label color.
WithMarkTextColor(Color) ColorPalette
// WithLabelTextColor returns a new ColorPalette with the specified value label color.
WithLabelTextColor(Color) ColorPalette
// WithLegendTextColor returns a new ColorPalette with the specified legend text color.
WithLegendTextColor(Color) ColorPalette
// WithXAxisTextColor returns a new ColorPalette with the specified x-axis label color.
WithXAxisTextColor(Color) ColorPalette
// WithYAxisTextColor returns a new ColorPalette with the specified y-axis label color.
WithYAxisTextColor(Color) ColorPalette
// WithSeriesColors returns a new ColorPalette with the specified series colors.
// Trend line colors default to match series colors. Use WithSeriesTrendColors for further customization.
WithSeriesColors([]Color) ColorPalette
// WithSeriesTrendColors returns a new ColorPalette with the specified trend line colors.
WithSeriesTrendColors([]Color) ColorPalette
// WithBackgroundColor returns a new ColorPalette with the specified background color.
WithBackgroundColor(Color) ColorPalette
// WithTitleBorderColor returns a new ColorPalette with the specified title border color.
WithTitleBorderColor(Color) ColorPalette
// WithLegendBorderColor returns a new ColorPalette with the specified legend border color.
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 not found.
func MakeTheme ¶
func MakeTheme(opt ThemeOption) ColorPalette
MakeTheme constructs a 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 contains options for rendering the chart title.
Title TitleOption
// Legend contains 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 are 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 with 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 properties including 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 contains options for rendering the chart title.
Title TitleOption
// Legend contains options for the data legend.
Legend LegendOption
// Deprecated: ValueFormatter is deprecated, instead set the ValueFormatter at `SeriesList[*].Label.ValueFormatter`.
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 with 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 series chart type. Default is "line".
Type string
// Values provides the series data values.
Values []float64
// YAxisIndex is the y-axis to apply the series to: 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 circular charts. Default is "40%".
Radius string
// MarkPoint provides a mark point configuration for this series. If Label is enabled, MarkPoint
// replaces the label where rendered.
MarkPoint SeriesMarkPoint
// MarkLine provides amark line configuration for this series. When using MarkLine, configure
// padding on the chart's right side to ensure space for the values.
MarkLine SeriesMarkLine
}
GenericSeries references a population of data for any chart type. Chart-specific fields are only active for chart types that 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.
Title string
// TitleFontStyle specifies the font style for the axis title.
TitleFontStyle FontStyle
// Labels specifies custom labels for the axis. If empty, numeric indices are used.
// Must match the data size for the corresponding axis.
Labels []string
// LabelFontStyle specifies the font style for the axis labels.
LabelFontStyle FontStyle
// LabelRotation is the rotation angle in radians for labels. Use DegreesToRadians(float64) to convert from degrees.
LabelRotation float64
// LabelCount is the number of labels to show on the axis. Use a smaller count to reduce text collisions.
LabelCount int
// LabelCountAdjustment specifies relative influence on label count.
// Negative values result in cleaner graphs; positive values may cause 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 contains options for rendering the chart title.
Title TitleOption
// Values provides the 2D 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 contains configuration options for the x-axis.
XAxis HeatMapAxis
// YAxis contains configuration options for the y-axis.
YAxis HeatMapAxis
// ScaleMinValue overrides the minimum value for color gradient calculation. If nil, calculated from the data.
ScaleMinValue *float64
// ScaleMaxValue overrides the maximum value for color gradient calculation. If nil, calculated from the data.
ScaleMaxValue *float64
// ValuesLabel contains configuration for displaying numeric values on 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 when *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 label position for the series: "left" or "right".
SeriesLabelPosition string
// XAxis contains options for the x-axis.
XAxis XAxisOption
// YAxis contains options for the y-axis.
YAxis YAxisOption
// Title contains options for rendering the chart title.
Title TitleOption
// Legend contains 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 grouped bars. BarHeight takes priority over a set margin.
BarMargin *float64
// ValueFormatter defines how float values are 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 with 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.
func (HorizontalBarSeriesList) SumSeriesValues ¶ added in v0.5.0
func (h HorizontalBarSeriesList) SumSeriesValues() []float64
SumSeriesValues returns a float64 slice with each series totaled by the value index.
func (HorizontalBarSeriesList) ToGenericSeriesList ¶ added in v0.5.0
func (h HorizontalBarSeriesList) ToGenericSeriesList() GenericSeriesList
type LabelStyle ¶ added in v0.5.16
type LabelStyle struct {
// FontStyle overrides font properties (color, size, family) for this specific label.
FontStyle FontStyle
// BackgroundColor provides a background color behind the label text.
BackgroundColor Color
// CornerRadius sets the radius for rounded corners on the background rectangle.
CornerRadius int
// BorderColor sets the border color around the label background.
BorderColor Color
// BorderWidth sets the width of the border around the label background.
BorderWidth float64
}
LabelStyle contains optional styling overrides for individual label rendering. All fields are optional - zero values mean "use default styling from series or theme".
type LegendOption ¶
type LegendOption struct {
// Show specifies if the legend should be rendered. Set to *false (via Ptr(false)) to hide the legend.
Show *bool
// Theme specifies the colors used for the legend.
Theme ColorPalette
// SeriesNames provides the text labels for the data series.
SeriesNames []string
// FontStyle specifies the font, size, and style for legend text.
FontStyle FontStyle
// Padding specifies the space around the legend.
Padding Box
// Offset specifies the position of the legend relative to the left and top sides.
Offset OffsetStr
// Align is the legend marker and text alignment: 'left', 'right', or 'center'. Default is 'left'.
Align string
// Vertical when set to *true makes the legend orientation vertical.
Vertical *bool
// Symbol defines the icon shape next to each label. Options: 'square', 'dot', 'diamond', 'circle'.
Symbol Symbol // TODO - should Symbol configuration be changed now that we support per-series symbols
// OverlayChart when set to *true renders the legend over the chart. Ignored if Vertical is true (Vertical always forces overlay).
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 if the 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 when 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 first y-axis is stacked.
StackSeries *bool
// XAxis contains options for the x-axis.
XAxis XAxisOption
// YAxis contains options for the y-axis. At most two y-axes are supported.
YAxis []YAxisOption
// Title contains options for rendering the chart title.
Title TitleOption
// Legend contains options for the data legend.
Legend LegendOption
// Symbol specifies the symbol to draw at data points. Empty (default) varies by dataset.
// Options: 'none', 'circle', 'dot', 'square', 'diamond'. Can be overridden per series.
Symbol Symbol
// LineStrokeWidth is the width of the rendered line.
LineStrokeWidth float64
// StrokeSmoothingTension controls line smoothing (0-1). 0 creates straight lines, 1 creates heavily smoothed curves.
// Smoothing the line may move it from hitting points exactly.
// Higher tension values move the line further from exact data points.
StrokeSmoothingTension float64
// FillArea when set to *true fills the area below the line.
FillArea *bool
// FillOpacity is the opacity/alpha (0-255) of the area fill.
FillOpacity uint8
// ValueFormatter defines how float values are 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 with 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.
func (LineSeriesList) SumSeriesValues ¶ added in v0.5.0
func (l LineSeriesList) SumSeriesValues() []float64
SumSeriesValues returns a float64 slice with each series totaled by 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 is a function that modifies ChartOption.
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 output format for the chart.
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 output format for the chart.
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 output format for the chart.
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 chart theme 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 for rendering charts.
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 renders a table directly to an image with the provided options. Table options differ from other charts as they include Painter initialization state. To render a table on an existing Painter, use TableOptionRender.
func TableRenderValues ¶ added in v0.4.0
TableRenderValues renders a table chart with the provided header and data values.
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 provided options applied. Useful for rendering relative to 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 draws a filled diamond centered at (cx, cy) with the given width and height.
func (*Painter) FilledRect ¶ added in v0.4.3
FilledRect draws 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 are skipped, resulting in a gap. Single or isolated points result in just a dot being drawn at the point.
func (*Painter) MeasureText ¶
MeasureText returns 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 tension smooths out the line, the line no longer hits the provided points exactly. The more variable the points and the higher the tension, the more the line deviates.
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 specified position using the given font style. Specifying radians rotates 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 drawing area for the Painter.
func PainterFontOption ¶
func PainterFontOption(font *truetype.Font) PainterOptionFunc
PainterFontOption sets the default font face for the Painter. Used when FontStyle in chart configs doesn't specify a font.
func PainterPaddingOption ¶
func PainterPaddingOption(padding Box) PainterOptionFunc
PainterPaddingOption sets the padding within the painter canvas.
func PainterThemeOption ¶
func PainterThemeOption(theme ColorPalette) PainterOptionFunc
PainterThemeOption sets the default theme for the Painter. Used when specific chart options don't have a theme set.
type PainterOptions ¶
type PainterOptions struct {
// OutputFormat specifies the output type: "svg", "png", "jpg". Default is "png".
OutputFormat string
// Width is the width of the painter canvas.
Width int
// Height is the height of the painter canvas.
Height int
// Font is the default font for rendering text.
Font *truetype.Font
// Theme is the default theme used when charts don't specify one.
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 contains options for rendering the chart title.
Title TitleOption
// Legend contains options for the data legend.
Legend LegendOption
// Radius sets the pie radius. Default is "40%".
Radius string
// SegmentGap provides the gap between each pie slice.
SegmentGap float64
// Deprecated: ValueFormatter is deprecated, instead set the ValueFormatter at `SeriesList[*].Label.ValueFormatter`.
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 with 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
// 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. Constructed using NewSeriesListRadar.
SeriesList RadarSeriesList
// Title contains options for rendering the chart title.
Title TitleOption
// Legend contains options for the data legend.
Legend LegendOption
// RadarIndicators provides the radar indicator list.
RadarIndicators []RadarIndicator
// Radius sets the chart radius. Default is "40%".
Radius string
// ValueFormatter defines how float values are 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 with the provided data slice.
type RadarIndicator ¶
type RadarIndicator struct {
// Name specifies a name for the indicator.
Name string
// Max is the maximum value of indicator.
Max float64
// Min is the minimum value of indicator.
Min float64
// FontStyle provides the font configuration for the indicator.
FontStyle FontStyle
}
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 radar 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 contains options for the x-axis.
XAxis XAxisOption
// YAxis contains options for the y-axis. At most two y-axes are supported.
YAxis []YAxisOption
// Title contains options for rendering the chart title.
Title TitleOption
// Legend contains options for the data legend.
Legend LegendOption
// Symbol specifies the default shape for each data point. Default is 'dot'.
// Options: 'circle', 'dot', 'square', 'diamond'. Can be overridden per series.
Symbol Symbol
// SymbolSize specifies the size for each data point. Default is 2.0.
SymbolSize float64
// ValueFormatter defines how float values are 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 with 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 scatter 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.
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 {
// Show controls whether data labels are displayed for this series.
// Use Ptr(true) to show labels, Ptr(false) to hide them, or nil for chart-specific defaults.
Show *bool
// LabelFormatter provides complete control over label content and per-point styling.
// When set, this takes precedence for label production.
LabelFormatter SeriesLabelFormatter
// Deprecated: FormatTemplate is deprecated, use LabelFormatter instead for better control.
// Template string for formatting data labels with placeholders:
// {b}: the name of the data item
// {c}: the value of the data item
// {d}: the percentage of the data item (pie/doughnut charts only)
// Example: "{b}: {c} ({d})" produces "Sales: 150 (25%)"
FormatTemplate string
// ValueFormatter functions as the simplest method of number formatting or customization.
// Only utilized when other methods are not set.
ValueFormatter ValueFormatter
// FontStyle specifies the default font styling for labels in this series.
// Individual labels can override this via LabelFormatter's LabelStyle return value.
FontStyle FontStyle
// 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 configures how individual data point labels are rendered on charts.
type SeriesLabelFormatter ¶ added in v0.5.16
type SeriesLabelFormatter func(index int, name string, val float64) (string, *LabelStyle)
SeriesLabelFormatter is a function that generates custom labels with optional per-point styling. This provides full control over label content and appearance for each data point.
Parameters:
- index: The data point index within the series
- name: The series name for this data point
- val: The numeric value for this data point
Returns:
- string: The label text to display. Return "" to hide the label for this point
- *LabelStyle: Optional styling override for this specific label. Return nil to use default series/theme styling.
func LabelFormatterGradientColor ¶ added in v0.5.16
func LabelFormatterGradientColor(values []float64, colors ...Color) SeriesLabelFormatter
LabelFormatterGradientColor returns a SeriesLabelFormatter that colors labels with a gradient between multiple colors. The minimum value gets the first color, maximum value gets the last color, and intermediate values are interpolated. For two colors: lowColor -> highColor. For three+ colors: first -> second -> ... -> last. This formatter requires the complete data values to determine the min/max range for color interpolation.
func LabelFormatterGradientGreenRed ¶ added in v0.5.16
func LabelFormatterGradientGreenRed(values []float64) SeriesLabelFormatter
LabelFormatterGradientGreenRed returns a SeriesLabelFormatter that colors labels from green (minimum) to red (maximum). This formatter requires the complete data values to determine the min/max range for color interpolation.
func LabelFormatterGradientRedGreen ¶ added in v0.5.16
func LabelFormatterGradientRedGreen(values []float64) SeriesLabelFormatter
LabelFormatterGradientRedGreen returns a SeriesLabelFormatter that colors labels from red (minimum) to green (maximum). This formatter requires the complete data values to determine the min/max range for color interpolation.
func LabelFormatterThresholdMax ¶ added in v0.5.16
func LabelFormatterThresholdMax(threshold float64) SeriesLabelFormatter
LabelFormatterThresholdMax returns a SeriesLabelFormatter that only shows labels for values at or below the specified threshold. Values above the threshold will have empty labels (effectively hiding them).
func LabelFormatterThresholdMin ¶ added in v0.5.16
func LabelFormatterThresholdMin(threshold float64) SeriesLabelFormatter
LabelFormatterThresholdMin returns a SeriesLabelFormatter that only shows labels for values above the specified threshold. Values at or below the threshold will have empty labels (effectively hiding them).
func LabelFormatterTopN ¶ added in v0.5.16
func LabelFormatterTopN(values []float64, n int) SeriesLabelFormatter
LabelFormatterTopN returns a SeriesLabelFormatter that only shows labels for the top N highest values in the provided slice. This formatter requires the complete data values to determine which values are in the top N.
type SeriesMark ¶ added in v0.5.0
type SeriesMark struct {
// Type is the mark data type: "max", "min", "average". "average" is only for mark line.
Type string
// Global specifies the mark references the sum of all series. 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. Set on a specific Series instance.
func (*SeriesMarkLine) AddGlobalLines ¶ added in v0.5.0
func (m *SeriesMarkLine) AddGlobalLines(markTypes ...string)
AddGlobalLines adds "global" mark lines, which reference the sum of all 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 adds 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. 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. Set on a specific Series instance.
func (*SeriesMarkPoint) AddGlobalPoints ¶ added in v0.5.0
func (m *SeriesMarkPoint) AddGlobalPoints(markTypes ...string)
AddGlobalPoints adds "global" mark points, which reference the sum of all 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 adds 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 lines are sharp and precise, 1 provides smoother lines.
StrokeSmoothingTension float64
// LineColor overrides 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 type. Set on a specific Series instance.
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 is the text content of the table cell.
Text string
// FontStyle contains the font configuration for the cell text.
FontStyle FontStyle
// FillColor sets the background color for this table cell.
FillColor Color
// Row is the row index of the table cell.
Row int
// Column is the column index of the table cell.
Column int
}
TableCell represents a single cell in a table.
type TableChartOption ¶
type TableChartOption struct {
// OutputFormat specifies the output type: "svg", "png", "jpg".
OutputFormat string
// Theme specifies the colors used for the table.
Theme ColorPalette
// Padding specifies the padding around the 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 provides the column span for each column.
Spans []int
// TextAligns specifies the text alignment for each cell.
TextAligns []string
// FontStyle contains the font configuration for table text.
FontStyle FontStyle
// HeaderBackgroundColor provides the background color for the header row.
HeaderBackgroundColor Color
// HeaderFontColor specifies the text color for header text.
HeaderFontColor Color
// RowBackgroundColors specifies the background colors for each row.
RowBackgroundColors []Color
// BackgroundColor specifies the general background color.
BackgroundColor Color
// CellModifier is an optional function to modify TableCell style or content before rendering.
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 to *false (via Ptr(false)) to hide the title.
Show *bool
// Theme specifies the colors used for the title.
Theme ColorPalette
// Text is the title text. Supports '\n' for line breaks.
Text string
// Subtext is additional text below the title. Supports '\n' for line breaks.
Subtext string
// Offset specifies the position of the title relative to the left and top sides.
Offset OffsetStr
// FontStyle specifies the font, size, and style for the title text.
FontStyle FontStyle
// SubtextFontStyle specifies the font, size, and style for 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 to *false (via 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 set, the title is rendered below the x-axis.
Title string
// TitleFontStyle specifies the font, size, and color for the axis title.
TitleFontStyle FontStyle
// Labels provides labels for each value on the x-axis. Indices must match series data indices.
Labels []string
// DataStartIndex specifies the starting index for data values.
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 is the rotation angle in radians for labels. Use DegreesToRadians(float64) to convert from degrees.
LabelRotation float64
// LabelOffset is the position offset for each label.
LabelOffset OffsetInt
// ValueFormatter defines how float values are rendered to strings, notably for numeric axis labels.
ValueFormatter ValueFormatter
// Unit suggests the axis step size (recommendation only). Larger values result in fewer labels.
Unit float64
// LabelCount is the number of labels to show on the axis. Use a smaller count to reduce text 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 to *false (via 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 set, the axis name is rendered on the outside of the y-Axis.
Title string
// TitleFontStyle specifies the font, size, and color for the axis title.
TitleFontStyle FontStyle
// Min forces the minimum value of the y-axis when set (Use Ptr(float64)).
Min *float64
// Max forces the maximum value of the y-axis when set (Use Ptr(float64)).
Max *float64
// RangeValuePaddingScale suggests a padding scale to apply to the max and min values.
RangeValuePaddingScale *float64
// Labels provides labels for each value on the y-axis.
Labels []string
// Position describes the y-axis position: 'left' or 'right'.
Position string
// Deprecated: FontStyle is deprecated, use LabelFontStyle.
FontStyle FontStyle
// LabelFontStyle specifies the font configuration for each label.
LabelFontStyle FontStyle
// LabelRotation is the rotation angle in radians for labels. Use DegreesToRadians(float64) to convert from degrees.
LabelRotation float64
// Deprecated: Formatter is deprecated, use ValueFormatter instead.
Formatter string
// Unit suggests the axis step size (recommendation only). Larger values result in fewer labels.
Unit float64
// LabelCount is the number of labels to show on the axis. Use a smaller count to reduce text collisions.
LabelCount int
// LabelCountAdjustment specifies relative influence on label count.
// Negative values result in cleaner graphs; positive values may cause text collisions.
LabelCountAdjustment int
// LabelSkipCount specifies a qty of lines between labels that show only horizontal lines without labels.
LabelSkipCount int
// SplitLineShow when set to *true shows horizontal axis split lines.
SplitLineShow *bool
// SpineLineShow controls whether the vertical spine line is shown.
// Default is hidden unless it's a category axis.
SpineLineShow *bool
// ValueFormatter defines how float values are 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