Documentation ¶
Index ¶
- type Axis
- type AxisScale
- type AxisTick
- type CirclePos
- type DecimalAlign
- type Manager
- func (m *Manager) AddFunction(name string, handler interface{}) *Manager
- func (m *Manager) Do(path, template string, methods ...string) *Manager
- func (m *Manager) ExecuteTemplate(r *rest.Rest, n string, d interface{}) error
- func (m *Manager) GetRootDir() string
- func (m *Manager) HasTemplate(n string) bool
- func (m *Manager) PostInit() error
- func (m *Manager) Render(ctx context.Context, n string, d interface{}) error
- func (m *Manager) Start() error
- func (m *Manager) Template(n string, d interface{}) (template.HTML, error)
- type WindRoseBreakdown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AxisScale ¶
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 (*Manager) ExecuteTemplate ¶
ExecuteTemplate executes the named template
func (*Manager) GetRootDir ¶
func (*Manager) HasTemplate ¶
type WindRoseBreakdown ¶
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