charts

package module
v2.6.10 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 15 Imported by: 74

README

go-charts

license Build Status

中文

go-charts base on go-chart,it is simpler way for generating charts, which supports svg and png format and themes: light, dark, grafana and ant. The default format is png and the default theme is light.

Apache ECharts is popular among Front-end developers, so go-charts supports the option of Apache ECharts. Developers can generate charts almost the same as Apache ECharts.

Screenshot of common charts, the left part is light theme, the right part is grafana theme.

go-charts

go-table

Chart Type

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

Example

More examples can be found in the ./examples/ directory.

Line Chart
package main

import (
	charts "github.com/vicanso/go-charts/v2"
)

func main() {
	values := [][]float64{
		{
			120,
			132,
			101,
			134,
			90,
			230,
			210,
		},
		{
			// snip...
		},
		{
			// snip...
		},
		{
			// snip...
		},
		{
			// snip...
		},
	}
	p, err := charts.LineRender(
		values,
		charts.TitleTextOptionFunc("Line"),
		charts.XAxisDataOptionFunc([]string{
			"Mon",
			"Tue",
			"Wed",
			"Thu",
			"Fri",
			"Sat",
			"Sun",
		}),
		charts.LegendLabelsOptionFunc([]string{
			"Email",
			"Union Ads",
			"Video Ads",
			"Direct",
			"Search Engine",
		}, charts.PositionCenter),
	)

	if err != nil {
		panic(err)
	}

	buf, err := p.Bytes()
	if err != nil {
		panic(err)
	}
	// snip...
}
Bar Chart
package main

import (
	"github.com/vicanso/go-charts/v2"
)

func main() {
	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,
			)
		},
	)
	if err != nil {
		panic(err)
	}

	buf, err := p.Bytes()
	if err != nil {
		panic(err)
	}
	// snip...
}
Horizontal Bar Chart
package main

import (
	"github.com/vicanso/go-charts/v2"
)

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",
		}),
	)
	if err != nil {
		panic(err)
	}

	buf, err := p.Bytes()
	if err != nil {
		panic(err)
	}
	// snip...
}
Pie Chart
package main

import (
	"github.com/vicanso/go-charts/v2"
)

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(),
	)
	if err != nil {
		panic(err)
	}

	buf, err := p.Bytes()
	if err != nil {
		panic(err)
	}
	// snip...	
}
Radar Chart
package main

import (
	"github.com/vicanso/go-charts/v2"
)

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,
		}),
	)
	if err != nil {
		panic(err)
	}

	buf, err := p.Bytes()
	if err != nil {
		panic(err)
	}
	// snip...
}
Funnel Chart
package main

import (
	"github.com/vicanso/go-charts/v2"
)

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",
		}),
	)
	if err != nil {
		panic(err)
	}

	buf, err := p.Bytes()
	if err != nil {
		panic(err)
	}
	// snip...
}
Table
package main

import (
	"github.com/vicanso/go-charts/v2"
)

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,
		// 设置第三列的span
		2: 3,
		3: 2,
		4: 2,
	}
	p, err := charts.TableRender(
		header,
		data,
		spans,
	)
	if err != nil {
		panic(err)
	}

	buf, err := p.Bytes()
	if err != nil {
		panic(err)
	}
	// snip...
}
ECharts Render
package main

import (
	"github.com/vicanso/go-charts/v2"
)

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...
}

ECharts Option

The name with [] is new parameter, others are the same as echarts.

  • [type] The canvas type, support svg and png, default is svg
  • [theme] The theme, support dark, light and grafana, default is light
  • [fontFamily] The font family for chart
  • [padding] The padding of chart
  • [box] The canvas box of chart
  • [width] The width of chart
  • [height] The height of chart
  • title Title component, including main title and subtitle
    • title.text The main title text, supporting for \n for newlines
    • title.subtextSubtitle text, supporting for \n for newlines
    • title.left Distance between title component and the left side of the container. Left value can be instant pixel value like 20; it can also be a percentage value relative to container width like '20%'; and it can also be 'left', 'center', or 'right'.
    • title.top Distance between title component and the top side of the container. Top value can be instant pixel value like 20
    • title.textStyle.color Text color for title
    • title.textStyle.fontSize Text font size for title
    • title.textStyle.fontFamily Text font family for title, it will change the font family for chart
  • xAxis The x axis in cartesian(rectangular) coordinate. go-charts only support one x axis.
    • xAxis.boundaryGap The boundary gap on both sides of a coordinate axis. The setting and behavior of category axes and non-category axes are different. If set null or true, the label appear in the center part of two axis ticks.
    • xAxis.splitNumber Number of segments that the axis is split into. Note that this number serves only as a recommendation, and the true segments may be adjusted based on readability
    • xAxis.data Category data, only support string array.
  • yAxis The y axis in cartesian(rectangular) coordinate, it support 2 y axis
    • yAxis.min The minimum value of axis. It will be automatically computed to make sure axis tick is equally distributed when not set
    • yAxis.max The maximum value of axis. It will be automatically computed to make sure axis tick is equally distributed when not se.
    • yAxis.axisLabel.formatter Formatter of axis label, which supports string template: "formatter": "{value} kg"
    • yAxis.axisLine.lineStyle.color The color for line
  • legend Legend component
    • legend.show Whether to show legend
    • legend.data Data array of legend, only support string array: ["Email", "Video Ads"]
    • legend.align Legend marker and text aligning. Support left and right, default is left
    • legend.padding legend space around content
    • legend.left Distance between legend component and the left side of the container. Left value can be instant pixel value like 20; it can also be a percentage value relative to container width like '20%'; and it can also be 'left', 'center', or 'right'.
    • legend.top Distance between legend component and the top side of the container. Top value can be instant pixel value like 20
  • radar Coordinate for radar charts
    • radar.indicator Indicator of radar chart, which is used to assign multiple variables(dimensions) in radar chart
      • radar.indicator.name Indicator's name
      • radar.indicator.max The maximum value of indicator
      • radar.indicator.min The minimum value of indicator, default value is 0.
  • series The series for chart
    • series.name Series name used for displaying in legend.
    • series.type Series type: line, bar, pie, radar or funnel
    • series.radius Radius of Pie chart:50%, default is 40%
    • series.yAxisIndex Index of y axis to combine with, which is useful for multiple y axes in one chart
    • series.label.show Whether to show label
    • series.label.distance Distance to the host graphic element
    • series.label.color Label color
    • series.itemStyle.color Color for the series's item
    • series.markPoint Mark point in a chart.
    • series.markPoint.symbolSize Symbol size, default is 30
    • series.markPoint.data Data array for mark points, each of which is an object and the type only support max and min: [{"type": "max"}, {"type": "min"}]
    • series.markLine Mark line in a chart
    • series.markPoint.data Data array for mark points, each of which is an object and the type only support max, min and average: `[{"type": "max"}, {"type": "min"}, {"type": "average"}]``
    • series.data Data array of series, which can be in the following forms:
      • value It's a float array: [1.1, 2,3, 5.2]
      • object It's a object value array: [{"value": 1048, "name": "Search Engine"},{"value": 735,"name": "Direct"}]
  • [children] The options of children chart

Performance

Generate a png chart will be less than 20ms. It's better than using chrome headless with echarts.

BenchmarkMultiChartPNGRender-8                78          15216336 ns/op         2298308 B/op       1148 allocs/op
BenchmarkMultiChartSVGRender-8               367           3356325 ns/op        20597282 B/op       3088 allocs/op

Documentation

Overview

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	ChartTypeLine   = "line"
	ChartTypeBar    = "bar"
	ChartTypePie    = "pie"
	ChartTypeRadar  = "radar"
	ChartTypeFunnel = "funnel"
	// horizontal bar
	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"
View Source
const ThemeDark = "dark"
View Source
const ThemeGrafana = "grafana"
View Source
const ThemeLight = "light"

Variables

View Source
var BoxZero = chart.BoxZero
View Source
var ErrFontNotExists = errors.New("font is not exists")
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,
		},
	},
	Padding: Box{
		Left:   10,
		Top:    10,
		Right:  10,
		Bottom: 10,
	},
}
View Source
var TableLightThemeSetting = TableSetting{
	HeaderColor: Color{
		R: 240,
		G: 240,
		B: 240,
		A: 255,
	},
	HeaderFontColor: Color{
		R: 98,
		G: 105,
		B: 118,
		A: 255,
	},
	FontColor: Color{
		R: 70,
		G: 70,
		B: 70,
		A: 255,
	},
	RowColors: []Color{
		drawing.ColorWhite,
		{
			R: 247,
			G: 247,
			B: 247,
			A: 255,
		},
	},
	Padding: Box{
		Left:   10,
		Top:    10,
		Right:  10,
		Bottom: 10,
	},
}

Functions

func AddTheme

func AddTheme(name string, opt ThemeOption)

func FalseFlag

func FalseFlag() *bool

func GetDefaultFont added in v2.4.4

func GetDefaultFont() (*truetype.Font, error)

GetDefaultFont get default font

func GetFont

func GetFont(fontFamily string) (*truetype.Font, error)

GetFont get the font by font family

func GetNullValue added in v2.3.0

func GetNullValue() float64

GetNullValue gets the null value

func InstallFont

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

InstallFont installs the font for charts

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 NewFloatPoint

func NewFloatPoint(f float64) *float64

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(opt AxisRangeOption) axisRange

NewRange returns a axis range

func NewRightYAxis

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

NewRightYAxis returns a right y axis renderer

func NewSector added in v2.6.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 added in v2.4.4

func SetDefaultFont(font *truetype.Font)

SetDefaultFont set default font

func SetDefaultHeight

func SetDefaultHeight(height int)

SetDefaultHeight sets default height of chart

func SetDefaultTableSetting

func SetDefaultTableSetting(setting TableSetting)

SetDefaultTableSetting sets the default setting for table

func SetDefaultTheme

func SetDefaultTheme(name string)

SetDefaultTheme sets default theme

func SetDefaultWidth

func SetDefaultWidth(width int)

SetDefaultWidth sets default width of chart

func SetNullValue added in v2.3.0

func SetNullValue(v float64)

SetNullValue sets the null value, default is MaxFloat64

func TrueFlag

func TrueFlag() *bool

Types

type AxisOption

type AxisOption struct {
	// The theme of chart
	Theme ColorPalette
	// Formatter for y axis text value
	Formatter string
	// The label of axis
	Data []string
	// The boundary gap on both sides of a coordinate axis.
	// Nil or *true means the center part of two axis ticks
	BoundaryGap *bool
	// The flag for show axis, set this to *false will hide axis
	Show *bool
	// The position of axis, it can be 'left', 'top', 'right' or 'bottom'
	Position string
	// Number of segments that the axis is split into. Note that this number serves only as a recommendation.
	SplitNumber int
	// The line color of axis
	StrokeColor Color
	// The line width
	StrokeWidth float64
	// The length of the axis tick
	TickLength int
	// The first axis
	FirstAxis int
	// The margin value of label
	LabelMargin int
	// The font size of label
	FontSize float64
	// The font of label
	Font *truetype.Font
	// The color of label
	FontColor Color
	// The flag for show axis split line, set this to true will show axis split line
	SplitLineShow bool
	// The color of split line
	SplitLineColor Color
	// The text rotation of label
	TextRotation float64
	// The offset of label
	LabelOffset Box
	Unit        int
}

type AxisRangeOption

type AxisRangeOption struct {
	Painter *Painter
	// The min value of axis
	Min float64
	// The max value of axis
	Max float64
	// The size of axis
	Size int
	// Boundary gap
	Boundary bool
	// The count of divide
	DivideCount int
}

type BarChartOption

type BarChartOption struct {
	// The theme
	Theme ColorPalette
	// The font size
	Font *truetype.Font
	// The data series list
	SeriesList SeriesList
	// The x axis option
	XAxis XAxisOption
	// The padding of line chart
	Padding Box
	// The y axis option
	YAxisOptions []YAxisOption
	// The option of title
	Title TitleOption
	// The legend option
	Legend   LegendOption
	BarWidth int
	// Margin of bar
	BarMargin int
}

type Box

type Box = chart.Box

type ChartOption

type ChartOption struct {

	// The output type of chart, "svg" or "png", default value is "svg"
	Type string
	// The font family, which should be installed first
	FontFamily string
	// The theme of chart, "light" and "dark".
	// The default theme is "light"
	Theme string
	// The title option
	Title TitleOption
	// The legend option
	Legend LegendOption
	// The x axis option
	XAxis XAxisOption
	// The y axis option list
	YAxisOptions []YAxisOption
	// The width of chart, default width is 600
	Width int
	// The height of chart, default height is 400
	Height int
	Parent *Painter
	// The padding for chart, default padding is [20, 10, 10, 10]
	Padding Box
	// The canvas box for chart
	Box Box
	// The series list
	SeriesList SeriesList
	// The radar indicator list
	RadarIndicators []RadarIndicator
	// The background color of chart
	BackgroundColor Color
	// The flag for show symbol of line, set this to *false will hide symbol
	SymbolShow *bool
	// The stroke width of line chart
	LineStrokeWidth float64
	// The bar with of bar chart
	BarWidth int
	// The margin of each bar
	BarMargin int
	// The bar height of horizontal bar chart
	BarHeight int
	// Fill the area of line chart
	FillArea bool
	// background fill (alpha) opacity
	Opacity uint8
	// The child charts
	Children []ChartOption
	// The value formatter
	ValueFormatter ValueFormatter
	// contains filtered or unexported fields
}

type Color

type Color = drawing.Color

type ColorPalette

type ColorPalette interface {
	IsDark() bool
	GetAxisStrokeColor() Color
	SetAxisStrokeColor(Color)
	GetAxisSplitLineColor() Color
	SetAxisSplitLineColor(Color)
	GetSeriesColor(int) Color
	SetSeriesColor([]Color)
	GetBackgroundColor() Color
	SetBackgroundColor(Color)
	GetTextColor() Color
	SetTextColor(Color)
	GetFontSize() float64
	SetFontSize(float64)
	GetFont() *truetype.Font
	SetFont(*truetype.Font)
}

func NewTheme

func NewTheme(name string) ColorPalette

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的配置
	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 {
	// The theme
	Theme ColorPalette
	// The font size
	Font *truetype.Font
	// The data series list
	SeriesList SeriesList
	// The padding of line chart
	Padding Box
	// The option of title
	Title TitleOption
	// The legend option
	Legend LegendOption
}

type GridOption

type GridOption struct {
	Column      int
	Row         int
	ColumnSpans []int
	// 忽略不展示的column
	IgnoreColumnLines []int
	// 忽略不展示的row
	IgnoreRowLines []int
}

type GridPainterOption

type GridPainterOption struct {
	// The stroke width
	StrokeWidth float64
	// The stroke color
	StrokeColor Color
	// The spans of column
	ColumnSpans []int
	// The column of grid
	Column int
	// The row of grid
	Row int
	// Ignore first row
	IgnoreFirstRow bool
	// Ignore last row
	IgnoreLastRow bool
	// Ignore first column
	IgnoreFirstColumn bool
	// Ignore last column
	IgnoreLastColumn bool
}

type HorizontalBarChartOption

type HorizontalBarChartOption struct {
	// The theme
	Theme ColorPalette
	// The font size
	Font *truetype.Font
	// The data series list
	SeriesList SeriesList
	// The x axis option
	XAxis XAxisOption
	// The padding of line chart
	Padding Box
	// The y axis option
	YAxisOptions []YAxisOption
	// The option of title
	Title TitleOption
	// The legend option
	Legend    LegendOption
	BarHeight int
	// Margin of bar
	BarMargin int
}

type LabelFormatter

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

LabelFormatter label formatter

func NewFunnelLabelFormatter added in v2.5.5

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 formaatter

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 added in v2.3.0

type LabelValue struct {
	Index int
	Value float64
	X     int
	Y     int
	// 旋转
	Radians float64
	// 字体颜色
	FontColor Color
	// 字体大小
	FontSize float64
	Orient   string
	Offset   Box
}

type LegendOption

type LegendOption struct {
	// The theme
	Theme ColorPalette
	// Text array of legend
	Data []string
	// Distance between legend component and the left side of the container.
	// It can be pixel value: 20, percentage value: 20%,
	// or position value: right, center.
	Left string
	// Distance between legend component and the top side of the container.
	// It can be pixel value: 20.
	Top string
	// Legend marker and text aligning, it can be left or right, default is left.
	Align string
	// The layout orientation of legend, it can be horizontal or vertical, default is horizontal.
	Orient string
	// Icon of the legend.
	Icon string
	// Font size of legend text
	FontSize float64
	// FontColor color of legend text
	FontColor Color
	// The flag for show legend, set this to *false will hide legend
	Show *bool
	// The padding of legend
	Padding Box
}

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 {
	// The theme
	Theme ColorPalette
	// The font size
	Font *truetype.Font
	// The data series list
	SeriesList SeriesList
	// The x axis option
	XAxis XAxisOption
	// The padding of line chart
	Padding Box
	// The y axis option
	YAxisOptions []YAxisOption
	// The option of title
	Title TitleOption
	// The legend option
	Legend LegendOption
	// The flag for show symbol of line, set this to *false will hide symbol
	SymbolShow *bool
	// The stroke width of line
	StrokeWidth float64
	// Fill the area of line
	FillArea bool

	// background fill (alpha) opacity
	Opacity uint8
	// contains filtered or unexported fields
}

type MultiTextOption

type MultiTextOption struct {
	TextList []string
	Orient   string
	Unit     int
	Position string
	Align    string
	// The text rotation of label
	TextRotation float64
	Offset       Box
	// The first text index
	First int
}

type OptionFunc

type OptionFunc func(opt *ChartOption)

OptionFunc option function

func BackgroundColorOptionFunc

func BackgroundColorOptionFunc(color Color) OptionFunc

BackgroundColorOptionFunc set background color of chart

func BoxOptionFunc

func BoxOptionFunc(box Box) OptionFunc

BoxOptionFunc set box of chart

func ChildOptionFunc

func ChildOptionFunc(child ...ChartOption) OptionFunc

ChildOptionFunc add child chart

func FontFamilyOptionFunc

func FontFamilyOptionFunc(fontFamily string) OptionFunc

FontFamilyOptionFunc set font family 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 PNGTypeOption

func PNGTypeOption() OptionFunc

PNGTypeOption 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 SVGTypeOption

func SVGTypeOption() OptionFunc

SVGTypeOption set svg type of chart's output

func ThemeOptionFunc

func ThemeOptionFunc(theme string) 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 TypeOptionFunc

func TypeOptionFunc(t string) OptionFunc

TypeOptionFunc set type of chart's output

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, support 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 added in v2.5.0

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) GetRenderer added in v2.6.8

func (p *Painter) GetRenderer() chart.Renderer

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) RoundedRect added in v2.6.6

func (p *Painter) RoundedRect(box Box, radius int) *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 added in v2.5.0

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 added in v2.5.0

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 {
	// Draw type, "svg" or "png", default type is "png"
	Type string
	// The width of draw painter
	Width int
	// The height of draw painter
	Height int
	// The font for painter
	Font *truetype.Font
}

type PieChartOption

type PieChartOption struct {
	// The theme
	Theme ColorPalette
	// The font size
	Font *truetype.Font
	// The data series list
	SeriesList SeriesList
	// The padding of line chart
	Padding Box
	// The option of title
	Title TitleOption
	// The legend option
	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 {
	// The theme
	Theme ColorPalette
	// The font size
	Font *truetype.Font
	// The data series list
	SeriesList SeriesList
	// The padding of line chart
	Padding Box
	// The option of title
	Title TitleOption
	// The legend option
	Legend LegendOption
	// The radar indicator list
	RadarIndicators []RadarIndicator
	// contains filtered or unexported fields
}

type RadarIndicator

type RadarIndicator struct {
	// Indicator's name
	Name string
	// The maximum value of indicator
	Max float64
	// 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 {

	// The type of series, it can be "line", "bar" or "pie".
	// Default value is "line"
	Type string
	// The data list of series
	Data []SeriesData
	// The Y axis index, it should be 0 or 1.
	// Default value is 0
	AxisIndex int
	// The style for series
	Style chart.Style
	// The label for series
	Label SeriesLabel
	// The name of series
	Name string
	// Radius for Pie chart, e.g.: 40%, default is "40%"
	Radius string
	// Round for bar chart
	RoundRadius int
	// Mark point for series
	MarkPoint SeriesMarkPoint
	// Make line for series
	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 {
	// The value of series data
	Value float64
	// The style of 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
	// The color for label
	Color Color
	// Show flag for label
	Show bool
	// Distance to the host graphic element.
	Distance int
	// The position of label
	Position string
	// The offset of label's position
	Offset Box
	// The font size of label
	FontSize float64
}

type SeriesLabelPainter added in v2.3.0

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

func NewSeriesLabelPainter added in v2.3.0

func NewSeriesLabelPainter(params SeriesLabelPainterParams) *SeriesLabelPainter

func (*SeriesLabelPainter) Add added in v2.3.0

func (o *SeriesLabelPainter) Add(value LabelValue)

func (*SeriesLabelPainter) Render added in v2.3.0

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

type SeriesLabelPainterParams added in v2.3.0

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) GetMaxMin

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

GetMaxMin 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 {
	// The mark data type, it can be "max", "min", "average".
	// The "average" is only for mark line
	Type string
}

type SeriesMarkLine

type SeriesMarkLine struct {
	// The mark data of series mark line
	Data []SeriesMarkData
}

func NewMarkLine

func NewMarkLine(markLineTypes ...string) SeriesMarkLine

NewMarkLine returns a series mark line

type SeriesMarkPoint

type SeriesMarkPoint struct {
	// The width of symbol, default value is 30
	SymbolSize int
	// The mark data of 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 added in v2.0.1

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 {
	// The output type
	Type string
	// The width of table
	Width int
	// The theme
	Theme ColorPalette
	// The padding of table cell
	Padding Box
	// The header data of table
	Header []string
	// The data of table
	Data [][]string
	// The span list of table column
	Spans []int
	// The text align list of table cell
	TextAligns []string
	// The font size of table
	FontSize float64
	// The font family, which should be installed first
	FontFamily string
	Font       *truetype.Font
	// The font color of table
	FontColor Color
	// The background color of header
	HeaderBackgroundColor Color
	// The header font color
	HeaderFontColor Color
	// The background color of row
	RowBackgroundColors []Color
	// The 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 {
	// The color of header
	HeaderColor Color
	// The color of heder text
	HeaderFontColor Color
	// The color of table text
	FontColor Color
	// The color list of row
	RowColors []Color
	// The padding of cell
	Padding 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
	First  int
	Length int
	Orient string
	Count  int
	Unit   int
}

type TitleOption

type TitleOption struct {
	// The theme of chart
	Theme ColorPalette
	// Title text, support \n for new line
	Text string
	// Subtitle text, support \n for new line
	Subtext string
	// Distance between title component and the left side of the container.
	// It can be pixel value: 20, percentage value: 20%,
	// or position value: right, center.
	Left string
	// Distance between title component and the top side of the container.
	// It can be pixel value: 20.
	Top string
	// The font of label
	Font *truetype.Font
	// The font size of label
	FontSize float64
	// The color of label
	FontColor Color
	// The subtext font size of label
	SubtextFontSize float64
	// The subtext font color of label
	SubtextFontColor Color
}

type ValueFormatter added in v2.4.1

type ValueFormatter func(float64) string

type XAxisOption

type XAxisOption struct {
	// The font of x axis
	Font *truetype.Font
	// The boundary gap on both sides of a coordinate axis.
	// Nil or *true means the center part of two axis ticks
	BoundaryGap *bool
	// The data value of x axis
	Data []string
	// The theme of chart
	Theme ColorPalette
	// The font size of x axis label
	FontSize float64
	// The flag for show axis, set this to *false will hide axis
	Show *bool
	// Number of segments that the axis is split into. Note that this number serves only as a recommendation.
	SplitNumber int
	// The position of axis, it can be 'top' or 'bottom'
	Position string
	// The line color of axis
	StrokeColor Color
	// The color of label
	FontColor Color
	// The text rotation of label
	TextRotation float64
	// The first axis
	FirstAxis int
	// The offset of label
	LabelOffset Box
	// 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 {
	// The minimun value of axis.
	Min *float64
	// The maximum value of axis.
	Max *float64
	// The font of y axis
	Font *truetype.Font
	// The data value of x axis
	Data []string
	// The theme of chart
	Theme ColorPalette
	// The font size of x axis label
	FontSize float64
	// The position of axis, it can be 'left' or 'right'
	Position string
	// The color of label
	FontColor Color
	// Formatter for y axis text value
	Formatter string
	// Color for y axis
	Color Color
	// The flag for show axis, set this to *false will hide axis
	Show        *bool
	DivideCount int
	Unit        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