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
45 lines
970 B
Go
45 lines
970 B
Go
package chart
|
|
|
|
// ConcatSeries is a special type of series that concatenates its `InnerSeries`.
|
|
type ConcatSeries []Series
|
|
|
|
// Len returns the length of the concatenated set of series.
|
|
func (cs ConcatSeries) Len() int {
|
|
total := 0
|
|
for _, s := range cs {
|
|
if typed, isValuesProvider := s.(ValuesProvider); isValuesProvider {
|
|
total += typed.Len()
|
|
}
|
|
}
|
|
|
|
return total
|
|
}
|
|
|
|
// GetValue returns the value at the (meta) index (i.e 0 => totalLen-1)
|
|
func (cs ConcatSeries) GetValue(index int) (x, y float64) {
|
|
cursor := 0
|
|
for _, s := range cs {
|
|
if typed, isValuesProvider := s.(ValuesProvider); isValuesProvider {
|
|
len := typed.Len()
|
|
if index < cursor+len {
|
|
x, y = typed.GetValues(index - cursor) //FENCEPOSTS.
|
|
return
|
|
}
|
|
cursor += typed.Len()
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// Validate validates the series.
|
|
func (cs ConcatSeries) Validate() error {
|
|
var err error
|
|
for _, s := range cs {
|
|
err = s.Validate()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|