Skip to content

Conversation

VeraZab
Copy link
Contributor

@VeraZab VeraZab commented Aug 3, 2018

Closes: #528

Here are the changes that were introduced with this pr:

  • Folds are created based on the number of traces in fullData if the useFullData flag is used on a TraceAccordion: this is done in the StyleTracesPanel

  • When the useFullData flag is used, a new prop fullDataArrayPosition is passed to the Fold, which indicates the index/indexes in the fullData array, that Fold represents (depending on whether the fold represents a single trace or a group of traces).

  • If we're using fullData in the TraceAccordion, the format of traceIndexes changes as well, in the case that we have split traces. Because split traces all refer to a single trace in the data array, in the individual style tabs, we will have more than one Fold that will have the same traceIndex. Also in the grouped tab, we could have the same index repeated many times.
    Ex:
    grouped scattered traces fold, could have:
    traceIndexes: [0, 0, 0, 1],
    fullDataArrayPosition: [0, 1, 2, 3]

  • Styling split traces, writes to their data[x].transforms[y].styles[z].value object in the individual panel AND in the grouped trace panel. In the grouped case, it wasn't enough to just write the style to the parent trace because if a style had been already present in the transforms[y].styles[z].value object, then the parent could not override it.

@VeraZab VeraZab force-pushed the color-splits branch 3 times, most recently from 051016b to f2e321f Compare August 7, 2018 15:02
@VeraZab VeraZab changed the title Color splits Style splits Aug 7, 2018
@VeraZab VeraZab force-pushed the color-splits branch 8 times, most recently from 72f9278 to 1283e97 Compare August 7, 2018 23:54
excludeFits,
} = this.props;
renderGroupedTraceFolds(groupedTraces) {
if (this.props.useFullData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge useFullData and canGroup so that you don't need this if... mostly so you can remove the else case below :)

}
},
};
return Object.keys(groupedTraces).map((traceType, index) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the "grouped but not full data" case that's never used

}

renderIndividualTraceFolds(filteredTraces, filteredTracesFullDataPositions) {
if (this.props.useFullData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good refactoring! It shows that there's basically no reuse in this function any more, so we should go the next step and split it in half: renderTraceFolds for the non-canGroup case and renderUnGroupedTraceFolds for the canGroup-but-ungrouped case.

);

if (canGroup && filteredData.length > 1 && groupedTraces.length > 0) {
if (canAdd) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically an early-return case that means we don't need groupedTraces so let's move it up above the computation of groupedTraces and save a bit of time when canAdd

<TabPanel>
<PlotlyPanel>
{individualTraces ? individualTraces : null}
{filteredTraces.length
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ternary is reused in a few places. Let's push it into renderIndividualTraceFolds to make it a bit more robust, and then we can make this code more readable.

<TabPanel>
<PlotlyPanel>{groupedTraces ? groupedTraces : null}</PlotlyPanel>
<PlotlyPanel>
{Object.keys(groupedTraces).length
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's push this ternary into renderGroupedTraceFolds

}
);

if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels like this should be in shame.js no? Must it really be in this file?


const GraphSubplotsPanel = (props, {localize: _}) => (
<SubplotAccordion canGroup>
<SubplotAccordion>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});
}

render() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring. This is a pretty hairy component and it's already looking a lot better! At some point I wonder if we can't break it apart more completely by having a GroupedTraceAccordion but not today.

@nicolaskruchten
Copy link
Contributor

Percy's diffs seem really odd to me here, not sure what it's doing. Locally I see Trace Opacity just fine, and I don't see weird extra padding.

@nicolaskruchten
Copy link
Contributor

Only issue I see so far is:

image

src/shame.js Outdated

let indexOfSplitTransform = null;

graphDiv.data[traceIndex].transforms.filter((t, i) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why filter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, just didn't want to write a for loop.. i could write a for loop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forEach?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our linter won't complain, but generally function inside filter should return something...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah you're right, changing

src/shame.js Outdated
function getProp(group) {
let indexOfStyleObject = null;

graphDiv.data[traceIndex].transforms[indexOfSplitTransform].styles.filter(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@dmt0
Copy link
Contributor

dmt0 commented Aug 8, 2018

just comments above, and 💃!

@VeraZab
Copy link
Contributor Author

VeraZab commented Aug 8, 2018

ok, I think I've changed everything that needed to be changed on this pr.
Yet I do see that in one of the jsons, the trace opacity widget dissapeared.

I made a codepen with the same json here:
https://codepen.io/veraz/pen/ajQwyb?editors=1010

I do not see opacity in fullData, posted in plotly_js channel, might open an issue in plotly.js

@VeraZab
Copy link
Contributor Author

VeraZab commented Aug 9, 2018

ok, so, from a conversation with @alexcjohnson , this seems to be the correct behaviour.
I don't know why we had that widget before, but it does not seem to be correct.

"
scatter traces with fill are not allowed to have opacity. The reason is that lines & markers need to be drawn in a separate group from the fills, in order to get the layering right when there are multiple filled traces, so it’s not possible to change the opacity of the entire trace as a single group.
"

@VeraZab VeraZab merged commit 142d86c into master Aug 9, 2018
@VeraZab VeraZab deleted the color-splits branch August 9, 2018 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants