chart

package module
v0.0.0-...-a6f99b2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 25 Imported by: 0

README

chart

Chart resources for Ecletus Framework

Documentation

Index

Constants

View Source
const (
	DEFAULT_CONFIG_DIR = "config/charts"
	URI                = "/reports.json"
)

Variables

View Source
var (
	E_REPORT_FACTORY  = PKG + ".reportFactory"
	E_REPORTS_FACTORY = PKG + ".reportsFactory"
)
View Source
var (
	PKG = path_helpers.GetCalledDir()
)

Functions

func Events

func Events(dis edis.EventDispatcherInterface) *events

func ParseDateRange

func ParseDateRange(start, end string) (startDate, endDate time.Time, err error)

date format 2015-01-23

func Random

func Random(min, max int, cb func(i, v int) bool)

func RegisterFuncFactory

func RegisterFuncFactory(id string, factory ChartFuncFactory)

Types

type Chart

type Chart struct {
	ChartFactory     `json:"-"`
	ID               string
	ChartLabel       string
	ChartDescription string
	Config           *ChartConfig
	IsSite           bool
	AdminName        string
}

func NewChart

func NewChart(cfg *ChartConfig, factory ChartFactory) *Chart

func (*Chart) Description

func (c *Chart) Description() string

func (*Chart) Find

func (c *Chart) Find(ctx *Context) (out *OutputChart, err error)

func (*Chart) GetInfo

func (c *Chart) GetInfo(infos ...ChartInfo) (label, description string)

func (*Chart) Label

func (c *Chart) Label() string

func (*Chart) Option

func (c *Chart) Option(key string) interface{}

func (*Chart) OptionMap

func (c *Chart) OptionMap(key string) map[string]interface{}

func (*Chart) String

func (c *Chart) String() string

type ChartConfig

type ChartConfig struct {
	ResourceName string
	AdminName    string
	Label        string
	Description  string
	Site         bool
	Factory      string
	Options      map[string]interface{}
	// JSON Value
	DataSet string
	ID      string
}

type ChartFactory

type ChartFactory interface {
	Factory(ctx *Context) (Finder, error)
}

type ChartFuncFactory

type ChartFuncFactory func(ctx *Context) (Finder, error)

func (ChartFuncFactory) Factory

func (f ChartFuncFactory) Factory(ctx *Context) (Finder, error)

type ChartInfo

type ChartInfo interface {
	Label() string
	Description() string
}

type ChartRenderInfo

type ChartRenderInfo struct {
	*Chart
	UID string
}

type ChartReportEvent

type ChartReportEvent struct {
	edis.EventInterface
	Context *Context
}

type ChartReportFactoryEvent

type ChartReportFactoryEvent struct {
	*ChartReportEvent
	Finder Finder
}

func NewReportFactoryEvent

func NewReportFactoryEvent(ctx *Context) *ChartReportFactoryEvent

type ChartReportsFactoryEvent

type ChartReportsFactoryEvent struct {
	*ChartReportEvent
	Finder Finder
}

type Charts

type Charts struct {
	Factory *OutputChartFactory
}

func (*Charts) AdminHandler

func (c *Charts) AdminHandler(ctx *admin.Context)

func (*Charts) RegisterAdminRoutes

func (c *Charts) RegisterAdminRoutes(Admin *admin.Admin)

func (*Charts) RegisterFuncMaps

func (c *Charts) RegisterFuncMaps(register func(string, interface{}))

func (*Charts) RegisterSiteRoutes

func (c *Charts) RegisterSiteRoutes(router *xroute.Mux)

func (*Charts) SiteHandler

func (c *Charts) SiteHandler(w http.ResponseWriter, r *http.Request, rctx *xroute.RouteContext)

type ChartsMap

type ChartsMap struct {
	// contains filtered or unexported fields
}

func (*ChartsMap) Add

func (c *ChartsMap) Add(charts ...*Chart)

func (*ChartsMap) Get

func (c *ChartsMap) Get(uid string) (chart *Chart, ok bool)

type Config

type Config struct {
	Uri struct {
		SiteUri  string
		AdminUri string
	}
	Charts map[string]*ChartConfig
}

func LoadConfigDir

func LoadConfigDir(configDir string) (config *Config, err error)

func LoadConfigFile

func LoadConfigFile(pth string) (config *Config, err error)

func (*Config) LoadDefaults

func (c *Config) LoadDefaults()

func (*Config) Merge

func (c *Config) Merge(cfg *Config)

type Context

type Context struct {
	*core.Errors

	Chart        *Chart
	Context      *core.Context
	AdminContext *admin.Context
	StartDate    time.Time
	EndDate      time.Time
}

type FakeFinder

type FakeFinder struct {
	Min int
	Max int
}

func (*FakeFinder) Find

func (f *FakeFinder) Find(ctx *Context) (res []Record, err error)

type Finder

type Finder interface {
	Find(ctx *Context) (res []Record, err error)
}

type FinderFunc

type FinderFunc func(ctx *Context) (res []Record, err error)

func (FinderFunc) Find

func (f FinderFunc) Find(ctx *Context) (res []Record, err error)

type FinderInfo

type FinderInfo interface {
	ChartInfo
	Finder
}

func NewFinderInfo

func NewFinderInfo(finder Finder, label, description string) FinderInfo

type IntRange

type IntRange struct {
	// contains filtered or unexported fields
}

range specification, note that min <= max

func (*IntRange) NextRandom

func (ir *IntRange) NextRandom(r *rand.Rand) int

get next random value within the interval including min and max

type OutputChart

type OutputChart struct {
	Label       string
	Description string
	Result      []Record
}

type OutputChartFactory

type OutputChartFactory struct {
	Config      *Config
	Resources   map[string]map[string]*ResourceFactory
	Funcs       map[string]ChartFuncFactory
	AdminCharts map[string]*ChartsMap
	SiteCharts  ChartsMap
}

func NewOutputChartFactory

func NewOutputChartFactory(config *Config) (f *OutputChartFactory)

func (*OutputChartFactory) AdminFactory

func (f *OutputChartFactory) AdminFactory(context *admin.Context, startDate, endDate time.Time, chartsUID ...string) (result map[string]*OutputChart)

func (*OutputChartFactory) GetOrRegisterResource

func (f *OutputChartFactory) GetOrRegisterResource(res *admin.Resource) (rf *ResourceFactory)

func (*OutputChartFactory) LoadAdminResources

func (f *OutputChartFactory) LoadAdminResources(Admin *admin.Admin)

func (*OutputChartFactory) LoadFuncs

func (f *OutputChartFactory) LoadFuncs()

func (*OutputChartFactory) RegisterFunc

func (f *OutputChartFactory) RegisterFunc(cfg *ChartConfig) bool

type Plugin

type Plugin struct {
	admin_plugin.AdminNames
	plug.EventDispatcher
	ConfigDir string
	RouterKey string
	ChartsKey string
	// contains filtered or unexported fields
}

func (*Plugin) OnRegister

func (p *Plugin) OnRegister()

func (*Plugin) ProvideOptions

func (p *Plugin) ProvideOptions() []string

func (*Plugin) ProvidesOptions

func (p *Plugin) ProvidesOptions(options *plug.Options) error

func (*Plugin) RequireOptions

func (p *Plugin) RequireOptions() []string

type QueryFinder

type QueryFinder struct {
	DB        *aorm.DB
	TableName string
	FieldName string
}

func (*QueryFinder) Find

func (q *QueryFinder) Find(ctx *Context) (res []Record, err error)

type Record

type Record struct {
	Total string
	Date  time.Time
}

type ResourceFactory

type ResourceFactory struct {
	Resource *admin.Resource
	Charts   map[string]*Chart
}

func (*ResourceFactory) RegisterChart

func (f *ResourceFactory) RegisterChart(cfg *ChartConfig) *Chart

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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