| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- {# This template adds attributes unique
- to pieChart #}
- {% extends "content.html" %}
- {% block body %}
- data_{{ chart.name }}={{ chart.series_js|striptags }};
- nv.addGraph(function() {
- var chart = nv.models.{{ chart.model }}(){% if chart.use_interactive_guideline %}.useInteractiveGuideline(true){% endif %};
- chart.margin({top: {{ chart.margin_top }}, right: {{ chart.margin_right }}, bottom: {{ chart.margin_bottom }}, left: {{ chart.margin_left }}});
- var datum = data_{{ chart.name }}[0].values;
- {% if not chart.color_list and chart.color_category %}
- chart.color(d3.scale.{{ chart.color_category }}().range());
- {% endif %}
- chart.tooltip.contentGenerator(function(d, elem) {
- var x = String(d.data.label);
- var y = String(d.data.value);
- tooltip_str = '<center><b>'+x+'</b></center>' + y;
- return tooltip_str;
- });
- {# showLabels only supported in pieChart #}
- chart.showLabels({{chart.show_labels|lower}});
- {% if chart.donut %}
- chart.donut(true);
- chart.donutRatio({{ chart.donutRatio }});
- {% else %}
- chart.donut(false);
- {% endif %}
- chart.showLegend({{chart.show_legend|lower}});
- {# add custom chart attributes #}
- {% for attr, value in chart.chart_attr.items() %}
- {% if value is string and value.startswith(".") %}:
- chart.{{ attr }}{{ value }};
- {% else %}
- chart.{{ attr }}({{ value }});
- {% endif %}
- {% endfor %}
- {% if chart.resize %}
- nv.utils.windowResize(chart.update);
- {% endif %}
- {% if chart.color_list %}
- var mycolor = new Array();
- {% for color in chart.color_list %}
- mycolor[{{ loop.index - 1}}] = "{{ color }}";
- {% endfor %}
- {% endif %}
- chart
- .x(function(d) { return d.label })
- .y(function(d) { return d.value });
- {% if chart.width %}
- chart.width({{ chart.width }});
- {% endif %}
- {% if chart.height %}
- chart.height({{ chart.height }});
- {% endif %}
- {% if chart.color_list %}
- chart.color(mycolor);
- {% endif %}
- {% block rendering_opts %}
- {% 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 inject %}
- {{super()}}
- {% endblock inject %}
- {% block extras %}
- {# extra chart attributes #}
- {% if chart.extras %}
- {{ chart.extras }}
- {% endif %}
- {% endblock extras %}
- {% if chart.callback %}
- },{{ chart.callback }});
- {% endif %}
- {% block close %}
- {{ super() }}
- {% endblock close %}
- {% endblock body %}
|