@@ -2,7 +2,6 @@ import React, {Component} from 'react';
22import PropTypes from 'prop-types' ;
33import nestedProperty from 'plotly.js/src/lib/nested_property' ;
44import {
5- findFullTraceIndex ,
65 getDisplayName ,
76 plotlyTraceToCustomTrace ,
87 renderTraceIcon ,
@@ -29,29 +28,23 @@ export default function connectTraceToPlot(WrappedComponent) {
2928 const { data, fullData, plotly} = context ;
3029
3130 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+ }
5138 }
5239
5340 this . childContext = {
54- getValObject,
41+ getValObject : attr =>
42+ plotly
43+ ? plotly . PlotSchema . getTraceValObject (
44+ fullTrace ,
45+ nestedProperty ( { } , attr ) . parts
46+ )
47+ : null ,
5548 updateContainer : this . updateTrace ,
5649 deleteContainer : this . deleteTrace ,
5750 container : trace ,
0 commit comments