You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2018/08/01 18:54:09 UTC
[incubator-superset] branch master updated: Annotation Styles for
Time Series Annotations (#5437)
This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 9831730 Annotation Styles for Time Series Annotations (#5437)
9831730 is described below
commit 98317303518b084faeeb56b97f259a5de212e4b7
Author: JamshedRahman <31...@users.noreply.github.com>
AuthorDate: Wed Aug 1 11:54:03 2018 -0700
Annotation Styles for Time Series Annotations (#5437)
---
.../components/controls/AnnotationLayer.jsx | 30 ++++++++++++++++++++--
superset/assets/src/visualizations/nvd3_vis.js | 9 ++++++-
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/superset/assets/src/explore/components/controls/AnnotationLayer.jsx b/superset/assets/src/explore/components/controls/AnnotationLayer.jsx
index 875b959..6cb2f2d 100644
--- a/superset/assets/src/explore/components/controls/AnnotationLayer.jsx
+++ b/superset/assets/src/explore/components/controls/AnnotationLayer.jsx
@@ -36,6 +36,8 @@ const propTypes = {
opacity: PropTypes.string,
style: PropTypes.string,
width: PropTypes.number,
+ showMarkers: PropTypes.bool,
+ hideLine: PropTypes.bool,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
overrides: PropTypes.object,
show: PropTypes.bool,
@@ -61,6 +63,8 @@ const defaultProps = {
opacity: '',
style: 'solid',
width: 1,
+ showMarkers: false,
+ hideLine: false,
overrides: {},
colorScheme: 'd3Category10',
show: true,
@@ -78,7 +82,7 @@ export default class AnnotationLayer extends React.PureComponent {
constructor(props) {
super(props);
const { name, annotationType, sourceType,
- color, opacity, style, width, value,
+ color, opacity, style, width, showMarkers, hideLine, value,
overrides, show, titleColumn, descriptionColumns,
timeColumn, intervalEndColumn } = props;
this.state = {
@@ -100,6 +104,8 @@ export default class AnnotationLayer extends React.PureComponent {
opacity,
style,
width,
+ showMarkers,
+ hideLine,
// refData
isNew: !this.props.name,
isLoadingOptions: true,
@@ -469,7 +475,7 @@ export default class AnnotationLayer extends React.PureComponent {
}
renderDisplayConfiguration() {
- const { color, opacity, style, width } = this.state;
+ const { color, opacity, style, width, showMarkers, hideLine, annotationType } = this.state;
const colorScheme = [...ALL_COLOR_SCHEMES[this.props.colorScheme]];
if (color && color !== AUTOMATIC_COLOR &&
!colorScheme.find(x => x.toLowerCase() === color.toLowerCase())) {
@@ -533,6 +539,26 @@ export default class AnnotationLayer extends React.PureComponent {
value={width}
onChange={v => this.setState({ width: v })}
/>
+ {annotationType === AnnotationTypes.TIME_SERIES &&
+ <CheckboxControl
+ hovered
+ name="annotation-layer-show-markers"
+ label="Show Markers"
+ description={'Shows or hides markers for the time series'}
+ value={showMarkers}
+ onChange={v => this.setState({ showMarkers: v })}
+ />
+ }
+ {annotationType === AnnotationTypes.TIME_SERIES &&
+ <CheckboxControl
+ hovered
+ name="annotation-layer-hide-line"
+ label="Hide Line"
+ description={'Hides the Line for the time series'}
+ value={hideLine}
+ onChange={v => this.setState({ hideLine: v })}
+ />
+ }
</PopoverSection>
);
}
diff --git a/superset/assets/src/visualizations/nvd3_vis.js b/superset/assets/src/visualizations/nvd3_vis.js
index 199fa04..4dcdb40 100644
--- a/superset/assets/src/visualizations/nvd3_vis.js
+++ b/superset/assets/src/visualizations/nvd3_vis.js
@@ -623,7 +623,7 @@ export default function nvd3Vis(slice, payload) {
key,
color: a.color,
strokeWidth: a.width,
- classed: `${a.opacity} ${a.style}`,
+ classed: `${a.opacity} ${a.style} nv-timeseries-annotation-layer showMarkers${a.showMarkers} hideLine${a.hideLine}`,
};
})), []);
data.push(...timeSeriesAnnotations);
@@ -854,6 +854,13 @@ export default function nvd3Vis(slice, payload) {
.attr('height', height)
.attr('width', width)
.call(chart);
+
+ // Display styles for Time Series Annotations
+ d3.selectAll('.slice_container .nv-timeseries-annotation-layer.showMarkerstrue .nv-point')
+ .style('stroke-opacity', 1)
+ .style('fill-opacity', 1);
+ d3.selectAll('.slice_container .nv-timeseries-annotation-layer.hideLinetrue')
+ .style('stroke-width', 0);
}
}