charts
packagemoduleThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
README¶
go-analyze/charts
Our library focuses on generating beautiful charts and graphs within Go. Graphs are used to show a lot of different types of data, needing to be represented in a unique in order to convey the meaning behind the data. This Go module attempts to use sophisticated defaults to try and render this data in a simple way, while still offering intuitive options to update the graph rendering as you see fit.
Functionality
Currently supported chart types:line,scatter,bar,horizontal bar,pie,doughnut,radar,candlestick,funnel andtable.
New users should check out theFeatures Overview on our Wiki to see commonly used features for each chart type, as well as linking to specific examples for the feature.
We also have an extensivecatalog of examples. Reference theREADME within theexamples directory to see a list of our example implementations of each chart type and configurations.
Themes
Our library offers a wide range of themes, the examples below are only a small subset of what we offer. See ourThemes list in Feature Overview to see our complete theme list.

Line Chart

Line Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#line-charts
import ("github.com/go-analyze/charts")func main() {// values specified where the first index is for each data series or source, and the second index is for each sample.values := [][]float64{{// Email120, // Mon132, // Tue101, // Wed134, // Thu90, // Fri230, // Sat210, // Sun},{// values for 'Search Engine' go here},}opt := charts.NewLineChartOptionWithData(values)opt.Title = charts.TitleOption{Text: "Line Chart Demo",}opt.XAxis.Labels = []string{// The 7 labels here match to the 7 values above"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",}opt.Legend = charts.LegendOption{SeriesNames: []string{"Email", "Search Engine",},}// other options as desired...p := charts.NewPainter(charts.PainterOptions{Width: 600,Height: 400,})err := p.LineChart(opt)// ... err checkbuf, err := p.Bytes()// ...Top Line Chart Examples:
- line_chart-1-basic - Basic line chart with some simple styling changes and a demonstration of
nullvalues. - line_chart-2-symbols - Basic line chart which sets a different symbol for each series item.
- line_chart-3-smooth - Basic line chart with thick smooth lines drawn.
- line_chart-4-mark - Line chart with included mark points and mark lines.
- line_chart-6-stacked - Line chart with "Stacked" series enabled, making each series a layer on the chart and the top line showing the sum.
- line_chart-8-dual_y_axis - Basic line chart with two series, one rendered to the left axis and one to a second y axis on the right.
Scatter Chart

Scatter Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#scatter-charts
import ("github.com/go-analyze/charts")func main() {opt := charts.NewScatterChartOptionWithData([][]float64{{120, 132, 101, charts.GetNullValue(), 90, 230, 210},{ /* values for search engine go here */ },})opt.Title.Text = "Scatter"opt.XAxis.Labels = []string{// The 7 labels here match to the 7 values above"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",}opt.Legend.SeriesNames = []string{"Email", "Search Engine"}// set other field options as desired...p := charts.NewPainter(charts.PainterOptions{Width: 600,Height: 400,})err := p.ScatterChart(opt)// ... err checkbuf, err := p.Bytes()// ...Top Scatter Chart Examples:
- scatter_chart-1-basic - Basic scatter chart with some simple styling changes and a demonstration of
nullvalues. - scatter_chart-3-dense_data - Scatter chart with dense data, trend lines, and more custom styling configured.
Bar Chart

Bar Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#bar-charts
import ("github.com/go-analyze/charts")func main() {// values specified where the first index is for each data series or source, and the second index is for each sample.values := [][]float64{{ // Rainfall data2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3,},{// 'Evaporation' data goes here},}opt := charts.NewBarChartOptionWithData(values)opt.XAxis.Labels = []string{// A label for each position in the values above"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",}opt.Legend = charts.LegendOption{SeriesNames: []string{"Rainfall", "Evaporation",},Offset: charts.OffsetRight,}// Example of adding a mark line across the bars, or mark points for specific valuesopt.SeriesList[0].MarkLine.AddLines(charts.SeriesMarkTypeAverage)opt.SeriesList[0].MarkPoint.AddPoints(charts.SeriesMarkTypeMax, charts.SeriesMarkTypeMin)// other options as desired...p := charts.NewPainter(charts.PainterOptions{Width: 600,Height: 400,})err := p.BarChart(opt)// ... err checkbuf, err := p.Bytes()// ...Top Bar Chart Examples:
- bar_chart-1-basic - Basic bar chart.
- bar_chart-4-mark - Bar chart with included mark points and mark lines.
Horizontal Bar Chart

Horizontal Bar Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#horizontal-bar-charts
Top Horizontal Bar Chart Examples:
- horizontal_bar_chart-1-basic - Basic horizontal bar chart.
Pie Chart

Pie Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#pie-charts
import ("github.com/go-analyze/charts")func main() {values := []float64{1048, // Search Engine735, // Direct580, // Email484, // Union Ads300, // Video Ads}opt := charts.NewPieChartOptionWithData(values)opt.Title = charts.TitleOption{Text: "Pie Chart",Offset: charts.OffsetCenter,}opt.Legend.SeriesNames = []string{"Search Engine", "Direct", "Email", "Union Ads", "Video Ads",}// other options as desired...p := charts.NewPainter(charts.PainterOptions{Width: 600,Height: 400,})err := p.PieChart(opt)// ... err checkbuf, err := p.Bytes()// ...Top Pie Chart Examples:
- pie_chart-1-basic - Pie chart with a variety of customization demonstrated including positioning the legend in the bottom right corner.
- pie_chart-2-radius - Pie chart which varies the series radius by the percentage of the series.
Doughnut Chart

Doughnut Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#doughnut-charts
Top Radar Chart Examples:
- doughnut_chart-1-basic - Basic doughnut chart.
- doughnut_chart-2-styles - A variety of styles shown for doughnut charts.
Radar Chart

Radar Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#radar-charts
Top Radar Chart Examples:
- radar_chart-1-basic - Basic radar chart.
Heat Map Chart

Heat Map Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#heat-map-charts
Top Radar Chart Examples:
- heat_map-1-basic - Basic heat map chart.
Table

Table Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#tables
Top Table Examples:
- table-1 - Table with a variety of table specific configuration and styling demonstrated.
Candlestick Chart

Candlestick Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#candlestick-charts
import ("github.com/go-analyze/charts")func main() {ohlcData := []charts.OHLCData{{Open: 100.0, High: 110.0, Low: 95.0, Close: 105.0},{Open: 105.0, High: 115.0, Low: 100.0, Close: 112.0},{Open: 112.0, High: 118.0, Low: 108.0, Close: 115.0},// ... more OHLC data}opt := charts.NewCandlestickOptionWithData(ohlcData)opt.Title.Text = "Candlestick Chart"opt.XAxis.Labels = []string{"Day 1", "Day 2", "Day 3", // ... matching data points}p := charts.NewPainter(charts.PainterOptions{Width: 800,Height: 600,})err := p.CandlestickChart(opt)// ... err checkbuf, err := p.Bytes()// ...Top Candlestick Chart Examples:
- candlestick_chart-1-basic - Basic OHLC data visualization with a candlestick chart.
- candlestick_chart-4-patterns - Automatic pattern detection.
- candlestick_chart-5-aggregation - Time-based aggregation of candlestick data.
Funnel Chart
Funnel Chart Feature List:https://github.com/go-analyze/charts/wiki/Feature-Overview#funnel-charts
import ("github.com/go-analyze/charts")func main() {values := []float64{100, // Show80, // Click60, // Visit40, // Inquiry20, // Order}opt := charts.NewFunnelChartOptionWithData(values)opt.Title.Text = "Funnel Chart"opt.Legend.SeriesNames = []string{"Show", "Click", "Visit", "Inquiry", "Order",}p := charts.NewPainter(charts.PainterOptions{Width: 600,Height: 400,})err := p.FunnelChart(opt)// ... err checkbuf, err := p.Bytes()Top Funnel Chart Examples:
- funnel_chart-1-basic - Basic funnel chart.
ECharts Render
import ("github.com/go-analyze/charts")func main() {buf, err := charts.RenderEChartsToPNG(`{"title": {"text": "Line Chart"},"xAxis": {"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]},"series": [{"data": [150, 230, 224, 218, 135, 147, 260]}]}`)// snip...Current Project Status
Forked fromvicanso/go-charts and the archivedwcharczuk/go-chart, our project introduces enhancements for rendering challenging datasets. We aim to build upon their solid foundation to offer a more versatile and user-friendly charting solution.
API Stability
We're committed to refining the API, incorporating feedback and new ideas to enhance flexibility and ease of use.
Until thev1.0.0 release, API changes should be anticipated. We detail needed API changes on our wikiVersion Migration Guide.
Changes
Notable improvements in our fork include:
- Expanded Features: We continue to develop and extend this library. Recent additions include scatter charts with trend lines, a wide range of built-in themes, stacked series, improved support for eCharts configurations, and smooth line rendering.
- Intuitive Configuration: Our goal is to ensure configuration options are clear and easy to use. In addition to refining the Go API, we have expanded our documentation in bothGoDocs and theWiki.
- Expanded Testing: We are committed to comprehensive test coverage. Increased test coverage has led to significant bug fixes, ensuring better reliability across a wide range of configurations.
Our library is an evolving project, aiming to become a standout choice for Go developers seeking powerful yet easy-to-use charting tools. We welcome contributions and feedback as we continue to enhance our library's functionality, configurability, and reliability.
wcharczuk/go-chart Changes
If you're migrating fromwcharczuk/go-chart, you should be able to migrate with minimal modifications. Thewcharczuk/go-chart codebase has been integrated into ourchartdraw package. Any necessary changes are documented in ourwcharczuk/go‐chart Migration Guide.
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 CandlestickChartOption
- type CandlestickPatternConfig
- func (c *CandlestickPatternConfig) MergePatterns(other *CandlestickPatternConfig) *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithDarkCloudCover() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithDoji() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithDojiThreshold(threshold float64) *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithDragonfly() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithEngulfingBear() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithEngulfingBull() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithEngulfingMinSize(size float64) *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithEveningStar() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithGravestone() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithHammer() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithInvertedHammer() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithMarubozuBear() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithMarubozuBull() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithMorningStar() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithPatternFormatter(formatter PatternFormatter) *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithPatternsAll() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithPatternsBearish() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithPatternsBullish() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithPatternsCore() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithPatternsReversal() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithPatternsTrend() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithPiercingLine() *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithPreferPatternLabels(prefer bool) *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithShadowRatio(ratio float64) *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithShadowTolerance(tolerance float64) *CandlestickPatternConfig
- func (c *CandlestickPatternConfig) WithShootingStar() *CandlestickPatternConfig
- type CandlestickSeries
- type CandlestickSeriesList
- type CandlestickSeriesOption
- 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 LayoutBuilderGrid
- type LayoutBuilderRow
- type LegendOption
- type LineChartOption
- type LineSeries
- type LineSeriesList
- type LineSeriesOption
- type OHLCData
- 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 CandleStickRender(values [][]OHLCData, 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) CandlestickChart(opt CandlestickChartOption) 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) DashedLineStroke(points []Point, 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) LayoutByGrid(cols, rows int) LayoutBuilderGrid
- func (p *Painter) LayoutByRows() LayoutBuilderRow
- 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) SmoothDashedLineStroke(points []Point, tension float64, strokeColor Color, strokeWidth float64, ...)
- 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 PatternDetectionResult
- type PatternFormatter
- 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"ChartTypeCandlestick = "candlestick")
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")
const (// CandleStyleFilled always fills bodies.CandleStyleFilled = "filled"// CandleStyleTraditional uses hollow bullish, filled bearish.CandleStyleTraditional = "traditional"// CandleStyleOutline always outlines only.CandleStyleOutline = "outline")
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 (// SeriesTrendTypeLinear represents a linear regression trend line that fits a straight line through the data points.SeriesTrendTypeLinear = "linear"// SeriesTrendTypeCubic represents a cubic polynomial (degree 3) regression trend line that fits a curved line through the data points.SeriesTrendTypeCubic = "cubic"// Deprecated: SeriesTrendTypeAverage is deprecated, use SeriesTrendTypeSMA instead.SeriesTrendTypeAverage = "average"// SeriesTrendTypeSMA represents a Simple Moving Average trend line that smooths data using a sliding window average.SeriesTrendTypeSMA = "sma"// SeriesTrendTypeEMA represents an Exponential Moving Average trend line that gives more weight to recent data points.SeriesTrendTypeEMA = "ema"// SeriesTrendTypeBollingerUpper represents the upper Bollinger Band (SMA + 2 * standard deviation).// Designed for financial time-series analysis to identify volatility boundaries around price movements.SeriesTrendTypeBollingerUpper = "bollinger_upper"// SeriesTrendTypeBollingerLower represents the lower Bollinger Band (SMA - 2 * standard deviation).// Designed for financial time-series analysis to identify volatility boundaries around price movements.SeriesTrendTypeBollingerLower = "bollinger_lower"// SeriesTrendTypeRSI represents the Relative Strength Index momentum oscillator (0-100 scale).// Measures momentum by analyzing sequential price changes, designed for financial time-series analysis.SeriesTrendTypeRSI = "rsi")
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 is R: 0, G: 0, B: 128.ColorNavy =drawing.ColorNavy// ColorTeal is R: 0, G: 128, B: 128.ColorTeal =drawing.ColorTeal// ColorAqua (or Cyan) is R: 0, G: 255, B: 255.ColorAqua =drawing.ColorAqua// ColorDarkGray is R: 40, G: 40, B: 40.ColorDarkGray =Color{R: 40, G: 40, B: 40, A: 255}// ColorLightGray is R: 211, G: 211, B: 211.ColorLightGray =drawing.ColorLightGray// ColorSlateGray is R: 112, G: 128, B: 144.ColorSlateGray =drawing.ColorSlateGray// ColorLightSlateGray is R: 119, G: 136, B: 211.ColorLightSlateGray =drawing.ColorLightSlateGray// ColorAzure is R: 240, G: 255, B: 255.ColorAzure =drawing.ColorAzure// ColorBeige is R: 245, G: 245, B: 220.ColorBeige =drawing.ColorBeige// ColorBrown is R: 165, G: 42, B: 42.ColorBrown =drawing.ColorBrown// ColorChocolate is R: 210, G: 105, B: 30.ColorChocolate =drawing.ColorChocolate// ColorCoral is R: 255, G: 127, B: 80.ColorCoral =drawing.ColorCoral// ColorLightCoral is R: 240, G: 128, B: 128.ColorLightCoral =drawing.ColorLightCoral// ColorGold is R: 255, G: 215, B: 0.ColorGold =drawing.ColorGold// ColorIndigo is R: 75, G: 0, B: 130.ColorIndigo =drawing.ColorIndigo// ColorIvory is R: 255, G: 255, B: 250.ColorIvory =drawing.ColorIvory// ColorOrange is R: 255, G: 165, B: 0.ColorOrange =drawing.ColorOrange// ColorPink is R: 255, G: 192, B: 203.ColorPink =drawing.ColorPink// ColorPlum is R: 221, G: 160, B: 221.ColorPlum =drawing.ColorPlum// ColorSalmon is R: 250, G: 128, B: 114.ColorSalmon =drawing.ColorSalmon// ColorTan is R: 210, G: 180, B: 140.ColorTan =drawing.ColorTan// ColorKhaki is R: 240, G: 230, B: 140.ColorKhaki =drawing.ColorKhaki// ColorTurquoise is R: 64, G: 224, B: 208.ColorTurquoise =drawing.ColorTurquoise// ColorViolet is R: 238, G: 130, B: 238.ColorViolet =drawing.ColorViolet// ColorSkyBlue is R: 135, G: 206, B: 235.ColorSkyBlue =drawing.ColorSkyBlue// ColorLavender is R: 230, G: 230, B: 250.ColorLavender =drawing.ColorLavender// ColorThistle is R: 216, G: 191, B: 216.ColorThistle =drawing.ColorThistle// ColorBlackAlt1 is slightly lighter shade of black: R: 51, G: 51, B: 51.ColorBlackAlt1 =chartdraw.ColorBlack// ColorBlueAlt1 is lighter shade of blue: R:0, G: 116, B: 217.ColorBlueAlt1 =chartdraw.ColorBlue// ColorBlueAlt2 is a sea blue: R: 106, G: 195, B: 203.ColorBlueAlt2 =chartdraw.ColorAlternateBlue// ColorBlueAlt3 is the echarts shade of blue: R: 84, G: 112, B: 198.ColorBlueAlt3 =Color{R: 84, G: 112, B: 198, A: 255}// ColorAquaAlt1 is a lighter aqua: R: 0, G: 217, B: 210.ColorAquaAlt1 =chartdraw.ColorCyan// ColorAquaAlt2 is the echarts shade of aqua: R: 115, G: 192, B: 222.ColorAquaAlt2 =Color{R: 115, G: 192, B: 222, A: 255}// 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}// ColorGreenAlt5 is a brighter green: R: 34, G: 197, B: 94.ColorGreenAlt5 =Color{R: 34, G: 197, B: 94, A: 255}// ColorGreenAlt6 is the echarts shade of green: R: 145, G: 204, B: 117.ColorGreenAlt6 =Color{R: 145, G: 204, B: 117, A: 255}// ColorGreenAlt7 is natural pale moss green: R: 121, G: 191, B: 127.ColorGreenAlt7 =Color{R: 121, G: 191, B: 127, A: 255}// ColorPurpleAlt1 is echarts shade of dark purple: R: 154, G: 96, B: 180.ColorPurpleAlt1 =Color{R: 154, G: 96, B: 180, A: 255}// ColorPurpleAlt2 is echarts shade of light purple: R: 234, G: 124, B: 204.ColorPurpleAlt2 =Color{R: 234, G: 124, B: 204, 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}// ColorRedAlt3 is a brighter red: R: 239, G: 68, B: 68.ColorRedAlt3 =Color{R: 239, G: 68, B: 68, A: 255}// ColorRedAlt4 is the echarts shade of red: R: 238, G: 102, B: 102.ColorRedAlt4 =Color{R: 238, G: 102, B: 102, 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}// ColorOrangeAlt4 is echarts shade of orange: R: 252, G: 132, B: 82.ColorOrangeAlt4 =Color{R: 252, G: 132, B: 82, 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(indexint, namestring, valfloat64) (string, *LabelStyle) {return defaultValueFormatter(val),nil}// LabelFormatterNameShortValue puts the series name next to the value with up to 2 decimal places.LabelFormatterNameShortValue = func(indexint, namestring, valfloat64) (string, *LabelStyle) {return name + ": " + defaultValueFormatter(val),nil})
var BoxZero =chartdraw.BoxZeroBoxZero 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¶
funcDegreesToRadians¶added inv0.4.1
DegreesToRadians returns degrees as radians.
funcFormatValueHumanize¶added inv0.3.1
FormatValueHumanize formats a value with specified precision and comma separators.
funcFormatValueHumanizeShort¶added inv0.3.1
FormatValueHumanizeShort formats a value with specified precision and comma separators.Values over 1,000 are shortened with k, M, G, T suffixes.
funcGetNullValue¶
func GetNullValue()float64
GetNullValue returns the null value for setting series points with "no" or "unknown" value.
funcInstallFont¶
InstallFont installs a font for chart rendering.
funcInstallTheme¶
func InstallTheme(namestring, optThemeOption)
InstallTheme adds a theme to the catalog for later retrieval using GetTheme.
funcIntSliceToFloat64¶added inv0.5.0
IntSliceToFloat64 converts an int slice to a float64 slice for use in charts.
funcPtr¶added inv0.5.0
func Ptr[Tany](val T) *T
Ptr is a helper function for building config options that reference pointers.
funcRadiansToDegrees¶added inv0.4.1
RadiansToDegrees translates a radian value to a degree value.
funcRenderEChartsToJPG¶added inv0.5.1
RenderEChartsToJPG renders an ECharts option JSON string to JPG bytes.
funcRenderEChartsToPNG¶
RenderEChartsToPNG renders an ECharts option JSON string to PNG bytes.
funcRenderEChartsToSVG¶
RenderEChartsToSVG renders an ECharts option JSON string to SVG bytes.
funcSetDefaultChartDimensions¶added inv0.4.0
func SetDefaultChartDimensions(width, heightint)
SetDefaultChartDimensions sets the default chart width and height when not otherwise specified in their configuration.
funcSetDefaultFont¶
SetDefaultFont sets the default font by name.
funcSetDefaultTheme¶
SetDefaultTheme sets the default theme by name.
funcSliceToFloat64¶added inv0.5.0
SliceToFloat64 converts a slice of arbitrary types to float64 using the provided conversion function.
Types¶
typeBarChartOption¶
type BarChartOption struct {// Theme specifies the colors used for the bar chart.ThemeColorPalette// Padding specifies the padding around the chart.PaddingBox// 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.SeriesListBarSeriesList// 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".SeriesLabelPositionstring// XAxis contains options for the x-axis.XAxisXAxisOption// YAxis contains options for the y-axis. At most two y-axes are supported.YAxis []YAxisOption// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// BarWidth specifies the width of each bar. May be reduced to fit all series on the chart.BarWidthint// TODO - v0.6 - Update to float64 to represent a precent// BarMargin specifies the margin between grouped bars. BarWidth takes priority over a set margin.BarMargin *float64// TODO - v0.6 - Update to be percent based// 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.ValueFormatterValueFormatter}BarChartOption defines the options for rendering a bar chart. Render the chart using Painter.BarChart.
funcNewBarChartOptionWithData¶added inv0.4.0
func NewBarChartOptionWithData(data [][]float64)BarChartOption
NewBarChartOptionWithData returns an initialized BarChartOption with the SeriesList set with the provided data slice.
funcNewBarChartOptionWithSeries¶added inv0.5.9
func NewBarChartOptionWithSeries(slBarSeriesList)BarChartOption
NewBarChartOptionWithSeries returns an initialized BarChartOption with the provided SeriesList.
typeBarSeries¶added inv0.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.YAxisIndexint// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring// MarkPoint provides a configuration for mark points for this series. If Label is also enabled, the MarkPoint// will replace the label where rendered.MarkPointSeriesMarkPoint// 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.MarkLineSeriesMarkLine// contains filtered or unexported fields}BarSeries references a population of data for bar charts.
typeBarSeriesList¶added inv0.5.0
type BarSeriesList []BarSeries
BarSeriesList provides the data populations for bar charts (BarChartOption).
funcNewSeriesListBar¶added inv0.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 populationof the data, while the second dimension provides the samples for the population (on the X-Axis).
func (BarSeriesList)SetSeriesLabels¶added inv0.5.6
func (bBarSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
func (BarSeriesList)SumSeries¶added inv0.5.0
func (bBarSeriesList) SumSeries() []float64
SumSeries returns a float64 slice with the sum of each series.
func (BarSeriesList)SumSeriesValues¶added inv0.5.0
func (bBarSeriesList) SumSeriesValues() []float64
SumSeriesValues returns a float64 slice with each series totaled by the value index.
func (BarSeriesList)ToGenericSeriesList¶added inv0.5.0
func (bBarSeriesList) ToGenericSeriesList()GenericSeriesList
typeBarSeriesOption¶added inv0.4.0
type BarSeriesOption struct {LabelSeriesLabelNames []stringMarkPointSeriesMarkPointMarkLineSeriesMarkLine}BarSeriesOption provides series customization for NewSeriesListBar or NewSeriesListHorizontalBar.
typeBox¶
Box defines spacing boundaries around a component.
funcNewBox¶added inv0.4.6
NewBox returns a new Box with the specified left, top, right, and bottom values to define the position and dimensions.
funcNewBoxEqual¶added inv0.4.6
NewBoxEqual returns a new box with equal sizes to each side.
typeCandlestickChartOption¶added inv0.5.17
type CandlestickChartOption struct {// Theme specifies the colors used for the candlestick chart.ThemeColorPalette// Padding specifies the padding around the chart.PaddingBox// SeriesList provides the OHLC data population for the chart. Typically constructed using NewSeriesListCandlestick.SeriesListCandlestickSeriesList// XAxis contains options for the x-axis.XAxisXAxisOption// YAxis contains options for the y-axis. At most two y-axes are supported.YAxis []YAxisOption// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// CandleWidth sets body width ratio (0.0–1.0, default 0.8).CandleWidthfloat64// ShowWicks controls whether high-low wicks are displayed by default. When nil, wicks are shown.// Individual series can override this setting.ShowWicks *bool// WickWidth sets wick stroke width in pixels (default 1.0).WickWidthfloat64// CandleMargin sets inter-series spacing ratio (0.0–1.0, auto by default).// Only applies with multiple candlestick series.CandleMargin *float64// ValueFormatter formats numeric values.ValueFormatterValueFormatter}CandlestickChartOption defines options for rendering candlestick charts. Render the chart using Painter.CandlestickChart.
funcNewCandlestickOptionWithData¶added inv0.5.17
func NewCandlestickOptionWithData(data ...[]OHLCData)CandlestickChartOption
NewCandlestickOptionWithData creates a CandlestickChartOption from OHLC data slices.
funcNewCandlestickOptionWithSeries¶added inv0.5.17
func NewCandlestickOptionWithSeries(series ...CandlestickSeries)CandlestickChartOption
NewCandlestickOptionWithSeries returns an initialized CandlestickChartOption with the provided Series.
typeCandlestickPatternConfig¶added inv0.5.17
type CandlestickPatternConfig struct {// PreferPatternLabels controls pattern/user label precedence// true = pattern labels have priority over user labels, false = user labels have priority over pattern labelsPreferPatternLabelsbool// PatternFormatter allows custom formatting, if nil, uses default formatting with theme colors.PatternFormatterPatternFormatter// EnabledPatterns lists specific patterns to detect// nil or empty = no patterns detected (PatternConfig must be set to enable)// Use With* methods to configure patternsEnabledPatterns []string// DojiThreshold is the body-to-range ratio threshold for doji pattern detection.// Default: 0.05 (5% - standard textbook definition)// A candlestick where the body is ≤5% of the total range is considered a doji.DojiThresholdfloat64// ShadowTolerance is the shadow-to-range ratio threshold for patterns requiring minimal shadows.// Used by marubozu patterns to determine acceptable shadow size.// Default: 0.01 (1% of range)ShadowTolerancefloat64// ShadowRatio is the minimum shadow-to-body ratio for patterns requiring long shadows.// Used by hammer, shooting star, and similar patterns.// Default: 2.0 (shadow must be at least 2x the body - standard textbook definition)ShadowRatiofloat64// EngulfingMinSize is the minimum size ratio for engulfing patterns.// The engulfing candle body must be at least this percentage of the engulfed candle body.// Default: 1.0 (100% - must completely engulf the previous body)EngulfingMinSizefloat64}CandlestickPatternConfig configures automatic pattern detection.EXPERIMENTAL: Pattern detection logic is under active development and may change in future versions.
func (*CandlestickPatternConfig)MergePatterns¶added inv0.5.17
func (c *CandlestickPatternConfig) MergePatterns(other *CandlestickPatternConfig) *CandlestickPatternConfig
MergePatterns creates a new CandlestickPatternConfig by combining the enabled patterns config with another.It returns a union of both pattern sets with the current config taking precedence for other settings.
func (*CandlestickPatternConfig)WithDarkCloudCover¶added inv0.5.17
func (c *CandlestickPatternConfig) WithDarkCloudCover() *CandlestickPatternConfig
WithDarkCloudCover adds the dark cloud cover pattern.
func (*CandlestickPatternConfig)WithDoji¶added inv0.5.17
func (c *CandlestickPatternConfig) WithDoji() *CandlestickPatternConfig
WithDoji adds the doji pattern.
func (*CandlestickPatternConfig)WithDojiThreshold¶added inv0.5.17
func (c *CandlestickPatternConfig) WithDojiThreshold(thresholdfloat64) *CandlestickPatternConfig
WithDojiThreshold sets the doji threshold (default: 0.05).
func (*CandlestickPatternConfig)WithDragonfly¶added inv0.5.17
func (c *CandlestickPatternConfig) WithDragonfly() *CandlestickPatternConfig
WithDragonfly adds the dragonfly doji pattern.
func (*CandlestickPatternConfig)WithEngulfingBear¶added inv0.5.17
func (c *CandlestickPatternConfig) WithEngulfingBear() *CandlestickPatternConfig
WithEngulfingBear adds the bearish engulfing pattern.
func (*CandlestickPatternConfig)WithEngulfingBull¶added inv0.5.17
func (c *CandlestickPatternConfig) WithEngulfingBull() *CandlestickPatternConfig
WithEngulfingBull adds the bullish engulfing pattern.
func (*CandlestickPatternConfig)WithEngulfingMinSize¶added inv0.5.17
func (c *CandlestickPatternConfig) WithEngulfingMinSize(sizefloat64) *CandlestickPatternConfig
WithEngulfingMinSize sets the engulfing minimum size (default: 1.0).
func (*CandlestickPatternConfig)WithEveningStar¶added inv0.5.17
func (c *CandlestickPatternConfig) WithEveningStar() *CandlestickPatternConfig
WithEveningStar adds the evening star pattern.
func (*CandlestickPatternConfig)WithGravestone¶added inv0.5.17
func (c *CandlestickPatternConfig) WithGravestone() *CandlestickPatternConfig
WithGravestone adds the gravestone doji pattern.
func (*CandlestickPatternConfig)WithHammer¶added inv0.5.17
func (c *CandlestickPatternConfig) WithHammer() *CandlestickPatternConfig
WithHammer adds the hammer pattern.
func (*CandlestickPatternConfig)WithInvertedHammer¶added inv0.5.17
func (c *CandlestickPatternConfig) WithInvertedHammer() *CandlestickPatternConfig
WithInvertedHammer adds the inverted hammer pattern.
func (*CandlestickPatternConfig)WithMarubozuBear¶added inv0.5.17
func (c *CandlestickPatternConfig) WithMarubozuBear() *CandlestickPatternConfig
WithMarubozuBear adds the bearish marubozu pattern.
func (*CandlestickPatternConfig)WithMarubozuBull¶added inv0.5.17
func (c *CandlestickPatternConfig) WithMarubozuBull() *CandlestickPatternConfig
WithMarubozuBull adds the bullish marubozu pattern.
func (*CandlestickPatternConfig)WithMorningStar¶added inv0.5.17
func (c *CandlestickPatternConfig) WithMorningStar() *CandlestickPatternConfig
WithMorningStar adds the morning star pattern.
func (*CandlestickPatternConfig)WithPatternFormatter¶added inv0.5.17
func (c *CandlestickPatternConfig) WithPatternFormatter(formatterPatternFormatter) *CandlestickPatternConfig
WithPatternFormatter sets a custom pattern formatter.
func (*CandlestickPatternConfig)WithPatternsAll¶added inv0.5.17
func (c *CandlestickPatternConfig) WithPatternsAll() *CandlestickPatternConfig
WithPatternsAll enables all standard patterns.
func (*CandlestickPatternConfig)WithPatternsBearish¶added inv0.5.17
func (c *CandlestickPatternConfig) WithPatternsBearish() *CandlestickPatternConfig
WithPatternsBearish enables only bearish patterns.
func (*CandlestickPatternConfig)WithPatternsBullish¶added inv0.5.17
func (c *CandlestickPatternConfig) WithPatternsBullish() *CandlestickPatternConfig
WithPatternsBullish enables only bullish patterns.
func (*CandlestickPatternConfig)WithPatternsCore¶added inv0.5.17
func (c *CandlestickPatternConfig) WithPatternsCore() *CandlestickPatternConfig
WithPatternsCore enables only the most reliable patterns that work well without volume.
func (*CandlestickPatternConfig)WithPatternsReversal¶added inv0.5.17
func (c *CandlestickPatternConfig) WithPatternsReversal() *CandlestickPatternConfig
WithPatternsReversal enables only reversal patterns.
func (*CandlestickPatternConfig)WithPatternsTrend¶added inv0.5.17
func (c *CandlestickPatternConfig) WithPatternsTrend() *CandlestickPatternConfig
WithPatternsTrend enables only trend continuation patterns.
func (*CandlestickPatternConfig)WithPiercingLine¶added inv0.5.17
func (c *CandlestickPatternConfig) WithPiercingLine() *CandlestickPatternConfig
WithPiercingLine adds the piercing line pattern.
func (*CandlestickPatternConfig)WithPreferPatternLabels¶added inv0.5.17
func (c *CandlestickPatternConfig) WithPreferPatternLabels(preferbool) *CandlestickPatternConfig
WithPreferPatternLabels sets whether pattern labels have priority over user labels.
func (*CandlestickPatternConfig)WithShadowRatio¶added inv0.5.17
func (c *CandlestickPatternConfig) WithShadowRatio(ratiofloat64) *CandlestickPatternConfig
WithShadowRatio sets the shadow ratio (default: 2.0).
func (*CandlestickPatternConfig)WithShadowTolerance¶added inv0.5.17
func (c *CandlestickPatternConfig) WithShadowTolerance(tolerancefloat64) *CandlestickPatternConfig
WithShadowTolerance sets the shadow tolerance (default: 0.01).
func (*CandlestickPatternConfig)WithShootingStar¶added inv0.5.17
func (c *CandlestickPatternConfig) WithShootingStar() *CandlestickPatternConfig
WithShootingStar adds the shooting star pattern.
typeCandlestickSeries¶added inv0.5.17
type CandlestickSeries struct {// Data provides OHLC data for each time period.Data []OHLCData// YAxisIndex is the index for the axis, it must be 0 or 1.YAxisIndexint// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring// OpenMarkPoint provides mark points for open values.OpenMarkPointSeriesMarkPoint// OpenMarkLine provides mark lines for open values.OpenMarkLineSeriesMarkLine// OpenTrendLine provides trend lines for open values.OpenTrendLine []SeriesTrendLine// HighMarkPoint provides mark points for high values.HighMarkPointSeriesMarkPoint// HighMarkLine provides mark lines for high values.HighMarkLineSeriesMarkLine// HighTrendLine provides trend lines for high values.HighTrendLine []SeriesTrendLine// LowMarkPoint provides mark points for low values.LowMarkPointSeriesMarkPoint// LowMarkLine provides mark lines for low values.LowMarkLineSeriesMarkLine// LowTrendLine provides trend lines for low values.LowTrendLine []SeriesTrendLine// CloseMarkPoint provides mark points for close values.CloseMarkPointSeriesMarkPoint// CloseMarkLine provides mark lines for close values.CloseMarkLineSeriesMarkLine// CloseTrendLine provides trend lines for close values.CloseTrendLine []SeriesTrendLine// ShowWicks hides wicks when false (body only). Overrides chart-level setting.ShowWicks *bool// CandleStyle specifies the visual style: CandleStyleFilled, CandleStyleTraditional, or CandleStyleOutline.CandleStylestring// PatternConfig configures automatic pattern detection and labeling.PatternConfig *CandlestickPatternConfig// contains filtered or unexported fields}CandlestickSeries references OHLC data for candlestick charts.
funcAggregateCandlestick¶added inv0.5.17
func AggregateCandlestick(dataCandlestickSeries, factorint)CandlestickSeries
AggregateCandlestick aggregates OHLC data by the specified factor.
func (*CandlestickSeries)ExtractClosePrices¶added inv0.5.17
func (k *CandlestickSeries) ExtractClosePrices() []float64
ExtractClosePrices extracts close prices from OHLC data for use with indicators.
func (*CandlestickSeries)ExtractHighPrices¶added inv0.5.17
func (k *CandlestickSeries) ExtractHighPrices() []float64
ExtractHighPrices extracts high prices from OHLC data.
func (*CandlestickSeries)ExtractLowPrices¶added inv0.5.17
func (k *CandlestickSeries) ExtractLowPrices() []float64
ExtractLowPrices extracts low prices from OHLC data.
func (*CandlestickSeries)ExtractOpenPrices¶added inv0.5.17
func (k *CandlestickSeries) ExtractOpenPrices() []float64
ExtractOpenPrices extracts open prices from OHLC data.
func (*CandlestickSeries)Summary¶added inv0.5.17
func (k *CandlestickSeries) Summary() populationSummary
typeCandlestickSeriesList¶added inv0.5.17
type CandlestickSeriesList []CandlestickSeries
CandlestickSeriesList holds multiple CandlestickSeries values.
funcNewSeriesListCandlestick¶added inv0.5.17
func NewSeriesListCandlestick(data [][]OHLCData, opts ...CandlestickSeriesOption)CandlestickSeriesList
NewSeriesListCandlestick builds a SeriesList for candlestick charts from OHLC data.
func (CandlestickSeriesList)SetSeriesLabels¶added inv0.5.17
func (kCandlestickSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
func (CandlestickSeriesList)SumSeries¶added inv0.5.17
func (kCandlestickSeriesList) SumSeries() []float64
SumSeries returns a float64 slice with the sum of each series.For candlestick series, this sums the High and Low values (used for range calculations).
func (CandlestickSeriesList)ToGenericSeriesList¶added inv0.5.17
func (kCandlestickSeriesList) ToGenericSeriesList()GenericSeriesList
ToGenericSeriesList converts candlestick series to generic series format.Each candlestick is encoded as 4 consecutive float64 values: [Open, High, Low, Close].Invalid OHLC data is encoded with null values to maintain the 4-element structure.
typeCandlestickSeriesOption¶added inv0.5.17
type CandlestickSeriesOption struct {// Label styles the series labels.LabelSeriesLabel// Names provide data names for each series.Names []string// OpenMarkPoint marks open prices.OpenMarkPointSeriesMarkPoint// OpenMarkLine draws reference lines for open prices.OpenMarkLineSeriesMarkLine// OpenTrendLine adds trend lines based on opens.OpenTrendLine []SeriesTrendLine// HighMarkPoint marks high prices.HighMarkPointSeriesMarkPoint// HighMarkLine draws reference lines for highs.HighMarkLineSeriesMarkLine// HighTrendLine adds trend lines based on highs.HighTrendLine []SeriesTrendLine// LowMarkPoint marks low prices.LowMarkPointSeriesMarkPoint// LowMarkLine draws reference lines for lows.LowMarkLineSeriesMarkLine// LowTrendLine adds trend lines based on lows.LowTrendLine []SeriesTrendLine// CloseMarkPoint marks closing prices.CloseMarkPointSeriesMarkPoint// CloseMarkLine draws reference lines for closes.CloseMarkLineSeriesMarkLine// CloseTrendLine adds trend lines based on closes.CloseTrendLine []SeriesTrendLine// CandleStyle sets the drawing style for candles.CandleStylestring// PatternConfig configures candlestick pattern detection.PatternConfig *CandlestickPatternConfig}CandlestickSeriesOption configures optional elements when buildingcandlestick series.
typeChartOption¶
type ChartOption struct {// OutputFormat specifies the output type of chart: "svg", "png", or "jpg". Default is "png".OutputFormatstring// Width is the width of the chart.Widthint// Height is the height of the chart.Heightint// 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".ThemeColorPalette// Padding specifies the padding for the chart. Default is [20, 20, 20, 20].PaddingBox// XAxis contains options for the x-axis.XAxisXAxisOption// YAxis contains options for the y-axis. At most two y-axes are supported.YAxis []YAxisOption// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// 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.BoxBox// SeriesList provides the population data for the chart, constructed through NewSeriesListGeneric.SeriesListGenericSeriesList// 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'.SymbolSymbol// TODO - v0.6 - consider combining symbol with size into a SymbolStyle struct// LineStrokeWidth is the stroke width for line charts.LineStrokeWidthfloat64// 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.FillOpacityuint8// Deprecated: BarWidth is deprecated, instead use BarSize.BarWidthint// Deprecated: BarHeight is deprecated, instead use BarSize.BarHeightint// BarSize represents the width of bars, or height for horizontal bar charts.BarSizeint// 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%".Radiusstring// Children are child charts to render together.Children []ChartOption// ValueFormatter formats numeric values into labels.ValueFormatterValueFormatter// contains filtered or unexported fields}ChartOption represents a generic method of representing a chart. This can be useful when you want to renderdifferent chart types with the same data and configuration.
typeColor¶
Color represents an RGBA color.
funcColorConvertGo¶added inv0.4.4
ColorConvertGo converts Go's built-in colors to our Color struct.Allows easy use of colors defined in image/colornames.
funcColorFromHex¶added inv0.4.4
ColorFromHex returns a color from a CSS hex code.Trims a leading '#' character if present.
funcColorFromKnown¶added inv0.4.4
ColorFromKnown returns an internal color from a known (basic) color name.
funcColorFromRGBA¶added inv0.4.4
ColorFromRGBA returns a color from CSS 'rgb(i,i,i)' or 'rgba(i,i,i,f)' format.
funcParseColor¶added inv0.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').
typeColorPalette¶
type ColorPalette interface {IsDark()boolGetXAxisStrokeColor()ColorGetYAxisStrokeColor()ColorGetAxisSplitLineColor()ColorGetSeriesColor(int)ColorGetSeriesTrendColor(int)ColorGetBackgroundColor()ColorGetTitleTextColor()ColorGetMarkTextColor()ColorGetLabelTextColor()ColorGetLegendTextColor()ColorGetXAxisTextColor()ColorGetYAxisTextColor()ColorGetTitleBorderColor()ColorGetLegendBorderColor()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// GetCandleWickColor returns the color for the high-low wicks.GetCandleWickColor()Color// GetSeriesUpDownColors returns distinct "up" and "down" colors for each series index.GetSeriesUpDownColors(indexint) (Color,Color)}ColorPalette provides the theming for the chart.
funcGetTheme¶
func GetTheme(namestring)ColorPalette
GetTheme returns an installed theme by name, or the default if not found.
funcMakeTheme¶
func MakeTheme(optThemeOption)ColorPalette
MakeTheme constructs a theme without installing it into the catalog.
typeDoughnutChartOption¶added inv0.5.6
type DoughnutChartOption struct {// Theme specifies the colors used for the doughnut chart.ThemeColorPalette// Padding specifies the padding around the chart.PaddingBox// SeriesList provides the data population for the chart. Typically constructed using NewSeriesListDoughnut.SeriesListDoughnutSeriesList// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// RadiusRing sets the outer radius of the ring, for example "40%".// Default is "40%".RadiusRingstring// RadiusCenter is the radius for the center hole of the doughnut and must be smaller than RadiusRing.RadiusCenterstring// 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).CenterValuesstring// CenterValuesFontStyle provides the styling for center values (series labels prefer their specific series styling).CenterValuesFontStyleFontStyle// SegmentGap provides a margin between each series section.SegmentGapfloat64// ValueFormatter defines how float values are rendered to strings, notably for series labels.ValueFormatterValueFormatter}DoughnutChartOption defines the options for rendering a doughnut chart. Render the chart using Painter.DoughnutChart.
funcNewDoughnutChartOptionWithData¶added inv0.5.6
func NewDoughnutChartOptionWithData(data []float64)DoughnutChartOption
NewDoughnutChartOptionWithData returns an initialized DoughnutChartOption with the SeriesList set with the provided data slice.
typeDoughnutSeries¶added inv0.5.6
type DoughnutSeries struct {// Value provides the value for the Doughnut section.Valuefloat64// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring// Radius for Doughnut chart, e.g.: 40%, default is "40%"Radiusstring}DoughnutSeries references a population of data for doughnut charts.
typeDoughnutSeriesList¶added inv0.5.6
type DoughnutSeriesList []DoughnutSeries
DoughnutSeriesList provides the data populations for Doughnut charts (DoughnutChartOption).
funcNewSeriesListDoughnut¶added inv0.5.6
func NewSeriesListDoughnut(values []float64, opts ...DoughnutSeriesOption)DoughnutSeriesList
NewSeriesListDoughnut builds a SeriesList for a doughnut chart.
func (DoughnutSeriesList)MaxValue¶added inv0.5.6
func (dDoughnutSeriesList) MaxValue()float64
MaxValue returns the maximum value within the series, or MinInt64 if no values.
func (DoughnutSeriesList)SetSeriesLabels¶added inv0.5.6
func (dDoughnutSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
func (DoughnutSeriesList)SumSeries¶added inv0.5.6
func (dDoughnutSeriesList) SumSeries()float64
func (DoughnutSeriesList)ToGenericSeriesList¶added inv0.5.6
func (dDoughnutSeriesList) ToGenericSeriesList()GenericSeriesList
typeDoughnutSeriesOption¶added inv0.5.6
type DoughnutSeriesOption struct {LabelSeriesLabelNames []string}DoughnutSeriesOption provides series customization for NewSeriesListDoughnut.
typeEChartStyle¶
EChartStyle describes color and opacity for ECharts elements.
typeEChartsAxisLabel¶
type EChartsAxisLabel struct {Formatterstring `json:"formatter,omitempty"`Show *bool `json:"show,omitempty"`Colorstring `json:"color,omitempty"`FontSize *int `json:"fontSize,omitempty"`}EChartsAxisLabel configures axis label display for ECharts.
typeEChartsAxisLine¶added inv0.5.0
type EChartsAxisLine struct {Show *bool `json:"show,omitempty"`LineStyle struct {Colorstring `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.
typeEChartsLabelOption¶
type EChartsLabelOption struct {Showbool `json:"show"`Distanceint `json:"distance"`Colorstring `json:"color"`}EChartsLabelOption configures data labels.
typeEChartsLegend¶
type EChartsLegend struct {Show *bool `json:"show"`Data []string `json:"data"`Alignstring `json:"align"`Orientstring `json:"orient"`PaddingEChartsPadding `json:"padding,omitempty"`LeftEChartsPosition `json:"left"`TopEChartsPosition `json:"top"`TextStyleEChartsTextStyle `json:"textStyle"`BackgroundColorstring `json:"backgroundColor,omitempty"`// TODO - add supportBorderColorstring `json:"borderColor,omitempty"`}EChartsLegend holds legend configuration from ECharts JSON.
typeEChartsMarkData¶
type EChartsMarkData struct {Typestring `json:"type"`// TODO - support position values belowXAxisfloat64 `json:"xAxis,omitempty"`YAxisfloat64 `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.
typeEChartsMarkLine¶
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.
typeEChartsMarkPoint¶
type EChartsMarkPoint struct {SymbolSizeint `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.
typeEChartsOption¶
type EChartsOption struct {Typestring `json:"type"`Themestring `json:"theme"`FontFamilystring `json:"fontFamily"`PaddingEChartsPadding `json:"padding"`BoxBox `json:"box"`Widthint `json:"width"`Heightint `json:"height"`Title struct {Show *bool `json:"show,omitempty"`Textstring `json:"text"`Subtextstring `json:"subtext"`LeftEChartsPosition `json:"left"`TopEChartsPosition `json:"top"`TextStyleEChartsTextStyle `json:"textStyle"`SubtextStyleEChartsTextStyle `json:"subtextStyle"`BackgroundColorstring `json:"backgroundColor,omitempty"`// TODO - add supportBorderColorstring `json:"borderColor,omitempty"`} `json:"title"`XAxisEChartsXAxis `json:"xAxis"`YAxisEChartsYAxis `json:"yAxis"`LegendEChartsLegend `json:"legend"`Radar struct {Indicator []RadarIndicator `json:"indicator"`} `json:"radar"`SeriesEChartsSeriesList `json:"series"`BackgroundColorstring `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.
typeEChartsPadding¶
type EChartsPadding struct {BoxBox}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.
typeEChartsPosition¶
type EChartsPositionstring
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.
typeEChartsSeries¶
type EChartsSeries struct {Data []EChartsSeriesData `json:"data"`Namestring `json:"name"`Typestring `json:"type"`Radiusstring `json:"radius"`YAxisIndexint `json:"yAxisIndex"`ItemStyleEChartStyle `json:"itemStyle,omitempty"`// TODO - add support// label configurationLabelEChartsLabelOption `json:"label"`MarkPointEChartsMarkPoint `json:"markPoint"`MarkLineEChartsMarkLine `json:"markLine"`Max *float64 `json:"max"`// TODO - add supportMin *float64 `json:"min"`// TODO - add support}EChartsSeries holds data and styling for one chart series.
typeEChartsSeriesData¶
type EChartsSeriesData struct {ValueEChartsSeriesDataValue `json:"value"`Namestring `json:"name"`ItemStyleEChartStyle `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.
typeEChartsSeriesDataValue¶
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.
typeEChartsSeriesList¶
type EChartsSeriesList []EChartsSeries
EChartsSeriesList is a list of EChartsSeries values.
func (EChartsSeriesList)ToSeriesList¶
func (esListEChartsSeriesList) ToSeriesList()GenericSeriesList
typeEChartsTextStyle¶
type EChartsTextStyle struct {Colorstring `json:"color"`FontFamilystring `json:"fontFamily"`FontSizefloat64 `json:"fontSize"`}EChartsTextStyle maps text style options from ECharts.
func (*EChartsTextStyle)ToFontStyle¶added inv0.5.0
func (et *EChartsTextStyle) ToFontStyle()FontStyle
ToFontStyle converts the text style to a FontStyle.
typeEChartsXAxis¶
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.
typeEChartsXAxisData¶
type EChartsXAxisData struct {BoundaryGap *bool `json:"boundaryGap,omitempty"`SplitNumberint `json:"splitNumber,omitempty"`AxisLabelEChartsAxisLabel `json:"axisLabel,omitempty"`AxisLineEChartsAxisLine `json:"axisLine,omitempty"`Data []string `json:"data"`Typestring `json:"type"`}EChartsXAxisData holds x-axis configuration extracted from ECharts JSON.
typeEChartsYAxis¶
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.
typeEChartsYAxisData¶
type EChartsYAxisData struct {Min *float64 `json:"min,omitempty"`Max *float64 `json:"max,omitempty"`AxisLabelEChartsAxisLabel `json:"axisLabel,omitempty"`AxisLineEChartsAxisLine `json:"axisLine,omitempty"`Data []string `json:"data"`}EChartsYAxisData holds a single y-axis configuration block.
typeFontStyle¶added inv0.2.0
FontStyle configures font properties including size, color, and family.
funcNewFontStyleWithSize¶added inv0.4.7
NewFontStyleWithSize constructs a new FontStyle with the specified font size. If you want to avoid directlyconstructing the FontStyle struct, you can use this followed by additional `WithX` function calls on the returnedFontStyle.
typeFunnelChartOption¶
type FunnelChartOption struct {// Theme specifies the colors used for the chart.ThemeColorPalette// Padding specifies the padding around the chart.PaddingBox// 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.SeriesListFunnelSeriesList// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// Deprecated: ValueFormatter is deprecated, instead set the ValueFormatter at `SeriesList[*].Label.ValueFormatter`.ValueFormatterValueFormatter}FunnelChartOption defines the options for rendering a funnel chart. Render the chart using Painter.FunnelChart.
funcNewFunnelChartOptionWithData¶added inv0.4.0
func NewFunnelChartOptionWithData(data []float64)FunnelChartOption
NewFunnelChartOptionWithData returns an initialized FunnelChartOption with the SeriesList set with the provided data slice.
typeFunnelSeries¶added inv0.5.0
type FunnelSeries struct {// Value provides the value for the funnel section.Valuefloat64// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring}FunnelSeries references a population of data for funnel charts.
typeFunnelSeriesList¶added inv0.5.0
type FunnelSeriesList []FunnelSeries
FunnelSeriesList provides the data populations for funnel charts (FunnelChartOption).
funcNewSeriesListFunnel¶added inv0.4.0
func NewSeriesListFunnel(values []float64, opts ...FunnelSeriesOption)FunnelSeriesList
NewSeriesListFunnel builds a series list for funnel charts.
func (FunnelSeriesList)SetSeriesLabels¶added inv0.5.6
func (fFunnelSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
func (FunnelSeriesList)ToGenericSeriesList¶added inv0.5.0
func (fFunnelSeriesList) ToGenericSeriesList()GenericSeriesList
typeFunnelSeriesOption¶added inv0.4.0
type FunnelSeriesOption struct {LabelSeriesLabelNames []string}FunnelSeriesOption provides series customization for NewSeriesListFunnel.
typeGenericSeries¶added inv0.5.0
type GenericSeries struct {// Type is the series chart type. Default is "line".Typestring// Values provides the series data values.// For ChartTypeCandlestick, the Values field must contain OHLC data encoded as groups of 4 consecutive// float64 values: [Open, High, Low, Close, ...]. For N candlesticks, Values must have exactly N*4 elements.Values []float64// YAxisIndex is the y-axis to apply the series to: must be 0 or 1.YAxisIndexint// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring// Radius for circular charts. Default is "40%".Radiusstring// MarkPoint provides a mark point configuration for this series. If Label is enabled, MarkPoint// replaces the label where rendered.MarkPointSeriesMarkPoint// 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.MarkLineSeriesMarkLine}GenericSeries references a population of data for any chart type. Chart-specific fields are only activefor chart types that support them.
typeGenericSeriesList¶added inv0.5.0
type GenericSeriesList []GenericSeries
GenericSeriesList provides the data populations for any chart type configured through ChartOption.
funcNewSeriesListGeneric¶added inv0.5.0
func NewSeriesListGeneric(values [][]float64, chartTypestring)GenericSeriesList
NewSeriesListGeneric returns a Generic series list for the given values and chart type (used in ChartOption).
func (GenericSeriesList)SetSeriesLabels¶added inv0.5.6
func (gGenericSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
typeHeatMapAxis¶added inv0.5.1
type HeatMapAxis struct {// Title specifies the title to display next to the axis.Titlestring// TitleFontStyle specifies the font style for the axis title.TitleFontStyleFontStyle// 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.LabelFontStyleFontStyle// LabelRotation is the rotation angle in radians for labels. Use DegreesToRadians(float64) to convert from degrees.LabelRotationfloat64// LabelCount is the number of labels to show on the axis. Use a smaller count to reduce text collisions.LabelCountint// LabelCountAdjustment specifies relative influence on label count.// Negative values result in cleaner graphs; positive values may cause text collisions.LabelCountAdjustmentint}HeatMapAxis contains configuration options for an axis on a heat map chart.
typeHeatMapOption¶added inv0.5.1
type HeatMapOption struct {// Theme specifies the color palette used for rendering the heat map.ThemeColorPalette// BaseColorIndex specifies which color from the theme palette to use as the base for gradients.BaseColorIndexint// Padding specifies the padding around the heat map chart.PaddingBox// 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.TitleTitleOption// 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.XAxisHeatMapAxis// YAxis contains configuration options for the y-axis.YAxisHeatMapAxis// 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.ValuesLabelSeriesLabel}HeatMapOption contains configuration options for a heat map chart. Render the chart using Painter.HeatMapChart.
funcNewHeatMapOptionWithData¶added inv0.5.1
func NewHeatMapOptionWithData(data [][]float64)HeatMapOption
NewHeatMapOptionWithData returns an initialized HeatMapOption with the provided data.
typeHorizontalBarChartOption¶
type HorizontalBarChartOption struct {// Theme specifies the colors used for the chart.ThemeColorPalette// Padding specifies the padding around the chart.PaddingBox// 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.SeriesListHorizontalBarSeriesList// 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".SeriesLabelPositionstring// XAxis contains options for the x-axis.XAxisXAxisOption// YAxis contains options for the y-axis.YAxisYAxisOption// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// BarHeight specifies the height of each horizontal bar. Height may be reduced to ensure all series fit on the chart.BarHeightint// TODO - v0.6 - Update to float64 to represent a precent// BarMargin specifies the margin between grouped bars. BarHeight takes priority over a set margin.BarMargin *float64// TODO - v0.6 - Update to be percent based// ValueFormatter defines how float values are rendered to strings, notably for numeric axis labels.ValueFormatterValueFormatter}HorizontalBarChartOption defines the options for rendering a horizontal bar chart.Render the chart using Painter.HorizontalBarChart.
funcNewHorizontalBarChartOptionWithData¶added inv0.4.0
func NewHorizontalBarChartOptionWithData(data [][]float64)HorizontalBarChartOption
NewHorizontalBarChartOptionWithData returns an initialized HorizontalBarChartOption with the SeriesList set with the provided data slice.
typeHorizontalBarSeries¶added inv0.5.0
type HorizontalBarSeries struct {// Values provides the series data values.Values []float64// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring// MarkLine provides a configuration for mark lines for this series.MarkLineSeriesMarkLine}HorizontalBarSeries references a population of data for horizontal bar charts.
func (*HorizontalBarSeries)Summary¶added inv0.5.0
func (h *HorizontalBarSeries) Summary() populationSummary
typeHorizontalBarSeriesList¶added inv0.5.0
type HorizontalBarSeriesList []HorizontalBarSeries
HorizontalBarSeriesList provides the data populations for horizontal bar charts (HorizontalBarChartOption).
funcNewSeriesListHorizontalBar¶added inv0.4.0
func NewSeriesListHorizontalBar(values [][]float64, opts ...BarSeriesOption)HorizontalBarSeriesList
NewSeriesListHorizontalBar builds a SeriesList for a horizontal bar chart. Horizontal bar charts are unique in thatthese Series can not be combined with any other chart type.
func (HorizontalBarSeriesList)SetSeriesLabels¶added inv0.5.6
func (hHorizontalBarSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
func (HorizontalBarSeriesList)SumSeries¶added inv0.5.0
func (hHorizontalBarSeriesList) SumSeries() []float64
SumSeries returns a float64 slice with the sum of each series.
func (HorizontalBarSeriesList)SumSeriesValues¶added inv0.5.0
func (hHorizontalBarSeriesList) SumSeriesValues() []float64
SumSeriesValues returns a float64 slice with each series totaled by the value index.
func (HorizontalBarSeriesList)ToGenericSeriesList¶added inv0.5.0
func (hHorizontalBarSeriesList) ToGenericSeriesList()GenericSeriesList
typeLabelStyle¶added inv0.5.16
type LabelStyle struct {// FontStyle overrides font properties (color, size, family) for this specific label.FontStyleFontStyle// BackgroundColor provides a background color behind the label text.BackgroundColorColor// CornerRadius sets the radius for rounded corners on the background rectangle.CornerRadiusint// BorderColor sets the border color around the label background.BorderColorColor// BorderWidth sets the width of the border around the label background.BorderWidthfloat64}LabelStyle contains optional styling overrides for individual label rendering.All fields are optional - zero values mean "use default styling from series or theme".
typeLayoutBuilderGrid¶added inv0.5.19
type LayoutBuilderGrid interface {// CellAt defines a new cell at the specified position with the given name.// The cell defaults to a 1x1 span, adjust larger by calling Span.CellAt(namestring, col, rowint)LayoutBuilderGrid// Span modifies the span of the previously defined cell.// Must be called after CellAt.Span(colSpan, rowSpanint)LayoutBuilderGrid// Offset applies position adjustments to the previously defined cell.// Accepts pixels ("20") or percentages ("10%") - percentages are relative to the cell's own dimensions.// Must be called after CellAt. Useful for fine-tuning and creating overlapping effects.Offset(x, ystring)LayoutBuilderGrid// Build creates child painters based on the defined grid layout.// Returns a map of cell names to their corresponding painters.Build() (map[string]*Painter,error)}LayoutBuilderGrid is returned by Painter.LayoutByGrid() and provides methodsfor building grid-based layouts with cell spanning support.
typeLayoutBuilderRow¶added inv0.5.19
type LayoutBuilderRow interface {// Row starts defining a new row.// If the current row has columns, it commits the row and starts a new one.// If the current row is empty, this is a no-op (prevents accidental empty rows).// Multiple consecutive Row() calls without column definitions are idempotent.Row()LayoutBuilderRow// RowGap adds vertical spacing between rows (pixels or percentage).// Creates an empty row with the specified height (equivalent to Row().Height(height)).RowGap(heightstring)LayoutBuilderRow// Columns adds columns with equal width distribution to the current row. Use Col if you want to set a specific column width.Columns(names ...string)LayoutBuilderRow// Col adds a column with specified width to the current row (pixels, percentage, or empty for auto).Col(namestring, widthstring)LayoutBuilderRow// Height sets the current row height (pixels or percentage).Height(heightstring)LayoutBuilderRow// ColGap adds a horizontal gap in the current row (like adding an invisible column).// If gap is empty (""), it is treated as an auto-width gap and will// match other auto-width columns in the row.ColGap(gapstring)LayoutBuilderRow// RowOffset applies position adjustments to the entire current row. Unlike Offset (which is cell specific),// this adjustment will adjust all rows following.// Accepts pixels ("20") or percentages ("10%") - percentages are relative to the painter height.// Negative values create overlapping effects, positive values create gaps.RowOffset(ystring)LayoutBuilderRow// Offset applies position adjustments to the last added column in the current row.// Accepts pixels ("20") or percentages ("10%") - percentages are relative to the cell's dimensions.// X offset percentage is relative to the cell's width, Y offset percentage is relative to the row's height.// Negative values create overlapping effects. If no columns have been added yet, this is a no-op.Offset(x, ystring)LayoutBuilderRow// Build creates child painters from the entire layout definition.// Returns a map of cell names to their corresponding painters.Build() (map[string]*Painter,error)}LayoutBuilderRow is returned by Painter.LayoutByRows() and provides methods for building row-based layouts.The builder starts already in a row context, ready to define columns immediately.
typeLegendOption¶
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.ThemeColorPalette// SeriesNames provides the text labels for the data series.SeriesNames []string// FontStyle specifies the font, size, and style for legend text.FontStyleFontStyle// Padding specifies the space around the legend.PaddingBox// Offset specifies the position of the legend relative to the left and top sides.OffsetOffsetStr// Align is the legend marker and text alignment: 'left', 'right', or 'center'. Default is 'left'.Alignstring// 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'.SymbolSymbol// TODO - should Symbol configuration be changed now that we support per-series symbols// TODO - v0.6 - consider combining symbol with size into a SymbolStyle struct// 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.BorderWidthfloat64// 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.
typeLineChartOption¶
type LineChartOption struct {// Theme specifies the colors used for the line chart.ThemeColorPalette// Padding specifies the padding around the chart.PaddingBox// 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.SeriesListLineSeriesList// 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.XAxisXAxisOption// YAxis contains options for the y-axis. At most two y-axes are supported.YAxis []YAxisOption// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// 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.SymbolSymbol// TODO - v0.6 - consider combining symbol with size into a SymbolStyle struct// LineStrokeWidth is the width of the rendered line.LineStrokeWidthfloat64// 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.StrokeSmoothingTensionfloat64// FillArea when set to *true fills the area below the line.FillArea *bool// FillOpacity is the opacity/alpha (0-255) of the area fill.FillOpacityuint8// ValueFormatter defines how float values are rendered to strings, notably for numeric axis labels.ValueFormatterValueFormatter}LineChartOption defines the options for rendering a line chart. Render the chart using Painter.LineChart.
funcNewLineChartOptionWithData¶added inv0.4.0
func NewLineChartOptionWithData(data [][]float64)LineChartOption
NewLineChartOptionWithData returns an initialized LineChartOption with the SeriesList set with the provided data slice.
funcNewLineChartOptionWithSeries¶added inv0.5.9
func NewLineChartOptionWithSeries(slLineSeriesList)LineChartOption
NewLineChartOptionWithSeries returns an initialized LineChartOption with the provided SeriesList.
typeLineSeries¶added inv0.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.YAxisIndexint// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring// MarkPoint provides a configuration for mark points for this series. If Label is also enabled, the MarkPoint// will replace the label where rendered.MarkPointSeriesMarkPoint// 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.MarkLineSeriesMarkLine// TrendLine provides configurations for trend lines for this series.TrendLine []SeriesTrendLine// Symbol specifies a custom symbol for the series.SymbolSymbol// TODO - v0.6 - consider combining symbol with size into a SymbolStyle struct// contains filtered or unexported fields}LineSeries references a population of data for line charts.
func (*LineSeries)Summary¶added inv0.5.0
func (l *LineSeries) Summary() populationSummary
typeLineSeriesList¶added inv0.5.0
type LineSeriesList []LineSeries
LineSeriesList provides the data populations for line charts (LineChartOption).
funcNewSeriesListLine¶added inv0.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 populationof the data, while the second dimension provides the samples for the population.
func (LineSeriesList)SetSeriesLabels¶added inv0.5.6
func (lLineSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
func (LineSeriesList)SumSeries¶added inv0.5.0
func (lLineSeriesList) SumSeries() []float64
SumSeries returns a float64 slice with the sum of each series.
func (LineSeriesList)SumSeriesValues¶added inv0.5.0
func (lLineSeriesList) SumSeriesValues() []float64
SumSeriesValues returns a float64 slice with each series totaled by the value index.
func (LineSeriesList)ToGenericSeriesList¶added inv0.5.0
func (lLineSeriesList) ToGenericSeriesList()GenericSeriesList
typeLineSeriesOption¶added inv0.4.0
type LineSeriesOption struct {LabelSeriesLabelNames []stringMarkPointSeriesMarkPointMarkLineSeriesMarkLineTrendLine []SeriesTrendLine}LineSeriesOption provides series customization for NewSeriesListLine.
typeOHLCData¶added inv0.5.17
type OHLCData struct {// Open is the opening price for the time period.Openfloat64// High is the highest price during the time period.Highfloat64// Low is the lowest price during the time period.Lowfloat64// Close is the closing price for the time period.Closefloat64}OHLCData represents Open, High, Low, Close financial data for a single time period.All values must satisfy: High >= Open, Close and Low <= Open, Close for valid candlesticks.
typeOffsetInt¶added inv0.3.0
type OffsetInt struct {// Top indicates a vertical spacing adjustment from the top.Topint// Left indicates a horizontal spacing adjustment from the left.Leftint}OffsetInt provides an ability to configure a shift from the top or left alignments.
typeOffsetStr¶added inv0.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'.Leftstring// 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'.Topstring}OffsetStr provides an ability to configure a shift from the top or left alignments using flexible string inputs.
func (OffsetStr)WithLeft¶added inv0.3.0
WithLeft returns a copy of the offset with the Left value set.
typeOptionFunc¶
type OptionFunc func(opt *ChartOption)
OptionFunc is a function that modifies ChartOption.
funcChildOptionFunc¶
func ChildOptionFunc(child ...ChartOption)OptionFunc
ChildOptionFunc adds a Child chart on top of the current one. Use Padding and Box for positioning.
funcDimensionsOptionFunc¶added inv0.4.0
func DimensionsOptionFunc(width, heightint)OptionFunc
DimensionsOptionFunc sets the width and height dimensions of the chart.
funcFontOptionFuncdeprecated
func FontOptionFunc(font *truetype.Font)OptionFunc
Deprecated: FontOptionFunc is deprecated, fonts should be set on the specific elements (SeriesLabel, Title, etc).
funcJPGOutputOptionFunc¶added inv0.5.1
func JPGOutputOptionFunc()OptionFunc
JPGOutputOptionFunc sets JPG as the image output format for the chart.
funcLegendLabelsOptionFunc¶
func LegendLabelsOptionFunc(labels []string)OptionFunc
LegendLabelsOptionFunc sets the legend series name labels of the chart.
funcLegendOptionFunc¶
func LegendOptionFunc(legendLegendOption)OptionFunc
LegendOptionFunc sets the legend of the chart.
funcMarkLineOptionFunc¶
func MarkLineOptionFunc(seriesIndexint, markLineTypes ...string)OptionFunc
MarkLineOptionFunc sets the mark line for series of the chart.
funcMarkPointOptionFunc¶
func MarkPointOptionFunc(seriesIndexint, markPointTypes ...string)OptionFunc
MarkPointOptionFunc sets the mark point for series of the chart.
funcPNGOutputOptionFunc¶added inv0.4.0
func PNGOutputOptionFunc()OptionFunc
PNGOutputOptionFunc sets PNG as the image output format for the chart.
funcPaddingOptionFunc¶
func PaddingOptionFunc(paddingBox)OptionFunc
PaddingOptionFunc sets the padding of the chart.
funcRadarIndicatorOptionFunc¶
func RadarIndicatorOptionFunc(names []string, values []float64)OptionFunc
RadarIndicatorOptionFunc sets the radar indicator of chart
funcSVGOutputOptionFunc¶added inv0.4.0
func SVGOutputOptionFunc()OptionFunc
SVGOutputOptionFunc sets SVG as the image output format for the chart.
funcSeriesShowLabel¶added inv0.4.0
func SeriesShowLabel(showbool)OptionFunc
SeriesShowLabel sets the series show label state for all series.
funcThemeNameOptionFunc¶
func ThemeNameOptionFunc(themestring)OptionFunc
ThemeNameOptionFunc sets the chart theme by name.
funcThemeOptionFunc¶
func ThemeOptionFunc(themeColorPalette)OptionFunc
ThemeOptionFunc sets the theme of the chart.
funcTitleOptionFunc¶
func TitleOptionFunc(titleTitleOption)OptionFunc
TitleOptionFunc sets the title of the chart.
funcTitleTextOptionFunc¶
func TitleTextOptionFunc(textstring, subtext ...string)OptionFunc
TitleTextOptionFunc sets the title text of chart.
funcXAxisLabelsOptionFunc¶added inv0.4.9
func XAxisLabelsOptionFunc(labels []string)OptionFunc
XAxisLabelsOptionFunc sets the x-axis labels of the chart.
funcXAxisOptionFunc¶
func XAxisOptionFunc(xAxisOptionXAxisOption)OptionFunc
XAxisOptionFunc sets the x-axis of the chart.
funcYAxisLabelsOptionFunc¶added inv0.4.9
func YAxisLabelsOptionFunc(labels []string)OptionFunc
YAxisLabelsOptionFunc sets the y-axis labels of the chart.
funcYAxisOptionFunc¶
func YAxisOptionFunc(yAxisOption ...YAxisOption)OptionFunc
YAxisOptionFunc sets the y-axis of chart, supports up to two y-axis.
typePainter¶
type Painter struct {// contains filtered or unexported fields}Painter is the primary struct for drawing charts/graphs.
funcBarRender¶
func BarRender(values [][]float64, opts ...OptionFunc) (*Painter,error)
BarRender renders a bar chart.
funcCandleStickRender¶added inv0.5.17
func CandleStickRender(values [][]OHLCData, opts ...OptionFunc) (*Painter,error)
CandleStickRender renders a candlestick chart.
funcDoughnutRender¶added inv0.5.6
func DoughnutRender(values []float64, opts ...OptionFunc) (*Painter,error)
DoughnutRender renders a doughnut or ring chart.
funcFunnelRender¶
func FunnelRender(values []float64, opts ...OptionFunc) (*Painter,error)
FunnelRender renders a funnel chart.
funcHorizontalBarRender¶
func HorizontalBarRender(values [][]float64, opts ...OptionFunc) (*Painter,error)
HorizontalBarRender renders a horizontal bar chart.
funcLineRender¶
func LineRender(values [][]float64, opts ...OptionFunc) (*Painter,error)
LineRender renders a line chart.
funcNewPainter¶
func NewPainter(optsPainterOptions, opt ...PainterOptionFunc) *Painter
NewPainter creates a painter for rendering charts.
funcPieRender¶
func PieRender(values []float64, opts ...OptionFunc) (*Painter,error)
PieRender renders a pie chart.
funcRadarRender¶
func RadarRender(values [][]float64, opts ...OptionFunc) (*Painter,error)
RadarRender renders a radar chart.
funcRender¶
func Render(optChartOption, opts ...OptionFunc) (*Painter,error)
Render creates and renders a chart based on the provided options.
funcScatterRender¶added inv0.5.0
func ScatterRender(values [][]float64, opts ...OptionFunc) (*Painter,error)
ScatterRender renders a scatter chart.
funcTableOptionRenderDirect¶added inv0.4.0
func TableOptionRenderDirect(optTableChartOption) (*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.
funcTableRenderValues¶added inv0.4.0
TableRenderValues renders a table chart with the provided header and data values.
func (*Painter)ArrowDown¶added inv0.4.0
ArrowDown draws an arrow at the given point and dimensions pointing down.
func (*Painter)ArrowRight¶
func (p *Painter) ArrowRight(x, y, width, heightint,fillColor, strokeColorColor, strokeWidthfloat64)
ArrowRight draws an arrow at the given point and dimensions pointing right.
func (*Painter)ArrowUp¶added inv0.4.0
ArrowUp draws an arrow at the given point and dimensions pointing up.
func (*Painter)BarChart¶added inv0.4.0
func (p *Painter) BarChart(optBarChartOption)error
BarChart renders a bar chart with the provided configuration to the painter.
func (*Painter)CandlestickChart¶added inv0.5.17
func (p *Painter) CandlestickChart(optCandlestickChartOption)error
CandlestickChart renders a candlestick 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)DashedLineStroke¶added inv0.5.17
func (p *Painter) DashedLineStroke(points []Point, strokeColorColor, strokeWidthfloat64, strokeDashArray []float64)
DashedLineStroke draws line segments through the provided points with dashed strokes.Points with values of math.MaxInt32 are skipped, resulting in a gap.
func (*Painter)Dots¶
func (p *Painter) Dots(points []Point, fillColor, strokeColorColor, strokeWidthfloat64, dotRadiusfloat64)
Dots prints filled circles for the given points.
func (*Painter)DoughnutChart¶added inv0.5.6
func (p *Painter) DoughnutChart(optDoughnutChartOption)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 inv0.4.9
func (p *Painter) FilledDiamond(cx, cy, width, heightint, fillColor, strokeColorColor, strokeWidthfloat64)
FilledDiamond draws a filled diamond centered at (cx, cy) with the given width and height.
func (*Painter)FilledRect¶added inv0.4.3
FilledRect draws a filled box with the given coordinates.
func (*Painter)FunnelChart¶added inv0.4.0
func (p *Painter) FunnelChart(optFunnelChartOption)error
FunnelChart renders a funnel chart with the provided configuration to the painter.
func (*Painter)HeatMapChart¶added inv0.5.1
func (p *Painter) HeatMapChart(optHeatMapOption)error
HeatMapChart renders a heat map with the provided configuration to the painter.
func (*Painter)HorizontalBarChart¶added inv0.4.0
func (p *Painter) HorizontalBarChart(optHorizontalBarChartOption)error
HorizontalBarChart renders a horizontal bar chart with the provided configuration to the painter.
func (*Painter)HorizontalMarkLine¶added inv0.4.10
func (p *Painter) HorizontalMarkLine(x, y, widthint, fillColor, strokeColorColor, strokeWidthfloat64, strokeDashArray []float64)
HorizontalMarkLine draws a horizontal line with a small circle and arrow at the right.
func (*Painter)LayoutByGrid¶added inv0.5.19
func (p *Painter) LayoutByGrid(cols, rowsint)LayoutBuilderGrid
LayoutByGrid returns builder for dividing the painter into child painters with a grid based layout.This is typically the easiest way to align multiple charts on to a single Painter.Specify how many rows and columns the painter should be divided into,then define each child painter using CellAt and Span.
func (*Painter)LayoutByRows¶added inv0.5.19
func (p *Painter) LayoutByRows()LayoutBuilderRow
LayoutByRows returns builder for dividing the painter into child painters with a row-based layout.This provides a flexible way to create dashboards and complex layouts where rows are built progressively.The builder starts already in a row context, ready to accept column definitions immediately.
func (*Painter)LineChart¶added inv0.4.0
func (p *Painter) LineChart(optLineChartOption)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 inv0.4.0
func (p *Painter) PieChart(optPieChartOption)error
PieChart renders a pie chart with the provided configuration to the painter.
func (*Painter)Polygon¶
func (p *Painter) Polygon(centerPoint, radiusfloat64, sidesint, strokeColorColor, strokeWidthfloat64)
Polygon draws a polygon with the specified center, radius, and number of sides.
func (*Painter)RadarChart¶added inv0.4.0
func (p *Painter) RadarChart(optRadarChartOption)error
RadarChart renders a radar chart with the provided configuration to the painter.
func (*Painter)ScatterChart¶added inv0.5.0
func (p *Painter) ScatterChart(optScatterChartOption)error
ScatterChart renders a scatter chart with the provided configuration to the painter.
func (*Painter)SmoothDashedLineStroke¶added inv0.5.17
func (p *Painter) SmoothDashedLineStroke(points []Point, tensionfloat64, strokeColorColor, strokeWidthfloat64, strokeDashArray []float64)
SmoothDashedLineStroke draws a smooth dashed curve through the given points.
func (*Painter)SmoothLineStroke¶
func (p *Painter) SmoothLineStroke(points []Point, tensionfloat64, strokeColorColor, strokeWidthfloat64)
SmoothLineStroke draws a smooth curve through the given points using Quadratic Bézier segments and atension 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 variablethe points and the higher the tension, the more the line deviates.
func (*Painter)TableChart¶added inv0.4.0
func (p *Painter) TableChart(optTableChartOption)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.
typePainterOptionFunc¶added inv0.4.0
type PainterOptionFunc func(*Painter)
PainterOptionFunc defines a function that can modify a Painter after creation.
funcPainterBoxOption¶
func PainterBoxOption(boxBox)PainterOptionFunc
PainterBoxOption sets a specific drawing area for the Painter.
funcPainterFontOption¶
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.
funcPainterPaddingOption¶
func PainterPaddingOption(paddingBox)PainterOptionFunc
PainterPaddingOption sets the padding within the painter canvas.
funcPainterThemeOption¶
func PainterThemeOption(themeColorPalette)PainterOptionFunc
PainterThemeOption sets the default theme for the Painter.Used when specific chart options don't have a theme set.
typePainterOptions¶
type PainterOptions struct {// OutputFormat specifies the output type: "svg", "png", "jpg". Default is "png".OutputFormatstring// Width is the width of the painter canvas.Widthint// Height is the height of the painter canvas.Heightint// Font is the default font for rendering text.Font *truetype.Font// Theme is the default theme used when charts don't specify one.ThemeColorPalette}PainterOptions contains parameters for creating a new Painter.
typePatternDetectionResult¶added inv0.5.17
type PatternDetectionResult struct {// Index is the pattern's series data point position.Indexint// PatternName is the display name (e.g., "Doji", "Hammer").PatternNamestring// PatternType is the identifier constant (e.g., CandlestickPatternDoji).PatternTypestring}PatternDetectionResult holds detected pattern information.
typePatternFormatter¶added inv0.5.17
type PatternFormatter func(patterns []PatternDetectionResult, seriesNamestring, valuefloat64) (string, *LabelStyle)
PatternFormatter allows custom formatting of detected patterns.
typePieChartOption¶
type PieChartOption struct {// Theme specifies the colors used for the pie chart.ThemeColorPalette// Padding specifies the padding around the chart.PaddingBox// 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.SeriesListPieSeriesList// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// Radius sets the pie radius. Default is "40%".Radiusstring// SegmentGap provides the gap between each pie slice.SegmentGapfloat64// Deprecated: ValueFormatter is deprecated, instead set the ValueFormatter at `SeriesList[*].Label.ValueFormatter`.ValueFormatterValueFormatter}PieChartOption defines the options for rendering a pie chart. Render the chart using Painter.PieChart.
funcNewPieChartOptionWithData¶added inv0.4.0
func NewPieChartOptionWithData(data []float64)PieChartOption
NewPieChartOptionWithData returns an initialized PieChartOption with the SeriesList set with the provided data slice.
typePieSeries¶added inv0.5.0
type PieSeries struct {// Value provides the value for the pie section.Valuefloat64// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring// Radius for Pie chart, e.g.: 40%, default is "40%"Radiusstring}PieSeries references a population of data for pie charts.
typePieSeriesList¶added inv0.5.0
type PieSeriesList []PieSeries
PieSeriesList provides the data populations for pie charts (PieChartOption).
funcNewSeriesListPie¶added inv0.4.0
func NewSeriesListPie(values []float64, opts ...PieSeriesOption)PieSeriesList
NewSeriesListPie builds a SeriesList for a pie chart.
func (PieSeriesList)MaxValue¶added inv0.5.0
func (pPieSeriesList) MaxValue()float64
MaxValue returns the maximum value within the series, or MinInt64 if no values.
func (PieSeriesList)SetSeriesLabels¶added inv0.5.6
func (pPieSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
func (PieSeriesList)SumSeries¶added inv0.5.0
func (pPieSeriesList) SumSeries()float64
func (PieSeriesList)ToGenericSeriesList¶added inv0.5.0
func (pPieSeriesList) ToGenericSeriesList()GenericSeriesList
typePieSeriesOption¶
type PieSeriesOption struct {LabelSeriesLabelNames []string}PieSeriesOption provides series customization for NewSeriesListPie.
typeRadarChartOption¶
type RadarChartOption struct {// Theme specifies the colors used for the radar chart.ThemeColorPalette// Padding specifies the padding around the chart.PaddingBox// 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.SeriesListRadarSeriesList// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// RadarIndicators provides the radar indicator list.RadarIndicators []RadarIndicator// Radius sets the chart radius. Default is "40%".Radiusstring// ValueFormatter defines how float values are rendered to strings, notably for series labels.ValueFormatterValueFormatter}RadarChartOption defines the options for rendering a radar chart. Render the chart using Painter.RadarChart.
funcNewRadarChartOptionWithData¶added inv0.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.
typeRadarIndicator¶
type RadarIndicator struct {// Name specifies a name for the indicator.Namestring// Max is the maximum value of indicator.Maxfloat64// Min is the minimum value of indicator.Minfloat64// FontStyle provides the font configuration for the indicator.FontStyleFontStyle}RadarIndicator defines the dimensions of a radar chart axis.
funcNewRadarIndicators¶
func NewRadarIndicators(names []string, values []float64) []RadarIndicator
NewRadarIndicators returns a radar indicator list.
typeRadarSeries¶added inv0.5.0
type RadarSeries struct {// Values provides the series data list.Values []float64// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring}RadarSeries references a population of data for radar charts.
typeRadarSeriesList¶added inv0.5.0
type RadarSeriesList []RadarSeries
RadarSeriesList provides the data populations for radar charts (RadarChartOption).
funcNewSeriesListRadar¶added inv0.4.0
func NewSeriesListRadar(values [][]float64, opts ...RadarSeriesOption)RadarSeriesList
NewSeriesListRadar builds a SeriesList for a Radar chart.
func (RadarSeriesList)SetSeriesLabels¶added inv0.5.6
func (rRadarSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
func (RadarSeriesList)ToGenericSeriesList¶added inv0.5.0
func (rRadarSeriesList) ToGenericSeriesList()GenericSeriesList
typeRadarSeriesOption¶added inv0.4.0
type RadarSeriesOption struct {LabelSeriesLabelNames []string}RadarSeriesOption provides series customization for NewSeriesListRadar.
typeScatterChartOption¶added inv0.5.0
type ScatterChartOption struct {// Theme specifies the colors used for the scatter chart.ThemeColorPalette// Padding specifies the padding around the chart.PaddingBox// 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.SeriesListScatterSeriesList// XAxis contains options for the x-axis.XAxisXAxisOption// YAxis contains options for the y-axis. At most two y-axes are supported.YAxis []YAxisOption// Title contains options for rendering the chart title.TitleTitleOption// Legend contains options for the data legend.LegendLegendOption// Symbol specifies the default shape for each data point. Default is 'dot'.// Options: 'circle', 'dot', 'square', 'diamond'. Can be overridden per series.SymbolSymbol// TODO - v0.6 - consider combining symbol with size into a SymbolStyle struct// SymbolSize specifies the size for each data point. Default is 2.0.SymbolSizefloat64// ValueFormatter defines how float values are rendered to strings, notably for numeric axis labels.ValueFormatterValueFormatter}ScatterChartOption defines the options for rendering a scatter chart. Render the chart using Painter.ScatterChart.
funcNewScatterChartOptionWithData¶added inv0.5.0
func NewScatterChartOptionWithData(data [][]float64)ScatterChartOption
NewScatterChartOptionWithData returns an initialized ScatterChartOption with the SeriesList set with the provided data slice.
funcNewScatterChartOptionWithSeries¶added inv0.5.9
func NewScatterChartOptionWithSeries(slScatterSeriesList)ScatterChartOption
NewScatterChartOptionWithSeries returns an initialized ScatterChartOption with the provided SeriesList.
typeScatterSeries¶added inv0.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.YAxisIndexint// Label provides the series labels.LabelSeriesLabel// Name specifies a name for the series.Namestring// 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.MarkLineSeriesMarkLine// TrendLine provides configurations for trend lines for this series.TrendLine []SeriesTrendLine// Symbol specifies a custom symbol for the series.SymbolSymbol// TODO - v0.6 - consider combining symbol with size into a SymbolStyle struct// contains filtered or unexported fields}ScatterSeries references a population of data for scatter charts.
func (*ScatterSeries)Summary¶added inv0.5.0
func (s *ScatterSeries) Summary() populationSummary
typeScatterSeriesList¶added inv0.5.0
type ScatterSeriesList []ScatterSeries
ScatterSeriesList provides the data populations for scatter charts (ScatterChartOption).
funcNewSeriesListScatter¶added inv0.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 populationof the data, while the second dimension provides the samples for the population.
funcNewSeriesListScatterMultiValue¶added inv0.5.0
func NewSeriesListScatterMultiValue(values [][][]float64, opts ...ScatterSeriesOption)ScatterSeriesList
NewSeriesListScatterMultiValue builds a SeriesList for a scatter charts. The first dimension of the values indicatesthe population of the data, while the second dimension provides the samples for the population. Multiple values fora single sample can be provided using the last dimension.
func (ScatterSeriesList)SetSeriesLabels¶added inv0.5.6
func (sScatterSeriesList) SetSeriesLabels(labelSeriesLabel)
SetSeriesLabels sets the label for all elements in the series.
func (ScatterSeriesList)SumSeries¶added inv0.5.0
func (sScatterSeriesList) SumSeries() []float64
SumSeries returns a float64 slice with the sum of each series.
func (ScatterSeriesList)ToGenericSeriesList¶added inv0.5.6
func (sScatterSeriesList) ToGenericSeriesList()GenericSeriesList
typeScatterSeriesOption¶added inv0.5.0
type ScatterSeriesOption struct {LabelSeriesLabelNames []stringMarkLineSeriesMarkLineTrendLine []SeriesTrendLine}ScatterSeriesOption provides series customization for NewSeriesListScatter and NewSeriesListScatterMultiValue.
typeSeriesLabel¶
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.LabelFormatterSeriesLabelFormatter// 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%)"FormatTemplatestring// ValueFormatter functions as the simplest method of number formatting or customization.// Only utilized when other methods are not set.ValueFormatterValueFormatter// FontStyle specifies the default font styling for labels in this series.// Individual labels can override this via LabelFormatter's LabelStyle return value.FontStyleFontStyle// Distance specifies the pixel distance between the label and its associated data point or chart element.Distanceint// TODO - do we want to replace with just Offset?// Offset specifies an offset from the position.OffsetOffsetInt}SeriesLabel configures how individual data point labels are rendered on charts.
typeSeriesLabelFormatter¶added inv0.5.16
type SeriesLabelFormatter func(indexint, namestring, valfloat64) (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 nilto use default series/theme styling.
funcLabelFormatterGradientColor¶added inv0.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.
funcLabelFormatterGradientGreenRed¶added inv0.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.
funcLabelFormatterGradientRedGreen¶added inv0.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.
funcLabelFormatterThresholdMax¶added inv0.5.16
func LabelFormatterThresholdMax(thresholdfloat64)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).
funcLabelFormatterThresholdMin¶added inv0.5.16
func LabelFormatterThresholdMin(thresholdfloat64)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).
funcLabelFormatterTopN¶added inv0.5.16
func LabelFormatterTopN(values []float64, nint)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.
typeSeriesMark¶added inv0.5.0
type SeriesMark struct {// Type is the mark data type: "max", "min", "average". "average" is only for mark line.Typestring// 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.Globalbool}SeriesMark describes a single mark line or point type.
typeSeriesMarkLine¶
type SeriesMarkLine struct {// ValueFormatter is used to produce the label for the Mark Line.ValueFormatterValueFormatter// Lines are the mark lines for the series.LinesSeriesMarkList}SeriesMarkLine configures mark lines for a series.
funcNewMarkLine¶
func NewMarkLine(markLineTypes ...string)SeriesMarkLine
NewMarkLine returns a mark line for the provided types. Set on a specific Series instance.
func (*SeriesMarkLine)AddGlobalLines¶added inv0.5.0
func (m *SeriesMarkLine) AddGlobalLines(markTypes ...string)
AddGlobalLines adds "global" mark lines, which reference the sum of all series. These marksare only rendered when the Series is "Stacked" and the mark line is on the LAST Series of the SeriesList.
func (*SeriesMarkLine)AddLines¶added inv0.5.0
func (m *SeriesMarkLine) AddLines(markTypes ...string)
AddLines adds mark lines for the series.
typeSeriesMarkList¶added inv0.5.0
type SeriesMarkList []SeriesMark
SeriesMarkList is a slice of SeriesMark values.
funcNewSeriesMarkGlobalList¶added inv0.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 ison the LAST Series of the SeriesList.
funcNewSeriesMarkList¶added inv0.5.0
func NewSeriesMarkList(markTypes ...string)SeriesMarkList
NewSeriesMarkList returns a SeriesMarkList initialized for the given types.
typeSeriesMarkPoint¶
type SeriesMarkPoint struct {// SymbolSize is the width of symbol, default value is 28.SymbolSizeint// ValueFormatter is used to produce the label for the Mark Point.ValueFormatterValueFormatter// Points are the mark points for the series.PointsSeriesMarkList}SeriesMarkPoint configures mark points for a series.
funcNewMarkPoint¶
func NewMarkPoint(markPointTypes ...string)SeriesMarkPoint
NewMarkPoint returns a mark point for the provided types. Set on a specific Series instance.
func (*SeriesMarkPoint)AddGlobalPoints¶added inv0.5.0
func (m *SeriesMarkPoint) AddGlobalPoints(markTypes ...string)
AddGlobalPoints adds "global" mark points, which reference the sum of all series. These marksare only rendered when the Series is "Stacked" and the mark point is on the LAST Series of the SeriesList.
func (*SeriesMarkPoint)AddPoints¶added inv0.5.0
func (m *SeriesMarkPoint) AddPoints(markTypes ...string)
AddPoints adds mark points for the series.
typeSeriesTrendLine¶added inv0.5.0
type SeriesTrendLine struct {// LineStrokeWidth is the width of the rendered line.LineStrokeWidthfloat64// StrokeSmoothingTension should be between 0 and 1. At 0 lines are sharp and precise, 1 provides smoother lines.StrokeSmoothingTensionfloat64// LineColor overrides the theme color for this trend line.LineColorColor// DashedLine indicates if the trend line will be a dashed line. Default depends on chart type.DashedLine *bool// Type specifies the trend line type: "linear", "cubic", "sma", "ema", "rsi".Typestring// Deprecated: Window is deprecated, use Period instead.Windowint// Period specifies the number of data points to consider for trend calculations.// Used by moving averages (SMA, EMA), Bollinger Bands, RSI, and other indicators.// For example, Period=20 calculates a 20-period moving average.Periodint}SeriesTrendLine describes the rendered trend line style.
funcNewTrendLine¶added inv0.5.0
func NewTrendLine(trendTypestring) []SeriesTrendLine
NewTrendLine returns a trend line for the provided type. Set on a specific Series instance.
typeSymbol¶added inv0.4.9
type Symbolstring
Symbol defines the shape used for data points and legends.
typeTableCell¶
type TableCell struct {// Text is the text content of the table cell.Textstring// FontStyle contains the font configuration for the cell text.FontStyleFontStyle// FillColor sets the background color for this table cell.FillColorColor// Row is the row index of the table cell.Rowint// Column is the column index of the table cell.Columnint}TableCell represents a single cell in a table.
typeTableChartOption¶
type TableChartOption struct {// OutputFormat specifies the output type: "svg", "png", "jpg".OutputFormatstring// Theme specifies the colors used for the table.ThemeColorPalette// Padding specifies the padding around the table.PaddingBox// Width specifies the width of the table.Widthint// 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.FontStyleFontStyle// HeaderBackgroundColor provides the background color for the header row.HeaderBackgroundColorColor// HeaderFontColor specifies the text color for header text.HeaderFontColorColor// RowBackgroundColors specifies the background colors for each row.RowBackgroundColors []Color// BackgroundColor specifies the general background color.BackgroundColorColor// 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.
typeThemeOption¶
type ThemeOption struct {// IsDarkMode indicates whether the theme is designed for dark backgrounds, affecting color adjustments and text visibility.IsDarkModebool// AxisStrokeColor is the default stroke color for both axes.AxisStrokeColorColor// XAxisStrokeColor overrides AxisStrokeColor for the x-axis.XAxisStrokeColorColor// YAxisStrokeColor overrides AxisStrokeColor for the y-axis.YAxisStrokeColorColor// AxisSplitLineColor sets the color of grid lines drawn between ticks.AxisSplitLineColorColor// BackgroundColor sets the chart background.BackgroundColorColor// TextColor is the default font color applied if specific text colors are unset.TextColorColor// TextColorTitle sets the title text color.TextColorTitleColor// TextColorMark sets the color of mark line and point labels.TextColorMarkColor// TextColorLabel defines the color of series labels.TextColorLabelColor// TextColorLegend defines the legend text color.TextColorLegendColor// TextColorXAxis defines the x-axis label text color.TextColorXAxisColor// TextColorYAxis defines the y-axis label text color.TextColorYAxisColor// TitleBorderColor draws an optional border around the title.TitleBorderColorColor// LegendBorderColor draws an optional border around the legend.LegendBorderColorColor// SeriesColors provides the color palette used for series data.SeriesColors []Color// SeriesTrendColors provides the palette for rendered trend lines.SeriesTrendColors []Color// CandleWickColor is the color for the high-low wicks. If not set, uses body color.CandleWickColorColor// SeriesUpDownColors provides distinct up/down (bear/bull) color pairs for each series.SeriesUpDownColors [][2]Color}ThemeOption defines color options for a theme.
typeTitleOption¶
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.ThemeColorPalette// Text is the title text. Supports '\n' for line breaks.Textstring// Subtext is additional text below the title. Supports '\n' for line breaks.Subtextstring// Offset specifies the position of the title relative to the left and top sides.OffsetOffsetStr// FontStyle specifies the font, size, and style for the title text.FontStyleFontStyle// SubtextFontStyle specifies the font, size, and style for the subtext.SubtextFontStyleFontStyle// BorderWidth can be set to a non-zero value to render a box around the title.BorderWidthfloat64}TitleOption configures rendering of a chart title.
typeValueFormatter¶
ValueFormatter defines a function that formats numeric values into string representations for display on charts.
typeXAxisOption¶
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.ThemeColorPalette// Title specifies a name for the axis. If set, the title is rendered below the x-axis.Titlestring// TitleFontStyle specifies the font, size, and color for the axis title.TitleFontStyleFontStyle// 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.DataStartIndexint// 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.Positionstring// 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.FontStyleFontStyle// LabelFontStyle specifies the font configuration for each label.LabelFontStyleFontStyle// LabelRotation is the rotation angle in radians for labels. Use DegreesToRadians(float64) to convert from degrees.LabelRotationfloat64// LabelOffset is the position offset for each label.LabelOffsetOffsetInt// ValueFormatter defines how float values are rendered to strings, notably for numeric axis labels.ValueFormatterValueFormatter// Unit suggests the axis step size (recommendation only). Larger values result in fewer labels.Unitfloat64// LabelCount is the number of labels to show on the axis. Use a smaller count to reduce text collisions.LabelCountint// 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.LabelCountAdjustmentint}XAxisOption configures the horizontal axis.
typeYAxisOption¶
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.ThemeColorPalette// Title specifies a name for the axis. If set, the axis name is rendered on the outside of the y-Axis.Titlestring// TitleFontStyle specifies the font, size, and color for the axis title.TitleFontStyleFontStyle// 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'.Positionstring// Deprecated: FontStyle is deprecated, use LabelFontStyle.FontStyleFontStyle// LabelFontStyle specifies the font configuration for each label.LabelFontStyleFontStyle// LabelRotation is the rotation angle in radians for labels. Use DegreesToRadians(float64) to convert from degrees.LabelRotationfloat64// Deprecated: Formatter is deprecated, use ValueFormatter instead.Formatterstring// Unit suggests the axis step size (recommendation only). Larger values result in fewer labels.Unitfloat64// LabelCount is the number of labels to show on the axis. Use a smaller count to reduce text collisions.LabelCountint// LabelCountAdjustment specifies relative influence on label count.// Negative values result in cleaner graphs; positive values may cause text collisions.LabelCountAdjustmentint// LabelSkipCount specifies a qty of lines between labels that show only horizontal lines without labels.LabelSkipCountint// 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.ValueFormatterValueFormatter// contains filtered or unexported fields}YAxisOption configures the vertical axis.
Source Files¶
- alias.go
- axis.go
- bar_chart.go
- candlestick_chart.go
- candlestick_patterns.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