Skip to content

Commit

Permalink
Merge pull request #789 from gemini-hlsw/enhancement/set-plotly-theme
Browse files Browse the repository at this point in the history
Enhancement: Extend settings to set default plotly theme.
  • Loading branch information
jchate6 authored Dec 20, 2023
2 parents 0c545bd + d4a61a8 commit 0735da0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tom_common/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
from django.apps import AppConfig
from django.conf import settings
import plotly.io as pio


class TomCommonConfig(AppConfig):
name = 'tom_common'

def ready(self):
# Set default plotly theme on startup
valid_themes = ['plotly', 'plotly_white', 'plotly_dark', 'ggplot2', 'seaborn', 'simple_white', 'none']

# Get the theme from settings, default to "plotly_white".
plotly_theme = getattr(settings, 'PLOTLY_THEME', 'plotly_white')
if plotly_theme not in valid_themes:
plotly_theme = 'plotly_white'

pio.templates.default = plotly_theme
4 changes: 4 additions & 0 deletions tom_setup/templates/tom_setup/settings.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ REST_FRAMEWORK = {
'PAGE_SIZE': 100
}

# Default Plotly theme setting, can set to any valid theme:
# 'plotly', 'plotly_white', 'plotly_dark', 'ggplot2', 'seaborn', 'simple_white', 'none'
PLOTLY_THEME = 'plotly_white'

try:
from local_settings import * # noqa
except ImportError:
Expand Down

0 comments on commit 0735da0

Please sign in to comment.