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

Annotation Styles for Time Series Annotations #5437

Merged
merged 1 commit into from
Aug 1, 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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -61,6 +63,8 @@ const defaultProps = {
opacity: '',
style: 'solid',
width: 1,
showMarkers: false,
hideLine: false,
overrides: {},
colorScheme: 'd3Category10',
show: true,
Expand All @@ -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 = {
Expand All @@ -100,6 +104,8 @@ export default class AnnotationLayer extends React.PureComponent {
opacity,
style,
width,
showMarkers,
hideLine,
// refData
isNew: !this.props.name,
isLoadingOptions: true,
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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>
);
}
Expand Down
9 changes: 8 additions & 1 deletion superset/assets/src/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,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);
Expand Down Expand Up @@ -842,6 +842,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);
}
}
return chart;
Expand Down