forked from ukosuagwu/python-nvd3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpiechart.html
More file actions
100 lines (80 loc) · 2.82 KB
/
Copy pathpiechart.html
File metadata and controls
100 lines (80 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{# 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 %}