Skip to content

Commit 01ab620

Browse files
committed
add gl2d plot index + register it in plotly.js
1 parent 6640747 commit 01ab620

File tree

4 files changed

+61
-36
lines changed

4 files changed

+61
-36
lines changed

src/plot_api/plot_api.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -418,39 +418,6 @@ function setPlotContext(gd, config) {
418418
}
419419
}
420420

421-
function plotGl2d(gd) {
422-
var fullLayout = gd._fullLayout,
423-
fullData = gd._fullData,
424-
subplotIds = plots.getSubplotIds(fullLayout, 'gl2d');
425-
426-
for(var i = 0; i < subplotIds.length; i++) {
427-
var subplotId = subplotIds[i],
428-
subplotObj = fullLayout._plots[subplotId],
429-
fullSubplotData = plots.getSubplotData(fullData, 'gl2d', subplotId);
430-
var scene;
431-
432-
// ref. to corresp. Scene instance
433-
scene = subplotObj._scene2d;
434-
435-
// If Scene is not instantiated, create one!
436-
if(scene === undefined) {
437-
scene = new Plotly.Scene2D({
438-
container: gd.querySelector('.gl-container'),
439-
id: subplotId,
440-
staticPlot: gd._context.staticPlot,
441-
plotGlPixelRatio: gd._context.plotGlPixelRatio
442-
},
443-
fullLayout
444-
);
445-
446-
// set ref to Scene instance
447-
subplotObj._scene2d = scene;
448-
}
449-
450-
scene.plot(fullSubplotData, fullLayout, gd.layout);
451-
}
452-
}
453-
454421
function plotPolar(gd, data, layout) {
455422
// build or reuse the container skeleton
456423
var plotContainer = d3.select(gd).selectAll('.plot-container')

src/plotly.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ var Geo = require('./plots/geo');
4444
Plots.registerSubplot(Geo);
4545
exports.Scene = require('./plots/gl3d/scene');
4646
exports.Gl3dLayout = require('./plots/gl3d/layout');
47-
exports.Scene2D = require('./plots/gl2d/scene2d');
47+
48+
var Gl2d = require('./plots/gl2d');
49+
Plots.registerSubplot(Gl2d);
50+
4851
exports.micropolar = require('./plots/polar/micropolar');
4952

5053
// components

src/plots/gl2d/index.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright 2012-2016, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
10+
'use strict';
11+
12+
var Plotly = require('../../plotly');
13+
14+
var Scene2D = require('./scene2d');
15+
16+
var Plots = Plotly.Plots;
17+
18+
19+
exports.type = 'gl2d';
20+
21+
exports.attr = ['xaxis', 'yaxis'];
22+
23+
exports.idRoot = ['x', 'y'];
24+
25+
exports.attributes = require('../cartesian/attributes');
26+
27+
exports.plot = function plotGl2d(gd) {
28+
var fullLayout = gd._fullLayout,
29+
fullData = gd._fullData,
30+
subplotIds = Plots.getSubplotIds(fullLayout, 'gl2d');
31+
32+
for(var i = 0; i < subplotIds.length; i++) {
33+
var subplotId = subplotIds[i],
34+
subplotObj = fullLayout._plots[subplotId],
35+
fullSubplotData = Plots.getSubplotData(fullData, 'gl2d', subplotId);
36+
37+
// ref. to corresp. Scene instance
38+
var scene = subplotObj._scene2d;
39+
40+
// If Scene is not instantiated, create one!
41+
if(scene === undefined) {
42+
scene = new Scene2D({
43+
container: gd.querySelector('.gl-container'),
44+
id: subplotId,
45+
staticPlot: gd._context.staticPlot,
46+
plotGlPixelRatio: gd._context.plotGlPixelRatio
47+
},
48+
fullLayout
49+
);
50+
51+
// set ref to Scene instance
52+
subplotObj._scene2d = scene;
53+
}
54+
55+
scene.plot(fullSubplotData, fullLayout, gd.layout);
56+
}
57+
};

src/plots/gl2d/scene2d.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ var showNoWebGlMsg = require('../../lib/show_no_webgl_msg');
2525
var AXES = ['xaxis', 'yaxis'];
2626
var STATIC_CANVAS, STATIC_CONTEXT;
2727

28-
Plotly.Plots.registerSubplot('gl2d', ['xaxis', 'yaxis'], ['x', 'y'],
29-
Plotly.Axes.attributes);
3028

3129
function Scene2D(options, fullLayout) {
3230
this.container = options.container;

0 commit comments

Comments
 (0)