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

Override time grain in annotations #5084

Merged
merged 1 commit into from
May 30, 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
4 changes: 4 additions & 0 deletions superset/assets/src/chart/chartAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -427,6 +427,29 @@ export default class AnnotationLayer extends React.PureComponent {
}
}}
/>
<CheckboxControl
hovered
name="annotation-override-timegrain"
label="Override time grain"
description={`This controls whether the time grain field from the current
view should be passed down to the chart containing the annotation data.`}
value={!!Object.keys(overrides).find(x => 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 } });
}
}}
/>
<TextControl
hovered
name="annotation-layer-timeshift"
Expand Down