mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
Let the user decide the label type of pie charts (#819)
This commit is contained in:
parent
1101de5ae4
commit
29e3dd404d
@ -117,9 +117,10 @@ function nvd3Vis(slice) {
|
|||||||
chart.valueFormat(f);
|
chart.valueFormat(f);
|
||||||
if (fd.donut) {
|
if (fd.donut) {
|
||||||
chart.donut(true);
|
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);
|
chart.cornerRadius(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -695,6 +695,16 @@ class FormFactory(object):
|
|||||||
"default": 'linear',
|
"default": 'linear',
|
||||||
"description": _("Line interpolation as defined by d3.js")
|
"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, {
|
'code': (TextAreaField, {
|
||||||
"label": _("Code"),
|
"label": _("Code"),
|
||||||
"description": _("Put your code here"),
|
"description": _("Put your code here"),
|
||||||
@ -789,6 +799,11 @@ class FormFactory(object):
|
|||||||
"default": False,
|
"default": False,
|
||||||
"description": _("Do you want a donut or a pie?")
|
"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, {
|
'contribution': (BetterBooleanField, {
|
||||||
"label": _("Contribution"),
|
"label": _("Contribution"),
|
||||||
"default": False,
|
"default": False,
|
||||||
|
@ -1175,7 +1175,9 @@ class DistributionPieViz(NVD3Viz):
|
|||||||
'fields': (
|
'fields': (
|
||||||
'metrics', 'groupby',
|
'metrics', 'groupby',
|
||||||
'limit',
|
'limit',
|
||||||
|
'pie_label_type',
|
||||||
('donut', 'show_legend'),
|
('donut', 'show_legend'),
|
||||||
|
'labels_outside',
|
||||||
)
|
)
|
||||||
},)
|
},)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user