Skip to content

Commit de94891

Browse files
bind to fullInput instead of fullData
1 parent c043eac commit de94891

File tree

7 files changed

+19
-60
lines changed

7 files changed

+19
-60
lines changed

src/components/containers/TraceMarkerSection.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TraceMarkerSection extends Component {
1515

1616
setLocals(context) {
1717
const _ = this.props.localize;
18-
const traceType = context.fullContainer._fullInput.type;
18+
const traceType = context.fullContainer.type;
1919
if (['bar', 'histogram'].includes(traceType)) {
2020
this.name = _('Bars');
2121
} else {

src/components/containers/derived.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,10 @@ const TraceTypeSection = (props, context) => {
1111
const {fullContainer, fullData} = context;
1212

1313
const ifConnectedToTrace =
14-
fullContainer &&
15-
((fullContainer._fullInput &&
16-
props.traceTypes.includes(fullContainer._fullInput.type)) ||
17-
props.traceTypes.includes(fullContainer.type));
14+
fullContainer && props.traceTypes.includes(fullContainer.type);
1815

1916
const ifConnectedToLayout =
20-
fullData &&
21-
fullData.some(
22-
t =>
23-
props.traceTypes.includes(t._fullInput.type) ||
24-
fullData.some(t => props.traceTypes.includes(t.type))
25-
);
17+
fullData && fullData.some(t => props.traceTypes.includes(t.type));
2618

2719
if (ifConnectedToTrace || ifConnectedToLayout) {
2820
return <Section {...props} />;

src/components/fields/TraceSelector.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ class TraceSelector extends Component {
6868
container &&
6969
container.uid &&
7070
!container.mode &&
71-
fullContainer._fullInput &&
72-
fullContainer._fullInput.type === 'scatter'
71+
fullContainer.type === 'scatter'
7372
) {
7473
updateContainer({
7574
type: 'scatter',

src/lib/connectTraceToPlot.js

+14-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import nestedProperty from 'plotly.js/src/lib/nested_property';
44
import {
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,

src/lib/findFullTraceIndex.js

-9
This file was deleted.

src/lib/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import connectToContainer, {
1313
import {computeTraceOptionsFromSchema} from './computeTraceOptionsFromSchema';
1414
import connectTraceToPlot from './connectTraceToPlot';
1515
import dereference from './dereference';
16-
import findFullTraceIndex from './findFullTraceIndex';
1716
import getAllAxes, {
1817
axisIdToAxisName,
1918
traceTypeToAxisType,
@@ -88,7 +87,6 @@ export {
8887
computeTraceOptionsFromSchema,
8988
traceTypeToPlotlyInitFigure,
9089
dereference,
91-
findFullTraceIndex,
9290
getAllAxes,
9391
getAxisTitle,
9492
getDisplayName,

src/lib/unpackPlotProps.js

+1-15
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,7 @@ export default function unpackPlotProps(props, context) {
1414
attrMeta = context.getValObject(props.attr) || {};
1515
}
1616

17-
/*
18-
* This needed to be adjusted as financial charts
19-
* do not contain their 'true' attributes, but rather attributes of the trace
20-
* types that are used to compose them. Financial chart attributes are found in
21-
* fullContainer._fullInput
22-
*/
23-
let fullContainer = context.fullContainer;
24-
if (
25-
fullContainer &&
26-
fullContainer._fullInput &&
27-
(fullContainer._fullInput.type === 'ohlc' ||
28-
fullContainer._fullInput.type === 'candlestick')
29-
) {
30-
fullContainer = fullContainer._fullInput;
31-
}
17+
const fullContainer = context.fullContainer;
3218

3319
const fullProperty = nestedProperty(fullContainer, props.attr);
3420
let fullValue = fullProperty.get();

0 commit comments

Comments
 (0)