@@ -2,10 +2,13 @@ import Info from '../fields/Info';
22import MenuPanel from './MenuPanel' ;
33import React , { Component , cloneElement } from 'react' ;
44import 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,12 +24,23 @@ 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 ) ;
2732 this . children = [ ] ;
2833 let menuPanel = null ;
2934
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+
3044 for ( let i = 0 ; i < children . length ; i ++ ) {
3145 const child = children [ i ] ;
3246 if ( ! child ) {
@@ -47,6 +61,17 @@ export default class Section extends Component {
4761 let newProps = { } ;
4862 if ( child . plotProps ) {
4963 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 ) ;
5075 } else if ( isAttr ) {
5176 if ( child . type . supplyPlotProps ) {
5277 plotProps = child . type . supplyPlotProps ( child . props , nextContext ) ;
@@ -94,3 +119,4 @@ Section.propTypes = {
94119} ;
95120
96121Section . contextTypes = containerConnectedContextTypes ;
122+ export default localize ( Section ) ;
0 commit comments