Skip to content

Commit e97434e

Browse files
author
Mark Gibbs
committed
Tidy up some of the linter objections
1 parent 3d38a72 commit e97434e

File tree

2 files changed

+31
-34
lines changed

2 files changed

+31
-34
lines changed

demo/demo/dash_apps.py

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,29 @@
1212
from django_plotly_dash import DjangoDash
1313

1414
#from .urls import app_name
15-
app_name ="DPD demo application"
15+
app_name = "DPD demo application"
1616

1717
dashboard_name1 = 'dash_example_1'
1818
dash_example1 = DjangoDash(name=dashboard_name1,
19-
serve_locally=True,
20-
app_name=app_name
21-
)
19+
serve_locally=True,
20+
app_name=app_name
21+
)
2222

2323
# Below is a random Dash app.
2424
# I encountered no major problems in using Dash this way. I did encounter problems but it was because
2525
# I was using e.g. Bootstrap inconsistenyly across the dash layout. Staying consistent worked fine for me.
2626
dash_example1.layout = html.Div(id='main',
27-
children=[
28-
29-
html.Div([
30-
dcc.Dropdown(
31-
id='my-dropdown1',
32-
options=[
33-
{'label': 'New York City', 'value': 'NYC'},
34-
{'label': 'Montreal', 'value': 'MTL'},
35-
{'label': 'San Francisco', 'value': 'SF'}
36-
],
37-
value='NYC',
38-
className='col-md-12',
39-
40-
),
41-
html.Div(id='test-output-div')
42-
]),
27+
children=[
28+
html.Div([dcc.Dropdown(id='my-dropdown1',
29+
options=[{'label': 'New York City', 'value': 'NYC'},
30+
{'label': 'Montreal', 'value': 'MTL'},
31+
{'label': 'San Francisco', 'value': 'SF'}
32+
],
33+
value='NYC',
34+
className='col-md-12',
35+
),
36+
html.Div(id='test-output-div')
37+
]),
4338

4439
dcc.Dropdown(
4540
id='my-dropdown2',
@@ -59,32 +54,31 @@
5954
@dash_example1.expanded_callback(
6055
dash.dependencies.Output('test-output-div', 'children'),
6156
[dash.dependencies.Input('my-dropdown1', 'value')])
62-
def callback_test(*args, **kwargs):
57+
def callback_test(*args, **kwargs): #pylint: disable=unused-argument
58+
'Callback to generate test data on each change of the dropdown'
6359

6460
# Creating a random Graph from a Plotly example:
6561
N = 500
6662
random_x = np.linspace(0, 1, N)
6763
random_y = np.random.randn(N)
6864

6965
# Create a trace
70-
trace = go.Scatter(
71-
x = random_x,
72-
y = random_y
73-
)
66+
trace = go.Scatter(x=random_x,
67+
y=random_y)
7468

7569
data = [trace]
7670

7771
layout = dict(title='',
78-
yaxis = dict(zeroline = False, title='Total Expense (£)',),
79-
xaxis = dict(zeroline = False, title='Date', tickangle=0),
80-
margin=dict(t=20, b=50, l=50, r=40),
81-
height=350,
82-
)
72+
yaxis=dict(zeroline=False, title='Total Expense (£)',),
73+
xaxis=dict(zeroline=False, title='Date', tickangle=0),
74+
margin=dict(t=20, b=50, l=50, r=40),
75+
height=350,
76+
)
8377

8478

8579
fig = dict(data=data, layout=layout)
8680
line_graph = dcc.Graph(id='line-area-graph2', figure=fig, style={'display':'inline-block', 'width':'100%',
87-
'height': '100%;'} )
81+
'height':'100%;'} )
8882
children = [line_graph]
8983

9084
return children

demo/demo/views.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
from django.shortcuts import render
66

7-
def dash_example_1_view(request, template_name="demo_six.html",**kwargs):
8-
7+
#pylint: disable=unused-argument
8+
9+
def dash_example_1_view(request, template_name="demo_six.html", **kwargs):
10+
'Example view that inserts content into the dash context passed to the dash application'
11+
912
context = {}
10-
13+
1114
# create some context to send over to Dash:
1215
dash_context = request.session.get("django_plotly_dash", dict())
1316
dash_context['django_to_dash_context'] = "I am Dash receiving context from Django"

0 commit comments

Comments
 (0)