Skip to content

Commit

Permalink
Merge pull request #105 from wkerl/custom_y_range
Browse files Browse the repository at this point in the history
possibility to adjust the y-axis range
  • Loading branch information
areski committed Jan 4, 2016
2 parents 0f3fc07 + 1c71935 commit 5604f2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nvd3/NVD3Chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def __init__(self, **kwargs):
Signal that x axis is a date axis
:keyword: **date_format** - default - ``%x``
see https://github.com/mbostock/d3/wiki/Time-Formatting
:keyword: **y_axis_scale_min** - default - ``''``.
:keyword: **y_axis_scale_max** - default - ``''``.
:keyword: **x_axis_format** - default - ``''``.
:keyword: **y_axis_format** - default - ``''``.
:keyword: **style** - default - ``''``
Expand Down Expand Up @@ -135,6 +137,8 @@ def __init__(self, **kwargs):
self.style = kwargs.get('style', '')
self.date_format = kwargs.get('date_format', '%x')
self.x_axis_date = kwargs.get('x_axis_date', False)
self.y_axis_scale_min = kwargs.get('y_axis_scale_min', '')
self.y_axis_scale_max = kwargs.get('y_axis_scale_max', '')
#: x-axis contain date format or not
# possible duplicate of x_axis_date
self.date_flag = kwargs.get('date_flag', False)
Expand Down
6 changes: 6 additions & 0 deletions nvd3/templates/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@

{% endblock custoattr %}

{% block y_axis_scale %}
{% if chart.y_axis_scale_min or chart.y_axis_scale_max %}
chart.forceY([{{ chart.y_axis_scale_min }},{{ chart.y_axis_scale_max }}]);
{% endif %}
{% endblock y_axis_scale %}

{% block inject %}
{# Inject data to D3 #}
d3.select('#{{ chart.name }} svg')
Expand Down

0 comments on commit 5604f2e

Please sign in to comment.