Skip to content
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

Table view - squashed #2052

Merged
merged 44 commits into from
Oct 5, 2017
Merged

Table view - squashed #2052

merged 44 commits into from
Oct 5, 2017

Conversation

monfera
Copy link
Contributor

@monfera monfera commented Oct 3, 2017

Squashed version of #1834

Before starting review, I'd push proper mocks, also as codepen examples. I'll also need to recheck attributes and add jasmine tests.

@monfera monfera self-assigned this Oct 3, 2017
@monfera monfera added this to the v1.31.0 milestone Oct 3, 2017
@monfera
Copy link
Contributor Author

monfera commented Oct 3, 2017

@etpinard Bird mock is now added, I'll need to replace the other tech test mocks too (they have JS etc.) table_plain_birds.json

image

@monfera monfera requested a review from etpinard October 3, 2017 14:13
Copy link
Contributor

@etpinard etpinard left a comment

Choose a reason for hiding this comment

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

Here's a first review. My comments are mostly pointing at ways to reuse existing code especially components Drawing and Color. I caught a few typos in there too.

I'm a little disappointing that the new text-wrapping code is embedded deep inside table/plot.js. How hard would it be to factor it out and place it in svg_text_utils.js?

},

format: {
valType: 'data_array',
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this should be an arrayOk valType: 'string', to format all values to same way more easily?


height: {
valType: 'number',
dflt: 28,
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting number. How did you come up with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just took a look at what'd look balanced with a font height of 12px although it could as well be computed
image

}
},

font: {
Copy link
Contributor

Choose a reason for hiding this comment

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

role: 'info',
dflt: [],
description: [
'Dimension values. `values[n]` represents the value of the `n`th point in the dataset,',
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't values be 2D? That is, values[n][m] represents the value of ....

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'll need to revise all attribute descriptions, indeed it's a nested array:
image

}
}
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need to add editType declarations to these attributes.

See #1999

function conditionalPanelRerender(gd, tableControlView, cellsColumnBlock, pages, prevPages, d, revolverIndex) {
var shouldComponentUpdate = pages[revolverIndex] !== prevPages[revolverIndex];
if(shouldComponentUpdate) {
window.clearTimeout(d.currentRepaint[revolverIndex]);
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to spell out window when using setTimeout and clearTimeout

// this code block is only invoked for items where d.cellHeightMayIncrease is truthy
var element = this;
var columnCellElement = element.parentNode;
var box = columnCellElement.getBoundingClientRect();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid these getBoundingClientRect calls?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The key test here (which I assume will fail given the getBoundingClientRect call) is to call Plotly.newPlot into an element that's not in the DOM, and insert it in the DOM afterward - ala https://codepen.io/anon/pen/XjakQy
If you really do need a getBoundingClientRect result, use Drawing.bBox.

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 think that #2053 should address it. I added a 'core' line now to express this. Here, the difference between parent and child bounding box top matters. What do people, or we, do with detached nodes? I'm trying to minimize open points for this specific PR, unless of course users would run into serious issues with it otherwise.

});

// MathJax styling has to be killed for HTML DOM color specifications to seep through
cellTextHolder.selectAll('svg').selectAll('*')
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks hacky. Can we do better?

Copy link
Collaborator

Choose a reason for hiding this comment

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

in regular convertToTspans MathJax gets colored here based on the color that was already applied to the text it was converted from - does that not apply 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.

I'll check your link, maybe it solves the need for the current hack, I wasn't happy it drew in black when fill was white but thought maybe there's a better way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

probably just an order-of-operations issue, we assume the text is fully styled before being converted to MathJax. It would probably be good for us to break this out like we did with positionText so it can be applied either before or after conversion.

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, thanks for the lead!

Copy link
Contributor Author

@monfera monfera Oct 4, 2017

Choose a reason for hiding this comment

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

@alexcjohnson @etpinard Fully agree w/ the order of operations (LaTeX coloring), a quick initial look didn't lead to a 5-minute solution, plan to do it tomorrow. Other tasks are,

  • ensuring table works fine with Plotly.restyle, and
  • more defaulting should happens (eg. now the user always needs to specify column order)

which seem more pressing than internal changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Please add item to #2056


it('\'dimension\' specification should have a default of an empty array', function() {
var fullTrace = _supply({});
expect(fullTrace.dimensions).toEqual([]);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this? A copy from parcoords?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, vestigial. I'll read through the code before the next round.

});
});

describe('@noCI table', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why @noCI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically I didn't intend to check in table_test.js 😃

@etpinard
Copy link
Contributor

etpinard commented Oct 3, 2017

A few (opinionated) comments from https://codepen.io/monfera/pen/ZXXMLo?editors=1010#0

  • I find column swapping a little too bubbly:

peek 2017-10-03 11-08

Is there an easy way to reduce the recoil action on drag-end?

  • It would be nice to add plotly_hover and plotly_click events on the cells:
  • It would be nice to make the header values (and maybe even the cells?) editable: true


"cells": {

"values": [
Copy link
Contributor

@etpinard etpinard Oct 3, 2017

Choose a reason for hiding this comment

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

Hmm. So here the values[i] represent columns - which I think is fair for table. But this means that cells.values is the transpose of the z attribute in heatmap traces. Which at the very least write this down in the table/index.js module description.

@alexcjohnson
Copy link
Collaborator

thinking ahead to Plotly.react, we'll probably need an attribute for scroll position, so the trace attributes fully specify the view. Also for export, people may want to be able to snapshot at the current view.

@rreusser
Copy link
Contributor

rreusser commented Oct 3, 2017

@alexcjohnson That's true. The only caveat is that high-frequency updates like scroll position shouldn't go through controlled update cycles or even setState (which is delayed by one frame and so makes things unnecessarily jumpy). In other words, I don't think the scroll position should be controlled. Which is equivalent to saying it would just be initialScrollY/initialScrollX or equivalent.

So in summary, it updates the plotly attr so the current scroll position is reproduced correctly, but after that it can only be set via the UI.

Glad to hear other thoughts on the matter, but that's what I think needs to happen.

@monfera
Copy link
Contributor Author

monfera commented Oct 3, 2017

@etpinard I can taper down the bouncy column drag to less or non-bouncy easing.

@monfera
Copy link
Contributor Author

monfera commented Oct 3, 2017

@alexcjohnson @rreusser is it decided that plot state will be fully specified? That'd include things like zoom level, pan position, the use of a selection box or even the contours of a lasso. Not suggesting it's not a desired thing at all though!

@rreusser I'm not sure if it adds to or questions anything you said, but wanted to mention that controlling scroll position might be desirable. For example, some journal incorporates a table and links scroll position to an advance-based story arc, or part of some product tour. I think it'd apply to other things as well. I'd prefer observables over fully restating the state because it allows lightweight, minimal updates upon very specific signals, ie. you save on both spec diffing and incremental rerendering. Such signals may be a lot of things besides scroll position; could be for responsive features such as devicePixelRatio, window/document or container element size, or even things like mouse position (for hover).

@rreusser
Copy link
Contributor

rreusser commented Oct 3, 2017

@monfera That's valid. I was wondering about that. I guess the key part is that we somehow avoid feeding UI scrolling from feeding back into controlled UI updates.

@alexcjohnson
Copy link
Collaborator

alexcjohnson commented Oct 3, 2017

is it decided that plot state will be fully specified? That'd include things like zoom level, pan position, the use of a selection box or even the contours of a lasso.

Yes. Specify all the things.

I guess the key part is that we somehow avoid feeding UI scrolling from feeding back into controlled UI updates.

We can certainly throttle these events (wooo we have a util for that 🎉 ) but we definitely want users to be able to watch the scroll state, and for example highlight points on a separate plot corresponding to the visible rows, and vice versa - click a point and scroll to that row in the table (hmm, those are a little more involved, as they require not only the pixel scroll, which is required to fully specify the state, but also some way to translate that bidirectionally to row numbers). Anyway my more immediate concern is other edits not resetting the table scroll - like the issues @etpinard fixed for geo plots in #2030.


@monfera edit here, as we don't have threading and topic locality is nice: added the need for full representation as an item to the follow-up issue #2056

@alexcjohnson
Copy link
Collaborator

Looks to me like shape-rendering: crispEdges is getting inherited in a few places it shouldn't: the scroll handle and MathJax are where I notice it.

@monfera monfera mentioned this pull request Oct 3, 2017
@monfera monfera force-pushed the table-squashed branch 4 times, most recently from 45b6843 to addb85b Compare October 5, 2017 13:20
@etpinard
Copy link
Contributor

etpinard commented Oct 5, 2017

image

This sums up this PR. A very nice looking and performant trace type. 👏 to @monfera for his very user-first approach. But, unfortunately, not much work was put in reusability for our other components.

I hope @monfera will have time to make a followup PR knocking out a few items in #2056 in the next few days and adding jasmine tests along the way. Factoring out the text wrap logic ( #2053 ) we'll make a bunch of folks happy, I hope this happens soon. Items #2057 and #2054 are less important to me in the short-term.

Let's get this thing in master 💃 💃

@monfera
Copy link
Contributor Author

monfera commented Oct 5, 2017

Thanks @etpinard and @alexcjohnson for the numerous review points!

@monfera monfera changed the title [WIP] table view - squashed Table view - squashed Oct 5, 2017
@monfera monfera merged commit 50e933c into master Oct 5, 2017
@alexcjohnson alexcjohnson deleted the table-squashed branch October 5, 2017 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants