Skip to content

Commit

Permalink
[pie] improvements to pie charts (apache#5236)
Browse files Browse the repository at this point in the history
Pie chart was using `limit` instead of `row_limit` which didn't work.

Also set a lower default limit to 25 to prevent the chart from getting
super crowded.

Unrelated drive-by fix of setting "percentage metric" to default to `[]`
  • Loading branch information
mistercrunch committed Aug 12, 2018
1 parent e1c1b39 commit bef106a
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 @@ -206,6 +206,7 @@ export const controls = {
percent_metrics: {
...metrics,
multi: true,
default: [],
label: t('Percentage Metrics'),
default: [],
validators: [],
Expand Down Expand Up @@ -1447,6 +1448,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.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const visTypes = {
['metric'],
['adhoc_filters'],
['groupby'],
['limit'],
['row_limit'],
],
},
{
Expand All @@ -151,11 +151,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 @@ -272,6 +272,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 bef106a

Please sign in to comment.