Skip to content

Multi-value support in trace tabs #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 8, 2018
Merged

Conversation

nicolaskruchten
Copy link
Contributor

This PR includes the change to hide text editors in multi-value contexts, and also adds support for styling text scatters, which we missed in the original passes through there :)

@@ -16,11 +16,7 @@ const AxesFold = connectAxesToLayout(Fold);

const TraceTypeSection = (props, context) => {
const {fullContainer} = context;
if (
fullContainer &&
fullContainer._fullInput &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why we were checking _fullInput here but it was failing in multi-valued contexts

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah _fullInput is where the true trace type for financial traces lie
_fullData.type for an ohlc trace will show scatter, _fullData._fullInput.type, will show ohlc

And all traces are supposed to have a _fullInput key, with type..so that's why I'm looking here
We could also look in Data.type..

But yeah, if you don't look there, it won't properly look for financials

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, right, I keep forgetting to check stuff with financial traces. right now they cause crashes apparently... joy!


this.markerColor = nestedProperty(fullContainer, 'marker.color').get();
this.borderWidth = nestedProperty(fullContainer, 'marker.line.width').get();

if (this.markerColor === MULTI_VALUED) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is very tricky: we don't actually end up using default values here and I couldn't figure out how to do it... we use the values from the first trace. I've added a note to fit'n'finish

Copy link
Contributor

Choose a reason for hiding this comment

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

well, that's what the current workspace does, sounds ok to me!

@@ -0,0 +1,77 @@
import {MULTI_VALUED} from './constants';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was moved from connectAxesToLayout basically unmodified.

@VeraZab
Copy link
Contributor

VeraZab commented Feb 8, 2018

this is great @nicolaskruchten ! 💃 once we put back _fullInput (in that comment above)

@nicolaskruchten
Copy link
Contributor Author

well, we can't just "put it back" as it doesn't work in all cases. need to find a more general solution.

Seems like in general the financial traces cause a lot of problems :(

@VeraZab
Copy link
Contributor

VeraZab commented Feb 8, 2018

what cases does it not work for?
I've just tried from master to create 2 ohlcs, that doesn't crash, there's some errors (trace.name and line.color), but it's mostly ok.

for fin charts, the true values are in _fullInput, that has to go back.
it's not just trace.type actually, it's also the true attributes, like {open, high, low, close}, you won't find those in gd._fullData, because fin charts are a composition of traces.

@nicolaskruchten
Copy link
Contributor Author

Per my comment, it doesn't work properly in grouped-trace contexts. I will fix it, don't worry, my point is I can't just undo my change :)

@nicolaskruchten
Copy link
Contributor Author

Ah, and the crash is just another variant of issues that crop up when we delete traces. It actually happens without financial traces, I just happened to have all financial traces up when I noticed it.

@VeraZab
Copy link
Contributor

VeraZab commented Feb 8, 2018

well, Etienne admits that they're a bit of a mess, but that's what we've got now :(
plotly/plotly.js#2281

@@ -29,7 +29,7 @@ import {localize} from '../lib';

const StyleTracesPanel = ({localize: _}) => (
<TraceAccordion canGroup>
<TextEditor label={_('Name')} richTextOnly />
<TextEditor label={_('Name')} attr="name" richTextOnly />
<TraceOrientation
Copy link
Contributor

Choose a reason for hiding this comment

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

oh yeah 👍

@nicolaskruchten
Copy link
Contributor Author

ok ready for re-review. I patched things up so that nothing is totally crazy but I've excluded the financial traces from the grouping altogether as it wasn't possible for me to find a constellation of settings that made them work correctly.

@nicolaskruchten
Copy link
Contributor Author

(I logged this in #290 of course for another pass later)

fullContainer._fullInput &&
props.traceTypes.includes(fullContainer._fullInput.type)
((fullContainer._fullInput &&
props.traceTypes.includes(fullContainer._fullInput.type)) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@VeraZab _fullInput is not available in some code paths, so this is the compromise. Specifically, in the grouped context, the all keys starting with _ are missing from container as per the original logic from the grouped Axes. If I remove this exclusion, we end up with circular JSON objects that cannot be serialized :)

}, {});

const groupedTraces = Object.keys(tracesByGroup)
.filter(traceType => !['ohlc', 'candlestick'].includes(traceType))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is ugly but prevents really weird outcomes.

@VeraZab
Copy link
Contributor

VeraZab commented Feb 8, 2018

great 💃

@nicolaskruchten nicolaskruchten merged commit 3555fa5 into master Feb 8, 2018
@nicolaskruchten nicolaskruchten deleted the multi_value_trace branch February 8, 2018 20:18
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.

2 participants