Documentation ¶
Overview ¶
Package pic defines the Plug-in Chart API for EngageOne® Designer/Generate. It provides the export functions called by Designer/Generate to create a chart image, and functions to help parse the chart configuration settings.
To use this package you must implement the pic.Client and pic.Builder interfaces. Tell pic about your Client implementation by calling the pic.SetClient() method in the init() function of your main.go file. When Designer/Generate needs to create a chart image, pic will call your Client.NewBuilder() method to create the image via your Builder implementation.
You must build your application with the -buildmode=c-shared option in order to create a .dll file that can be loaded by Designer and Generate. If you run Generate on Linux you will also need to build a .so file.
Index ¶
- Constants
- Variables
- func SetClient(c Client, o Options)
- type Builder
- type Client
- type Color
- type ColorSpace
- type Config
- func (c *Config) Color(name string) Color
- func (c *Config) Data() *Data
- func (c *Config) DataColors() (colors []Color)
- func (c *Config) DataFonts() (fonts []Font)
- func (c *Config) DataFormats() DataStyles
- func (c *Config) DataLabels() []Value
- func (c *Config) DataStyles() DataStyles
- func (c *Config) DataTitles() (titles []Value)
- func (c *Config) DataValues() Dataset
- func (c *Config) Dataset(name string) Dataset
- func (c *Config) Font(name string) Font
- func (c *Config) Integer(name string) int32
- func (c *Config) Name() string
- func (c *Config) Number(name string) float64
- func (c *Config) NumberFormat() NumberFormat
- func (c *Config) ResolveFont(f Font) *FontStyle
- func (c *Config) ResolveInteger(v Value) int32
- func (c *Config) ResolveNumber(v Value) float64
- func (c *Config) ResolveTwiplet(v Value) Twiplet
- func (c *Config) Twiplet(name string) Twiplet
- func (c *Config) Value(name string) Value
- type Data
- type DataStyle
- type DataStyles
- type DataType
- type Dataset
- type Font
- type FontAttribute
- type FontResource
- type FontStyle
- type GUID
- type Image
- type ImageFormat
- type LogLevel
- type NumberFormat
- type Options
- type ReturnCode
- type Twiplet
- type Value
Constants ¶
const Inch = 144000.0
Inch defines the number of units in one inch.
Variables ¶
var DefaultColor = Color{K: 100}
DefaultColor represents the default colour value (black).
var DefaultFont = Font{}
DefaultFont can be used to query the default font from Designer/Generate.
Functions ¶
Types ¶
type Builder ¶
type Builder interface { SetFormat(format *ImageFormat, colorSpace *ColorSpace) SetSize(width, height Twiplet, dpi int32) Render() (*bytes.Buffer, error) }
Builder creates a chart image.
type ColorSpace ¶
type ColorSpace int32
ColorSpace represents the preferred image colour space.
const ( Named ColorSpace = C.ENCH_ColorNamed RGB ColorSpace = C.ENCH_ColorRgb CMYK ColorSpace = C.ENCH_ColorCmyk )
Image colour spaces understood by Designer/Generate.
func (ColorSpace) String ¶
func (cs ColorSpace) String() string
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents the configuration of the chart to be rendered.
func (*Config) DataColors ¶
DataColors gets the data colours dataset from the configuration.
func (*Config) DataFormats ¶
func (c *Config) DataFormats() DataStyles
DataFormats gets the data formats dataset from the configuration.
func (*Config) DataLabels ¶
DataLabels gets the data labels dataset from the configuration.
func (*Config) DataStyles ¶
func (c *Config) DataStyles() DataStyles
DataStyles gets the data styles dataset from the configuration.
func (*Config) DataTitles ¶
DataTitles gets the data titles dataset from the configuration.
func (*Config) DataValues ¶
DataValues gets the data values dataset from the configuration.
func (*Config) Integer ¶
Integer gets the value of a property as an integer. Zero is returned if the string is empty or the conversion fails.
func (*Config) Number ¶
Number gets the value of a property as a number. Zero is returned if the string is empty or the conversion fails.
func (*Config) NumberFormat ¶
func (c *Config) NumberFormat() NumberFormat
NumberFormat defines how a number should be formatted for display.
func (*Config) ResolveFont ¶
ResolveFont gets a font resource from a Font value.
func (*Config) ResolveInteger ¶
ResolveInteger converts a value to an integer. Zero is returned if the string is empty or the conversion fails.
func (*Config) ResolveNumber ¶
ResolveNumber converts a value to a number. Zero is returned if the string is empty or the conversion fails.
func (*Config) ResolveTwiplet ¶
ResolveTwiplet converts a value to a Twiplet. Zero is returned if the string is empty or the conversion fails.
type Data ¶
type Data struct { Values Dataset Titles []Value Colors []Color Styles DataStyles Labels []Value Fonts []Font Formats DataStyles }
Data represents the chart data properties.
type DataStyles ¶
type DataStyles [][]DataStyle
DataStyles represents a set of styles to apply to the data values.
func (DataStyles) At ¶
func (ds DataStyles) At(row, col int) *DataStyle
At returns the data style of a particular data value.
func (DataStyles) CustomFormat ¶
func (ds DataStyles) CustomFormat(row, col int) Value
CustomFormat determines the special custom format setting of a data value.
type DataType ¶
type DataType int32
DataType represents a data field type.
const ( NotSet DataType = C.ENCH_DataNotSet Neutral DataType = C.ENCH_DataNeutral Integer DataType = C.ENCH_DataInteger Number DataType = C.ENCH_DataNumber Date DataType = C.ENCH_DataDate Time DataType = C.ENCH_DataTime Currency DataType = C.ENCH_DataCurrency )
Data types understood by Designer/Generate.
type Dataset ¶
type Dataset [][]Value
Dataset represents a set of data values from the chart configuration.
type FontAttribute ¶
type FontAttribute uint16
FontAttribute represents the attributes of a font.
const ( Bold FontAttribute = C.ENCH_FontBold Italic FontAttribute = C.ENCH_FontItalic EmulateBold FontAttribute = C.ENCH_FontEmulateBold EmulateItalic FontAttribute = C.ENCH_FontEmulateItalic EmulateTypeface FontAttribute = C.ENCH_FontEmulateTypeface )
Font attributes understood by Designer/Generate.
type FontResource ¶
type FontResource struct { Typeface string PointSize float64 Attributes FontAttribute Filename string TruetypeFont *truetype.Font }
FontResource represents a font resource from Designer/Generate.
func (*FontResource) Bold ¶
func (fr *FontResource) Bold() bool
Bold determines whether the font has the Bold attribute.
func (*FontResource) EmulateBold ¶
func (fr *FontResource) EmulateBold() bool
EmulateBold determines whether the font has the EmulateBold attribute.
func (*FontResource) EmulateItalic ¶
func (fr *FontResource) EmulateItalic() bool
EmulateItalic determines whether the font has the EmulateItalic attribute.
func (*FontResource) EmulateTypeface ¶
func (fr *FontResource) EmulateTypeface() bool
EmulateTypeface determines whether the font has the EmulateTypeface attribute.
func (*FontResource) Italic ¶
func (fr *FontResource) Italic() bool
Italic determines whether the font has the Italic attribute.
type FontStyle ¶
type FontStyle struct { *FontResource Color Underline bool }
FontStyle represents a font style from Designer/Generate.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents the chart image requirements.
type ImageFormat ¶
type ImageFormat int32
ImageFormat represents the preferred image format.
const ( BMP ImageFormat = C.ENCH_ImageBmp PNG ImageFormat = C.ENCH_ImagePng JPG ImageFormat = C.ENCH_ImageJpg SVG ImageFormat = C.ENCH_ImageSvg )
Image formats understood by Designer/Generate.
func (ImageFormat) String ¶
func (f ImageFormat) String() string
type NumberFormat ¶
type NumberFormat struct {
ThousandsSeparator, DecimalPoint rune
}
NumberFormat defines how a number should be formatted for display.
type ReturnCode ¶
type ReturnCode int32
ReturnCode represents the API return codes.
const ( OK ReturnCode = C.ENCHRC_OK Failed ReturnCode = C.ENCHRC_Failed NotImplemented ReturnCode = C.ENCHRC_NotImplemented InvalidFilePath ReturnCode = C.ENCHRC_InvalidFilePath MissingProperty ReturnCode = C.ENCHRC_MissingProperty InvalidValue ReturnCode = C.ENCHRC_InvalidValue UnresolvedFont ReturnCode = C.ENCHRC_UnresolvedFont InvalidDataString ReturnCode = C.ENCHRC_InvalidDataString EmptyDataString ReturnCode = C.ENCHRC_EmptyDataString JavaException ReturnCode = C.ENCHRC_JavaException FailedToCreateJavaVM ReturnCode = C.ENCHRC_FailedToCreateJavaVM )
API return codes understood by Designer/Generate.
func EnchCreateImage ¶
func EnchCreateImage( callbackPtr unsafe.Pointer, propertiesPtr, symbolsPtr *C.char, imagePtr unsafe.Pointer, ) (rc ReturnCode)
EnchCreateImage is called by Designer/Generate to create a chart image from a list of configuration settings (propertiesPtr). These settings appear in the form name=value where value may be a constant, or refer to a field in the symbol table (symbolsPtr). Image information is conveyed via imagePtr; a C pointer represented by the Image struct. The callbackPtr parameter contains pointers to functions defined by Designer/Generate to resolve data values, fonts and locale information.
func EnchDestroyImage ¶
func EnchDestroyImage(imagePtr unsafe.Pointer) ReturnCode
EnchDestroyImage is called by Designer/Generate to destroy the chart image data created by EnchCreateImage.
func EnchTerminate ¶
func EnchTerminate() ReturnCode
EnchTerminate is called by Generate to tidy up before the program exits. The Failed ReturnCode is returned here to indicate that it is unsafe for Generate to unload this module as the Go runtime may still need to do some garbage collection.
func (ReturnCode) String ¶
func (rc ReturnCode) String() string
type Twiplet ¶
type Twiplet int32
Twiplet represents a unit of measure in 1/100ths of a twip.