Skip to content

Commit

Permalink
Merge 258c3ba into 8c1c1fa
Browse files Browse the repository at this point in the history
  • Loading branch information
quetzaluz committed Jan 5, 2018
2 parents 8c1c1fa + 258c3ba commit 9862c3c
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 3 deletions.
2 changes: 2 additions & 0 deletions nvd3/NVD3Chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def __init__(self, **kwargs):
:keyword: **xAxis_rotateLabel** - default - ``0``
:keyword: **xAxis_staggerLabel** - default - ``False``
:keyword: **xAxis_showMaxMin** - default - ``True``
:keyword: **right_align_y_axis** - default - ``False``
:keyword: **show_controls** - default - ``True``
:keyword: **show_legend** - default - ``True``
:keyword: **show_labels** - default - ``True``
Expand Down Expand Up @@ -132,6 +133,7 @@ def __init__(self, **kwargs):
self.xAxis_rotateLabel = kwargs.get('xAxis_rotateLabel', 0)
self.xAxis_staggerLabel = kwargs.get('xAxis_staggerLabel', False)
self.xAxis_showMaxMin = kwargs.get('xAxis_showMaxMin', True)
self.right_align_y_axis = kwargs.get('right_align_y_axis', False)
self.show_controls = kwargs.get('show_controls', True)
self.show_legend = kwargs.get('show_legend', True)
self.show_labels = kwargs.get('show_labels', True)
Expand Down
6 changes: 3 additions & 3 deletions nvd3/templates/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{% block init %}
nv.addGraph(function() {
var chart = nv.models.{{ chart.model }}(){% if chart.use_interactive_guideline %}.useInteractiveGuideline(true){% endif %}{% if not chart.show_controls %}.showControls(false){% endif %};
var chart = nv.models.{{ chart.model }}(){% if chart.use_interactive_guideline %}.useInteractiveGuideline(true){% endif %}{% if not chart.show_controls %}.showControls(false){% endif %}{% if chart.right_align_y_axis %}.rightAlignYAxis(true){% endif %};

chart.margin({top: {{ chart.margin_top }}, right: {{ chart.margin_right }}, bottom: {{ chart.margin_bottom }}, left: {{ chart.margin_left }}});
chart.xAxis.rotateLabels({{chart.xAxis_rotateLabel}})
Expand All @@ -25,18 +25,18 @@
{% endif %}
{% endblock init %}

{% block rendering_opts %}
{% if chart.stacked %}
chart.stacked(true);
{% endif %}

{% if chart.no_data_message %}
chart.noData('{{chart.no_data_message}}')
{% endif %}


{% if chart.show_controls == False %}
chart.showControls(false);
{% endif %}
{% endblock rendering_opts %}

{% block focus %}
{% endblock focus %}
Expand Down
4 changes: 4 additions & 0 deletions nvd3/templates/discretebarchart.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
{{super()}}
{% endblock init %}

{% block rendering_opts %}
{{super()}}
{% endblock rendering_opts %}

{% block axes %}
{{super()}}
{% endblock axes %}
Expand Down
3 changes: 3 additions & 0 deletions nvd3/templates/linebarwfocuschart.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
{% block init %}
{{super()}}
{% endblock init %}
{% block rendering_opts %}
{{super()}}
{% endblock rendering_opts %}
{% block axes %}
{{super()}}
{% endblock axes %}
Expand Down
4 changes: 4 additions & 0 deletions nvd3/templates/linechart.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
{{super()}}
{% endblock init %}

{% block rendering_opts %}
{{super()}}
{% endblock rendering_opts %}

{% block axes %}
{{super()}}
{% endblock axes %}
Expand Down
4 changes: 4 additions & 0 deletions nvd3/templates/multichart.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
{{super()}}
{% endblock init %}

{% block rendering_opts %}
{{super()}}
{% endblock rendering_opts %}

{% block axes %}
{{super()}}
{% endblock axes %}
Expand Down
4 changes: 4 additions & 0 deletions nvd3/templates/scatterchart.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
{{super()}}
{% endblock init %}

{% block rendering_opts %}
{{super()}}
{% endblock rendering_opts %}

{% block axes %}
{{super()}}
{% endblock axes %}
Expand Down
25 changes: 25 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from nvd3 import discreteBarChart
from nvd3 import pieChart
from nvd3 import multiBarChart
from nvd3 import multiChart
from nvd3 import bulletChart
from nvd3.NVD3Chart import stab
from nvd3.translator import Function, AnonymousFunction, Assignment
Expand Down Expand Up @@ -120,6 +121,30 @@ def test_MultiBarChart(self):
chart.add_serie(y=ydata, x=xdata, extra=extra)
chart.buildhtml()

def test_multiChart(self):
"""Test Multi (line plus bar) Chart"""
type = "multiChart"
chart = multiChart(
name=type, x_is_date=False, x_axis_format="AM_PM",
no_data_message='custom message shows when there is no data',
xAxis_staggerLabel=True
)

xdata = [1,2,3,4,5,6]
ydata = [115.5,160.5,108,145.5,84,70.5]
ydata2 = [48624,42944,43439,24194,38440,31651]
kwargs1 = {'color': 'brown'}
kwargs2 = {'color': '#bada55'}
extra_serie = {"tooltip": {"y_start": "There is ", "y_end": " calls"}}
chart.add_serie(y=ydata, x=xdata, type='line', yaxis=1, name='visits', extra=extra_serie, **kwargs1)
extra_serie = {"tooltip": {"y_start": "", "y_end": " at this point"}}
chart.add_serie(y=ydata2, x=xdata, type='bar', yaxis=2,name='spend', extra=extra_serie, **kwargs2)
chart.buildhtml()

assert("chart.noData('custom message shows when there is no data')" in chart.htmlcontent)
assert("function get_am_pm" in chart.htmlcontent)


def test_multiBarHorizontalChart(self):
"""Test multi Bar Horizontal Chart"""
type = "multiBarHorizontalChart"
Expand Down

0 comments on commit 9862c3c

Please sign in to comment.