Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: [MIQ-2130] Fix big chart by adding LIMIT to control panel #265

Merged
merged 4 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions superset/assets/src/explore/controlPanels/BigNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* under the License.
*/
import { t } from '@superset-ui/translation';
import { ROW_LIMIT_OPTIONS } from '../controls';
import * as v from '../validators';
import { formatSelectOptions } from '../../../src/modules/utils';

export default {
controlPanelSections: [
Expand All @@ -26,6 +29,7 @@ export default {
controlSetRows: [
['metric'],
['adhoc_filters'],
['row_limit'],
],
},
{
Expand All @@ -43,5 +47,10 @@ export default {
y_axis_format: {
label: t('Number format'),
},
row_limit: {
default: 'None',
validators: [v.nonEmpty],
choices: formatSelectOptions(['None', ...ROW_LIMIT_OPTIONS])
},
},
};
9 changes: 9 additions & 0 deletions superset/assets/src/explore/controlPanels/BigNumberTotal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* under the License.
*/
import { t } from '@superset-ui/translation';
import { ROW_LIMIT_OPTIONS } from '../controls';
import * as v from '../validators';
import { formatSelectOptions } from '../../../src/modules/utils';

export default {
controlPanelSections: [
Expand All @@ -27,6 +30,7 @@ export default {
['metric'],
['percentageMetric'],
['adhoc_filters'],
['row_limit'],
],
},
{
Expand All @@ -43,6 +47,11 @@ export default {
y_axis_format: {
label: t('Number format'),
},
row_limit: {
default: 'None',
validators: [v.nonEmpty],
choices: formatSelectOptions(['None', ...ROW_LIMIT_OPTIONS])
},
percentage_format: {
label: t('Percent format'),
},
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/src/explore/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const D3_PERCENT_FORMAT_OPTIONS = [
['.3%', '.3% (12345.432 => 1234543.200%)'],
];

const ROW_LIMIT_OPTIONS = [10, 50, 100, 250, 500, 1000, 5000, 10000, 50000];
export const ROW_LIMIT_OPTIONS = [10, 50, 100, 250, 500, 1000, 5000, 10000, 50000];

const SERIES_LIMITS = [0, 5, 10, 25, 50, 100, 500];

Expand Down
14 changes: 14 additions & 0 deletions superset/assets/src/explore/visTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
*/
import React from 'react';
import { D3_TIME_FORMAT_OPTIONS } from './controls';
import { ROW_LIMIT_OPTIONS } from './controls';
import * as v from './validators';
import { t } from '../locales';
import { formatSelectOptions } from 'src/modules/utils';

export const sections = {
druidTimeSeries: {
Expand Down Expand Up @@ -1405,6 +1407,7 @@ export const visTypes = {
controlSetRows: [
['metric'],
['adhoc_filters'],
['row_limit'],
],
},
{
Expand All @@ -1421,6 +1424,11 @@ export const visTypes = {
y_axis_format: {
label: t('Number format'),
},
row_limit: {
default: 'None',
validators: [v.nonEmpty],
choices: formatSelectOptions(['None', ...ROW_LIMIT_OPTIONS])
},
},
},

Expand All @@ -1433,6 +1441,7 @@ export const visTypes = {
controlSetRows: [
['metric'],
['adhoc_filters'],
['row_limit'],
],
},
{
Expand All @@ -1448,6 +1457,11 @@ export const visTypes = {
y_axis_format: {
label: t('Number format'),
},
row_limit: {
default: 'None',
validators: [v.nonEmpty],
choices: formatSelectOptions(['None', ...ROW_LIMIT_OPTIONS])
},
},
},

Expand Down
11 changes: 10 additions & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ def query_obj(self):
)
limit = int(form_data.get('limit') or 0)
timeseries_limit_metric = form_data.get('timeseries_limit_metric')
row_limit = int(form_data.get('row_limit') or config.get('ROW_LIMIT'))
if form_data.get('row_limit') == 'None' or config.get('ROW_LIMIT') == 'None':
row_limit = form_data.get('row_limit') or config.get('ROW_LIMIT')
else:
row_limit = int(form_data.get('row_limit') or config.get('ROW_LIMIT'))

# default order direction
order_desc = form_data.get('order_desc', True)
Expand Down Expand Up @@ -1097,6 +1100,9 @@ def query_obj(self):
raise Exception(_('Pick a metric!'))
d['metrics'] = [self.form_data.get('metric')]
self.form_data['metric'] = metric
row_limit = self.form_data.get('row_limit')
if row_limit == 'None':
d['row_limit'] = None
return d


Expand All @@ -1122,6 +1128,9 @@ def query_obj(self):
d['metrics'] = [metric]

self.form_data['metric'] = metric
row_limit = self.form_data.get('row_limit')
if row_limit == 'None':
d['row_limit'] = None
return d


Expand Down