Let the user decide the label type of pie charts (#819)

This commit is contained in:
x4base 2016-07-28 13:39:29 -05:00 committed by Maxime Beauchemin
parent 1101de5ae4
commit 29e3dd404d
3 changed files with 20 additions and 2 deletions

View File

@ -117,9 +117,10 @@ function nvd3Vis(slice) {
chart.valueFormat(f);
if (fd.donut) {
chart.donut(true);
chart.labelsOutside(true);
}
chart.labelsOutside(true);
chart.labelsOutside(fd.labels_outside);
chart.labelThreshold(0.05) //Configure the minimum slice size for labels to show up
.labelType(fd.pie_label_type);
chart.cornerRadius(true);
break;

View File

@ -695,6 +695,16 @@ class FormFactory(object):
"default": 'linear',
"description": _("Line interpolation as defined by d3.js")
}),
'pie_label_type': (SelectField, {
"label": _("Label Type"),
"default": 'key',
"choices": (
('key', _("Category Name")),
('value', _("Value")),
('percent', _("Percentage")),
),
"description": _("What should be shown on the label?")
}),
'code': (TextAreaField, {
"label": _("Code"),
"description": _("Put your code here"),
@ -789,6 +799,11 @@ class FormFactory(object):
"default": False,
"description": _("Do you want a donut or a pie?")
}),
'labels_outside': (BetterBooleanField, {
"label": _("Put labels outside"),
"default": True,
"description": _("Put the labels outside the pie?")
}),
'contribution': (BetterBooleanField, {
"label": _("Contribution"),
"default": False,

View File

@ -1175,7 +1175,9 @@ class DistributionPieViz(NVD3Viz):
'fields': (
'metrics', 'groupby',
'limit',
'pie_label_type',
('donut', 'show_legend'),
'labels_outside',
)
},)