axes

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package axes calculates the required layout and draws the X and Y axes of a heat map.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LongestString

func LongestString(strings []string) int

LongestString returns the length of the longest string in the string array.

func RequiredWidth

func RequiredWidth(ls string) int

RequiredWidth calculates the minimum width required in order to draw the Y axis and its labels. The parameter ls is the longest string in yLabels.

Types

type Label

type Label struct {
	// Label content.
	Text string

	// Position of the label within the canvas.
	Pos image.Point
}

Label is one text label on an axis.

type XDetails

type XDetails struct {
	// Start is the point where the X axis starts.
	// Both coordinates of Start are less than End.
	Start image.Point
	// End is the point where the X axis ends.
	End image.Point

	// Labels are the labels for values on the X axis in an increasing order.
	Labels []*Label
}

XDetails contain information about the X axis that will NOT be drawn onto the canvas.

func NewXDetails

func NewXDetails(cvsAr image.Rectangle, yEnd image.Point, labels []string, cellWidth int) (*XDetails, error)

NewXDetails retrieves details about the X axis required to draw it on a canvas of the provided area. The yEnd is the point where the Y axis ends.

type YDetails

type YDetails struct {
	// Width in character cells of the Y axis and its character labels.
	Width int

	// Start is the point where the Y axis starts.
	// The Y coordinate of Start is less than the Y coordinate of End.
	Start image.Point

	// End is the point where the Y axis ends.
	End image.Point

	// Labels are the labels for values on the Y axis in an increasing order.
	Labels []*Label
}

YDetails contain information about the Y axis that will NOT be drawn onto the canvas, but will take up space.

func NewYDetails

func NewYDetails(labels []string) (*YDetails, error)

NewYDetails retrieves details about the Y axis required to draw it on a canvas of the provided area.

Jump to

Keyboard shortcuts

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