Skip to content

Commit 0b5b003

Browse files
committed
Merge pull request #418 from plotly/etienne-devtools
Etienne devtools improvements
2 parents db9fd34 + b4368a4 commit 0b5b003

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

devtools/test_dashboard/devtools.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
'use strict';
2+
3+
/* global Plotly:false */
4+
15
var Fuse = require('fuse.js');
26
var mocks = require('../../build/test_dashboard_mocks.json');
37

8+
// put d3 in window scope
9+
var d3 = window.d3 = Plotly.d3;
410

511
// Our gracious testing object
612
var Tabs = {
@@ -35,8 +41,8 @@ var Tabs = {
3541
plotMock: function(mockName, id) {
3642
var mockURL = '/test/image/mocks/' + mockName + '.json';
3743

38-
window.Plotly.d3.json(mockURL, function(err, fig) {
39-
window.Plotly.plot(Tabs.fresh(id), fig.data, fig.layout);
44+
d3.json(mockURL, function(err, fig) {
45+
Plotly.plot(Tabs.fresh(id), fig.data, fig.layout);
4046

4147
console.warn('Plotting:', mockURL);
4248
});
@@ -47,12 +53,13 @@ var Tabs = {
4753
var gd = Tabs.getGraph(id);
4854

4955
if(!gd._fullLayout || !gd._fullData) {
56+
console.error('no graph with id ' + id + ' found.');
5057
return;
5158
}
5259

5360
var image = new Image();
5461

55-
window.Plotly.Snapshot.toImage(gd, { format: 'png' }).on('success', function(img) {
62+
Plotly.Snapshot.toImage(gd, { format: 'png' }).on('success', function(img) {
5663
image.src = img;
5764

5865
var imageDiv = document.getElementById('snapshot');
@@ -72,7 +79,7 @@ var Tabs = {
7279
}
7380

7481
for(var i = 0; i < plots.length; i++) {
75-
window.Plotly.purge(plots[i]);
82+
Plotly.purge(plots[i]);
7683
}
7784
},
7885

devtools/test_dashboard/server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,23 @@ function writeFilePromise(path, contents) {
134134
function bundlePlotly() {
135135
b.bundle(function(err) {
136136
if(err) {
137-
console.error('Error while bundling!', err);
137+
console.error('Error while bundling!', JSON.stringify(String(err)));
138+
} else {
139+
console.log('Bundle updated at ' + new Date().toLocaleTimeString());
138140
}
139141

140142
if(firstBundle) {
141143
open('http://localhost:' + PORT + '/devtools/test_dashboard');
142144
firstBundle = false;
143145
}
144-
console.log('Bundle updated at ' + new Date().toLocaleTimeString());
145146
}).pipe(fs.createWriteStream(constants.pathToPlotlyBuild));
146147
}
147148

148149
function bundleDevtools() {
149150
return new Promise(function(resolve, reject) {
150151
devtools.bundle(function(err) {
151152
if(err) {
152-
console.error('Error while bundling!', err);
153+
console.error('Error while bundling!', JSON.stringify(String(err)));
153154
return reject(err);
154155
} else {
155156
return resolve();

devtools/test_dashboard/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ header span{
6161
}
6262
.dashboard-plot{
6363
margin-bottom: 30px;
64+
width: 1100px;
6465
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
"test-syntax": "node test/syntax_test.js",
3636
"test-bundle": "node tasks/test_bundle.js",
3737
"test": "npm run citest-jasmine && npm run test-image && npm run test-syntax && npm run test-bundle",
38-
"start": "npm run start-test_dashboard",
3938
"start-test_dashboard": "node devtools/test_dashboard/server.js",
4039
"start-image_viewer": "node devtools/image_viewer/server.js",
40+
"start": "npm run start-test_dashboard",
4141
"baseline": "./tasks/baseline.sh",
4242
"preversion": "npm-link-check && npm dedupe",
4343
"version": "npm run build && git add -A dist src build",

0 commit comments

Comments
 (0)