graph

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DfltTexTemplateExt  string = ".tmpl"
	DfltTexTemplateDir  string = "tmpl"
	DfltTexTemplateMain string = "master.tmpl"
	DfltTexCommand      string = "pdflatex"
)

Default TeXGraph parameter values.

Variables

View Source
var (
	DfltTeXTemplateDelims = []string{"__{", "}__"}
)
View Source
var DfltTeXTemplates embed.FS
View Source
var (
	ErrBadGrapher = fmt.Errorf(
		"bad grapher, available graphers are: %q",
		common.MapKeys(GrapherFactories))
)
View Source
var GrapherFactories = map[string]GrapherFactory{
	"tex": newTeXGrapher,
}

GrapherFactories maps Format type tags to FormatReaders.

Functions

func Generate

func Generate(_ *dataframe.DataFrame, config *Config) error

GenerateGraphs generates the graphs, e.g., PDFs from TeX files.

func Write

func Write(_ *dataframe.DataFrame, config *Config) error

WriteGraphFiles writes graph files, e.g., TeX files, using options from the config.

Types

type AxisLine

type AxisLine struct {
	Min   float64 `yaml:"min"`
	Max   float64 `yaml:"max"`
	Label string  `yaml:"label"`
}

type Config

type Config struct {
	// GrapherType is the graphing program name.
	GrapherType string `yaml:"type"`
	// Graphs is list of graph specifications.
	Graphs []yaml.Node `yaml:"graphs"`
}

type Grapher

type Grapher interface {
	Write() error
	Generate() error
}

type GrapherFactory

type GrapherFactory func(*yaml.Node, *Config) (Grapher, error)

type TeXGrapher

type TeXGrapher struct {
	// Name is the graph handle.
	Name string `yaml:"name"`
	// Directory is an output directory for all files. If it is an empty string,
	// the current working directory is used. The path is created recursively
	// if it does not exist.
	Directory string    `yaml:"directory"`
	Axes      []TexAxis `yaml:"axes"`
	// TableFile is the path to the data file, usually a CSV file,
	// used for creating the graph.
	// It is propagated to all child TeXTables, if they do not
	// have a TableFile defined locally.
	TableFile string `yaml:"table_file"`
	// TemplateDir is the path to the directory which contains
	// the graph file templates.
	TemplateDir string `yaml:"template_directory"`
	// TemplateMain is the file name of the main (root) template.
	TemplateMain string `yaml:"template_main"`
	// TemplateDelims are the Go template control structure delimiters.
	TemplateDelims []string `yaml:"template_delims"`
	// TeXCommand is the name of the binary which is used to generate
	// the graph from graph files.
	TeXCommand string `yaml:"tex_command"`

	TemplatePattern string     `yaml:"-"`
	Templates       fs.FS      `yaml:"-"`
	Spec            *yaml.Node `yaml:"-"`
}

func (*TeXGrapher) Generate

func (g *TeXGrapher) Generate() error

Generate generates graphs from graph files.

func (*TeXGrapher) Write

func (g *TeXGrapher) Write() error

Write writes the graph files from templates.

type TeXTable

type TeXTable struct {
	XField      string `yaml:"x_field"`
	YField      string `yaml:"y_field"`
	ColSep      string `yaml:"col_sep"`
	LegendEntry string `yaml:"legend_entry"`
	TableFile   string `yaml:"table_file"`
}

type TexAxis

type TexAxis struct {
	X           AxisLine   `yaml:"x"`
	Y           AxisLine   `yaml:"y"`
	Tables      []TeXTable `yaml:"tables"`
	RawOptions  string     `yaml:"raw_options"`
	Width       string     `yaml:"width"`
	Height      string     `yaml:"height"`
	LegendStyle string     `yaml:"legend_style"`
}

Jump to

Keyboard shortcuts

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