-
Notifications
You must be signed in to change notification settings - Fork 3
/
chart-types.go
108 lines (91 loc) · 2.23 KB
/
chart-types.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package chart
/*
// These allow constructing json to tweak chart options on the front'ends piechart lib (apexcharts)
// See: https://apexcharts.com/docs/options/
Example usage:
import (
"github.com/doddle/lander/pkg/chart"
)
type FinalPieChart struct {
ChartOpts chart.ChartOpts `json:"chartOptions"`
Series []int64 `json:"series"`
Total int64 `json:"total"`
}
func foo(){
result := FinalPieChart{
Total: someNumber,
Series: resultSeries,
ChartOpts: chart.ChartOpts{
Legend: chart.Legend{Show: true},
//Theme: chart.Theme{Palette: "palette1"},
//Title: chart.Title{Text: "Nodes"},
PlotOpt: chart.PlotOpt{
Pie: chart.PlotOptPie{
ExpandOnClick: false,
Size: 119,
},
},
Colors: resultColors,
Stroke: chart.Stroke{Width: -1},
Chart: chart.Chart{
ID: "pie-nodes",
//DropShadow: chart.DropShadow{
// Effect: false,
//},
},
Labels: resultLabels,
},
}
}
*/
type Opts struct {
Chart Chart `json:"chart"`
Labels []string `json:"labels"`
PlotOpt PlotOpt `json:"plotOptions"`
Legend Legend `json:"legend"`
Stroke Stroke `json:"stroke"`
Theme Theme `json:"theme"`
Title Title `json:"title"`
Colors []string `json:"colors"`
}
type Title struct {
Text string `json:"text"`
}
type Data struct {
Labels []string `json:"labels"`
Datasets []Dataset `json:"datasets"`
}
type Dataset struct {
BorderWidth int64 `json:"borderWidth"`
BorderColor []string `json:"borderColor"`
BackgroundColor []string `json:"backgroundColor"`
Data []int64 `json:"data"`
}
type Options struct {
Responsive bool `json:"responsive"`
MaintainAspectRatio bool `json:"maintainAspectRatio"`
}
type PlotOpt struct {
Pie PlotOptPie `json:"pie"`
}
type PlotOptPie struct {
CustomScale float64 `json:"customScale,omitempty"`
ExpandOnClick bool `json:"expandOnClick"`
Size int64 `json:"size,omitempty"`
}
type Theme struct {
Palette string `json:"palette"`
}
type Stroke struct {
Width float64 `json:"width"`
}
type Legend struct {
Show bool `json:"show"`
}
type Chart struct {
ID string `json:"id"`
DropShadow DropShadow `json:"dropShadow"`
}
type DropShadow struct {
Effect bool `json:"effect"`
}