Skip to content

Commit 99e66ad

Browse files
authored
Merge pull request #5832 from plotly/simplify-devtool
Simplify devtool by relying on XMLHttpRequest instead of varying d3.json function
2 parents 437f70e + cdff506 commit 99e66ad

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

devtools/test_dashboard/devtools.js

+16-19
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ var Fuse = require('fuse.js/dist/fuse.common.js');
66
var mocks = require('../../build/test_dashboard_mocks.json');
77
var credentials = require('../../build/credentials.json');
88
var Lib = require('@src/lib');
9-
var d3 = require('../../test/strict-d3');
10-
var d3Json = d3.json;
119

1210
require('./perf');
1311

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

63-
d3Json(mockURL, function(err, fig) {
64-
Plotly.newPlot(Tabs.fresh(id), fig);
65-
66-
console.warn('Plotting:', mockURL);
67-
});
68-
},
69-
70-
getMock: function(mockName, callback) {
71-
var mockURL = '/test/image/mocks/' + mockName + '.json';
72-
73-
d3Json(mockURL, function(err, fig) {
74-
if(typeof callback !== 'function') {
75-
window.mock = fig;
76-
} else {
77-
callback(err, fig);
61+
console.warn('Plotting:', mockURL);
62+
63+
var request = new XMLHttpRequest();
64+
request.open('GET', mockURL, true);
65+
request.responseType = '';
66+
request.send();
67+
68+
request.onreadystatechange = function() {
69+
if(this.readyState === 4) {
70+
if(this.status === 200) {
71+
var fig = JSON.parse(this.responseText);
72+
Plotly.newPlot(Tabs.fresh(id), fig);
73+
} else {
74+
console.error(this.statusText);
75+
}
7876
}
79-
});
77+
};
8078
},
8179

8280
// Save a png snapshot and display it below the plot
@@ -152,7 +150,6 @@ var Tabs = {
152150
// Bind things to the window
153151
window.Tabs = Tabs;
154152
window.Lib = Lib;
155-
window.d3 = d3;
156153
window.onload = handleOnLoad;
157154
setInterval(function() {
158155
window.gd = Tabs.getGraph() || Tabs.fresh();

draftlogs/5832_change.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Simplify devtool by relying on `XMLHttpRequest` instead of `d3.json` [[#5832](https://github.com/plotly/plotly.js/pull/5832)]

0 commit comments

Comments
 (0)