widgets

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2019 License: MIT Imports: 12 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllChartTypes = []maps.Map{
	{
		"name":        "线图",
		"code":        "line",
		"description": "使用线图展示数据",
		"instance":    new(LineChart),
	},
	{
		"name":        "饼图",
		"code":        "pie",
		"description": "使用饼图展示数据",
		"instance":    new(PieChart),
	},
	{
		"name":        "HTML",
		"code":        "html",
		"description": "使用HTML写一个图表",
		"instance":    new(HTMLChart),
	},
	{
		"name":        "URL",
		"code":        "url",
		"description": "引入一个外部的URL,要注意可能产生的安全问题",
		"instance":    new(URLChart),
	},
	{
		"name":        "时钟",
		"code":        "clock",
		"description": "使用时钟展示当前时间,时间格式可以类似于 Mon Jan 21 16:46:06 CST 2019、2019-01-02 03:04:95 或一个时间戳 1548060582",
		"instance":    new(ClockChart),
	},
	{
		"name":        "Javascript",
		"code":        "javascript",
		"description": "直接使用Javascript代码来写图表",
		"instance":    new(JavascriptChart),
	},
}
View Source
var StatChartTypes = []maps.Map{
	{
		"name":        "线图",
		"code":        "line",
		"description": "使用线图展示数据",
		"instance":    new(LineChart),
	},
	{
		"name":        "饼图",
		"code":        "pie",
		"description": "使用饼图展示数据",
		"instance":    new(PieChart),
	},
	{
		"name":        "HTML",
		"code":        "html",
		"description": "使用HTML写一个图表",
		"instance":    new(HTMLChart),
	},
	{
		"name":        "URL",
		"code":        "url",
		"description": "引入一个外部的URL,要注意可能产生的安全问题",
		"instance":    new(URLChart),
	},
	{
		"name":        "时钟",
		"code":        "clock",
		"description": "使用时钟展示当前时间,时间格式可以类似于 Mon Jan 21 16:46:06 CST 2019、2019-01-02 03:04:95 或一个时间戳 1548060582",
		"instance":    new(ClockChart),
	},
	{
		"name":        "Javascript",
		"code":        "javascript",
		"description": "直接使用Javascript代码来写图表",
		"instance":    new(JavascriptChart),
	},
}

Functions

func FindChartTypeName

func FindChartTypeName(chartType string) string

查找类型对应的名称

Types

type Chart

type Chart struct {
	Id           string                 `yaml:"id" json:"id"`
	On           bool                   `yaml:"on" json:"on"`
	Name         string                 `yaml:"name" json:"name"`
	Description  string                 `yaml:"description" json:"description"`
	Columns      uint8                  `yaml:"columns" json:"columns"`           // 列
	Type         string                 `yaml:"type" json:"type"`                 // 类型
	Options      map[string]interface{} `yaml:"options" json:"options"`           // 选项
	Requirements []string               `yaml:"requirements" json:"requirements"` // 绘制chart需要的特征
}

Chart定义

func NewChart

func NewChart() *Chart

获取新对象

func (*Chart) AsObject

func (this *Chart) AsObject() (ChartInterface, error)

转换为具体对象

func (*Chart) Validate

func (this *Chart) Validate() error

校验

type ChartInterface

type ChartInterface interface {
	AsJavascript(options map[string]interface{}) (code string, err error)
}

Chart接口

type ClockChart

type ClockChart struct {
}

时钟

func (*ClockChart) AsJavascript

func (this *ClockChart) AsJavascript(options map[string]interface{}) (code string, err error)

type HTMLChart

type HTMLChart struct {
	HTML string `yaml:"html" json:"html"`
}

HTML Chart

func (*HTMLChart) AsJavascript

func (this *HTMLChart) AsJavascript(options map[string]interface{}) (code string, err error)

type JavascriptChart

type JavascriptChart struct {
	Code string `yaml:"code" json:"code"`
}

Javascript

func (*JavascriptChart) AsJavascript

func (this *JavascriptChart) AsJavascript(options map[string]interface{}) (code string, err error)

type LineChart

type LineChart struct {
	Params []string
	Limit  int
}

线图

func (*LineChart) AsJavascript

func (this *LineChart) AsJavascript(options map[string]interface{}) (code string, err error)

type PieChart

type PieChart struct {
	Param string
	Limit int
}

Pie

func (*PieChart) AsJavascript

func (this *PieChart) AsJavascript(options map[string]interface{}) (code string, err error)

type URLChart

type URLChart struct {
	URL string `yaml:"url" json:"url"`
}

URL Chart

func (*URLChart) AsJavascript

func (this *URLChart) AsJavascript(options map[string]interface{}) (code string, err error)

type Widget

type Widget struct {
	Id          string   `yaml:"id" json:"id"`
	On          bool     `yaml:"on" json:"on"`
	Name        string   `yaml:"name" json:"name"`
	Code        string   `yaml:"code" json:"code"`
	Author      string   `yaml:"author" json:"author"`
	Version     string   `yaml:"version" json:"version"`
	Description string   `yaml:"description" json:"description"`
	Charts      []*Chart `yaml:"charts" json:"charts"`
	CreatedAt   int64    `yaml:"createdAt" json:"createdAt"` // 添加时间,用来排序
}

Widget定义

func LoadAllWidgets

func LoadAllWidgets() []*Widget

获取所有Widget列表

func NewWidget

func NewWidget() *Widget

获取新对象

func NewWidgetFromId

func NewWidgetFromId(widgetId string) *Widget

从文件中加载Widget

func (*Widget) AddChart

func (this *Widget) AddChart(chart *Chart)

添加Chart

func (*Widget) Delete

func (this *Widget) Delete() error

删除当前Widget

func (*Widget) FindChart

func (this *Widget) FindChart(chartId string) *Chart

查找Chart

func (*Widget) RemoveChart

func (this *Widget) RemoveChart(chartId string)

删除Chart

func (*Widget) Save

func (this *Widget) Save() error

保存

Jump to

Keyboard shortcuts

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