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

feat(explore): support show annotation label [ID-8] #17307

Merged
merged 10 commits into from
Dec 2, 2021
5 changes: 5 additions & 0 deletions docs/src/resources/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@
"description": "Should the layer be shown",
"type": "boolean"
},
"showLabel": {
"description": "Should the label always be shown",
"type": "boolean"
},
"showMarkers": {
"description": "Should markers be shown. Only applies to line annotations.",
"type": "boolean"
Expand Down Expand Up @@ -201,6 +205,7 @@
"required": [
"name",
"show",
"showLabel",
"showMarkers",
"value"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ describe('Visualization > Line', () => {
value: 'y=140000',
overrides: { time_range: null },
show: false,
showLabel: false,
titleColumn: '',
descriptionColumns: [],
timeColumn: '',
Expand Down Expand Up @@ -263,6 +264,7 @@ describe('Visualization > Line', () => {
value,
overrides: { time_range: null },
show: true,
showLabel: false,
titleColumn: 'ds',
descriptionColumns: ['ds'],
timeColumn: 'ds',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
overrides: PropTypes.object,
show: PropTypes.bool,
showLabel: PropTypes.bool,
titleColumn: PropTypes.string,
descriptionColumns: PropTypes.arrayOf(PropTypes.string),
timeColumn: PropTypes.string,
Expand Down Expand Up @@ -85,6 +86,7 @@ const defaultProps = {
overrides: {},
colorScheme: 'd3Category10',
show: true,
showLabel: false,
titleColumn: '',
descriptionColumns: [],
timeColumn: '',
Expand All @@ -111,6 +113,7 @@ export default class AnnotationLayer extends React.PureComponent {
value,
overrides,
show,
showLabel,
titleColumn,
descriptionColumns,
timeColumn,
Expand Down Expand Up @@ -142,6 +145,7 @@ export default class AnnotationLayer extends React.PureComponent {
value,
overrides,
show,
showLabel,
// slice
titleColumn,
descriptionColumns,
Expand Down Expand Up @@ -323,6 +327,7 @@ export default class AnnotationLayer extends React.PureComponent {
'value',
'overrides',
'show',
'showLabel',
'titleColumn',
'descriptionColumns',
'timeColumn',
Expand Down Expand Up @@ -689,7 +694,8 @@ export default class AnnotationLayer extends React.PureComponent {
}

render() {
const { isNew, name, annotationType, sourceType, show } = this.state;
const { isNew, name, annotationType, sourceType, show, showLabel } =
this.state;
const isValid = this.isValidForm();
const metadata = getChartMetadataRegistry().get(this.props.vizType);
const supportedAnnotationTypes = metadata
Expand Down Expand Up @@ -725,6 +731,14 @@ export default class AnnotationLayer extends React.PureComponent {
value={!show}
onChange={v => this.setState({ show: !v })}
/>
<CheckboxControl
name="annotation-label-show"
label={t('Show label')}
value={showLabel}
hovered
description={t('Whether to always show the annotation label')}
onChange={v => this.setState({ showLabel: v })}
/>
<SelectControl
ariaLabel={t('Annotation layer type')}
hovered
Expand Down
3 changes: 3 additions & 0 deletions superset/charts/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,9 @@ class AnnotationLayerSchema(Schema):
allow_none=True,
)
show = fields.Boolean(description="Should the layer be shown", required=True)
showLabel = fields.Boolean(
description="Should the label always be shown", allow_none=True,
)
showMarkers = fields.Boolean(
description="Should markers be shown. Only applies to line annotations.",
required=True,
Expand Down