Skip to content

Commit ffd5fb8

Browse files
sapkjonasfranz
authored andcommitted
Set heatmap color range configurable (#5165)
1 parent 7e5eec4 commit ffd5fb8

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

custom/conf/app.ini.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ MAX_DISPLAY_FILE_SIZE = 8388608
8585
SHOW_USER_EMAIL = true
8686
; Set the default theme for the Gitea install
8787
DEFAULT_THEME = gitea
88+
; Set the color range to use for heatmap (default to `['#f4f4f4', '#459928']` but can use `['#2d303b', '#80bb46']` with the theme `arc-green`)
89+
HEATMAP_COLOR_RANGE = `['#f4f4f4', '#459928']`
8890

8991
[ui.admin]
9092
; Number of users that are displayed on one page

modules/setting/setting.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ var (
300300
MaxDisplayFileSize int64
301301
ShowUserEmail bool
302302
DefaultTheme string
303+
HeatmapColorRange string
303304

304305
Admin struct {
305306
UserPagingNum int
@@ -326,6 +327,7 @@ var (
326327
ThemeColorMetaTag: `#6cc644`,
327328
MaxDisplayFileSize: 8388608,
328329
DefaultTheme: `gitea`,
330+
HeatmapColorRange: `['#f4f4f4', '#459928']`,
329331
Admin: struct {
330332
UserPagingNum int
331333
RepoPagingNum int

modules/templates/helper.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ func NewFuncMap() []template.FuncMap {
193193
"DefaultTheme": func() string {
194194
return setting.UI.DefaultTheme
195195
},
196+
"HeatmapColorRange": func() string {
197+
return setting.UI.HeatmapColorRange
198+
},
196199
"dict": func(values ...interface{}) (map[string]interface{}, error) {
197200
if len(values) == 0 {
198201
return nil, errors.New("invalid dict call")

templates/base/footer.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
var heatmap = calendarHeatmap()
6666
.data(chartData)
6767
.selector('#user-heatmap')
68-
.colorRange(['#f4f4f4', '#459928'])
68+
.colorRange({{SafeJS HeatmapColorRange}})
6969
.tooltipEnabled(true);
7070
heatmap();
7171
});

0 commit comments

Comments
 (0)