png

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const HaveGraphSupport = false

Variables

View Source
var DefaultColorList = []string{"blue", "green", "red", "purple", "brown", "yellow", "aqua", "grey", "magenta", "pink", "gold", "rose"}
View Source
var DefaultParams = PictureParams{
	Width:      330,
	Height:     250,
	Margin:     10,
	LogBase:    0,
	FgColor:    "white",
	BgColor:    "black",
	MajorLine:  "rose",
	MinorLine:  "grey",
	FontName:   "Sans",
	FontSize:   10,
	FontBold:   FontWeightNormal,
	FontItalic: FontSlantNormal,

	GraphOnly:  false,
	HideLegend: false,
	HideGrid:   false,
	HideAxes:   false,
	HideYAxis:  false,
	HideXAxis:  false,
	YAxisSide:  YAxisSideLeft,

	Title:       "",
	Vtitle:      "",
	VtitleRight: "",

	Tz: time.Local,

	ConnectedLimit: math.MaxInt32,
	LineMode:       LineModeSlope,
	AreaMode:       AreaModeNone,
	AreaAlpha:      math.NaN(),
	PieMode:        PieModeAverage,
	LineWidth:      1.2,
	ColorList:      DefaultColorList,

	YMin:    math.NaN(),
	YMax:    math.NaN(),
	YStep:   math.NaN(),
	XMin:    math.NaN(),
	XMax:    math.NaN(),
	XStep:   math.NaN(),
	XFormat: "",
	MinorY:  1,

	UniqueLegend:   false,
	DrawNullAsZero: false,
	DrawAsInfinite: false,

	YMinLeft:    math.NaN(),
	YMinRight:   math.NaN(),
	YMaxLeft:    math.NaN(),
	YMaxRight:   math.NaN(),
	YStepL:      math.NaN(),
	YStepR:      math.NaN(),
	YLimitLeft:  math.NaN(),
	YLimitRight: math.NaN(),

	YUnitSystem: "si",
	YDivisors:   []float64{4, 5, 6},

	RightWidth:  1.2,
	RightDashed: false,
	RightColor:  "",
	LeftWidth:   1.2,
	LeftDashed:  false,
	LeftColor:   "",

	MajorGridLineColor: "white",
	MinorGridLineColor: "grey",
}

Functions

func Description

func Description() map[string]types.FunctionDescription

skipcq: CRT-P0003

func EvalExprGraph

func EvalExprGraph(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error)

func MarshalPNG

func MarshalPNG(params PictureParams, results []*types.MetricData) []byte

skipcq: CRT-P0003

func MarshalPNGRequest

func MarshalPNGRequest(r *http.Request, results []*types.MetricData, templateName string) []byte

skipcq: CRT-P0003

func MarshalSVG

func MarshalSVG(params PictureParams, results []*types.MetricData) []byte

skipcq: CRT-P0003

func MarshalSVGRequest

func MarshalSVGRequest(r *http.Request, results []*types.MetricData, templateName string) []byte

skipcq: CRT-P0003

func SetColor

func SetColor(name, rgba string) error

func SetTemplate

func SetTemplate(name string, params *PictureParams)

SetTemplate adds a picture param template with specified name and parameters

Types

type AreaMode

type AreaMode int
const (
	AreaModeNone AreaMode = 1 << iota
	AreaModeFirst
	AreaModeAll
	AreaModeStacked
)

type FontSlant

type FontSlant int
const (
	FontSlantNormal FontSlant = iota
	FontSlantItalic
	FontSlantOblique
)

type FontWeight

type FontWeight int
const (
	FontWeightNormal FontWeight = iota
	FontWeightBold
)

type LineMode

type LineMode int
const (
	LineModeSlope LineMode = 1 << iota
	LineModeStaircase
	LineModeConnected
)

type PictureParams

type PictureParams struct {
	PixelRatio float64
	Width      float64
	Height     float64
	Margin     int
	LogBase    float64
	FgColor    string
	BgColor    string
	MajorLine  string
	MinorLine  string
	FontName   string
	FontSize   float64
	FontBold   FontWeight
	FontItalic FontSlant

	GraphOnly  bool
	HideLegend bool
	HideGrid   bool
	HideAxes   bool
	HideYAxis  bool
	HideXAxis  bool
	YAxisSide  YAxisSide

	Title       string
	Vtitle      string
	VtitleRight string

	Tz *time.Location

	ConnectedLimit int
	LineMode       LineMode
	AreaMode       AreaMode
	AreaAlpha      float64
	PieMode        PieMode
	LineWidth      float64
	ColorList      []string

	YMin    float64
	YMax    float64
	XMin    float64
	XMax    float64
	YStep   float64
	XStep   float64
	MinorY  int
	XFormat string

	YMaxLeft    float64
	YLimitLeft  float64
	YMaxRight   float64
	YLimitRight float64
	YMinLeft    float64
	YMinRight   float64
	YStepL      float64
	YStepR      float64

	UniqueLegend   bool
	DrawNullAsZero bool
	DrawAsInfinite bool

	YUnitSystem string
	YDivisors   []float64

	RightWidth  float64
	RightDashed bool
	RightColor  string
	LeftWidth   float64
	LeftDashed  bool
	LeftColor   string

	MinorGridLineColor string
	MajorGridLineColor string
}

func GetPictureParams

func GetPictureParams(r *http.Request, metricData []*types.MetricData) PictureParams

GetPictureParams returns PictureParams with default settings

func GetPictureParamsWithTemplate

func GetPictureParamsWithTemplate(r *http.Request, template string, metricData []*types.MetricData) PictureParams

GetPictureParamsWithTemplate returns PictureParams with specified template

type PieMode

type PieMode int
const (
	PieModeMaximum PieMode = 1 << iota
	PieModeMinimum
	PieModeAverage
)

type YAxisSide

type YAxisSide int
const (
	YAxisSideRight YAxisSide = 1 << iota
	YAxisSideLeft
)

Jump to

Keyboard shortcuts

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