Skip to content

Commit 258c3ba

Browse files
committed
Add test coverage for multiChart; ensure more chart types can inherit
rendering options like show_controls and no_data_message
1 parent d095eaf commit 258c3ba

7 files changed

Lines changed: 46 additions & 2 deletions

File tree

‎nvd3/templates/content.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
{% endif %}
2626
{% endblock init %}
2727

28+
{% block rendering_opts %}
2829
{% if chart.stacked %}
2930
chart.stacked(true);
3031
{% endif %}
3132

3233
{% if chart.no_data_message %}
3334
chart.noData('{{chart.no_data_message}}')
3435
{% endif %}
35-
36-
3736
{% if chart.show_controls == False %}
3837
chart.showControls(false);
3938
{% endif %}
39+
{% endblock rendering_opts %}
4040

4141
{% block focus %}
4242
{% endblock focus %}

‎nvd3/templates/discretebarchart.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
{{super()}}
1313
{% endblock init %}
1414

15+
{% block rendering_opts %}
16+
{{super()}}
17+
{% endblock rendering_opts %}
18+
1519
{% block axes %}
1620
{{super()}}
1721
{% endblock axes %}

‎nvd3/templates/linebarwfocuschart.html‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
{% block init %}
1212
{{super()}}
1313
{% endblock init %}
14+
{% block rendering_opts %}
15+
{{super()}}
16+
{% endblock rendering_opts %}
1417
{% block axes %}
1518
{{super()}}
1619
{% endblock axes %}

‎nvd3/templates/linechart.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
{{super()}}
1313
{% endblock init %}
1414

15+
{% block rendering_opts %}
16+
{{super()}}
17+
{% endblock rendering_opts %}
18+
1519
{% block axes %}
1620
{{super()}}
1721
{% endblock axes %}

‎nvd3/templates/multichart.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
{{super()}}
1313
{% endblock init %}
1414

15+
{% block rendering_opts %}
16+
{{super()}}
17+
{% endblock rendering_opts %}
18+
1519
{% block axes %}
1620
{{super()}}
1721
{% endblock axes %}

‎nvd3/templates/scatterchart.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
{{super()}}
1313
{% endblock init %}
1414

15+
{% block rendering_opts %}
16+
{{super()}}
17+
{% endblock rendering_opts %}
18+
1519
{% block axes %}
1620
{{super()}}
1721
{% endblock axes %}

‎tests.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from nvd3 import discreteBarChart
1212
from nvd3 import pieChart
1313
from nvd3 import multiBarChart
14+
from nvd3 import multiChart
1415
from nvd3 import bulletChart
1516
from nvd3.NVD3Chart import stab
1617
from nvd3.translator import Function, AnonymousFunction, Assignment
@@ -120,6 +121,30 @@ def test_MultiBarChart(self):
120121
chart.add_serie(y=ydata, x=xdata, extra=extra)
121122
chart.buildhtml()
122123

124+
def test_multiChart(self):
125+
"""Test Multi (line plus bar) Chart"""
126+
type = "multiChart"
127+
chart = multiChart(
128+
name=type, x_is_date=False, x_axis_format="AM_PM",
129+
no_data_message='custom message shows when there is no data',
130+
xAxis_staggerLabel=True
131+
)
132+
133+
xdata = [1,2,3,4,5,6]
134+
ydata = [115.5,160.5,108,145.5,84,70.5]
135+
ydata2 = [48624,42944,43439,24194,38440,31651]
136+
kwargs1 = {'color': 'brown'}
137+
kwargs2 = {'color': '#bada55'}
138+
extra_serie = {"tooltip": {"y_start": "There is ", "y_end": " calls"}}
139+
chart.add_serie(y=ydata, x=xdata, type='line', yaxis=1, name='visits', extra=extra_serie, **kwargs1)
140+
extra_serie = {"tooltip": {"y_start": "", "y_end": " at this point"}}
141+
chart.add_serie(y=ydata2, x=xdata, type='bar', yaxis=2,name='spend', extra=extra_serie, **kwargs2)
142+
chart.buildhtml()
143+
144+
assert("chart.noData('custom message shows when there is no data')" in chart.htmlcontent)
145+
assert("function get_am_pm" in chart.htmlcontent)
146+
147+
123148
def test_multiBarHorizontalChart(self):
124149
"""Test multi Bar Horizontal Chart"""
125150
type = "multiBarHorizontalChart"

0 commit comments

Comments
 (0)