mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
Let the user decide the label type of pie charts (#819)
This commit is contained in:
committed by
Maxime Beauchemin
parent
1101de5ae4
commit
29e3dd404d
@@ -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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1175,7 +1175,9 @@ class DistributionPieViz(NVD3Viz):
|
||||
'fields': (
|
||||
'metrics', 'groupby',
|
||||
'limit',
|
||||
'pie_label_type',
|
||||
('donut', 'show_legend'),
|
||||
'labels_outside',
|
||||
)
|
||||
},)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user