Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

ChartEditor: use react-chart-editor #405

Merged
merged 21 commits into from
Mar 24, 2018

Conversation

n-riesco
Copy link
Contributor

@jackparmer This is just to show you how Falcon would look like with react-chart-editor.

See that I've made the Table view the default.

I'm also thinking of making the tree view as big as the code editor. So that the chart editor can use the whole width.

@nicolaskruchten I'm looking forward to the new API (it'd simplify this PR a lot).

peek 2018-03-13 17-45

@jackparmer
Copy link
Contributor

jackparmer commented Mar 13, 2018 via email

@nicolaskruchten
Copy link
Contributor

Awesome! New release coming soon with the new API /cc @VeraZab

@n-riesco
Copy link
Contributor Author

@jackparmer I thought about autominimise, but I was concerned some users might find difficult to discover that they can make the schema view visible again. That's why I thought making the schema view as big as the code editor would be the solution.

@jackparmer
Copy link
Contributor

jackparmer commented Mar 13, 2018 via email

@VeraZab
Copy link

VeraZab commented Mar 13, 2018

@n-riesco just made a new release: https://www.npmjs.com/package/react-chart-editor

* Implemented ChartEditor using `[email protected]`.

* Enabled bundling of CSS by importing from a react component.

* Use table view by default (instead of ChartEditor).

Closes plotly#350
* Store gd in Settings state so that we can export the chart into Chart
  Studio.
* Removed obsolete props and state in Preview used by previous
  implementation of ChartEditor.
@n-riesco n-riesco force-pushed the charteditor/use-react-chart-editor branch from d963467 to b5624fe Compare March 15, 2018 13:24
* Moved TableTree from Settings into Preview, so that all the components
  under the Query panel live inside Preview.

* After this change, it'll be possible for move ChartEditor so that it
  fills all the available width.
* Hide code editor and schemas view, when the Chart Editor is selected.
@n-riesco
Copy link
Contributor Author

@jackparmer I've updated the PR. In this end I've gone for the option of hiding both the code editor and the table schemas view (it didn't make sense to hide the code editor while the table schemas view was still visible)

@nicolaskruchten @VeraZab As you can see in the screencast, I've got a problem with the initial plot size. Is there a way to set this size with the new API?

peek 2018-03-15 20-05

@nicolaskruchten
Copy link
Contributor

[email protected] and [email protected] should resolve the sizing issue!

@n-riesco
Copy link
Contributor Author

@nicolaskruchten 😿 I still see the same behaviour after upgrading to [email protected] and [email protected].

@n-riesco
Copy link
Contributor Author

@nicolaskruchten One thing, that is rather inconvenient with this workaround, is that I have to hard-code the height as style={{height: 400}}. I tried style={{minHeight: 400, height: '100%'}}, but it wouldn't work (the height of <PlotlyEditor> would be less than 400px).

peek 2018-03-16 21-12

@nicolaskruchten
Copy link
Contributor

What's the easiest way for me to get this running locally so I can play with the CSS? The height/width thing is a big pain point with this project in general :(

@jackparmer
Copy link
Contributor

@n-riesco
Copy link
Contributor Author

n-riesco commented Mar 19, 2018

@nicolaskruchten It turns out the issue isn't with the CSS. In fact, style={{minHeight: 400, width: '100%'}} works if I'm careful to mount <PlotEditor> only when the parent node is visible (otherwise this.PlotComponent throws errors when window.getComputedStyle(parentNode).display === 'none).

I have something working, but I'll clean it and push it into the PR tomorrow.

* Fixes PlotlyComponent  autosizing issue.
* Detect before render when chart panel becomes visible.
@n-riesco
Copy link
Contributor Author

n-riesco commented Mar 20, 2018

@nicolaskruchten In principle 85afe3b could be implemented inside react-chart-editor, but this solution isn't very efficient.

I think the place to deal with this issue is inside plotly.js (I don't know what the implications are, but ideally we should be able to tell plotly.js to ignore display: none; and draw the chart as if it was visible).


@etpinard @alexcjohnson ⬆️


To sum up the issue:

  • the issue is that <PlotlyComponent>'s initial size doesn't honour the bounding client rect.
  • the issue happens when <PlotlyComponent> is mounted, because React creates children before their parents.
  • and it also happens when <PlotlyComponent> is resized and <PlotlyComponent> isn't visible.

@nicolaskruchten
Copy link
Contributor

Seconded, this is a problem in the editor in general but I thought I'd more or less fixed it by firing window.resize after drawing. Clearly that's not late enough in the React loop to catch all cases. It's happening in Dash-land as well: https://plotly.slack.com/archives/C90K5TYP3/p1521599318000139

* Preview.componentWillReceiveProps now checks if props have change
  before triggering a state update.

* Do not pre-compute the CSV string (in order to reduce memory usage).

Fixes plotly#395
* Restored previous name, because `gd` could suggest it's the DOM
  element.

* `plotlyJSON` can be stringified safely.
@n-riesco
Copy link
Contributor Author

@nicolaskruchten thanks for reviewing https://github.com/n-riesco/plotly-database-connector/blob/04dd2463ccddf834b19ef4111cffa989bf7f7fa6/app/components/Settings/Preview/chart-editor.jsx . I've renamed gd back to plotlyJSON to make clear this isn't the DOM element.

@n-riesco
Copy link
Contributor Author

@shannonlal I'm done with this PR. Would you review it, please?

@shannonlal
Copy link
Contributor

@n-riesco Looking at this now

Copy link
Contributor

@shannonlal shannonlal left a comment

Choose a reason for hiding this comment

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

Your throughts on define a standard for file name convention? Maybe out it in the contributing doc? I noticed that as you have be updating files you have been moving away from camel case file names to dash. I am okay with this, I just want to know if we should standardize on this. We updated chart-editor.css and Preview.css. I wanted to know if we should be making them consistent

});

// Cap plots to 100k rows
const length = Math.min(rows.length, 100000);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be defined as a const at top. const MAX_ROWS=10000;

<div
ref={'container'}
style={{
minHeight: 400,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion. Maybe a constant or move to a separate file. I see the min height of 400 defined in a bunch of files. Maybe we should centralize to a single file? your thoughts?

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've re-enabled css-loader, so that we can import again .css files into a component. But I didn't create a chart-editor.css, because I feel we need tidy up the CSS in Falcon first:

import {Tab, Tabs, TabList, TabPanel} from 'react-tabs';
import ConnectionTabs from './Tabs/Tabs.react';
import UserConnections from './UserConnections/UserConnections.react';
import DialectSelector from './DialectSelector/DialectSelector.react';
import ConnectButton from './ConnectButton/ConnectButton.react';
import Preview from './Preview/Preview.react';
import TableTree from './Preview/TableTree.react.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file no longer in use? I was working on some jest tests for table tree. If it is not needed I can move on to some other tests

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, it's still in use (tests are always welcome 😄). I moved the import to Preview.react.js. Now Preview.react.js contains all the components displayed under the QUERY tab.

Copy link
Contributor

@shannonlal shannonlal left a comment

Choose a reason for hiding this comment

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

Nothing major. Just some minor comments and more questions about standards. I am going to give this a dancer now and let you make decision as to wether you want to fix my comments or move them to another issue. Overall a really nice job. 💃

columnNames = ['x', 'y'];

rows = [];
for (let i = 0; i < 100001; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be (MAX_LENGTH + 1)

@n-riesco
Copy link
Contributor Author

@shannonlal I've addressed all your comments except that about CSS (I'd rather address it after we devise a plan to tidy up the CSS in Falcon; see what I replied here).

@n-riesco n-riesco merged commit 3ffc80d into plotly:master Mar 24, 2018
@n-riesco n-riesco changed the title [WIP] ChartEditor: use react-chart-editor ChartEditor: use react-chart-editor Mar 24, 2018
@zhaodagang
Copy link

Use ChartEditor, must connect plot site and logined ?

@n-riesco
Copy link
Contributor Author

n-riesco commented May 8, 2018

@zhaodagang Falcon and react-chart-editor can be used without login.

react-chart-editor is based on the open-source library plotly.js.

If you create an account on https://plot.ly/ and login with Falcon, then you'll be able to upload your data and charts onto https://plot.ly/ .

@zhaodagang
Copy link

zhaodagang commented May 9, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants