Skip to content

Commit

Permalink
Merge pull request apache#95 from john-bodley/john-bodley-cherry-pick…
Browse files Browse the repository at this point in the history
…-5236

[pie] improvements to pie charts (apache#5236)
  • Loading branch information
john-bodley authored Aug 20, 2018
2 parents 64e8e0d + f8b6bef commit c7c6f68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions superset/assets/src/explore/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export const controls = {
percent_metrics: {
...metrics,
multi: true,
default: [],
label: t('Percentage Metrics'),
validators: [],
description: t('Metrics for which percentage of total are to be displayed'),
Expand Down Expand Up @@ -1444,6 +1445,16 @@ export const controls = {
description: t('Whether to display the legend (toggles)'),
},

show_labels: {
type: 'CheckboxControl',
label: t('Show Labels'),
renderTrigger: true,
default: true,
description: t(
'Whether to display the labels. Note that the label only displays when the the 5% ' +
'threshold.'),
},

show_values: {
type: 'CheckboxControl',
label: t('Show Values'),
Expand Down
9 changes: 7 additions & 2 deletions superset/assets/src/explore/visTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const visTypes = {
['metric'],
['adhoc_filters'],
['groupby'],
['limit'],
['row_limit'],
],
},
{
Expand All @@ -155,11 +155,16 @@ export const visTypes = {
controlSetRows: [
['pie_label_type'],
['donut', 'show_legend'],
['labels_outside'],
['show_labels', 'labels_outside'],
['color_scheme'],
],
},
],
controlOverrides: {
row_limit: {
default: 25,
},
},
},

line: {
Expand Down
1 change: 1 addition & 0 deletions superset/assets/src/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export default function nvd3Vis(slice, payload) {
if (fd.donut) {
chart.donut(true);
}
chart.showLabels(fd.show_labels);
chart.labelsOutside(fd.labels_outside);
chart.labelThreshold(0.05); // Configure the minimum slice size for labels to show up
if (fd.pie_label_type !== 'key_percent' && fd.pie_label_type !== 'key_value') {
Expand Down

0 comments on commit c7c6f68

Please sign in to comment.