template

package
v0.0.0-...-d8ac9bd Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

type Axis struct {
	Delta  float64
	Num    float64
	Format string
	Ticks  []AxisTick
}

type AxisScale

type AxisScale struct {
	Min    float64
	Max    float64
	Ticks  int
	Format string
	Points []float64
	Labels []string
	Size   float64
	Scale  float64
	Range  float64
}

func (AxisScale) Contains

func (as AxisScale) Contains(v float64) bool

type AxisTick

type AxisTick struct {
	Index int
	Label string
	Angle float64
}

type CirclePos

type CirclePos struct {
	Deg, Radian float64
	Radius      float64
	X, Y        float64
}

type DecimalAlign

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

DecimalAlign provides a means to align a table column against the decimal point.

For this to work you need to scan the column before you render it.

Here we will parse a column of reading keys:

1 {{ $valPad := decimalAlign }}

2 {{ range $reading := $keys }}

3 {{ $reading := getReading $reading }}

4 {{ $valPad.Add $reading.Value.Float $reading.Precision }}

5 {{ end }}

Line 1 creates $valPad which will be used to format the column. Line 4 adds a value to $valPad as well as the precision (decimal points)

Then in the table header:

<th class="alignCenter" style="width: {{$valPad.Width}};">Value</th>

and for each cell:

<td style="--pad: {{$valPad.Pad $reading.Value}};" class="alignDecimal">{{$reading.Value}}</td>

For css:

.alignDecimal {
   text-align: left;
   transform: translateX(calc(var(--pad, 0) * 1ch));
}

This works best with monospaced fonts.

func NewDecimalAlign

func NewDecimalAlign(a ...interface{}) *DecimalAlign

NewDecimalAlign returns a new instance. It takes 0, 1 or 2 parameters. the first is the initial number of digits to the left of '.' the second is the initial number of digits to the right of '.'. The defaults are 1 to the left and 0 to the right.

func (*DecimalAlign) Add

func (d *DecimalAlign) Add(v, precision interface{}) string

Add adds a value to this instance. v is the actual value whilst precision is the number of decimal points it will have. This returns "" always as templates require a result, and we do not want to write any erroneous text to the output.

func (*DecimalAlign) Pad

func (d *DecimalAlign) Pad(v interface{}) string

Pad returns the value to include with the --pad css variable for a specific table cell.

func (*DecimalAlign) Width

func (d *DecimalAlign) Width() string

Width returns the width of the table column in ch

type Manager

type Manager struct {
	Latest memory.Latest `kernel:"inject"`
	// contains filtered or unexported fields
}

func (*Manager) AddFunction

func (m *Manager) AddFunction(name string, handler interface{}) *Manager

func (*Manager) Do

func (m *Manager) Do(path, template string, methods ...string) *Manager

Do adds a simple handler that renders a template without any other processing

func (*Manager) ExecuteTemplate

func (m *Manager) ExecuteTemplate(r *rest.Rest, n string, d interface{}) error

ExecuteTemplate executes the named template

func (*Manager) GetRootDir

func (m *Manager) GetRootDir() string

func (*Manager) HasTemplate

func (m *Manager) HasTemplate(n string) bool

func (*Manager) PostInit

func (m *Manager) PostInit() error

func (*Manager) Render

func (m *Manager) Render(ctx context.Context, n string, d interface{}) error

Render executes the named template. Similar to ExecuteTemplate but runs against a context

func (*Manager) Start

func (m *Manager) Start() error

func (*Manager) Template

func (m *Manager) Template(n string, d interface{}) (template.HTML, error)

type WindRoseBreakdown

type WindRoseBreakdown struct {
	C1     CirclePos
	C2     CirclePos
	Bucket int
	Entry  int
	Radius float64
}

func (WindRoseBreakdown) Path

func (wrb WindRoseBreakdown) Path() string

func (WindRoseBreakdown) Seq

func (wrb WindRoseBreakdown) Seq() int

Seq returns a plot ordering where we order by compass point and then by reverse order so the larger values are plotted first ensuring smaller entries are not obscured

Jump to

Keyboard shortcuts

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