Debian Codegraph @

colors.go

raw symbols SCIP
1 package chart
2
3 import "github.com/wcharczuk/go-chart/v2/drawing"
4
5 var (
6 // ColorWhite is white.
7 ColorWhite = drawing.Color{R: 255, G: 255, B: 255, A: 255}
8 // ColorBlue is the basic theme blue color.
9 ColorBlue = drawing.Color{R: 0, G: 116, B: 217, A: 255}
10 // ColorCyan is the basic theme cyan color.
11 ColorCyan = drawing.Color{R: 0, G: 217, B: 210, A: 255}
12 // ColorGreen is the basic theme green color.
13 ColorGreen = drawing.Color{R: 0, G: 217, B: 101, A: 255}
14 // ColorRed is the basic theme red color.
15 ColorRed = drawing.Color{R: 217, G: 0, B: 116, A: 255}
16 // ColorOrange is the basic theme orange color.
17 ColorOrange = drawing.Color{R: 217, G: 101, B: 0, A: 255}
18 // ColorYellow is the basic theme yellow color.
19 ColorYellow = drawing.Color{R: 217, G: 210, B: 0, A: 255}
20 // ColorBlack is the basic theme black color.
21 ColorBlack = drawing.Color{R: 51, G: 51, B: 51, A: 255}
22 // ColorLightGray is the basic theme light gray color.
23 ColorLightGray = drawing.Color{R: 239, G: 239, B: 239, A: 255}
24
25 // ColorAlternateBlue is a alternate theme color.
26 ColorAlternateBlue = drawing.Color{R: 106, G: 195, B: 203, A: 255}
27 // ColorAlternateGreen is a alternate theme color.
28 ColorAlternateGreen = drawing.Color{R: 42, G: 190, B: 137, A: 255}
29 // ColorAlternateGray is a alternate theme color.
30 ColorAlternateGray = drawing.Color{R: 110, G: 128, B: 139, A: 255}
31 // ColorAlternateYellow is a alternate theme color.
32 ColorAlternateYellow = drawing.Color{R: 240, G: 174, B: 90, A: 255}
33 // ColorAlternateLightGray is a alternate theme color.
34 ColorAlternateLightGray = drawing.Color{R: 187, G: 190, B: 191, A: 255}
35
36 // ColorTransparent is a transparent (alpha zero) color.
37 ColorTransparent = drawing.Color{R: 1, G: 1, B: 1, A: 0}
38 )
39
40 var (
41 // DefaultBackgroundColor is the default chart background color.
42 // It is equivalent to css color:white.
43 DefaultBackgroundColor = ColorWhite
44 // DefaultBackgroundStrokeColor is the default chart border color.
45 // It is equivalent to color:white.
46 DefaultBackgroundStrokeColor = ColorWhite
47 // DefaultCanvasColor is the default chart canvas color.
48 // It is equivalent to css color:white.
49 DefaultCanvasColor = ColorWhite
50 // DefaultCanvasStrokeColor is the default chart canvas stroke color.
51 // It is equivalent to css color:white.
52 DefaultCanvasStrokeColor = ColorWhite
53 // DefaultTextColor is the default chart text color.
54 // It is equivalent to #333333.
55 DefaultTextColor = ColorBlack
56 // DefaultAxisColor is the default chart axis line color.
57 // It is equivalent to #333333.
58 DefaultAxisColor = ColorBlack
59 // DefaultStrokeColor is the default chart border color.
60 // It is equivalent to #efefef.
61 DefaultStrokeColor = ColorLightGray
62 // DefaultFillColor is the default fill color.
63 // It is equivalent to #0074d9.
64 DefaultFillColor = ColorBlue
65 // DefaultAnnotationFillColor is the default annotation background color.
66 DefaultAnnotationFillColor = ColorWhite
67 // DefaultGridLineColor is the default grid line color.
68 DefaultGridLineColor = ColorLightGray
69 )
70
71 var (
72 // DefaultColors are a couple default series colors.
73 DefaultColors = []drawing.Color{
74 ColorBlue,
75 ColorGreen,
76 ColorRed,
77 ColorCyan,
78 ColorOrange,
79 }
80
81 // DefaultAlternateColors are a couple alternate colors.
82 DefaultAlternateColors = []drawing.Color{
83 ColorAlternateBlue,
84 ColorAlternateGreen,
85 ColorAlternateGray,
86 ColorAlternateYellow,
87 ColorBlue,
88 ColorGreen,
89 ColorRed,
90 ColorCyan,
91 ColorOrange,
92 }
93 )
94
95 // GetDefaultColor returns a color from the default list by index.
96 // NOTE: the index will wrap around (using a modulo).
97 func GetDefaultColor(index int) drawing.Color {
98 finalIndex := index % len(DefaultColors)
99 return DefaultColors[finalIndex]
100 }
101
102 // GetAlternateColor returns a color from the default list by index.
103 // NOTE: the index will wrap around (using a modulo).
104 func GetAlternateColor(index int) drawing.Color {
105 finalIndex := index % len(DefaultAlternateColors)
106 return DefaultAlternateColors[finalIndex]
107 }
108
109 // ColorPalette is a set of colors that.
110 type ColorPalette interface {
111 BackgroundColor() drawing.Color
112 BackgroundStrokeColor() drawing.Color
113 CanvasColor() drawing.Color
114 CanvasStrokeColor() drawing.Color
115 AxisStrokeColor() drawing.Color
116 TextColor() drawing.Color
117 GetSeriesColor(index int) drawing.Color
118 }
119
120 // DefaultColorPalette represents the default palatte.
121 var DefaultColorPalette defaultColorPalette
122
123 type defaultColorPalette struct{}
124
125 func (dp defaultColorPalette) BackgroundColor() drawing.Color {
126 return DefaultBackgroundColor
127 }
128
129 func (dp defaultColorPalette) BackgroundStrokeColor() drawing.Color {
130 return DefaultBackgroundStrokeColor
131 }
132
133 func (dp defaultColorPalette) CanvasColor() drawing.Color {
134 return DefaultCanvasColor
135 }
136
137 func (dp defaultColorPalette) CanvasStrokeColor() drawing.Color {
138 return DefaultCanvasStrokeColor
139 }
140
141 func (dp defaultColorPalette) AxisStrokeColor() drawing.Color {
142 return DefaultAxisColor
143 }
144
145 func (dp defaultColorPalette) TextColor() drawing.Color {
146 return DefaultTextColor
147 }
148
149 func (dp defaultColorPalette) GetSeriesColor(index int) drawing.Color {
150 return GetDefaultColor(index)
151 }
152
153 // AlternateColorPalette represents the default palatte.
154 var AlternateColorPalette alternateColorPalette
155
156 type alternateColorPalette struct{}
157
158 func (ap alternateColorPalette) BackgroundColor() drawing.Color {
159 return DefaultBackgroundColor
160 }
161
162 func (ap alternateColorPalette) BackgroundStrokeColor() drawing.Color {
163 return DefaultBackgroundStrokeColor
164 }
165
166 func (ap alternateColorPalette) CanvasColor() drawing.Color {
167 return DefaultCanvasColor
168 }
169
170 func (ap alternateColorPalette) CanvasStrokeColor() drawing.Color {
171 return DefaultCanvasStrokeColor
172 }
173
174 func (ap alternateColorPalette) AxisStrokeColor() drawing.Color {
175 return DefaultAxisColor
176 }
177
178 func (ap alternateColorPalette) TextColor() drawing.Color {
179 return DefaultTextColor
180 }
181
182 func (ap alternateColorPalette) GetSeriesColor(index int) drawing.Color {
183 return GetAlternateColor(index)
184 }