Skip to content

Commit 204799c

Browse files
committed
🔪 src/plotly.js !!!
1 parent ed8d56d commit 204799c

File tree

4 files changed

+20
-54
lines changed

4 files changed

+20
-54
lines changed

src/plot_api/plot_api.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ var d3 = require('d3');
1414
var isNumeric = require('fast-isnumeric');
1515
var hasHover = require('has-hover');
1616

17-
var Plotly = require('../plotly');
1817
var Lib = require('../lib');
1918
var Events = require('../lib/events');
2019
var Queue = require('../lib/queue');
@@ -25,6 +24,7 @@ var Plots = require('../plots/plots');
2524
var Polar = require('../plots/polar/legacy');
2625
var initInteractions = require('../plots/cartesian/graph_interact');
2726

27+
var Axes = require('../plots/cartesian/axes');
2828
var Drawing = require('../components/drawing');
2929
var Color = require('../components/color');
3030
var xmlnsNamespaces = require('../constants/xmlns_namespaces');
@@ -176,7 +176,7 @@ exports.plot = function(gd, data, layout, config) {
176176
Drawing.initGradients(gd);
177177

178178
// save initial show spikes once per graph
179-
if(graphWasEmpty) Plotly.Axes.saveShowSpikeInitial(gd);
179+
if(graphWasEmpty) Axes.saveShowSpikeInitial(gd);
180180

181181
// prepare the data and find the autorange
182182

@@ -327,24 +327,24 @@ exports.plot = function(gd, data, layout, config) {
327327
function doAutoRangeAndConstraints() {
328328
if(gd._transitioning) return;
329329

330-
var axList = Plotly.Axes.list(gd, '', true);
330+
var axList = Axes.list(gd, '', true);
331331
for(var i = 0; i < axList.length; i++) {
332332
var ax = axList[i];
333333
cleanAxisConstraints(gd, ax);
334334

335-
Plotly.Axes.doAutoRange(ax);
335+
Axes.doAutoRange(ax);
336336
}
337337

338338
enforceAxisConstraints(gd);
339339

340340
// store initial ranges *after* enforcing constraints, otherwise
341341
// we will never look like we're at the initial ranges
342-
if(graphWasEmpty) Plotly.Axes.saveRangeInitial(gd);
342+
if(graphWasEmpty) Axes.saveRangeInitial(gd);
343343
}
344344

345345
// draw ticks, titles, and calculate axis scaling (._b, ._m)
346346
function drawAxes() {
347-
return Plotly.Axes.doTicks(gd, 'redraw');
347+
return Axes.doTicks(gd, 'redraw');
348348
}
349349

350350
// Now plot the data
@@ -1440,7 +1440,7 @@ function _restyle(gd, aobj, traces) {
14401440

14411441
// for autoranging multiple axes
14421442
function addToAxlist(axid) {
1443-
var axName = Plotly.Axes.id2name(axid);
1443+
var axName = Axes.id2name(axid);
14441444
if(axlist.indexOf(axName) === -1) axlist.push(axName);
14451445
}
14461446

@@ -1639,7 +1639,7 @@ function _restyle(gd, aobj, traces) {
16391639

16401640
// swap the data attributes of the relevant x and y axes?
16411641
if(['swapxyaxes', 'orientationaxes'].indexOf(ai) !== -1) {
1642-
Plotly.Axes.swap(gd, traces);
1642+
Axes.swap(gd, traces);
16431643
}
16441644

16451645
// swap hovermode if set to "compare x/y data"
@@ -1676,7 +1676,7 @@ function _restyle(gd, aobj, traces) {
16761676

16771677
// do we need to force a recalc?
16781678
var autorangeOn = false;
1679-
var axList = Plotly.Axes.list(gd);
1679+
var axList = Axes.list(gd);
16801680
for(i = 0; i < axList.length; i++) {
16811681
if(axList[i].autorange) {
16821682
autorangeOn = true;
@@ -1721,7 +1721,7 @@ function _restyle(gd, aobj, traces) {
17211721
* attribute object `{astr1: val1, astr2: val2 ...}`
17221722
* allows setting multiple attributes simultaneously
17231723
*/
1724-
Plotly.relayout = function relayout(gd, astr, val) {
1724+
exports.relayout = function relayout(gd, astr, val) {
17251725
gd = Lib.getGraphDiv(gd);
17261726
helpers.clearPromiseQueue(gd);
17271727

@@ -1787,7 +1787,7 @@ function _relayout(gd, aobj) {
17871787
var layout = gd.layout,
17881788
fullLayout = gd._fullLayout,
17891789
keys = Object.keys(aobj),
1790-
axes = Plotly.Axes.list(gd),
1790+
axes = Axes.list(gd),
17911791
arrayEdits = {},
17921792
arrayStr,
17931793
i,
@@ -2131,7 +2131,7 @@ function _relayout(gd, aobj) {
21312131
function refAutorange(gd, obj, axLetter) {
21322132
if(!Lib.isPlainObject(obj)) return false;
21332133
var axRef = obj[axLetter + 'ref'] || axLetter,
2134-
ax = Plotly.Axes.getFromId(gd, axRef);
2134+
ax = Axes.getFromId(gd, axRef);
21352135

21362136
if(!ax && axRef.charAt(0) === axLetter) {
21372137
// fall back on the primary axis in case we've referenced a
@@ -2141,7 +2141,7 @@ function refAutorange(gd, obj, axLetter) {
21412141
// The only thing this is used for is to determine whether to
21422142
// do a full `recalc`, so the only ill effect of this error is
21432143
// to waste some time.
2144-
ax = Plotly.Axes.getFromId(gd, axLetter);
2144+
ax = Axes.getFromId(gd, axLetter);
21452145
}
21462146
return (ax || {}).autorange;
21472147
}
@@ -2403,8 +2403,8 @@ function diffData(gd, oldFullData, newFullData, immutable) {
24032403
for(i = 0; i < oldFullData.length; i++) {
24042404
trace = newFullData[i];
24052405
diffOpts.autoranged = trace.xaxis ? (
2406-
Plotly.Axes.getFromId(gd, trace.xaxis).autorange ||
2407-
Plotly.Axes.getFromId(gd, trace.yaxis).autorange
2406+
Axes.getFromId(gd, trace.xaxis).autorange ||
2407+
Axes.getFromId(gd, trace.yaxis).autorange
24082408
) : false;
24092409
getDiffFlags(oldFullData[i], trace, [], diffOpts);
24102410
}

src/plot_api/subroutines.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var d3 = require('d3');
13-
var Plotly = require('../plotly');
1412
var Registry = require('../registry');
1513
var Plots = require('../plots/plots');
1614
var Lib = require('../lib');
@@ -19,6 +17,7 @@ var Color = require('../components/color');
1917
var Drawing = require('../components/drawing');
2018
var Titles = require('../components/titles');
2119
var ModeBar = require('../components/modebar');
20+
var Axes = require('../plots/cartesian/axes');
2221
var initInteractions = require('../plots/cartesian/graph_interact');
2322
var cartesianConstants = require('../plots/cartesian/constants');
2423
var alignmentConstants = require('../constants/alignment');
@@ -46,7 +45,7 @@ exports.lsInner = function(gd) {
4645
var fullLayout = gd._fullLayout;
4746
var gs = fullLayout._size;
4847
var pad = gs.p;
49-
var axList = Plotly.Axes.list(gd);
48+
var axList = Axes.list(gd);
5049

5150
// _has('cartesian') means SVG specifically, not GL2D - but GL2D
5251
// can still get here because it makes some of the SVG structure
@@ -339,7 +338,7 @@ exports.lsInner = function(gd) {
339338
plotinfo.ylines.attr('d', yPath);
340339
});
341340

342-
Plotly.Axes.makeClipPaths(gd);
341+
Axes.makeClipPaths(gd);
343342
exports.drawMainTitle(gd);
344343
ModeBar.manage(gd);
345344

@@ -471,7 +470,7 @@ exports.doLegend = function(gd) {
471470
};
472471

473472
exports.doTicksRelayout = function(gd) {
474-
Plotly.Axes.doTicks(gd, 'redraw');
473+
Axes.doTicks(gd, 'redraw');
475474
exports.drawMainTitle(gd);
476475
return Plots.previousPromises(gd);
477476
};

src/plotly.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/plots/plots.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
var d3 = require('d3');
1313
var isNumeric = require('fast-isnumeric');
1414

15-
var Plotly = require('../plotly');
16-
var PlotSchema = require('../plot_api/plot_schema');
1715
var Registry = require('../registry');
16+
var PlotSchema = require('../plot_api/plot_schema');
1817
var axisIDs = require('../plots/cartesian/axis_ids');
1918
var Lib = require('../lib');
2019
var _ = Lib._;

0 commit comments

Comments
 (0)