mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
* Fix bug for line_multi * refactor forEach to map * reorder fields * fix issue with datasource
This commit is contained in:
parent
a39dfb9ff9
commit
1d7f4f282e
@ -39,13 +39,14 @@ const defaultProps = {
|
|||||||
export default class DisplayQueryButton extends React.PureComponent {
|
export default class DisplayQueryButton extends React.PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
const { datasource } = props.latestQueryFormData;
|
||||||
this.state = {
|
this.state = {
|
||||||
language: null,
|
language: null,
|
||||||
query: null,
|
query: null,
|
||||||
data: null,
|
data: null,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
error: null,
|
error: null,
|
||||||
sqlSupported: props.latestQueryFormData.datasource.split('__')[1] === 'table',
|
sqlSupported: datasource && datasource.split('__')[1] === 'table',
|
||||||
};
|
};
|
||||||
this.beforeOpen = this.beforeOpen.bind(this);
|
this.beforeOpen = this.beforeOpen.bind(this);
|
||||||
}
|
}
|
||||||
|
@ -274,21 +274,14 @@ export const visTypes = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
sectionOverrides: {
|
sectionOverrides: {
|
||||||
datasourceAndVizType: {
|
|
||||||
label: t('Chart Type'),
|
|
||||||
controlSetRows: [
|
|
||||||
['viz_type'],
|
|
||||||
['slice_id', 'cache_timeout'],
|
|
||||||
],
|
|
||||||
},
|
|
||||||
sqlaTimeSeries: {
|
sqlaTimeSeries: {
|
||||||
controlSetRows: [
|
controlSetRows: [
|
||||||
['since', 'until'],
|
['time_range'],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
druidTimeSeries: {
|
druidTimeSeries: {
|
||||||
controlSetRows: [
|
controlSetRows: [
|
||||||
['since', 'until'],
|
['time_range'],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -12,12 +12,11 @@ export default function lineMulti(slice, payload) {
|
|||||||
const fd = slice.formData;
|
const fd = slice.formData;
|
||||||
|
|
||||||
// fetch data from all the charts
|
// fetch data from all the charts
|
||||||
const promises = [];
|
|
||||||
const subslices = [
|
const subslices = [
|
||||||
...payload.data.slices.axis1.map(subslice => [1, subslice]),
|
...payload.data.slices.axis1.map(subslice => [1, subslice]),
|
||||||
...payload.data.slices.axis2.map(subslice => [2, 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 || [];
|
let filters = subslice.form_data.filters || [];
|
||||||
filters.concat(fd.filters);
|
filters.concat(fd.filters);
|
||||||
if (fd.extra_filters) {
|
if (fd.extra_filters) {
|
||||||
@ -26,27 +25,25 @@ export default function lineMulti(slice, payload) {
|
|||||||
const fdCopy = {
|
const fdCopy = {
|
||||||
...subslice.form_data,
|
...subslice.form_data,
|
||||||
filters,
|
filters,
|
||||||
since: fd.since,
|
time_range: fd.time_range,
|
||||||
until: fd.until,
|
|
||||||
};
|
};
|
||||||
const url = getExploreLongUrl(fdCopy, 'json');
|
const url = getExploreLongUrl(fdCopy, 'json');
|
||||||
promises.push(new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
d3.json(url, (error, response) => {
|
d3.json(url, (error, response) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
} else {
|
} else {
|
||||||
const data = [];
|
const addPrefix = fd.prefix_metric_with_slice_name;
|
||||||
response.data.forEach((datum) => {
|
const data = response.data.map(({ key, values }) => ({
|
||||||
let key = datum.key;
|
key: addPrefix ? `${subslice.slice_name}: ${key}` : key,
|
||||||
if (fd.prefix_metric_with_slice_name) {
|
type: fdCopy.viz_type,
|
||||||
key = subslice.slice_name + ': ' + key;
|
values,
|
||||||
}
|
yAxis,
|
||||||
data.push({ key, values: datum.values, type: fdCopy.viz_type, yAxis });
|
}));
|
||||||
});
|
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all(promises).then((data) => {
|
Promise.all(promises).then((data) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user