Go CLI that turns the markdown currency of this stack (Redmine notes, Discourse posts, briefing output) into typeset PDFs: two embedded typst templates (report with title page/TOC/headers, dense brief), front-matter (title/subtitle/author/date/classification/template), GFM tables, and bar charts rendered in pure Go (go-chart) from fenced chart data blocks. Engine is a prebuilt typst 0.15.1 container pinned by digest and run --network none; PDF bytes to stdout or -o. Exit codes 0/1/2. All dev in docker (dev.sh/Makefile); unit tests + golden typst fixtures plus a host-side smoke against the real engine container. Generated with Crush Assisted-by: Crush:glm-5.2
43 lines
989 B
Go
43 lines
989 B
Go
package chart
|
|
|
|
// LinearCoefficientProvider is a type that returns linear cofficients.
|
|
type LinearCoefficientProvider interface {
|
|
Coefficients() (m, b, stdev, avg float64)
|
|
}
|
|
|
|
// LinearCoefficients returns a fixed linear coefficient pair.
|
|
func LinearCoefficients(m, b float64) LinearCoefficientSet {
|
|
return LinearCoefficientSet{
|
|
M: m,
|
|
B: b,
|
|
}
|
|
}
|
|
|
|
// NormalizedLinearCoefficients returns a fixed linear coefficient pair.
|
|
func NormalizedLinearCoefficients(m, b, stdev, avg float64) LinearCoefficientSet {
|
|
return LinearCoefficientSet{
|
|
M: m,
|
|
B: b,
|
|
StdDev: stdev,
|
|
Avg: avg,
|
|
}
|
|
}
|
|
|
|
// LinearCoefficientSet is the m and b values for the linear equation in the form:
|
|
// y = (m*x) + b
|
|
type LinearCoefficientSet struct {
|
|
M float64
|
|
B float64
|
|
StdDev float64
|
|
Avg float64
|
|
}
|
|
|
|
// Coefficients returns the coefficients.
|
|
func (lcs LinearCoefficientSet) Coefficients() (m, b, stdev, avg float64) {
|
|
m = lcs.M
|
|
b = lcs.B
|
|
stdev = lcs.StdDev
|
|
avg = lcs.Avg
|
|
return
|
|
}
|