@@ -2,7 +2,6 @@ import React, {Component} from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
import nestedProperty from 'plotly.js/src/lib/nested_property' ;
4
4
import {
5
- findFullTraceIndex ,
6
5
getDisplayName ,
7
6
plotlyTraceToCustomTrace ,
8
7
renderTraceIcon ,
@@ -29,29 +28,23 @@ export default function connectTraceToPlot(WrappedComponent) {
29
28
const { data, fullData, plotly} = context ;
30
29
31
30
const trace = traceIndexes . length > 0 ? data [ traceIndexes [ 0 ] ] : { } ;
32
- const fullTraceIndex =
33
- traceIndexes . length > 0
34
- ? findFullTraceIndex ( fullData , traceIndexes [ 0 ] )
35
- : findFullTraceIndex ( fullData , 0 ) ;
36
- const fullTrace = fullData [ fullTraceIndex ] || { } ;
37
-
38
- let getValObject ;
39
- if ( plotly && fullTrace . _fullInput ) {
40
- /*
41
- * Since fullTrace._fullInput contains the _module.attributes key:
42
- * https://github.com/plotly/plotly.js/blob/70f3f70ec5b306cf74630355676f5e318f685824/src/plot_api/plot_schema.js#L241
43
- * this will work for all chart types. This needed to be adjusted as financial charts
44
- * do not contain their 'true' attributes, but rather attributes of the trace types that are used to compose them
45
- */
46
- getValObject = attr =>
47
- plotly . PlotSchema . getTraceValObject (
48
- fullTrace . _fullInput ,
49
- nestedProperty ( { } , attr ) . parts
50
- ) ;
31
+
32
+ let fullTrace = { } ;
33
+ for ( let i = 0 ; i < fullData . length ; i ++ ) {
34
+ if ( trace . uid === fullData [ i ] . _fullInput . uid ) {
35
+ fullTrace = fullData [ i ] . _fullInput ;
36
+ break ;
37
+ }
51
38
}
52
39
53
40
this . childContext = {
54
- getValObject,
41
+ getValObject : attr =>
42
+ plotly
43
+ ? plotly . PlotSchema . getTraceValObject (
44
+ fullTrace ,
45
+ nestedProperty ( { } , attr ) . parts
46
+ )
47
+ : null ,
55
48
updateContainer : this . updateTrace ,
56
49
deleteContainer : this . deleteTrace ,
57
50
container : trace ,
0 commit comments