From 4d6163409c4d6e99f49cadc9b1aa0d01d3c3d206 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Thu, 12 Jul 2018 10:33:11 -0400 Subject: [PATCH] [pie] improvements to pie charts (#5236) 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 `[]` (cherry picked from commit f9352af80e81a075288c89c3bf2f8852215daade) --- superset/assets/src/explore/controls.jsx | 11 +++++++++++ superset/assets/src/explore/visTypes.js | 9 +++++++-- superset/assets/src/visualizations/nvd3_vis.js | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/superset/assets/src/explore/controls.jsx b/superset/assets/src/explore/controls.jsx index 7060f320e5d80..c049dc78dc7e9 100644 --- a/superset/assets/src/explore/controls.jsx +++ b/superset/assets/src/explore/controls.jsx @@ -206,6 +206,7 @@ export const controls = { percent_metrics: { ...metrics, multi: true, + default: [], label: t('Percentage Metrics'), default: [], validators: [], @@ -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'), diff --git a/superset/assets/src/explore/visTypes.js b/superset/assets/src/explore/visTypes.js index b0037ec5f496c..91fe89cbfa865 100644 --- a/superset/assets/src/explore/visTypes.js +++ b/superset/assets/src/explore/visTypes.js @@ -142,7 +142,7 @@ export const visTypes = { ['metric'], ['adhoc_filters'], ['groupby'], - ['limit'], + ['row_limit'], ], }, { @@ -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: { diff --git a/superset/assets/src/visualizations/nvd3_vis.js b/superset/assets/src/visualizations/nvd3_vis.js index 4619d4ddbf234..e8f7e92937076 100644 --- a/superset/assets/src/visualizations/nvd3_vis.js +++ b/superset/assets/src/visualizations/nvd3_vis.js @@ -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') {