mirror of
https://github.com/apache/superset.git
synced 2026-08-12 11:11:01 +00:00
chore: clean up mixed-timeseries chart (#1352)
This commit is contained in:
+4
-35
@@ -16,13 +16,8 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import {
|
||||
buildQueryContext,
|
||||
getMetricLabel,
|
||||
QueryFormData,
|
||||
QueryObject,
|
||||
normalizeOrderBy,
|
||||
} from '@superset-ui/core';
|
||||
import { buildQueryContext, QueryFormData, QueryObject, normalizeOrderBy } from '@superset-ui/core';
|
||||
import { pivotOperator } from '@superset-ui/chart-controls';
|
||||
|
||||
export default function buildQuery(formData: QueryFormData) {
|
||||
const {
|
||||
@@ -61,45 +56,19 @@ export default function buildQuery(formData: QueryFormData) {
|
||||
};
|
||||
|
||||
const queryContextA = buildQueryContext(formData1, baseQueryObject => {
|
||||
const metricLabels = (baseQueryObject.metrics || []).map(getMetricLabel);
|
||||
const queryObjectA = {
|
||||
...baseQueryObject,
|
||||
is_timeseries: true,
|
||||
post_processing: [
|
||||
{
|
||||
operation: 'pivot',
|
||||
options: {
|
||||
index: ['__timestamp'],
|
||||
columns: formData1.columns || [],
|
||||
// Create 'dummy' sum aggregates to assign cell values in pivot table
|
||||
aggregates: Object.fromEntries(
|
||||
metricLabels.map(metric => [metric, { operator: 'sum' }]),
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
post_processing: [pivotOperator(formData1, { ...baseQueryObject, is_timeseries: true })],
|
||||
} as QueryObject;
|
||||
return [normalizeOrderBy(queryObjectA)];
|
||||
});
|
||||
|
||||
const queryContextB = buildQueryContext(formData2, baseQueryObject => {
|
||||
const metricLabels = (baseQueryObject.metrics || []).map(getMetricLabel);
|
||||
const queryObjectB = {
|
||||
...baseQueryObject,
|
||||
is_timeseries: true,
|
||||
post_processing: [
|
||||
{
|
||||
operation: 'pivot',
|
||||
options: {
|
||||
index: ['__timestamp'],
|
||||
columns: formData2.columns || [],
|
||||
// Create 'dummy' sum aggregates to assign cell values in pivot table
|
||||
aggregates: Object.fromEntries(
|
||||
metricLabels.map(metric => [metric, { operator: 'sum' }]),
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
post_processing: [pivotOperator(formData2, { ...baseQueryObject, is_timeseries: true })],
|
||||
} as QueryObject;
|
||||
return [normalizeOrderBy(queryObjectB)];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user