feat(explore): support show annotation label [ID-8] (#17307)
* feat(explore): support always show annotation label * fix: lint * fix: lint * Hopefully appeasing the linter * fix: lint * Update superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx Co-authored-by: Geido <60598000+geido@users.noreply.github.com> * change to allow none * lint Co-authored-by: Evan Rusackas <evan@preset.io> Co-authored-by: Geido <60598000+geido@users.noreply.github.com>
This commit is contained in:
parent
72f3215ffc
commit
a3cce5705d
|
|
@ -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"
|
||||
|
|
@ -201,6 +205,7 @@
|
|||
"required": [
|
||||
"name",
|
||||
"show",
|
||||
"showLabel",
|
||||
"showMarkers",
|
||||
"value"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ describe('Visualization > Line', () => {
|
|||
value: 'y=140000',
|
||||
overrides: { time_range: null },
|
||||
show: false,
|
||||
showLabel: false,
|
||||
titleColumn: '',
|
||||
descriptionColumns: [],
|
||||
timeColumn: '',
|
||||
|
|
@ -263,6 +264,7 @@ describe('Visualization > Line', () => {
|
|||
value,
|
||||
overrides: { time_range: null },
|
||||
show: true,
|
||||
showLabel: false,
|
||||
titleColumn: 'ds',
|
||||
descriptionColumns: ['ds'],
|
||||
timeColumn: 'ds',
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -85,6 +86,7 @@ const defaultProps = {
|
|||
overrides: {},
|
||||
colorScheme: 'd3Category10',
|
||||
show: true,
|
||||
showLabel: false,
|
||||
titleColumn: '',
|
||||
descriptionColumns: [],
|
||||
timeColumn: '',
|
||||
|
|
@ -111,6 +113,7 @@ export default class AnnotationLayer extends React.PureComponent {
|
|||
value,
|
||||
overrides,
|
||||
show,
|
||||
showLabel,
|
||||
titleColumn,
|
||||
descriptionColumns,
|
||||
timeColumn,
|
||||
|
|
@ -142,6 +145,7 @@ export default class AnnotationLayer extends React.PureComponent {
|
|||
value,
|
||||
overrides,
|
||||
show,
|
||||
showLabel,
|
||||
// slice
|
||||
titleColumn,
|
||||
descriptionColumns,
|
||||
|
|
@ -323,6 +327,7 @@ export default class AnnotationLayer extends React.PureComponent {
|
|||
'value',
|
||||
'overrides',
|
||||
'show',
|
||||
'showLabel',
|
||||
'titleColumn',
|
||||
'descriptionColumns',
|
||||
'timeColumn',
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue