charts

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 16 Imported by: 0

README

go-analyze/charts

license Build Status

go-analyze/charts is a fork from vicanso/go-charts and based on wcharczuk/go-chart. Our library focuses on simplifying the generation of beautiful charts and graphs.

Current Project Status

Leveraging the strengths of vicanso/go-charts and wcharczuk/go-chart, our project introduces enhancements for rendering under challenging conditions and expands functionality with minimal setup. We aim to build upon their solid foundation to offer a more versatile and user-friendly charting solution.

API Stability

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

Until the v1.0.0 release, API changes should be anticipated. If you require a library with minimal user facing changes this project has not yet reached that level of maturity.

Changes

Notable improvements in our fork include:

  • Axis Improvements: Significant enhancements to axis rendering, data range selection, and configuration simplification were made in PR #3.
  • Theming: In PR #4 (and some subsequent changes) we introduced vivid-light and vivid-dark themes for more vibrant visualizations, alongside API changes for greater theme and font control. Long term we plan to make themes easier to mutate and define.
  • Configuration Simplification: PR #5 began our effort to streamline chart configuration, making names more descriptive and specific while focusing on a theme-centric approach. Documentation on configuration and use is also being improved.
  • Expanded Testing: Ongoing test coverage expansions have led to bug discoveries and fixes. This will continue to help ensure that our charts render perfectly for a wide range of configurations and use.

Our library is a work in progress, 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.

Functionality

Themes

Our built in themes are: light, dark, vivid-light, vivid-dark, ant, grafana

themes

Chart Types

These chart types are supported: line, bar, horizontal bar, pie, radar or funnel and table.

Please see a variety of examples in the ./examples/ directory.

Line Chart
Line Chart
package main

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{
		{
			120,
			132,
			101,
			134,
			90,
			230,
			210,
		},
		{
			// specify values for additional data series
		},
	}
	p, err := charts.LineRender(
		values,
		charts.TitleTextOptionFunc("Line"),
		charts.XAxisDataOptionFunc([]string{
			"Mon",	// notice the 7 labels here match to the 7 samples above
			"Tue",
			"Wed",
			"Thu",
			"Fri",
			"Sat",
			"Sun",
		}),
		charts.LegendLabelsOptionFunc([]string{
			"Email",
			"Search Engine",
		}, charts.PositionCenter),
	)
	// snip...
}
Bar Chart
Bar Chart
package main

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{
		{
			2.0,
			4.9,
			7.0,
			23.2,
			25.6,
			76.7,
			135.6,
			162.2,
			32.6,
			20.0,
			6.4,
			3.3,
		},
		{
			// snip...	
		},
	}
	p, err := charts.BarRender(
		values,
		charts.XAxisDataOptionFunc([]string{
			"Jan",
			"Feb",
			"Mar",
			"Apr",
			"May",
			"Jun",
			"Jul",
			"Aug",
			"Sep",
			"Oct",
			"Nov",
			"Dec",
		}),
		charts.LegendLabelsOptionFunc([]string{
			"Rainfall",
			"Evaporation",
		}, charts.PositionRight),
		charts.MarkLineOptionFunc(0, charts.SeriesMarkDataTypeAverage),
		charts.MarkPointOptionFunc(0, charts.SeriesMarkDataTypeMax,
			charts.SeriesMarkDataTypeMin),
		// custom option func
		func(opt *charts.ChartOption) {
			opt.SeriesList[1].MarkPoint = charts.NewMarkPoint(
				charts.SeriesMarkDataTypeMax,
				charts.SeriesMarkDataTypeMin,
			)
			opt.SeriesList[1].MarkLine = charts.NewMarkLine(
				charts.SeriesMarkDataTypeAverage,
			)
		},
	)
	// snip...
}
Horizontal Bar Chart
Horizontal Bar Chart
package main

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

func main() {
	values := [][]float64{
		{
			18203,
			23489,
			29034,
			104970,
			131744,
			630230,
		},
		{
			// snip...	
		},
	}
	p, err := charts.HorizontalBarRender(
		values,
		charts.TitleTextOptionFunc("World Population"),
		charts.PaddingOptionFunc(charts.Box{
			Top:    20,
			Right:  40,
			Bottom: 20,
			Left:   20,
		}),
		charts.LegendLabelsOptionFunc([]string{
			"2011",
			"2012",
		}),
		charts.YAxisDataOptionFunc([]string{
			"Brazil",
			"Indonesia",
			"USA",
			"India",
			"China",
			"World",
		}),
	)
	// snip...
}
Pie Chart
Pie Chart
package main

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

func main() {
	values := []float64{
		1048,
		735,
		580,
		484,
		300,
	}
	p, err := charts.PieRender(
		values,
		charts.TitleOptionFunc(charts.TitleOption{
			Text:    "Rainfall vs Evaporation",
			Subtext: "Fake Data",
			Left:    charts.PositionCenter,
		}),
		charts.PaddingOptionFunc(charts.Box{
			Top:    20,
			Right:  20,
			Bottom: 20,
			Left:   20,
		}),
		charts.LegendOptionFunc(charts.LegendOption{
			Orient: charts.OrientVertical,
			Data: []string{
				"Search Engine",
				"Direct",
				"Email",
				"Union Ads",
				"Video Ads",
			},
			Left: charts.PositionLeft,
		}),
		charts.PieSeriesShowLabel(),
	)
	// snip...	
}
Radar Chart
Radar Chart
package main

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

func main() {
	values := [][]float64{
		{
			4200,
			3000,
			20000,
			35000,
			50000,
			18000,
		},
		{
			// snip...
		},
	}
	p, err := charts.RadarRender(
		values,
		charts.TitleTextOptionFunc("Basic Radar Chart"),
		charts.LegendLabelsOptionFunc([]string{
			"Allocated Budget",
			"Actual Spending",
		}),
		charts.RadarIndicatorOptionFunc([]string{
			"Sales",
			"Administration",
			"Information Technology",
			"Customer Support",
			"Development",
			"Marketing",
		}, []float64{
			6500,
			16000,
			30000,
			38000,
			52000,
			25000,
		}),
	)
	// snip...
}
Table
Table
package main

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

func main() {
	header := []string{
		"Name",
		"Age",
		"Address",
		"Tag",
		"Action",
	}
	data := [][]string{
		{
			"John Brown",
			"32",
			"New York No. 1 Lake Park",
			"nice, developer",
			"Send Mail",
		},
		{
			"Jim Green	",
			"42",
			"London No. 1 Lake Park",
			"wow",
			"Send Mail",
		},
		{
			"Joe Black	",
			"32",
			"Sidney No. 1 Lake Park",
			"cool, teacher",
			"Send Mail",
		},
	}
	spans := map[int]int{
		0: 2,
		1: 1,
		2: 3,
		3: 2,
		4: 2,
	}
	p, err := charts.TableRender(
		header,
		data,
		spans,
	)
	// snip...
}
Funnel Chart
package main

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

func main() {
	values := []float64{
		100,
		80,
		60,
		40,
		20,
	}
	p, err := charts.FunnelRender(
		values,
		charts.TitleTextOptionFunc("Funnel"),
		charts.LegendLabelsOptionFunc([]string{
			"Show",
			"Click",
			"Visit",
			"Inquiry",
			"Order",
		}),
	)
	// snip...
}
ECharts Render
package main

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

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

Documentation

Index

Constants

View Source
const (
	ChartTypeLine          = "line"
	ChartTypeBar           = "bar"
	ChartTypePie           = "pie"
	ChartTypeRadar         = "radar"
	ChartTypeFunnel        = "funnel"
	ChartTypeHorizontalBar = "horizontalBar"
)
View Source
const (
	ChartOutputSVG = "svg"
	ChartOutputPNG = "png"
)
View Source
const (
	PositionLeft   = "left"
	PositionRight  = "right"
	PositionCenter = "center"
	PositionTop    = "top"
	PositionBottom = "bottom"
)
View Source
const (
	AlignLeft   = "left"
	AlignRight  = "right"
	AlignCenter = "center"
)
View Source
const (
	OrientHorizontal = "horizontal"
	OrientVertical   = "vertical"
)
View Source
const (
	SeriesMarkDataTypeMax     = "max"
	SeriesMarkDataTypeMin     = "min"
	SeriesMarkDataTypeAverage = "average"
)
View Source
const G_VALUE = M_VALUE * K_VALUE
View Source
const IconLineDot = "lineDot"
View Source
const IconRect = "rect"
View Source
const K_VALUE = float64(1000)
View Source
const M_VALUE = K_VALUE * K_VALUE
View Source
const T_VALUE = G_VALUE * K_VALUE
View Source
const ThemeAnt = "ant"

ThemeAnt is an ant styled theme.

View Source
const ThemeDark = "dark"

ThemeDark is a dark alternative to the default theme 'light, with series colors from echarts'.

View Source
const ThemeGrafana = "grafana"

ThemeGrafana is a grafana styled theme.

View Source
const ThemeLight = "light"

ThemeLight is the default theme used, with series colors from echarts.

View Source
const ThemeVividDark = "vivid-dark"

ThemeVividDark is a dark alternative to 'ThemeVividLight', with the same bright initial series colors.

View Source
const ThemeVividLight = "vivid-light"

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.

Variables

View Source
var BoxZero = chart.BoxZero
View Source
var TableDarkThemeSetting = TableSetting{
	HeaderColor:     Color{R: 38, G: 38, B: 42, A: 255},
	HeaderFontColor: Color{R: 216, G: 217, B: 218, A: 255},
	FontColor:       Color{R: 216, G: 217, B: 218, A: 255},
	RowColors: []Color{
		{R: 24, G: 24, B: 28, A: 255},
		{R: 38, G: 38, B: 42, A: 255},
	},
	CellPadding: Box{
		Left:   10,
		Top:    10,
		Right:  10,
		Bottom: 10,
	},
}
View Source
var TableLightThemeSetting = TableSetting{
	HeaderColor:     Color{R: 220, G: 220, B: 220, A: 255},
	HeaderFontColor: Color{R: 80, G: 80, B: 80, A: 255},
	FontColor:       Color{R: 50, G: 50, B: 50, A: 255},
	RowColors: []Color{
		drawing.ColorWhite,
		{R: 245, G: 245, B: 245, A: 255},
	},
	CellPadding: Box{
		Left:   10,
		Top:    10,
		Right:  10,
		Bottom: 10,
	},
}

Functions

func BoolPointer

func BoolPointer(b bool) *bool

BoolPointer returns a pointer to the given bool value, useful for configuration.

func False

func False() *bool

False returns a pointer to a false bool, useful for configuration.

func FloatPointer

func FloatPointer(f float64) *float64

FloatPointer returns a pointer to the given float64 value, useful for configuration.

func GetDefaultFont

func GetDefaultFont() *truetype.Font

GetDefaultFont get default font.

func GetFont

func GetFont(fontFamily string) *truetype.Font

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

func GetNullValue

func GetNullValue() float64

GetNullValue gets the null value

func InstallFont

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

InstallFont installs the font for charts

func InstallTheme

func InstallTheme(name string, opt ThemeOption)

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

func NewAxisPainter

func NewAxisPainter(p *Painter, opt AxisOption) *axisPainter

func NewBarChart

func NewBarChart(p *Painter, opt BarChartOption) *barChart

NewBarChart returns a bar chart renderer

func NewBottomXAxis

func NewBottomXAxis(p *Painter, opt XAxisOption) *axisPainter

NewBottomXAxis returns a bottom x axis renderer

func NewFunnelChart

func NewFunnelChart(p *Painter, opt FunnelChartOption) *funnelChart

NewFunnelChart returns a funnel chart renderer

func NewGridPainter

func NewGridPainter(p *Painter, opt GridPainterOption) *gridPainter

NewGridPainter returns new a grid renderer

func NewHorizontalBarChart

func NewHorizontalBarChart(p *Painter, opt HorizontalBarChartOption) *horizontalBarChart

NewHorizontalBarChart returns a horizontal bar chart renderer

func NewLeftYAxis

func NewLeftYAxis(p *Painter, opt YAxisOption) *axisPainter

NewLeftYAxis returns a left y axis renderer

func NewLegendPainter

func NewLegendPainter(p *Painter, opt LegendOption) *legendPainter

NewLegendPainter returns a legend renderer

func NewLineChart

func NewLineChart(p *Painter, opt LineChartOption) *lineChart

NewLineChart returns a line chart render

func NewMarkLinePainter

func NewMarkLinePainter(p *Painter) *markLinePainter

NewMarkLinePainter returns a mark line renderer

func NewMarkPointPainter

func NewMarkPointPainter(p *Painter) *markPointPainter

NewMarkPointPainter returns a mark point renderer

func NewPieChart

func NewPieChart(p *Painter, opt PieChartOption) *pieChart

NewPieChart returns a pie chart renderer

func NewRadarChart

func NewRadarChart(p *Painter, opt RadarChartOption) *radarChart

NewRadarChart returns a radar chart renderer

func NewRange

func NewRange(painter *Painter, size, divideCount int, min, max, minPaddingScale, maxPaddingScale float64) axisRange

NewRange returns a range of data for an axis, this range will have padding to better present the data.

func NewRightYAxis

func NewRightYAxis(p *Painter, opt YAxisOption) *axisPainter

NewRightYAxis returns a right y axis renderer

func NewSector added in v0.1.5

func NewSector(cx int, cy int, radius float64, labelRadius float64, value float64, currentValue float64, totalValue float64, labelLineLength int, label string, series Series, color Color) sector

func NewTableChart

func NewTableChart(p *Painter, opt TableChartOption) *tableChart

NewTableChart returns a table chart render

func NewTitlePainter

func NewTitlePainter(p *Painter, opt TitleOption) *titlePainter

NewTitlePainter returns a title renderer

func RenderEChartsToPNG

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

func RenderEChartsToSVG

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

func SetDefaultFont

func SetDefaultFont(fontFamily string) error

SetDefaultFont set default font by name.

func SetDefaultHeight

func SetDefaultHeight(height int)

SetDefaultHeight sets default height of chart

func SetDefaultTheme

func SetDefaultTheme(name string) error

SetDefaultTheme sets default theme by name.

func SetDefaultWidth

func SetDefaultWidth(width int)

SetDefaultWidth sets default width of chart

func SetNullValue

func SetNullValue(v float64)

SetNullValue sets the null value, default is MaxFloat64

func True

func True() *bool

True returns a pointer to a true bool, useful for configuration.

Types

type AxisOption

type AxisOption struct {
	// Show specifies if the axis should be rendered, set this to *false (through False()) to hide the axis.
	Show *bool
	// Theme specifies the colors used for the axis.
	Theme ColorPalette
	// Data provides labels for the axis.
	Data []string
	// DataStartIndex specifies what index the Data values should start from.
	DataStartIndex int
	// Formatter for replacing axis text values.
	Formatter string
	// Position describes the position of axis, it can be 'left', 'top', 'right' or 'bottom'.
	Position string
	// BoundaryGap specifies that the chart should have additional space on the left and right, with data points being
	// centered between two axis ticks.  Enabled by default, specify *false (through False()) to change the spacing.
	BoundaryGap *bool
	// StrokeWidth is the axis line width.
	StrokeWidth float64
	// TickLength is the length of each axis tick.
	TickLength int
	// LabelMargin specifies the margin value of each label.
	LabelMargin int
	// FontSize specifies the font size of each label.
	FontSize float64
	// Font is the font used to render each label.
	Font *truetype.Font
	// FontColor is the color used for text rendered.
	FontColor Color
	// SplitLineShow, set this to true will show axis split line.
	SplitLineShow bool
	// TextRotation are the radians for rotating the label.
	TextRotation float64
	// LabelOffset is the offset of each label.
	LabelOffset Offset
	// Unit is a suggestion for how large the axis step is, this is a recommendation only. Larger numbers result in fewer labels.
	Unit float64
	// LabelCount is the number of labels to show on the axis. Specify a smaller number to reduce writing collisions. This value takes priority over Unit.
	LabelCount int
	// LabelCountAdjustment specifies a relative influence on how many labels should be rendered.
	// Typically, this is negative to result in cleaner graphs, positive values may result in text collisions.
	LabelCountAdjustment int
	// LabelSkipCount specifies a number of lines between labels where there will be no label,
	// but a horizontal line will still be drawn.
	LabelSkipCount int
}

type BarChartOption

type BarChartOption struct {
	// Theme specifies the colors used for the bar chart.
	Theme ColorPalette
	// Padding specifies the padding of bar chart.
	Padding Box
	// Font is the font used to render the chart.
	Font *truetype.Font
	// SeriesList provides the data series.
	SeriesList SeriesList
	// XAxis are options for the x-axis.
	XAxis XAxisOption
	// YAxis are options for the y-axis (at most two).
	YAxis []YAxisOption
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// BarWidth specifies the width of each bar.
	BarWidth int
}

type Box

type Box = chart.Box

type ChartOption

type ChartOption struct {
	// OutputFormat specifies the output type of chart, "svg" or "png", default value is "png"
	OutputFormat string
	// Width is the width of chart, default width is 600.
	Width int
	// Height is the height of chart, default height is 400
	Height int
	// Theme specifies the colors used for the chart. Built in themes can be loaded using GetTheme with
	// "light", "dark", "vivid-light", "vivid-dark", "ant" or "grafana".
	Theme ColorPalette
	// Padding specifies the padding for chart, default padding is [20, 10, 10, 10]
	Padding Box
	// XAxis are options for the x-axis.
	XAxis XAxisOption
	// YAxis are options for the y-axis (at most two).
	YAxis []YAxisOption
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// Font is the font to use for rendering the chart.
	Font *truetype.Font
	// Box specifies the canvas box for the chart.
	Box    Box
	Parent *Painter
	// SeriesList provides the data series.
	SeriesList SeriesList
	// RadarIndicators are radar indicator list for radar charts
	RadarIndicators []RadarIndicator
	// SymbolShow set this to *false (using False()) to hide symbols.
	SymbolShow *bool
	// LineStrokeWidth is the stroke width for line charts.
	LineStrokeWidth float64
	// FillArea set to true to fill the area under the line in line charts
	FillArea bool
	// FillOpacity is the opacity (alpha) of the area fill in line charts.
	FillOpacity uint8
	// BarWidth is the width of the bars for bar charts.
	BarWidth int
	// BarHeight is the height of the bars for horizontal bar charts.
	BarHeight int
	// Children are child charts to pull options from.
	Children []ChartOption
	// ValueFormatter to format numeric values into labels.
	ValueFormatter ValueFormatter
}

type Color

type Color = drawing.Color

type ColorPalette

type ColorPalette interface {
	IsDark() bool
	GetAxisStrokeColor() Color
	GetAxisSplitLineColor() Color
	GetSeriesColor(int) Color
	GetBackgroundColor() Color
	GetTextColor() Color
	// WithAxisColor will provide a new ColorPalette that uses the specified color for axis values.
	// This includes the Axis Stroke, Split Line, and Text Color.
	WithAxisColor(Color) ColorPalette
	// WithTextColor will provide a new ColorPalette that uses the specified color for text.
	// This is generally recommended over using the FontColor config values.
	WithTextColor(Color) ColorPalette
}

func GetDefaultTheme

func GetDefaultTheme() ColorPalette

GetDefaultTheme returns the default theme.

func GetTheme

func GetTheme(name string) ColorPalette

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

func MakeTheme

func MakeTheme(opt ThemeOption) ColorPalette

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

type EChartStyle

type EChartStyle struct {
	Color string `json:"color"`
}

func (*EChartStyle) ToStyle

func (es *EChartStyle) ToStyle() Style

type EChartsAxisLabel

type EChartsAxisLabel struct {
	Formatter string `json:"formatter"`
}

type EChartsLabelOption

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

type EChartsLegend

type EChartsLegend struct {
	Show      *bool            `json:"show"`
	Data      []string         `json:"data"`
	Align     string           `json:"align"`
	Orient    string           `json:"orient"`
	Padding   EChartsPadding   `json:"padding"`
	Left      EChartsPosition  `json:"left"`
	Top       EChartsPosition  `json:"top"`
	TextStyle EChartsTextStyle `json:"textStyle"`
}

type EChartsMarkData

type EChartsMarkData struct {
	Type string `json:"type"`
}

func (*EChartsMarkData) UnmarshalJSON

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

type EChartsMarkLine

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

func (*EChartsMarkLine) ToSeriesMarkLine

func (eml *EChartsMarkLine) ToSeriesMarkLine() SeriesMarkLine

type EChartsMarkPoint

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

func (*EChartsMarkPoint) ToSeriesMarkPoint

func (emp *EChartsMarkPoint) ToSeriesMarkPoint() SeriesMarkPoint

type EChartsOption

type EChartsOption struct {
	Type       string         `json:"type"`
	Theme      string         `json:"theme"`
	FontFamily string         `json:"fontFamily"`
	Padding    EChartsPadding `json:"padding"`
	Box        chart.Box      `json:"box"`
	Width      int            `json:"width"`
	Height     int            `json:"height"`
	Title      struct {
		Text         string           `json:"text"`
		Subtext      string           `json:"subtext"`
		Left         EChartsPosition  `json:"left"`
		Top          EChartsPosition  `json:"top"`
		TextStyle    EChartsTextStyle `json:"textStyle"`
		SubtextStyle EChartsTextStyle `json:"subtextStyle"`
	} `json:"title"`
	XAxis  EChartsXAxis  `json:"xAxis"`
	YAxis  EChartsYAxis  `json:"yAxis"`
	Legend EChartsLegend `json:"legend"`
	Radar  struct {
		Indicator []RadarIndicator `json:"indicator"`
	} `json:"radar"`
	Series   EChartsSeriesList `json:"series"`
	Children []EChartsOption   `json:"children"`
}

func (*EChartsOption) ToOption

func (eo *EChartsOption) ToOption() ChartOption

type EChartsPadding

type EChartsPadding struct {
	Box chart.Box
}

func (*EChartsPadding) UnmarshalJSON

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

type EChartsPosition

type EChartsPosition string

func (*EChartsPosition) UnmarshalJSON

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

type EChartsSeries

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

type EChartsSeriesData

type EChartsSeriesData struct {
	Value     EChartsSeriesDataValue `json:"value"`
	Name      string                 `json:"name"`
	ItemStyle EChartStyle            `json:"itemStyle"`
}

func (*EChartsSeriesData) UnmarshalJSON

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

type EChartsSeriesDataValue

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

func NewEChartsSeriesDataValue

func NewEChartsSeriesDataValue(values ...float64) EChartsSeriesDataValue

func (*EChartsSeriesDataValue) First

func (value *EChartsSeriesDataValue) First() float64

func (*EChartsSeriesDataValue) UnmarshalJSON

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

type EChartsSeriesList

type EChartsSeriesList []EChartsSeries

func (EChartsSeriesList) ToSeriesList

func (esList EChartsSeriesList) ToSeriesList() SeriesList

type EChartsTextStyle

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

func (*EChartsTextStyle) ToStyle

func (et *EChartsTextStyle) ToStyle() chart.Style

type EChartsXAxis

type EChartsXAxis struct {
	Data []EChartsXAxisData
}

func (*EChartsXAxis) UnmarshalJSON

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

type EChartsXAxisData

type EChartsXAxisData struct {
	BoundaryGap *bool    `json:"boundaryGap"`
	SplitNumber int      `json:"splitNumber"`
	Data        []string `json:"data"`
	Type        string   `json:"type"`
}

type EChartsYAxis

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

func (*EChartsYAxis) UnmarshalJSON

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

type EChartsYAxisData

type EChartsYAxisData struct {
	Min       *float64         `json:"min"`
	Max       *float64         `json:"max"`
	AxisLabel EChartsAxisLabel `json:"axisLabel"`
	AxisLine  struct {
		LineStyle struct {
			Color string `json:"color"`
		} `json:"lineStyle"`
	} `json:"axisLine"`
	Data []string `json:"data"`
}

type FunnelChartOption

type FunnelChartOption struct {
	// Theme specifies the colors used for the chart.
	Theme ColorPalette
	// Padding specifies the padding of funnel chart.
	Padding Box
	// Font is the font used to render the chart.
	Font *truetype.Font
	// SeriesList provides the data series.
	SeriesList SeriesList
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
}

type GridOption

type GridOption struct {
	// Columns is the count of columns in the grid.
	Columns int
	// Rows are the count of rows in the grid.
	Rows int
	// ColumnSpans specifies the span for each column.
	ColumnSpans []int
	// IgnoreColumnLines specifies index for columns to not display.
	IgnoreColumnLines []int
	// IgnoreRowLines specifies index for rows to not display.
	IgnoreRowLines []int
}

type GridPainterOption

type GridPainterOption struct {
	// StrokeWidth is the grid line width.
	StrokeWidth float64
	// StrokeColor is the grid line color.
	StrokeColor Color
	// ColumnSpans specifies the span for each column.
	ColumnSpans []int
	// Columns is the count of columns in the grid.
	Columns int
	// Rows are the count of rows in the grid.
	Rows int
	// IgnoreFirstRow can be set to true to ignore the first row.
	IgnoreFirstRow bool
	// IgnoreLastRow can be set to true to ignore the last row.
	IgnoreLastRow bool
	// IgnoreFirstColumn can be set to true to ignore the first colum.
	IgnoreFirstColumn bool
	// IgnoreLastColumn can be set to true to ignore the last columns.
	IgnoreLastColumn bool
}

type HorizontalBarChartOption

type HorizontalBarChartOption struct {
	// Theme specifies the colors used for the chart.
	Theme ColorPalette
	// Padding specifies the padding of bar chart.
	Padding Box
	// Font is the font used to render the chart.
	Font *truetype.Font
	// SeriesList provides the data series.
	SeriesList SeriesList
	// XAxis are options for the x-axis.
	XAxis XAxisOption
	// YAxis are options for the y-axis (at most two).
	YAxis []YAxisOption
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// BarHeight specifies the height of each horizontal bar.
	BarHeight int
}

type LabelFormatter

type LabelFormatter func(index int, value float64, percent float64) string

LabelFormatter label formatter

func NewFunnelLabelFormatter

func NewFunnelLabelFormatter(seriesNames []string, layout string) LabelFormatter

NewFunnelLabelFormatter returns a funner label formatter

func NewLabelFormatter

func NewLabelFormatter(seriesNames []string, layout string) LabelFormatter

NewLabelFormatter returns a label formatter

func NewPieLabelFormatter

func NewPieLabelFormatter(seriesNames []string, layout string) LabelFormatter

NewPieLabelFormatter returns a pie label formatter

func NewValueLabelFormatter

func NewValueLabelFormatter(seriesNames []string, layout string) LabelFormatter

NewValueLabelFormatter returns a value formatter

type LabelValue

type LabelValue struct {
	Index     int
	Value     float64
	X         int
	Y         int
	Radians   float64
	FontColor Color
	FontSize  float64
	Orient    string
	Offset    Offset
}

type LegendOption

type LegendOption struct {
	// Show specifies if the legend should be rendered, set this to *false (through False()) to hide the legend.
	Show *bool
	// Theme specifies the colors used for the legend.
	Theme ColorPalette
	// Padding specifies space padding around the legend.
	Padding Box
	// Data provides text for the legend.
	Data []string
	// FontSize specifies the font size of each label.
	FontSize float64
	// Font is the font used to render each label.
	Font *truetype.Font
	// FontColor is the color used for text rendered.
	FontColor Color
	// Left is the distance between legend component and the left side of the container.
	// It can be pixel value (20), percentage value (20%), or position description: 'left', 'right', 'center'.
	Left string
	// Top is the distance between legend component and the top side of the container.
	// It can be pixel value (20), or percentage value (20%).
	Top string
	// Align is the legend marker and text alignment, it can be 'left' or 'right', default is 'left'.
	Align string
	// Orient is the layout orientation of legend, it can be 'horizontal' or 'vertical', default is 'horizontal'.
	Orient string
	// Icon to show next to the labels.	Can be 'rect' or 'dot'.
	Icon string
}

func NewLegendOption

func NewLegendOption(labels []string, left ...string) LegendOption

NewLegendOption returns a legend option

func (*LegendOption) IsEmpty

func (opt *LegendOption) IsEmpty() bool

IsEmpty checks legend is empty

type LineChartOption

type LineChartOption struct {
	// Theme specifies the colors used for the line chart.
	Theme ColorPalette
	// Padding specifies the padding of line chart.
	Padding Box
	// Font is the font used to render the chart.
	Font *truetype.Font
	// SeriesList provides the data series.
	SeriesList SeriesList
	// XAxis are options for the x-axis.
	XAxis XAxisOption
	// YAxis are options for the y-axis (at most two).
	YAxis []YAxisOption
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// SymbolShow set this to *false (through False()) to hide symbols.
	SymbolShow *bool
	// StrokeWidth is the width of the rendered line.
	StrokeWidth float64
	// FillArea set this to true to fill the area below the line.
	FillArea bool
	// FillOpacity is the opacity (alpha) of the area fill.
	FillOpacity uint8
	// contains filtered or unexported fields
}

type MultiTextOption

type MultiTextOption struct {
	TextList     []string
	Orient       string
	CenterLabels bool
	Align        string
	TextRotation float64
	Offset       Offset
	// The first text index
	First          int
	LabelCount     int
	LabelSkipCount int
}

type Offset added in v0.1.1

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

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

type OptionFunc

type OptionFunc func(opt *ChartOption)

OptionFunc option function

func BoxOptionFunc

func BoxOptionFunc(box Box) OptionFunc

BoxOptionFunc set box of chart

func ChildOptionFunc

func ChildOptionFunc(child ...ChartOption) OptionFunc

ChildOptionFunc add child chart

func FontOptionFunc

func FontOptionFunc(font *truetype.Font) OptionFunc

FontOptionFunc set font of chart.

func HeightOptionFunc

func HeightOptionFunc(height int) OptionFunc

HeightOptionFunc set height of chart

func LegendLabelsOptionFunc

func LegendLabelsOptionFunc(labels []string, left ...string) OptionFunc

LegendLabelsOptionFunc set legend labels of chart

func LegendOptionFunc

func LegendOptionFunc(legend LegendOption) OptionFunc

LegendOptionFunc set legend of chart

func MarkLineOptionFunc

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

MarkLineOptionFunc set mark line for series of chart

func MarkPointOptionFunc

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

MarkPointOptionFunc set mark point for series of chart

func OutputFormatOptionFunc

func OutputFormatOptionFunc(t string) OptionFunc

OutputFormatOptionFunc set type of chart's output.

func PNGOutputOption

func PNGOutputOption() OptionFunc

PNGOutputOption set png type of chart's output.

func PaddingOptionFunc

func PaddingOptionFunc(padding Box) OptionFunc

PaddingOptionFunc set padding of chart

func PieSeriesShowLabel

func PieSeriesShowLabel() OptionFunc

PieSeriesShowLabel set pie series show label

func RadarIndicatorOptionFunc

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

RadarIndicatorOptionFunc set radar indicator of chart

func SVGOutputOption

func SVGOutputOption() OptionFunc

SVGOutputOption set svg type of chart's output.

func ThemeNameOptionFunc

func ThemeNameOptionFunc(theme string) OptionFunc

ThemeNameOptionFunc set them of chart by name.

func ThemeOptionFunc

func ThemeOptionFunc(theme ColorPalette) OptionFunc

ThemeOptionFunc set them of chart

func TitleOptionFunc

func TitleOptionFunc(title TitleOption) OptionFunc

TitleOptionFunc set title of chart

func TitleTextOptionFunc

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

TitleTextOptionFunc set title text of chart

func WidthOptionFunc

func WidthOptionFunc(width int) OptionFunc

WidthOptionFunc set width of chart

func XAxisDataOptionFunc

func XAxisDataOptionFunc(data []string, boundaryGap ...*bool) OptionFunc

XAxisDataOptionFunc set x-axis data of chart

func XAxisOptionFunc

func XAxisOptionFunc(xAxisOption XAxisOption) OptionFunc

XAxisOptionFunc set x-axis of chart

func YAxisDataOptionFunc

func YAxisDataOptionFunc(data []string) OptionFunc

YAxisDataOptionFunc set y-axis data of chart

func YAxisOptionFunc

func YAxisOptionFunc(yAxisOption ...YAxisOption) OptionFunc

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

type Painter

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

func BarRender

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

BarRender bar chart render

func FunnelRender

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

FunnelRender funnel chart render

func HorizontalBarRender

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

HorizontalBarRender horizontal bar chart render

func LineRender

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

LineRender line chart render

func NewPainter

func NewPainter(opts PainterOptions, opt ...PainterOption) (*Painter, error)

NewPainter creates a painter

func PieRender

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

PieRender pie chart render

func RadarRender

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

RadarRender radar chart render

func Render

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

func TableOptionRender

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

TableOptionRender table render with option

func TableRender

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

TableRender table chart render

func (*Painter) ArcTo

func (p *Painter) ArcTo(cx, cy int, rx, ry, startAngle, delta float64) *Painter

func (*Painter) ArrowBottom

func (p *Painter) ArrowBottom(x, y, width, height int) *Painter

func (*Painter) ArrowLeft

func (p *Painter) ArrowLeft(x, y, width, height int) *Painter

func (*Painter) ArrowRight

func (p *Painter) ArrowRight(x, y, width, height int) *Painter

func (*Painter) ArrowTop

func (p *Painter) ArrowTop(x, y, width, height int) *Painter

func (*Painter) Bytes

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

Bytes returns the data of draw canvas

func (*Painter) Child

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

func (*Painter) Circle

func (p *Painter) Circle(radius float64, x, y int) *Painter

func (*Painter) ClearTextRotation

func (p *Painter) ClearTextRotation()

func (*Painter) Close

func (p *Painter) Close() *Painter

func (*Painter) Dots

func (p *Painter) Dots(points []Point) *Painter

func (*Painter) Fill

func (p *Painter) Fill() *Painter

func (*Painter) FillArea

func (p *Painter) FillArea(points []Point) *Painter

func (*Painter) FillStroke

func (p *Painter) FillStroke() *Painter

func (*Painter) Grid

func (p *Painter) Grid(opt GridOption) *Painter

func (*Painter) Height

func (p *Painter) Height() int

func (*Painter) LegendLineDot

func (p *Painter) LegendLineDot(box Box) *Painter

func (*Painter) LineStroke

func (p *Painter) LineStroke(points []Point) *Painter

func (*Painter) LineTo

func (p *Painter) LineTo(x, y int) *Painter

func (*Painter) MarkLine

func (p *Painter) MarkLine(x, y, width int) *Painter

func (*Painter) MeasureText

func (p *Painter) MeasureText(text string) Box

func (*Painter) MeasureTextMaxWidthHeight

func (p *Painter) MeasureTextMaxWidthHeight(textList []string) (int, int)

func (*Painter) MoveTo

func (p *Painter) MoveTo(x, y int) *Painter

MoveTo moves the cursor to a given point

func (*Painter) MultiText

func (p *Painter) MultiText(opt MultiTextOption) *Painter

func (*Painter) OverrideDrawingStyle

func (p *Painter) OverrideDrawingStyle(style Style) *Painter

func (*Painter) OverrideTextStyle

func (p *Painter) OverrideTextStyle(style Style) *Painter

func (*Painter) Pin

func (p *Painter) Pin(x, y, width int) *Painter

func (*Painter) Polygon

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

func (*Painter) QuadCurveTo

func (p *Painter) QuadCurveTo(cx, cy, x, y int) *Painter

func (*Painter) Rect

func (p *Painter) Rect(box Box) *Painter

func (*Painter) ResetStyle

func (p *Painter) ResetStyle() *Painter

func (*Painter) SetBackground

func (p *Painter) SetBackground(width, height int, color Color, inside ...bool) *Painter

func (*Painter) SetDrawingStyle

func (p *Painter) SetDrawingStyle(style Style) *Painter

func (*Painter) SetStyle

func (p *Painter) SetStyle(style Style)

func (*Painter) SetTextRotation

func (p *Painter) SetTextRotation(radians float64)

func (*Painter) SetTextStyle

func (p *Painter) SetTextStyle(style Style) *Painter

func (*Painter) SmoothLineStroke

func (p *Painter) SmoothLineStroke(points []Point) *Painter

func (*Painter) Stroke

func (p *Painter) Stroke() *Painter

func (*Painter) Text

func (p *Painter) Text(body string, x, y int) *Painter

func (*Painter) TextFit

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

func (*Painter) TextRotation

func (p *Painter) TextRotation(body string, x, y int, radians float64)

func (*Painter) Ticks

func (p *Painter) Ticks(opt TicksOption) *Painter

func (*Painter) Width

func (p *Painter) Width() int

type PainterOption

type PainterOption func(*Painter)

func PainterBoxOption

func PainterBoxOption(box Box) PainterOption

PainterBoxOption sets the box of draw painter

func PainterFontOption

func PainterFontOption(font *truetype.Font) PainterOption

PainterFontOption sets the font of draw painter

func PainterPaddingOption

func PainterPaddingOption(padding Box) PainterOption

PainterPaddingOption sets the padding of draw painter

func PainterStyleOption

func PainterStyleOption(style Style) PainterOption

PainterStyleOption sets the style of draw painter

func PainterThemeOption

func PainterThemeOption(theme ColorPalette) PainterOption

PainterThemeOption sets the theme of draw painter

func PainterWidthHeightOption

func PainterWidthHeightOption(width, height int) PainterOption

PainterWidthHeightOption set width or height of draw painter

type PainterOptions

type PainterOptions struct {
	// OutputFormat specifies the output type, "svg" or "png", default value is "png"
	OutputFormat string
	// Width is the width of the draw painter.
	Width int
	// Height is the height of the draw painter.
	Height int
	// Font is the font used for rendering text.
	Font *truetype.Font
}

type PieChartOption

type PieChartOption struct {
	// Theme specifies the colors used for the pie chart.
	Theme ColorPalette
	// Padding specifies the padding of pie chart.
	Padding Box
	// Font is the font used to render the chart.
	Font *truetype.Font
	// SeriesList provides the data series.
	SeriesList SeriesList
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// contains filtered or unexported fields
}

type PieSeriesOption

type PieSeriesOption struct {
	Radius string
	Label  SeriesLabel
	Names  []string
}

type Point

type Point struct {
	X int
	Y int
}

type RadarChartOption

type RadarChartOption struct {
	// Theme specifies the colors used for the pie chart.
	Theme ColorPalette
	// Padding specifies the padding of pie chart.
	Padding Box
	// Font is the font used to render the chart.
	Font *truetype.Font
	// SeriesList provides the data series.
	SeriesList SeriesList
	// Title are options for rendering the title.
	Title TitleOption
	// Legend are options for the data legend.
	Legend LegendOption
	// RadarIndicators provides the radar indicator list.
	RadarIndicators []RadarIndicator
	// contains filtered or unexported fields
}

type RadarIndicator

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

func NewRadarIndicators

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

NewRadarIndicators returns a radar indicator list

type Renderer

type Renderer interface {
	Render() (Box, error)
}

type Series

type Series struct {

	// Type is the type of series, it can be "line", "bar" or "pie". Default value is "line".
	Type string
	// Data provides the series data list.
	Data []SeriesData
	// YAxisIndex is the index for the axis, it should be 0 or 1.
	YAxisIndex int
	// Style represents the style for the series.
	Style chart.Style
	// Label provides the series labels.
	Label SeriesLabel
	// Name specifies a name for the series.
	Name string
	// Radius for Pie chart, e.g.: 40%, default is "40%"
	Radius string
	// MarkPoint provides a series for mark points.
	MarkPoint SeriesMarkPoint
	// MarkLine provides a series for mark lines.
	MarkLine SeriesMarkLine
	// Max value of series
	Min *float64
	// Min value of series
	Max *float64
	// contains filtered or unexported fields
}

func NewSeriesFromValues

func NewSeriesFromValues(values []float64, chartType ...string) Series

NewSeriesFromValues returns a series

func (*Series) Summary

func (s *Series) Summary() seriesSummary

Summary get summary of series

type SeriesData

type SeriesData struct {
	// Value is the retained value for the data.
	Value float64
	// Style provides a style for the series data.
	Style Style
}

func NewSeriesDataFromValues

func NewSeriesDataFromValues(values []float64) []SeriesData

NewSeriesDataFromValues return a series data

type SeriesLabel

type SeriesLabel struct {
	// Data label formatter, which supports string template.
	// {b}: the name of a data item.
	// {c}: the value of a data item.
	// {d}: the percent of a data item(pie chart).
	Formatter string
	// Color specifies the color for the label.
	Color Color
	// Show flag for label
	Show bool
	// Distance to the host graphic element.
	Distance int
	// Position defines the label position.
	Position string
	// Offset specifies an offset from the position.
	Offset Offset
	// FontSize is the size for text rendering.
	FontSize float64
}

type SeriesLabelPainter

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

func NewSeriesLabelPainter

func NewSeriesLabelPainter(params SeriesLabelPainterParams) *SeriesLabelPainter

func (*SeriesLabelPainter) Add

func (o *SeriesLabelPainter) Add(value LabelValue)

func (*SeriesLabelPainter) Render

func (o *SeriesLabelPainter) Render() (Box, error)

type SeriesLabelPainterParams

type SeriesLabelPainterParams struct {
	P           *Painter
	SeriesNames []string
	Label       SeriesLabel
	Theme       ColorPalette
	Font        *truetype.Font
}

type SeriesList

type SeriesList []Series

func NewFunnelSeriesList

func NewFunnelSeriesList(values []float64) SeriesList

NewFunnelSeriesList returns a series list for funnel

func NewPieSeriesList

func NewPieSeriesList(values []float64, opts ...PieSeriesOption) SeriesList

func NewSeriesListDataFromValues

func NewSeriesListDataFromValues(values [][]float64, chartType ...string) SeriesList

NewSeriesListDataFromValues returns a series list

func (SeriesList) Filter

func (sl SeriesList) Filter(chartType string) SeriesList

func (SeriesList) GetMinMax

func (sl SeriesList) GetMinMax(axisIndex int) (float64, float64)

GetMinMax get max and min value of series list

func (SeriesList) Names

func (sl SeriesList) Names() []string

Names returns the names of series list

type SeriesMarkData

type SeriesMarkData struct {
	// Type is the mark data type, it can be "max", "min", "average". "average" is only for mark line.
	Type string
}

type SeriesMarkLine

type SeriesMarkLine struct {
	// Data is the mark data for the series mark line.
	Data []SeriesMarkData
}

func NewMarkLine

func NewMarkLine(markLineTypes ...string) SeriesMarkLine

NewMarkLine returns a series mark line

type SeriesMarkPoint

type SeriesMarkPoint struct {
	// SymbolSize is the width of symbol, default value is 30.
	SymbolSize int
	// Data is the mark data for the series mark point.
	Data []SeriesMarkData
}

func NewMarkPoint

func NewMarkPoint(markPointTypes ...string) SeriesMarkPoint

NewMarkPoint returns a series mark point

type Style

type Style = chart.Style

type TableCell

type TableCell struct {
	// Text the text of table cell
	Text string
	// Style the current style of table cell
	Style Style
	// Row the row index of table cell
	Row int
	// Column the column index of table cell
	Column int
}

type TableChartOption

type TableChartOption struct {
	// OutputFormat specifies the output type, "svg" or "png".
	OutputFormat string
	// Theme specifies the colors used for the table.
	Theme ColorPalette
	// Padding specifies the padding of table.
	Padding Box
	// Width specifies the width of the table.
	Width int
	// Header provides header data for the top of the table.
	Header []string
	// Data provides the row and column data for the table.
	Data [][]string
	// Spans provide the span for each column on the table.
	Spans []int
	// TextAligns specifies the text alignment for each cell on the table.
	TextAligns []string
	// The font size of table contents.
	FontSize float64
	// Font is the font used to render the table.
	Font *truetype.Font
	// FontColor is the color used for text on the table.
	FontColor Color
	// HeaderBackgroundColor provides a background color of header row.
	HeaderBackgroundColor Color
	// HeaderFontColor specifies a text color for the header text.
	HeaderFontColor Color
	// RowBackgroundColors specifies an array of colors for each row.
	RowBackgroundColors []Color
	// BackgroundColor specifies a general background color.
	BackgroundColor Color
	// CellTextStyle customize text style of table cell
	CellTextStyle func(TableCell) *Style
	// CellStyle customize drawing style of table cell
	CellStyle func(TableCell) *Style
}

type TableSetting

type TableSetting struct {
	// HeaderColor specifies the color of the header.
	HeaderColor Color
	// HeaderFontColor specifies the color of header text.
	HeaderFontColor Color
	// FontColor specifies the color of table text.
	FontColor Color
	// RowColors specifies an array of colors for each row.
	RowColors []Color
	// Padding specifies the padding of each cell.
	CellPadding Box
}

type ThemeOption

type ThemeOption struct {
	IsDarkMode         bool
	AxisStrokeColor    Color
	AxisSplitLineColor Color
	BackgroundColor    Color
	TextColor          Color
	SeriesColors       []Color
}

type TicksOption

type TicksOption struct {
	// the first tick index
	First      int
	Length     int
	Orient     string
	LabelCount int
	TickSpaces int
}

type TitleOption

type TitleOption struct {
	// Show specifies if the title should be rendered, set this to *false (through False()) to hide the title.
	Show *bool
	// Theme specifies the colors used for the title.
	Theme ColorPalette
	// Text specifies the title text, supporting \n for new lines.
	Text string
	// Subtext to the title, supporting \n for new lines.
	Subtext string
	// Left is the distance between title component and the left side of the container.
	// It can be pixel value (20) or percentage value (20%), or position description: 'left', 'right', 'center'.
	Left string
	// Top is the distance between title component and the top side of the container.
	// It can be pixel value (20) or percentage value (20%).
	Top string
	// The font size of title.
	FontSize float64
	// Font is the font used to render the title.
	Font *truetype.Font
	// FontColor is the color used for text on the title.
	FontColor Color
	// SubtextFontSize specifies the size of the subtext.
	SubtextFontSize float64
	// SubtextFontColor specifies a unique color for the subtext.
	SubtextFontColor Color
}

type ValueFormatter

type ValueFormatter func(float64) string

type XAxisOption

type XAxisOption struct {
	// Show specifies if the x-axis should be rendered, set this to *false (through False()) to hide the axis.
	Show *bool
	// Theme specifies the colors used for the x-axis.
	Theme ColorPalette
	// Data provides labels for the x-axis.
	Data []string
	// DataStartIndex specifies what index the Data values should start from.
	DataStartIndex int
	// Position describes the position of x-axis, it can be 'top' or 'bottom'.
	Position string
	// BoundaryGap specifies that the chart should have additional space on the left and right, with data points being
	// centered between two axis ticks.  Enabled by default, specify *false (through False()) to change the spacing.
	BoundaryGap *bool
	// FontSize specifies the font size of each label.
	FontSize float64
	// Font is the font used to render each label.
	Font *truetype.Font
	// FontColor is the color used for text rendered.
	FontColor Color
	// TextRotation are the radians for rotating the label.
	TextRotation float64
	// LabelOffset is the offset of each label.
	LabelOffset Offset
	// Unit is a suggestion for how large the axis step is, this is a recommendation only. Larger numbers result in fewer labels.
	Unit float64
	// LabelCount is the number of labels to show on the axis.  Specify a smaller number to reduce writing collisions.
	LabelCount int
	// LabelCountAdjustment specifies a relative influence on how many labels should be rendered.
	// Typically, this is negative to result in cleaner graphs, positive values may result in text collisions.
	LabelCountAdjustment int
	// contains filtered or unexported fields
}

func NewXAxisOption

func NewXAxisOption(data []string, boundaryGap ...*bool) XAxisOption

NewXAxisOption returns a x axis option

func (*XAxisOption) ToAxisOption

func (opt *XAxisOption) ToAxisOption() AxisOption

type YAxisOption

type YAxisOption struct {
	// Show specifies if the y-axis should be rendered, set this to *false (through False()) to hide the axis.
	Show *bool
	// Theme specifies the colors used for the x-axis.
	Theme ColorPalette
	// Color for y-axis.
	AxisColor Color
	// Min, if set this will force the minimum value of y-axis.
	Min *float64
	// Max, if set this will force the maximum value of y-axis.
	Max *float64
	// RangeValuePaddingScale suggest a scale of padding added to the max and min values.
	RangeValuePaddingScale *float64
	// Data provides labels for the y-axis.
	Data []string
	// Position describes the position of y-axis, it can be 'left' or 'right'.
	Position string
	// FontSize specifies the font size of each label.
	FontSize float64
	// Font is the font used to render each label.
	Font *truetype.Font
	// FontColor is the color used for text rendered.
	FontColor Color
	// Formatter for replacing y-axis text values.
	Formatter string
	// Unit is a suggestion for how large the axis step is, this is a recommendation only. Larger numbers result in fewer labels.
	Unit float64
	// LabelCount is the number of labels to show on the axis.  Specify a smaller number to reduce writing collisions.
	LabelCount int
	// LabelCountAdjustment specifies a relative influence on how many labels should be rendered.
	// Typically, this is negative to result in cleaner graphs, positive values may result in text collisions.
	LabelCountAdjustment int
	// LabelSkipCount specifies a number of lines between labels where there will be no label and instead just a horizontal line.
	LabelSkipCount int

	// The flag for show axis split line, set this to true will show axis split line
	SplitLineShow *bool
	// contains filtered or unexported fields
}

func NewYAxisOptions

func NewYAxisOptions(data []string, others ...[]string) []YAxisOption

NewYAxisOptions returns a y-axis option

func (*YAxisOption) ToAxisOption

func (opt *YAxisOption) ToAxisOption(p *Painter) AxisOption

Jump to

Keyboard shortcuts

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