Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Cherry-pick(s): Bugfix multi-line chart and icon + unit test #87

Merged
merged 5 commits into from
Aug 15, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ describe('DisplayQueryButton', () => {
},
chartStatus: 'success',
queryEndpoint: 'localhost',
latestQueryFormData: {
datasource: '1__table',
},
};

it('is valid', () => {
Expand Down
2 changes: 2 additions & 0 deletions superset/assets/src/explore/components/DisplayQueryButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ const defaultProps = {
export default class DisplayQueryButton extends React.PureComponent {
constructor(props) {
super(props);
const { datasource } = props.latestQueryFormData;
this.state = {
language: null,
query: null,
isLoading: false,
error: null,
sqlSupported: datasource && datasource.split('__')[1] === 'table',
};
this.beforeOpen = this.beforeOpen.bind(this);
this.fetchQuery = this.fetchQuery.bind(this);
Expand Down
11 changes: 2 additions & 9 deletions superset/assets/src/explore/visTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,14 @@ export const visTypes = {
},
},
sectionOverrides: {
datasourceAndVizType: {
label: t('Chart Type'),
controlSetRows: [
['viz_type'],
['slice_id', 'cache_timeout'],
],
},
sqlaTimeSeries: {
controlSetRows: [
['since', 'until'],
['time_range'],
],
},
druidTimeSeries: {
controlSetRows: [
['since', 'until'],
['time_range'],
],
},
},
Expand Down
25 changes: 11 additions & 14 deletions superset/assets/src/visualizations/line_multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ export default function lineMulti(slice, payload) {
const fd = slice.formData;

// fetch data from all the charts
const promises = [];
const subslices = [
...payload.data.slices.axis1.map(subslice => [1, subslice]),
...payload.data.slices.axis2.map(subslice => [2, subslice]),
];
subslices.forEach(([yAxis, subslice]) => {
const promises = subslices.map(([yAxis, subslice]) => {
let filters = subslice.form_data.filters || [];
filters.concat(fd.filters);
if (fd.extra_filters) {
Expand All @@ -26,27 +25,25 @@ export default function lineMulti(slice, payload) {
const fdCopy = {
...subslice.form_data,
filters,
since: fd.since,
until: fd.until,
time_range: fd.time_range,
};
const url = getExploreLongUrl(fdCopy, 'json');
promises.push(new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
d3.json(url, (error, response) => {
if (error) {
reject(error);
} else {
const data = [];
response.data.forEach((datum) => {
let key = datum.key;
if (fd.prefix_metric_with_slice_name) {
key = subslice.slice_name + ': ' + key;
}
data.push({ key, values: datum.values, type: fdCopy.viz_type, yAxis });
});
const addPrefix = fd.prefix_metric_with_slice_name;
const data = response.data.map(({ key, values }) => ({
key: addPrefix ? `${subslice.slice_name}: ${key}` : key,
type: fdCopy.viz_type,
values,
yAxis,
}));
resolve(data);
}
});
}));
});
});

Promise.all(promises).then((data) => {
Expand Down
2 changes: 1 addition & 1 deletion superset/connectors/sqla/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def refresh(self, tables):
'Tables',
label=__('Tables'),
href='/tablemodelview/list/?_flt_1_is_sqllab_view=y',
icon='fa-upload',
icon='fa-table',
category='Sources',
category_label=__('Sources'),
category_icon='fa-table')
Expand Down