-
Notifications
You must be signed in to change notification settings - Fork 3
/
common.go
43 lines (37 loc) · 1.03 KB
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package chart
import (
"github.com/go-echarts/go-echarts/v2/charts"
"github.com/go-echarts/go-echarts/v2/components"
"github.com/go-echarts/go-echarts/v2/opts"
)
func NewTree(title string) *charts.Tree {
graph := charts.NewTree()
graph.SetGlobalOptions(
charts.WithInitializationOpts(opts.Initialization{
Width: "100%", Height: "95vh",
AssetsHost: "https://cdn.jsdelivr.net/npm/echarts@4/dist/", //use updated upstream js
}),
charts.WithTitleOpts(opts.Title{Title: title}),
charts.WithToolboxOpts(opts.Toolbox{
Show: true,
Feature: &opts.ToolBoxFeature{
SaveAsImage: &opts.ToolBoxFeatureSaveAsImage{
Show: true,
Type: "png",
Title: "Download as PNG",
},
},
}),
charts.WithTooltipOpts(opts.Tooltip{Show: false}),
)
return graph
}
func NewPage() *components.Page {
page := components.NewPage()
page.SetPageOptions(
components.WithInitializationOpts(opts.Initialization{
AssetsHost: "https://cdn.jsdelivr.net/npm/echarts@4/dist/", //use updated upstream js
}),
)
return page
}