Skip to content

Commit f33b2ab

Browse files
committed
Add message to traces with no opacity
1 parent a10137f commit f33b2ab

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

src/components/containers/Section.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ import Info from '../fields/Info';
22
import MenuPanel from './MenuPanel';
33
import React, {Component, cloneElement} from 'react';
44
import PropTypes from 'prop-types';
5-
import unpackPlotProps from 'lib/unpackPlotProps';
6-
import {containerConnectedContextTypes} from 'lib/connectToContainer';
5+
import {
6+
containerConnectedContextTypes,
7+
localize,
8+
unpackPlotProps,
9+
} from '../../lib';
710

8-
export default class Section extends Component {
11+
class Section extends Component {
912
constructor(props, context) {
1013
super(props, context);
1114

@@ -21,6 +24,8 @@ export default class Section extends Component {
2124
}
2225

2326
processAndSetChildren(nextProps, nextContext) {
27+
const {fullContainer} = nextContext;
28+
const {localize: _} = nextProps;
2429
this.sectionVisible = false;
2530

2631
const children = React.Children.toArray(nextProps.children);
@@ -47,6 +52,21 @@ export default class Section extends Component {
4752
let newProps = {};
4853
if (child.plotProps) {
4954
plotProps = child.plotProps;
55+
} else if (
56+
fullContainer.type === 'scatter' &&
57+
!fullContainer.opacity &&
58+
child.props.attr === 'opacity'
59+
) {
60+
this.sectionVisible = true;
61+
const child = (
62+
<Info>
63+
{_(
64+
'Trace opacity is not supported for a scatter trace with fill ' +
65+
'or for a scatter trace that gets filled by another scatter trace.'
66+
)}
67+
</Info>
68+
);
69+
this.children.push(child);
5070
} else if (isAttr) {
5171
if (child.type.supplyPlotProps) {
5272
plotProps = child.type.supplyPlotProps(child.props, nextContext);
@@ -94,3 +114,4 @@ Section.propTypes = {
94114
};
95115

96116
Section.contextTypes = containerConnectedContextTypes;
117+
export default localize(Section);

src/lib/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import bem from './bem';
22
import connectAnnotationToLayout from './connectAnnotationToLayout';
33
import connectAxesToLayout from './connectAxesToLayout';
44
import connectLayoutToPlot, {getLayoutContext} from './connectLayoutToPlot';
5-
import connectToContainer from './connectToContainer';
5+
import connectToContainer, {
6+
containerConnectedContextTypes,
7+
} from './connectToContainer';
68
import connectTraceToPlot from './connectTraceToPlot';
79
import dereference from './dereference';
810
import findFullTraceIndex from './findFullTraceIndex';
@@ -37,6 +39,7 @@ export {
3739
connectLayoutToPlot,
3840
connectToContainer,
3941
connectTraceToPlot,
42+
containerConnectedContextTypes,
4043
customTraceToPlotlyTrace,
4144
dereference,
4245
findFullTraceIndex,

src/styles/components/fields/_field.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@
5353
}
5454
}
5555

56-
&__delete{
56+
&__delete {
5757
display: flex;
5858
align-items: center;
5959
justify-content: center;
6060
padding-left: var(--spacing-quarter-unit);
6161
opacity: 0.5;
62-
svg{
62+
svg {
6363
display: block;
64-
path{
65-
fill: var(--color-text-base)
64+
path {
65+
fill: var(--color-text-base);
6666
}
6767
}
68-
&:hover{
68+
&:hover {
6969
cursor: pointer;
7070
opacity: 1;
71-
svg{
72-
path{
73-
fill: var(--color-sienna)
71+
svg {
72+
path {
73+
fill: var(--color-sienna);
7474
}
7575
}
7676
}

0 commit comments

Comments
 (0)