Documentation ¶
Index ¶
- Constants
- Variables
- func BoolPointer(b bool) *bool
- func False() *bool
- func FloatPointer(f float64) *float64
- func GetDefaultFont() *truetype.Font
- func GetFont(fontFamily string) *truetype.Font
- func GetNullValue() float64
- func InstallFont(fontFamily string, data []byte) error
- func InstallTheme(name string, opt ThemeOption)
- func NewAxisPainter(p *Painter, opt AxisOption) *axisPainter
- func NewBarChart(p *Painter, opt BarChartOption) *barChart
- func NewBottomXAxis(p *Painter, opt XAxisOption) *axisPainter
- 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(painter *Painter, size, divideCount int, ...) 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(fontFamily string) error
- func SetDefaultHeight(height int)
- func SetDefaultTheme(name string) error
- func SetDefaultWidth(width int)
- func SetNullValue(v float64)
- func True() *bool
- type AxisOption
- 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 FontStyle
- 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 Offset
- type OptionFunc
- func BoxOptionFunc(box Box) OptionFunc
- func ChildOptionFunc(child ...ChartOption) OptionFunc
- func FontOptionFunc(font *truetype.Font) 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 OutputFormatOptionFunc(t string) OptionFunc
- func PNGOutputOption() OptionFunc
- func PaddingOptionFunc(padding Box) OptionFunc
- func PieSeriesShowLabel() OptionFunc
- func RadarIndicatorOptionFunc(names []string, values []float64) OptionFunc
- func SVGOutputOption() OptionFunc
- func ThemeNameOptionFunc(theme string) OptionFunc
- func ThemeOptionFunc(theme ColorPalette) OptionFunc
- func TitleOptionFunc(title TitleOption) OptionFunc
- func TitleTextOptionFunc(text string, subtext ...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) 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 chartdraw.Style) *Painter
- func (p *Painter) OverrideFontStyle(style chartdraw.FontStyle) *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, roundTop, roundBottom bool) *Painter
- func (p *Painter) SetBackground(width, height int, color Color, inside ...bool) *Painter
- func (p *Painter) SetDrawingStyle(style chartdraw.Style) *Painter
- func (p *Painter) SetFontStyle(style chartdraw.FontStyle) *Painter
- func (p *Painter) SetStyle(style chartdraw.Style)
- func (p *Painter) SetTextRotation(radians float64)
- 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) chartdraw.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 chartdraw.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 TableCell
- type TableChartOption
- type ThemeOption
- type TicksOption
- type TitleOption
- type ValueFormatter
- type XAxisOption
- type YAxisOption
Constants ¶
const ( ChartTypeLine = "line" ChartTypeBar = "bar" ChartTypePie = "pie" ChartTypeRadar = "radar" ChartTypeFunnel = "funnel" 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"
ThemeAnt is an ant styled theme.
const ThemeDark = "dark"
ThemeDark is a dark alternative to the default theme 'light, with series colors from echarts'.
const ThemeGrafana = "grafana"
ThemeGrafana is a grafana styled theme.
const ThemeLight = "light"
ThemeLight is the default theme used, with series colors from echarts.
const ThemeVividDark = "vivid-dark"
ThemeVividDark is a dark alternative to 'ThemeVividLight', with the same bright initial series colors.
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 ¶
var BoxZero = chartdraw.BoxZero
Functions ¶
func BoolPointer ¶
BoolPointer returns a pointer to the given bool value, useful for configuration.
func FloatPointer ¶
FloatPointer returns a pointer to the given float64 value, useful for configuration.
func InstallFont ¶
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 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 ¶
SetDefaultFont set default font by name.
func SetDefaultHeight ¶
func SetDefaultHeight(height int)
SetDefaultHeight sets default height of chart
func SetDefaultTheme ¶
SetDefaultTheme sets default theme by name.
func SetNullValue ¶
func SetNullValue(v float64)
SetNullValue sets the null value, default is MaxFloat64
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 // FontStyle specifies the font configuration for each label. FontStyle FontStyle // 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 // RoundedBarCaps set to `true` to produce a bar graph where the bars have rounded tops. RoundedBarCaps *bool }
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 // 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 render together. Children []ChartOption // ValueFormatter to format numeric values into labels. ValueFormatter ValueFormatter // contains filtered or unexported fields }
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 // WithSeriesColors will provide a new ColorPalette that uses the specified series colors. WithSeriesColors([]Color) ColorPalette // WithBackgroundColor will provide a new ColorPalette that uses the specified color for the background. WithBackgroundColor(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"`
}
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 chartdraw.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 ¶
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() chartdraw.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 { // 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 ¶
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 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 // FontStyle specifies the font, size, and style for rendering the legend. FontStyle FontStyle // 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 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 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 ¶
TableRender table chart render
func (*Painter) ArrowBottom ¶
func (*Painter) ArrowRight ¶
func (*Painter) Child ¶
func (p *Painter) Child(opt ...PainterOption) *Painter
func (*Painter) ClearTextRotation ¶
func (p *Painter) ClearTextRotation()
func (*Painter) FillStroke ¶
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) OverrideFontStyle ¶ added in v0.2.0
func (*Painter) QuadCurveTo ¶
func (*Painter) ResetStyle ¶
func (*Painter) RoundedRect ¶ added in v0.1.7
func (*Painter) SetBackground ¶
func (*Painter) SetFontStyle ¶ added in v0.2.0
func (*Painter) SetTextRotation ¶
func (*Painter) SmoothLineStroke ¶
func (*Painter) TextRotation ¶
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 chartdraw.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 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 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 must be 0 or 1. YAxisIndex int // Label provides the series labels. Label SeriesLabel // Name specifies a name for the series. Name string // Radius for 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 ¶
NewSeriesFromValues returns a series
type SeriesData ¶
type SeriesData struct { // Value is the retained value for the data. Value float64 }
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 // FontStyle specifies the font and style for the label. FontStyle FontStyle // 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 }
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 TableCell ¶
type TableCell struct { // Text the text of table cell Text string // FontStyle contains the configuration for the cell text font. FontStyle FontStyle // FillColor sets a color for this table cell. FillColor drawing.Color // 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 // FontStyle contains the configuration for the table text font. FontStyle FontStyle // 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 // CellModifier is an optional function to modify the style or content of a specific TableCell before they are rendered. CellModifier func(TableCell) TableCell }
type ThemeOption ¶
type TicksOption ¶
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 // FontStyle specifies the font, size, and style for rendering the title. FontStyle FontStyle // SubtextFontStyle specifies the font, size, and style for rendering the subtext. SubtextFontStyle FontStyle }
type ValueFormatter ¶
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 // FontStyle specifies the font configuration for each label. FontStyle FontStyle // 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 // FontStyle specifies the font configuration for each label. FontStyle FontStyle // 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
Source Files ¶
- alias.go
- axis.go
- bar_chart.go
- chart_option.go
- charts.go
- color.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