diff --git a/superset/assets/src/chart/chartAction.js b/superset/assets/src/chart/chartAction.js index f1112f5a8dcdd..cb24f65f14705 100644 --- a/superset/assets/src/chart/chartAction.js +++ b/superset/assets/src/chart/chartAction.js @@ -70,6 +70,10 @@ export function runAnnotationQuery(annotation, timeout = 60, formData = null, ke return Promise.resolve(); } + const granularity = fd.time_grain_sqla || fd.granularity; + fd.time_grain_sqla = granularity; + fd.granularity = granularity; + const sliceFormData = Object.keys(annotation.overrides) .reduce((d, k) => ({ ...d, diff --git a/superset/assets/src/explore/components/controls/AnnotationLayer.jsx b/superset/assets/src/explore/components/controls/AnnotationLayer.jsx index 340389072aa2a..875b95922a743 100644 --- a/superset/assets/src/explore/components/controls/AnnotationLayer.jsx +++ b/superset/assets/src/explore/components/controls/AnnotationLayer.jsx @@ -269,8 +269,8 @@ export default class AnnotationLayer extends React.PureComponent { } else { label = 'Slice'; description = `Use a pre defined Superset Slice as a source for annotations and overlays. - 'your Slice must be one of these visualization types: - '[${getSupportedSourceTypes(sourceType) + 'your chart must be one of these visualization types: + '[${getSupportedSourceTypes(annotationType) .map(x => vizTypes[x].label).join(', ')}]'`; } } else if (annotationType === AnnotationTypes.FORMULA) { @@ -400,7 +400,7 @@ export default class AnnotationLayer extends React.PureComponent { name="annotation-override-since" label="Override 'Since'" description={`This controls whether the "Since" field from the current - view should be passed down to the slice containing the annotation data.`} + view should be passed down to the chart containing the annotation data.`} value={!!Object.keys(overrides).find(x => x === 'since')} onChange={(v) => { delete overrides.since; @@ -416,7 +416,7 @@ export default class AnnotationLayer extends React.PureComponent { name="annotation-override-until" label="Override 'Until'" description={`This controls whether the "Until" field from the current - view should be passed down to the slice containing the annotation data.`} + view should be passed down to the chart containing the annotation data.`} value={!!Object.keys(overrides).find(x => x === 'until')} onChange={(v) => { delete overrides.until; @@ -427,6 +427,29 @@ export default class AnnotationLayer extends React.PureComponent { } }} /> + x === 'time_grain_sqla')} + onChange={(v) => { + delete overrides.time_grain_sqla; + delete overrides.granularity; + if (v) { + this.setState({ + overrides: { + ...overrides, + time_grain_sqla: null, + granularity: null, + }, + }); + } else { + this.setState({ overrides: { ...overrides } }); + } + }} + />