Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/plotcss.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var Plotly = require('../src/plotly');
var Lib = require('../src/lib');
var rules = {
"X,X div": "font-family:'Open Sans', verdana, arial, sans-serif;margin:0;padding:0;",
"X input,X button": "font-family:'Open Sans', verdana, arial, sans-serif;",
Expand Down Expand Up @@ -58,5 +58,5 @@ for(var selector in rules) {
var fullSelector = selector.replace(/^,/,' ,')
.replace(/X/g, '.js-plotly-plot .plotly')
.replace(/Y/g, '.plotly-notifier');
Plotly.Lib.addStyleRule(fullSelector, rules[selector]);
Lib.addStyleRule(fullSelector, rules[selector]);
}
5 changes: 3 additions & 2 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var Plots = require('../../plots/plots');
var dragElement = require('../dragelement');
var Drawing = require('../drawing');
var Color = require('../color');
var svgTextUtils = require('../../lib/svg_text_utils');

var constants = require('./constants');
var getLegendData = require('./get_legend_data');
Expand Down Expand Up @@ -354,14 +355,14 @@ function drawTexts(g, gd) {
.text(name);

function textLayout(s) {
Plotly.util.convertToTspans(s, function() {
svgTextUtils.convertToTspans(s, function() {
s.selectAll('tspan.line').attr({x: s.attr('x')});
g.call(computeTextDimensions, gd);
});
}

if(gd._context.editable && !isPie) {
text.call(Plotly.util.makeEditable)
text.call(svgTextUtils.makeEditable)
.call(textLayout)
.on('edit', function(text) {
this.attr({'data-unformatted': text});
Expand Down
14 changes: 8 additions & 6 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
'use strict';

var Plotly = require('../../plotly');
var Plots = require('../../plots/plots');
var Axes = require('../../plots/cartesian/axes');
var Lib = require('../../lib');
var downloadImage = require('../../snapshot/download');
var Icons = require('../../../build/ploticon');
Expand Down Expand Up @@ -72,7 +74,7 @@ modeBarButtons.sendDataToCloud = {
title: 'Save and edit plot in cloud',
icon: Icons.disk,
click: function(gd) {
Plotly.Plots.sendDataToCloud(gd);
Plots.sendDataToCloud(gd);
}
};

Expand Down Expand Up @@ -181,7 +183,7 @@ function handleCartesian(gd, ev) {
var mag = (val === 'in') ? 0.5 : 2,
r0 = (1 + mag) / 2,
r1 = (1 - mag) / 2,
axList = Plotly.Axes.list(gd, null, true);
axList = Axes.list(gd, null, true);

var ax, axName;

Expand Down Expand Up @@ -263,7 +265,7 @@ function handleDrag3d(gd, ev) {
attr = button.getAttribute('data-attr'),
val = button.getAttribute('data-val') || true,
fullLayout = gd._fullLayout,
sceneIds = Plotly.Plots.getSubplotIds(fullLayout, 'gl3d'),
sceneIds = Plots.getSubplotIds(fullLayout, 'gl3d'),
layoutUpdate = {};

var parts = attr.split('.');
Expand Down Expand Up @@ -295,7 +297,7 @@ function handleCamera3d(gd, ev) {
var button = ev.currentTarget,
attr = button.getAttribute('data-attr'),
fullLayout = gd._fullLayout,
sceneIds = Plotly.Plots.getSubplotIds(fullLayout, 'gl3d');
sceneIds = Plots.getSubplotIds(fullLayout, 'gl3d');

for(var i = 0; i < sceneIds.length; i++) {
var sceneId = sceneIds[i],
Expand Down Expand Up @@ -327,7 +329,7 @@ function handleHover3d(gd, ev) {
val = button._previousVal || false,
layout = gd.layout,
fullLayout = gd._fullLayout,
sceneIds = Plotly.Plots.getSubplotIds(fullLayout, 'gl3d');
sceneIds = Plots.getSubplotIds(fullLayout, 'gl3d');

var axes = ['xaxis', 'yaxis', 'zaxis'],
spikeAttrs = ['showspikes', 'spikesides', 'spikethickness', 'spikecolor'];
Expand Down Expand Up @@ -415,7 +417,7 @@ function handleGeo(gd, ev) {
attr = button.getAttribute('data-attr'),
val = button.getAttribute('data-val') || true,
fullLayout = gd._fullLayout,
geoIds = Plotly.Plots.getSubplotIds(fullLayout, 'geo');
geoIds = Plots.getSubplotIds(fullLayout, 'geo');

for(var i = 0; i < geoIds.length; i++) {
var geo = fullLayout[geoIds[i]]._geo;
Expand Down
4 changes: 2 additions & 2 deletions src/components/modebar/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

var Plotly = require('../../plotly');
var Axes = require('../../plots/cartesian/axes');
var scatterSubTypes = require('../../traces/scatter/subtypes');

var createModeBar = require('./');
Expand Down Expand Up @@ -148,7 +148,7 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) {
}

function areAllAxesFixed(fullLayout) {
var axList = Plotly.Axes.list({_fullLayout: fullLayout}, null, true);
var axList = Axes.list({_fullLayout: fullLayout}, null, true);
var allFixed = true;

for(var i = 0; i < axList.length; i++) {
Expand Down
5 changes: 3 additions & 2 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var Queue = require('../lib/queue');

var Plots = require('../plots/plots');
var Fx = require('../plots/cartesian/graph_interact');
var Polar = require('../plots/polar');

var Color = require('../components/color');
var Drawing = require('../components/drawing');
Expand Down Expand Up @@ -419,7 +420,7 @@ function plotPolar(gd, data, layout) {
// fulfill gd requirements
if(data) gd.data = data;
if(layout) gd.layout = layout;
Plotly.micropolar.manager.fillLayout(gd);
Polar.manager.fillLayout(gd);

if(gd._fullLayout.autosize === 'initial' && gd._context.autosizable) {
plotAutoSize(gd, {});
Expand All @@ -432,7 +433,7 @@ function plotPolar(gd, data, layout) {
});

// instantiate framework
gd.framework = Plotly.micropolar.manager.framework(gd);
gd.framework = Polar.manager.framework(gd);

// plot
gd.framework({data: gd.data, layout: gd.layout}, paperDiv.node());
Expand Down
8 changes: 1 addition & 7 deletions src/plot_api/to_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var isNumeric = require('fast-isnumeric');

var Plotly = require('../plotly');
var Lib = require('../lib');
var Snapshot = require('../snapshot');


/**
Expand All @@ -22,7 +23,6 @@ var Lib = require('../lib');
* @param opts.height height of snapshot in px
*/
function toImage(gd, opts) {
var Snapshot = require('../snapshot');

var promise = new Promise(function(resolve, reject) {
// check for undefined opts
Expand Down Expand Up @@ -91,12 +91,6 @@ function toImage(gd, opts) {
var redrawFunc = Snapshot.getRedrawFunc(clonedGd);

Plotly.plot(clonedGd, clone.data, clone.layout, clone.config)
// TODO: the following is Plotly.Plots.redrawText but without the waiting.
// we shouldn't need to do this, but in *occasional* cases we do. Figure
// out why and take it out.

// not sure the above TODO makes sense anymore since
// we have converted to promises
.then(redrawFunc)
.then(wait)
.then(function(url) { resolve(url); })
Expand Down
1 change: 0 additions & 1 deletion src/plotly.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var Plots = exports.Plots = require('./plots/plots');

exports.Axes = require('./plots/cartesian/axes');
exports.Fx = require('./plots/cartesian/graph_interact');
exports.micropolar = require('./plots/polar/micropolar');

// components
exports.Color = require('./components/color');
Expand Down
2 changes: 1 addition & 1 deletion src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ function hover(gd, evt, subplot) {
else yvalArray = p2c(yaArray, ypx);

if(!isNumeric(xvalArray[0]) || !isNumeric(yvalArray[0])) {
Lib.warn('Plotly.Fx.hover failed', evt, gd);
Lib.warn('Fx.hover failed', evt, gd);
return dragElement.unhoverRaw(gd, evt);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/plots/gl2d/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

'use strict';

var Plotly = require('../../plotly');
var Plots = require('../plots');
var Axes = require('../cartesian/axes');

var convertHTMLToUnicode = require('../../lib/html2unicode');
var str2RGBArray = require('../../lib/str2rgbarray');
Expand Down Expand Up @@ -180,8 +181,8 @@ proto.merge = function(options) {
// is an axis shared with an already-drawn subplot ?
proto.hasSharedAxis = function(ax) {
var scene = this.scene,
subplotIds = Plotly.Plots.getSubplotIds(scene.fullLayout, 'gl2d'),
list = Plotly.Axes.findSubplotsWithAxis(subplotIds, ax);
subplotIds = Plots.getSubplotIds(scene.fullLayout, 'gl2d'),
list = Axes.findSubplotsWithAxis(subplotIds, ax);

// if index === 0, then the subplot is already drawn as subplots
// are drawn in order.
Expand Down
9 changes: 5 additions & 4 deletions src/plots/gl3d/layout/tick_marks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

module.exports = computeTickMarks;

var Plotly = require('../../../plotly');
var Axes = require('../../cartesian/axes');
var Lib = require('../../../lib');
var convertHTMLToUnicode = require('../../../lib/html2unicode');

var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis'];
Expand Down Expand Up @@ -64,10 +65,10 @@ function computeTickMarks(scene) {
var tickModeCached = axes.tickmode;
if(axes.tickmode === 'auto') {
axes.tickmode = 'linear';
var nticks = axes.nticks || Plotly.Lib.constrain((axes._length / 40), 4, 9);
Plotly.Axes.autoTicks(axes, Math.abs(axes.range[1] - axes.range[0]) / nticks);
var nticks = axes.nticks || Lib.constrain((axes._length / 40), 4, 9);
Axes.autoTicks(axes, Math.abs(axes.range[1] - axes.range[0]) / nticks);
}
var dataTicks = Plotly.Axes.calcTicks(axes);
var dataTicks = Axes.calcTicks(axes);
for(var j = 0; j < dataTicks.length; ++j) {
dataTicks[j].x = dataTicks[j].x * scene.dataScale[i];
dataTicks[j].text = convertHTMLToUnicode(dataTicks[j].text);
Expand Down
5 changes: 2 additions & 3 deletions src/plots/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

'use strict';

var Plotly = require('../plotly');

var fontAttrs = require('./font_attributes');
var colorAttrs = require('../components/color/attributes');

var extendFlat = Plotly.Lib.extendFlat;
var Lib = require('../lib');
var extendFlat = Lib.extendFlat;


module.exports = {
Expand Down
13 changes: 13 additions & 0 deletions src/plots/polar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var Polar = module.exports = require('./micropolar');

Polar.manager = require('./micropolar_manager');
10 changes: 3 additions & 7 deletions src/plots/polar/micropolar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
* LICENSE file in the root directory of this source tree.
*/

var Plotly = require('../../plotly');
var d3 = require('d3');
var Lib = require('../../lib');
var extendDeepAll = Lib.extendDeepAll;

var µ = module.exports = {
version: '0.2.2',
manager: require('./micropolar_manager')
};

var extendDeepAll = Plotly.Lib.extendDeepAll;
var µ = module.exports = { version: '0.2.2' };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use µ when we could use this instead?


µ.Axis = function module() {
var config = {
Expand Down
20 changes: 11 additions & 9 deletions src/plots/polar/micropolar_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@

'use strict';

var Plotly = require('../../plotly');
var d3 = require('d3');
var Lib = require('../../lib');
var Color = require('../../components/color');

var micropolar = require('./micropolar');
var UndoManager = require('./undo_manager');
var extendDeepAll = Lib.extendDeepAll;

var manager = module.exports = {};

var extendDeepAll = Plotly.Lib.extendDeepAll;

manager.framework = function(_gd) {
var config, previousConfigClone, plot, convertedInput, container;
var undoManager = new UndoManager();
Expand All @@ -29,8 +31,8 @@ manager.framework = function(_gd) {
_inputConfig :
extendDeepAll(config, _inputConfig);

if(!plot) plot = Plotly.micropolar.Axis();
convertedInput = Plotly.micropolar.adapter.plotly().convert(config);
if(!plot) plot = micropolar.Axis();
convertedInput = micropolar.adapter.plotly().convert(config);
plot.config(convertedInput).render(container);
_gd.data = config.data;
_gd.layout = config.layout;
Expand All @@ -41,12 +43,12 @@ manager.framework = function(_gd) {
exports.svg = function() { return plot.svg(); };
exports.getConfig = function() { return config; };
exports.getLiveConfig = function() {
return Plotly.micropolar.adapter.plotly().convert(plot.getLiveConfig(), true);
return micropolar.adapter.plotly().convert(plot.getLiveConfig(), true);
};
exports.getLiveScales = function() { return {t: plot.angularScale(), r: plot.radialScale()}; };
exports.setUndoPoint = function() {
var that = this;
var configClone = Plotly.micropolar.util.cloneJson(config);
var configClone = micropolar.util.cloneJson(config);
(function(_configClone, _previousConfigClone) {
undoManager.add({
undo: function() {
Expand All @@ -57,7 +59,7 @@ manager.framework = function(_gd) {
}
});
})(configClone, previousConfigClone);
previousConfigClone = Plotly.micropolar.util.cloneJson(configClone);
previousConfigClone = micropolar.util.cloneJson(configClone);
};
exports.undo = function() { undoManager.undo(); };
exports.redo = function() { undoManager.redo(); };
Expand All @@ -71,7 +73,7 @@ manager.fillLayout = function(_gd) {
dflts = {
width: 800,
height: 600,
paper_bgcolor: Plotly.Color.background,
paper_bgcolor: Color.background,
_container: container,
_paperdiv: paperDiv,
_paper: paper
Expand Down
9 changes: 5 additions & 4 deletions src/snapshot/cloneplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

'use strict';

var Plotly = require('../plotly');
var Lib = require('../lib');
var Plots = require('../plots/plots');

var extendFlat = Plotly.Lib.extendFlat;
var extendDeep = Plotly.Lib.extendDeep;
var extendFlat = Lib.extendFlat;
var extendDeep = Lib.extendDeep;

// Put default plotTile layouts here
function cloneLayoutOverride(tileClass) {
Expand Down Expand Up @@ -99,7 +100,7 @@ module.exports = function clonePlot(graphObj, options) {
}
}

var sceneIds = Plotly.Plots.getSubplotIds(newLayout, 'gl3d');
var sceneIds = Plots.getSubplotIds(newLayout, 'gl3d');

if(sceneIds.length) {
var axesImageOverride = {};
Expand Down
Loading