Documentation ¶
Index ¶
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func MustAsset(name string) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type Chart
- func (c *Chart) GetAsset(name string) ([]byte, error)
- func (c *Chart) GetAssetList() []string
- func (c *Chart) GetContent() template.HTML
- func (c *Chart) GetName() string
- func (c *Chart) GetOptions() template.JS
- func (c *Chart) GetTemplate() (*template.Template, string)
- func (c *Chart) SetContent(content interface{}) *Chart
Constants ¶
This section is empty.
Variables ¶
var AssetsList = []string{
"/echarts.min.js",
"/china.js",
"/echarts-gl.min.js",
"/echarts-liquidfill.min.js",
}
var List = map[string]string{
"base": `{{- define "base" }}
<div class="container">
<div class="item" id="{{ .ChartID }}"
style="width:{{ .InitOpts.Width }};height:{{ .InitOpts.Height }};"></div>
</div>
<script type="text/javascript">
"use strict";
let myChart___x__{{ .ChartID }}__x__ = echarts.init(document.getElementById('{{ .ChartID }}'), "{{ .Theme }}");
let option___x__{{ .ChartID }}__x__ = {
title: {{ .TitleOpts }},
tooltip: {{ .TooltipOpts }},
legend: {{ .LegendOpts }},
{{- if .HasGeo }}
geo: {{ .GeoComponentOpts }},
{{- end }}
{{- if .HasRadar }}
radar: {{ .RadarComponentOpts }},
{{- end }}
{{- if .HasParallel }}
parallel: {{ .ParallelComponentOpts }},
parallelAxis: {{ .ParallelAxisOpts }},
{{- end }}
{{- if .HasSingleAxis }}
singleAxis: {{ .SingleAxisOpts }},
{{- end }}
{{- if .ToolboxOpts.Show }}
toolbox: {{ .ToolboxOpts }},
{{- end }}
{{- if gt .DataZoomOptsList.Len 0 }}
dataZoom:{{ .DataZoomOptsList }},
{{- end }}
{{- if gt .VisualMapOptsList.Len 0 }}
visualMap:{{ .VisualMapOptsList }},
{{- end }}
{{- if .HasXYAxis }}
xAxis: {{ .XAxisOptsList }},
yAxis: {{ .YAxisOptsList }},
{{- end }}
{{- if .Has3DAxis }}
xAxis3D: {{ .XAxis3D }},
yAxis3D: {{ .YAxis3D }},
zAxis3D: {{ .ZAxis3D }},
grid3D: {{ .Grid3D }},
{{- end }}
series: [
{{ range .Series }}
{{- . }},
{{ end -}}
],
{{- if eq .Theme "white" }}
color: {{ .Colors }},
{{- end }}
{{- if ne .BackgroundColor "" }}
backgroundColor: {{ .BackgroundColor }}
{{- end }}
};
myChart___x__{{ .ChartID }}__x__.setOption(option___x__{{ .ChartID }}__x__);
{{- range .JSFunctions.Fns }}
{{ . }}
{{- end }}
</script>
{{ end }}`,
"chart": `{{- define "chart" }}
<!DOCTYPE html>
<html>
{{- template "header" . }}
<body>
{{- template "routers" . }}
{{- template "base" . }}
<style>
.container {margin-top:30px; display: flex;justify-content: center;align-items: center;}
.item {margin: auto;}
</style>
</body>
</html>
{{ end }}`,
"header": `{{ define "header" }}
<head>
<meta charset="utf-8">
<title>{{ .PageTitle }}</title>
{{- range .JSAssets.Values }}
<script src="{{ . }}"></script>
{{- end }}
{{- range .CSSAssets.Values }}
<link href="{{ . }}" rel="stylesheet">
{{- end }}
</head>
{{ end }}
`,
"page": `
{{- define "page" }}
<!DOCTYPE html>
<html>
{{- template "header" . }}
<body>
{{- template "routers" . }}
{{- range .Charts }}
{{ template "base" . }}
<br/>
{{- end }}
<style>
.container {display: flex;justify-content: center;align-items: center;}
.item {margin: auto;}
</style>
</body>
</html>
{{ end }}`,
"routes": `{{- define "routers" }}
<div class="select" style="margin-right:10px; margin-top:10px; position:fixed; right:10px;">
{{- if gt .Routers.Len 0}}
<select onchange="window.location.href=this.options[this.selectedIndex].value">
{{- range .Routers }}
<option value="{{ .URL }}">{{ .Text }}</option>
{{- end }}
</select>
{{- end -}}
</div>
{{ end }}`,
"timeline": `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>`,
}
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type Chart ¶
type Chart struct { *template2.BaseComponent Content interface{} }