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
- Variables
- func AddTheme(name string, opt ThemeOption)
- func FalseFlag() *bool
- func GetDefaultFont() (*truetype.Font, error)
- func GetFont(fontFamily string) (*truetype.Font, error)
- func GetNullValue() float64
- func InstallFont(fontFamily string, data []byte) error
- func NewAxisPainter(p *Painter, opt AxisOption) *axisPainter
- func NewBarChart(p *Painter, opt BarChartOption) *barChart
- func NewBottomXAxis(p *Painter, opt XAxisOption) *axisPainter
- func NewFloatPoint(f float64) *float64
- func NewFunnelChart(p *Painter, opt FunnelChartOption) *funnelChart
- func NewGridPainter(p *Painter, opt GridPainterOption) *gridPainter
- func NewHorizontalBarChart(p *Painter, opt HorizontalBarChartOption) *horizontalBarChart
- func NewLeftYAxis(p *Painter, opt YAxisOption) *axisPainter
- func NewLegendPainter(p *Painter, opt LegendOption) *legendPainter
- func NewLineChart(p *Painter, opt LineChartOption) *lineChart
- func NewMarkLinePainter(p *Painter) *markLinePainter
- func NewMarkPointPainter(p *Painter) *markPointPainter
- func NewPieChart(p *Painter, opt PieChartOption) *pieChart
- func NewRadarChart(p *Painter, opt RadarChartOption) *radarChart
- func NewRange(opt AxisRangeOption) axisRange
- func NewRightYAxis(p *Painter, opt YAxisOption) *axisPainter
- func NewSector(cx int, cy int, radius float64, labelRadius float64, value float64, ...) sector
- func NewTableChart(p *Painter, opt TableChartOption) *tableChart
- func NewTitlePainter(p *Painter, opt TitleOption) *titlePainter
- func RenderEChartsToPNG(options string) ([]byte, error)
- func RenderEChartsToSVG(options string) ([]byte, error)
- func SetDefaultFont(font *truetype.Font)
- func SetDefaultHeight(height int)
- func SetDefaultTableSetting(setting TableSetting)
- func SetDefaultTheme(name string)
- func SetDefaultWidth(width int)
- func SetNullValue(v float64)
- func TrueFlag() *bool
- type AxisOption
- type AxisRangeOption
- type BarChartOption
- type Box
- type ChartOption
- type Color
- type ColorPalette
- type EChartStyle
- type EChartsAxisLabel
- type EChartsLabelOption
- type EChartsLegend
- type EChartsMarkData
- type EChartsMarkLine
- type EChartsMarkPoint
- type EChartsOption
- type EChartsPadding
- type EChartsPosition
- type EChartsSeries
- type EChartsSeriesData
- type EChartsSeriesDataValue
- type EChartsSeriesList
- type EChartsTextStyle
- type EChartsXAxis
- type EChartsXAxisData
- type EChartsYAxis
- type EChartsYAxisData
- type FunnelChartOption
- type GridOption
- type GridPainterOption
- type HorizontalBarChartOption
- type LabelFormatter
- func NewFunnelLabelFormatter(seriesNames []string, layout string) LabelFormatter
- func NewLabelFormatter(seriesNames []string, layout string) LabelFormatter
- func NewPieLabelFormatter(seriesNames []string, layout string) LabelFormatter
- func NewValueLabelFormatter(seriesNames []string, layout string) LabelFormatter
- type LabelValue
- type LegendOption
- type LineChartOption
- type MultiTextOption
- type OptionFunc
- func BackgroundColorOptionFunc(color Color) OptionFunc
- func BoxOptionFunc(box Box) OptionFunc
- func ChildOptionFunc(child ...ChartOption) OptionFunc
- func FontFamilyOptionFunc(fontFamily string) OptionFunc
- func HeightOptionFunc(height int) OptionFunc
- func LegendLabelsOptionFunc(labels []string, left ...string) OptionFunc
- func LegendOptionFunc(legend LegendOption) OptionFunc
- func MarkLineOptionFunc(seriesIndex int, markLineTypes ...string) OptionFunc
- func MarkPointOptionFunc(seriesIndex int, markPointTypes ...string) OptionFunc
- func PNGTypeOption() OptionFunc
- func PaddingOptionFunc(padding Box) OptionFunc
- func PieSeriesShowLabel() OptionFunc
- func RadarIndicatorOptionFunc(names []string, values []float64) OptionFunc
- func SVGTypeOption() OptionFunc
- func ThemeOptionFunc(theme string) OptionFunc
- func TitleOptionFunc(title TitleOption) OptionFunc
- func TitleTextOptionFunc(text string, subtext ...string) OptionFunc
- func TypeOptionFunc(t string) OptionFunc
- func WidthOptionFunc(width int) OptionFunc
- func XAxisDataOptionFunc(data []string, boundaryGap ...*bool) OptionFunc
- func XAxisOptionFunc(xAxisOption XAxisOption) OptionFunc
- func YAxisDataOptionFunc(data []string) OptionFunc
- func YAxisOptionFunc(yAxisOption ...YAxisOption) OptionFunc
- type Painter
- func BarRender(values [][]float64, opts ...OptionFunc) (*Painter, error)
- func FunnelRender(values []float64, opts ...OptionFunc) (*Painter, error)
- func HorizontalBarRender(values [][]float64, opts ...OptionFunc) (*Painter, error)
- func LineRender(values [][]float64, opts ...OptionFunc) (*Painter, error)
- func NewPainter(opts PainterOptions, opt ...PainterOption) (*Painter, error)
- func PieRender(values []float64, opts ...OptionFunc) (*Painter, error)
- func RadarRender(values [][]float64, opts ...OptionFunc) (*Painter, error)
- func Render(opt ChartOption, opts ...OptionFunc) (*Painter, error)
- func TableOptionRender(opt TableChartOption) (*Painter, error)
- func TableRender(header []string, data [][]string, spanMaps ...map[int]int) (*Painter, error)
- func (p *Painter) ArcTo(cx, cy int, rx, ry, startAngle, delta float64) *Painter
- func (p *Painter) ArrowBottom(x, y, width, height int) *Painter
- func (p *Painter) ArrowLeft(x, y, width, height int) *Painter
- func (p *Painter) ArrowRight(x, y, width, height int) *Painter
- func (p *Painter) ArrowTop(x, y, width, height int) *Painter
- func (p *Painter) Bytes() ([]byte, error)
- func (p *Painter) Child(opt ...PainterOption) *Painter
- func (p *Painter) Circle(radius float64, x, y int) *Painter
- func (p *Painter) ClearTextRotation()
- func (p *Painter) Close() *Painter
- func (p *Painter) Dots(points []Point) *Painter
- func (p *Painter) Fill() *Painter
- func (p *Painter) FillArea(points []Point) *Painter
- func (p *Painter) FillStroke() *Painter
- func (p *Painter) GetRenderer() chart.Renderer
- func (p *Painter) Grid(opt GridOption) *Painter
- func (p *Painter) Height() int
- func (p *Painter) LegendLineDot(box Box) *Painter
- func (p *Painter) LineStroke(points []Point) *Painter
- func (p *Painter) LineTo(x, y int) *Painter
- func (p *Painter) MarkLine(x, y, width int) *Painter
- func (p *Painter) MeasureText(text string) Box
- func (p *Painter) MeasureTextMaxWidthHeight(textList []string) (int, int)
- func (p *Painter) MoveTo(x, y int) *Painter
- func (p *Painter) MultiText(opt MultiTextOption) *Painter
- func (p *Painter) OverrideDrawingStyle(style Style) *Painter
- func (p *Painter) OverrideTextStyle(style Style) *Painter
- func (p *Painter) Pin(x, y, width int) *Painter
- func (p *Painter) Polygon(center Point, radius float64, sides int) *Painter
- func (p *Painter) QuadCurveTo(cx, cy, x, y int) *Painter
- func (p *Painter) Rect(box Box) *Painter
- func (p *Painter) ResetStyle() *Painter
- func (p *Painter) RoundedRect(box Box, radius int) *Painter
- func (p *Painter) SetBackground(width, height int, color Color, inside ...bool) *Painter
- func (p *Painter) SetDrawingStyle(style Style) *Painter
- func (p *Painter) SetStyle(style Style)
- func (p *Painter) SetTextRotation(radians float64)
- func (p *Painter) SetTextStyle(style Style) *Painter
- func (p *Painter) SmoothLineStroke(points []Point) *Painter
- func (p *Painter) Stroke() *Painter
- func (p *Painter) Text(body string, x, y int) *Painter
- func (p *Painter) TextFit(body string, x, y, width int, textAligns ...string) chart.Box
- func (p *Painter) TextRotation(body string, x, y int, radians float64)
- func (p *Painter) Ticks(opt TicksOption) *Painter
- func (p *Painter) Width() int
- type PainterOption
- func PainterBoxOption(box Box) PainterOption
- func PainterFontOption(font *truetype.Font) PainterOption
- func PainterPaddingOption(padding Box) PainterOption
- func PainterStyleOption(style Style) PainterOption
- func PainterThemeOption(theme ColorPalette) PainterOption
- func PainterWidthHeightOption(width, height int) PainterOption
- type PainterOptions
- type PieChartOption
- type PieSeriesOption
- type Point
- type RadarChartOption
- type RadarIndicator
- type Renderer
- type Series
- type SeriesData
- type SeriesLabel
- type SeriesLabelPainter
- type SeriesLabelPainterParams
- type SeriesList
- type SeriesMarkData
- type SeriesMarkLine
- type SeriesMarkPoint
- type Style
- type TableCell
- type TableChartOption
- type TableSetting
- type ThemeOption
- type TicksOption
- type TitleOption
- type ValueFormatter
- type XAxisOption
- type YAxisOption
Constants ¶
const ( ChartTypeLine = "line" ChartTypeBar = "bar" ChartTypePie = "pie" ChartTypeRadar = "radar" ChartTypeFunnel = "funnel" // horizontal bar ChartTypeHorizontalBar = "horizontalBar" )
const ( ChartOutputSVG = "svg" ChartOutputPNG = "png" )
const ( PositionLeft = "left" PositionRight = "right" PositionCenter = "center" PositionTop = "top" PositionBottom = "bottom" )
const ( AlignLeft = "left" AlignRight = "right" AlignCenter = "center" )
const ( OrientHorizontal = "horizontal" OrientVertical = "vertical" )
const ( SeriesMarkDataTypeMax = "max" SeriesMarkDataTypeMin = "min" SeriesMarkDataTypeAverage = "average" )
const G_VALUE = M_VALUE * K_VALUE
const IconLineDot = "lineDot"
const IconRect = "rect"
const K_VALUE = float64(1000)
const M_VALUE = K_VALUE * K_VALUE
const T_VALUE = G_VALUE * K_VALUE
const ThemeAnt = "ant"
const ThemeDark = "dark"
const ThemeGrafana = "grafana"
const ThemeLight = "light"
Variables ¶
var BoxZero = chart.BoxZero
var ErrFontNotExists = errors.New("font is not exists")
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, }, }
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 GetDefaultFont ¶ added in v2.4.4
GetDefaultFont get default font
func InstallFont ¶
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 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 NewRightYAxis ¶
func NewRightYAxis(p *Painter, opt YAxisOption) *axisPainter
NewRightYAxis returns a right y axis renderer
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 RenderEChartsToSVG ¶
func SetDefaultFont ¶ added in v2.4.4
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 SetNullValue ¶ added in v2.3.0
func SetNullValue(v float64)
SetNullValue sets the null value, default is MaxFloat64
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 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 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 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 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 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 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 ¶
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 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 OptionFunc ¶
type OptionFunc func(opt *ChartOption)
OptionFunc option function
func BackgroundColorOptionFunc ¶
func BackgroundColorOptionFunc(color Color) OptionFunc
BackgroundColorOptionFunc set background color 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 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 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 ¶
TableRender table chart render
func (*Painter) ArrowBottom ¶
func (*Painter) ArrowRight ¶
func (*Painter) Child ¶
func (p *Painter) Child(opt ...PainterOption) *Painter
func (*Painter) ClearTextRotation ¶ added in v2.5.0
func (p *Painter) ClearTextRotation()
func (*Painter) FillStroke ¶
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) LegendLineDot ¶
func (*Painter) LineStroke ¶
func (*Painter) MeasureText ¶
func (*Painter) MeasureTextMaxWidthHeight ¶
func (*Painter) MultiText ¶
func (p *Painter) MultiText(opt MultiTextOption) *Painter
func (*Painter) OverrideDrawingStyle ¶
func (*Painter) OverrideTextStyle ¶
func (*Painter) QuadCurveTo ¶
func (*Painter) ResetStyle ¶
func (*Painter) RoundedRect ¶ added in v2.6.6
func (*Painter) SetBackground ¶
func (*Painter) SetDrawingStyle ¶
func (*Painter) SetTextRotation ¶ added in v2.5.0
func (*Painter) SetTextStyle ¶
func (*Painter) SmoothLineStroke ¶
func (*Painter) TextRotation ¶ added in v2.5.0
func (*Painter) Ticks ¶
func (p *Painter) Ticks(opt TicksOption) *Painter
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 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 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 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 ¶
NewSeriesFromValues returns a 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 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 ThemeOption ¶
type TicksOption ¶
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 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
Source Files ¶
- alias.go
- axis.go
- bar_chart.go
- chart_option.go
- charts.go
- echarts.go
- font.go
- funnel_chart.go
- grid.go
- horizontal_bar_chart.go
- legend.go
- line_chart.go
- mark_line.go
- mark_point.go
- painter.go
- pie_chart.go
- radar_chart.go
- range.go
- series.go
- series_label.go
- table.go
- theme.go
- title.go
- util.go
- xaxis.go
- yaxis.go