@@ -2,10 +2,13 @@ import Info from '../fields/Info';
2
2
import MenuPanel from './MenuPanel' ;
3
3
import React , { Component , cloneElement } from 'react' ;
4
4
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' ;
7
10
8
- export default class Section extends Component {
11
+ class Section extends Component {
9
12
constructor ( props , context ) {
10
13
super ( props , context ) ;
11
14
@@ -21,12 +24,23 @@ export default class Section extends Component {
21
24
}
22
25
23
26
processAndSetChildren ( nextProps , nextContext ) {
27
+ const { fullContainer} = nextContext ;
28
+ const { localize : _ } = nextProps ;
24
29
this . sectionVisible = false ;
25
30
26
31
const children = React . Children . toArray ( nextProps . children ) ;
27
32
this . children = [ ] ;
28
33
let menuPanel = null ;
29
34
35
+ /*
36
+ * show opacity disabled message for scatter traces that have a fill 'tonexty' || 'tonextx'
37
+ * based on:
38
+ * https://github.com/plotly/plotly.js/blob/master/src/traces/scatter/clean_data.js#L13
39
+ */
40
+ const cannotSetTraceOpacity =
41
+ fullContainer . type === 'scatter' &&
42
+ ( fullContainer . fill !== 'none' || fullContainer . fill !== 'toself' ) ;
43
+
30
44
for ( let i = 0 ; i < children . length ; i ++ ) {
31
45
const child = children [ i ] ;
32
46
if ( ! child ) {
@@ -47,6 +61,17 @@ export default class Section extends Component {
47
61
let newProps = { } ;
48
62
if ( child . plotProps ) {
49
63
plotProps = child . plotProps ;
64
+ } else if ( cannotSetTraceOpacity && child . props . attr === 'opacity' ) {
65
+ this . sectionVisible = true ;
66
+ const child = (
67
+ < Info >
68
+ { _ (
69
+ 'Trace opacity is not supported for a scatter trace with fill ' +
70
+ 'or for a scatter trace that gets filled by another scatter trace.'
71
+ ) }
72
+ </ Info >
73
+ ) ;
74
+ this . children . push ( child ) ;
50
75
} else if ( isAttr ) {
51
76
if ( child . type . supplyPlotProps ) {
52
77
plotProps = child . type . supplyPlotProps ( child . props , nextContext ) ;
@@ -94,3 +119,4 @@ Section.propTypes = {
94
119
} ;
95
120
96
121
Section . contextTypes = containerConnectedContextTypes ;
122
+ export default localize ( Section ) ;
0 commit comments