Skip to content

Commit

Permalink
Merge pull request #5832 from plotly/simplify-devtool
Browse files Browse the repository at this point in the history
Simplify devtool by relying on XMLHttpRequest instead of varying d3.json function
  • Loading branch information
archmoj authored Jul 18, 2021
2 parents 437f70e + cdff506 commit 99e66ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
35 changes: 16 additions & 19 deletions devtools/test_dashboard/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ var Fuse = require('fuse.js/dist/fuse.common.js');
var mocks = require('../../build/test_dashboard_mocks.json');
var credentials = require('../../build/credentials.json');
var Lib = require('@src/lib');
var d3 = require('../../test/strict-d3');
var d3Json = d3.json;

require('./perf');

Expand Down Expand Up @@ -60,23 +58,23 @@ var Tabs = {
plotMock: function(mockName, id) {
var mockURL = '/test/image/mocks/' + mockName + '.json';

d3Json(mockURL, function(err, fig) {
Plotly.newPlot(Tabs.fresh(id), fig);

console.warn('Plotting:', mockURL);
});
},

getMock: function(mockName, callback) {
var mockURL = '/test/image/mocks/' + mockName + '.json';

d3Json(mockURL, function(err, fig) {
if(typeof callback !== 'function') {
window.mock = fig;
} else {
callback(err, fig);
console.warn('Plotting:', mockURL);

var request = new XMLHttpRequest();
request.open('GET', mockURL, true);
request.responseType = '';
request.send();

request.onreadystatechange = function() {
if(this.readyState === 4) {
if(this.status === 200) {
var fig = JSON.parse(this.responseText);
Plotly.newPlot(Tabs.fresh(id), fig);
} else {
console.error(this.statusText);
}
}
});
};
},

// Save a png snapshot and display it below the plot
Expand Down Expand Up @@ -152,7 +150,6 @@ var Tabs = {
// Bind things to the window
window.Tabs = Tabs;
window.Lib = Lib;
window.d3 = d3;
window.onload = handleOnLoad;
setInterval(function() {
window.gd = Tabs.getGraph() || Tabs.fresh();
Expand Down
1 change: 1 addition & 0 deletions draftlogs/5832_change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Simplify devtool by relying on `XMLHttpRequest` instead of `d3.json` [[#5832](https://github.com/plotly/plotly.js/pull/5832)]

0 comments on commit 99e66ad

Please sign in to comment.