From 09f04f75ea5a22f7933ddc32ad468b9a502f6849 Mon Sep 17 00:00:00 2001 From: stephenLYZ <750188453@qq.com> Date: Mon, 1 Nov 2021 23:41:07 +0800 Subject: [PATCH 1/8] feat(explore): support always show annotation label --- docs/src/resources/openapi.json | 4 ++++ .../explore/visualizations/line.test.ts | 2 ++ .../AnnotationLayer.jsx | 22 ++++++++++++++++++- superset/charts/schemas.py | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/src/resources/openapi.json b/docs/src/resources/openapi.json index cdd51639054a4..74db2adee2b56 100644 --- a/docs/src/resources/openapi.json +++ b/docs/src/resources/openapi.json @@ -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" diff --git a/superset-frontend/cypress-base/cypress/integration/explore/visualizations/line.test.ts b/superset-frontend/cypress-base/cypress/integration/explore/visualizations/line.test.ts index 019bad7096ab5..63473a1b99cf8 100644 --- a/superset-frontend/cypress-base/cypress/integration/explore/visualizations/line.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/explore/visualizations/line.test.ts @@ -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', diff --git a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx index e6d5fbe96803a..95a499d572551 100644 --- a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx +++ b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx @@ -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,14 @@ 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 +737,14 @@ export default class AnnotationLayer extends React.PureComponent { value={!show} onChange={v => this.setState({ show: !v })} /> + this.setState({ showLabel: v })} + /> Date: Tue, 2 Nov 2021 00:57:38 +0800 Subject: [PATCH 2/8] fix: lint --- superset/charts/schemas.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py index dbfd45e9b7166..e1f7316683d0d 100644 --- a/superset/charts/schemas.py +++ b/superset/charts/schemas.py @@ -904,7 +904,10 @@ 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", required=True) + showLabel = fields.Boolean( + description="Should the label always be shown", + required=True + ) showMarkers = fields.Boolean( description="Should markers be shown. Only applies to line annotations.", required=True, From d28b9d8dd06bdc90b22a9799a7ad3595ecc8e827 Mon Sep 17 00:00:00 2001 From: stephenLYZ <750188453@qq.com> Date: Tue, 2 Nov 2021 10:56:54 +0800 Subject: [PATCH 3/8] fix: lint --- docs/src/resources/openapi.json | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/resources/openapi.json b/docs/src/resources/openapi.json index 74db2adee2b56..7913a24f6a8b9 100644 --- a/docs/src/resources/openapi.json +++ b/docs/src/resources/openapi.json @@ -205,6 +205,7 @@ "required": [ "name", "show", + "showLabel", "showMarkers", "value" ], From 1961a37bf5499213f5dc73434ab09fcf30ac11bd Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Tue, 2 Nov 2021 21:38:45 -0600 Subject: [PATCH 4/8] Hopefully appeasing the linter --- superset/charts/schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py index e1f7316683d0d..b4e03bb4e3199 100644 --- a/superset/charts/schemas.py +++ b/superset/charts/schemas.py @@ -906,7 +906,7 @@ class AnnotationLayerSchema(Schema): show = fields.Boolean(description="Should the layer be shown", required=True) showLabel = fields.Boolean( description="Should the label always be shown", - required=True + required=True, ) showMarkers = fields.Boolean( description="Should markers be shown. Only applies to line annotations.", From ee96f8253c1be62bb37d386ec518a097c1906a06 Mon Sep 17 00:00:00 2001 From: stephenLYZ <750188453@qq.com> Date: Thu, 4 Nov 2021 01:22:55 +0800 Subject: [PATCH 5/8] fix: lint --- superset/charts/schemas.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py index b4e03bb4e3199..0a8309d73a9b0 100644 --- a/superset/charts/schemas.py +++ b/superset/charts/schemas.py @@ -905,8 +905,7 @@ class AnnotationLayerSchema(Schema): ) show = fields.Boolean(description="Should the layer be shown", required=True) showLabel = fields.Boolean( - description="Should the label always be shown", - required=True, + description="Should the label always be shown", required=True, ) showMarkers = fields.Boolean( description="Should markers be shown. Only applies to line annotations.", From 5b25c9d6b0bd966d9b894e4919cbf1b01f61459f Mon Sep 17 00:00:00 2001 From: Stephen Liu <750188453@qq.com> Date: Wed, 24 Nov 2021 22:24:10 +0800 Subject: [PATCH 6/8] Update superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx Co-authored-by: Geido <60598000+geido@users.noreply.github.com> --- .../controls/AnnotationLayerControl/AnnotationLayer.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx index 95a499d572551..d7d65133e9680 100644 --- a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx +++ b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx @@ -739,7 +739,7 @@ export default class AnnotationLayer extends React.PureComponent { /> Date: Mon, 29 Nov 2021 22:00:04 +0800 Subject: [PATCH 7/8] change to allow none --- superset/charts/schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py index 0a8309d73a9b0..68afafee7f666 100644 --- a/superset/charts/schemas.py +++ b/superset/charts/schemas.py @@ -905,7 +905,7 @@ class AnnotationLayerSchema(Schema): ) show = fields.Boolean(description="Should the layer be shown", required=True) showLabel = fields.Boolean( - description="Should the label always be shown", required=True, + description="Should the label always be shown", allow_none=True, ) showMarkers = fields.Boolean( description="Should markers be shown. Only applies to line annotations.", From 944860d025b5c02f41fa9ade4a2e05d8a0ef5a97 Mon Sep 17 00:00:00 2001 From: stephenLYZ <750188453@qq.com> Date: Mon, 29 Nov 2021 22:12:14 +0800 Subject: [PATCH 8/8] lint --- .../AnnotationLayerControl/AnnotationLayer.jsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx index d7d65133e9680..e12ca06cc943c 100644 --- a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx +++ b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx @@ -694,14 +694,8 @@ export default class AnnotationLayer extends React.PureComponent { } render() { - const { - isNew, - name, - annotationType, - sourceType, - show, - showLabel, - } = 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