Plotly3D code improvements.#787
Conversation
Add a local copy of plotly.js version 2.18.2 to the collection
of node_modules installed on the server to be able to host the
javascript locally instead of using a CDN.
Use PG->getUniqueName('plotly3D') to get a unique string for
the variable names instead of relying on incrementing the variables
based on the number of graphs used. This allows this to avoid
conflicts in tests or pages that have more than a single problem
on the screen.
|
@somiaj: I added a pull request to this branch with some improvements. The main thing is that there is no need to use the |
|
I added one more small change to my pull request to this branch. That is I updated the method used for loading the javascript to work for the webwork3 rendering approach in which the javascript runs after the page has loaded. As such the DOMContentLoaded event has already run and the plotly javascript will also have already been loaded. So for that the initialization method in this macro needs to just run. |
…ames. Instead scope those sections properly in the javascript so that static variable names can be used. The only thing the unique id is really needed for is to have a unique html id for the containing div. This makes the generated javascript smaller since that generated id is quite long. Also fix the funcType 'perl' option. The funcType 'perl' and funcType 'data' need better documentation. Also update the package-lock.json file. Something wasn't done right there as running `npm install` modifies the lock file. Finally, update the loading method in javascript to work for webwork3 and similar rendering techniques where the javascript will be added to the page after the DOMContentLoaded event has already run.
Improvements to the plotly3D.pl macro.
drgrice1
left a comment
There was a problem hiding this comment.
Looks good. Thanks for making the requested changes.
|
Just for documentation, these are additional improvements to #728 |
|
Heads up, but this will need an |
|
After doing the above things, including clearing the cache, I'm getting the following plot for the example you posted on the #728: It appears that plotly.min.js is loading correctly, but doesn't seem to be rendering the plot. |
|
Scroll down, and use the last one in the comments there. |
|
Of course I used an old problem. The updated one at the bottom of #728 works great. |
|
@somiaj: Probably the best way is to run the |
|
Can't seem to get the script to work. I installed And it creates three files, |
Better describe how the various funcType work, including examples. Fix some typos.
|
You don't need to pass the I am not sure what is going wrong for you. If I cut an paste the command line that you posted it runs fine, and generates all of the webwork2 and pg POD. The only thing I can think of is to check that all of the perl modules are available that are used by the script. Those are Pod::Usage, Getopt::Long, Pod::Simple::XHTML, File::Find, File::Path, IO::File, Pod::Find, File::Basename, and POSIX. |
|
Okay, figured it out. The parser doesn't like symbolic links for |

Add a local copy of plotly.js version 2.18.2 to the collection of node_modules installed on the server to be able to host the javascript locally instead of using a CDN.
Use PG->getUniqueName('plotly3D') to get a unique string for the variable names instead of relying on incrementing the variables based on the number of graphs used. This allows this to avoid conflicts in tests or pages that have more than a single problem on the screen.