Skip to content

Commit 914dcbf

Browse files
committed
put polar modules in plots/polar
1 parent 769f6dd commit 914dcbf

File tree

5 files changed

+68
-15
lines changed

5 files changed

+68
-15
lines changed

src/polar/attributes/area.js renamed to src/plots/polar/area_attributes.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
var Plotly = require('../../plotly');
2-
3-
var scatterAttrs = Plotly.Scatter.attributes,
4-
scatterMarkerAttrs = scatterAttrs.marker;
1+
var scatterAttrs = require('../../traces/scatter/attributes');
2+
var scatterMarkerAttrs = scatterAttrs.marker;
53

64
module.exports = {
75
r: scatterAttrs.r,

src/polar/attributes/polaraxes.js renamed to src/plots/polar/axis_attributes.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
22

3-
var Plotly = require('../../plotly');
3+
var axesAttrs = require('../cartesian/attributes');
4+
var extendFlat = require('../../lib/extend').extendFlat;
45

5-
var extendFlat = Plotly.Lib.extendFlat;
6-
7-
var domainAttr = extendFlat({}, Plotly.Axes.layoutAttributes.domain, {
6+
var domainAttr = extendFlat({}, axesAttrs.domain, {
87
description: [
98
'Polar chart subplots are not supported yet.',
109
'This key has currently no effect.'

src/polar/micropolar.js renamed to src/plots/polar/micropolar.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
var Plotly = require('../plotly'),
2-
d3 = require('d3');
1+
var Plotly = require('../../plotly');
2+
var d3 = require('d3');
33

44
var µ = module.exports = {
5-
version: '0.2.2'
5+
version: '0.2.2',
6+
manager: require('./micropolar_manager')
67
};
78

89
var extendDeepAll = Plotly.Lib.extendDeepAll;
910

10-
1111
µ.Axis = function module() {
1212
var config = {
1313
data: [],

src/polar/micropolar_manager.js renamed to src/plots/polar/micropolar_manager.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

3-
var Plotly = require('../plotly'),
4-
d3 = require('d3'),
5-
UndoManager = require('./utils/undo_manager');
3+
var Plotly = require('../../plotly');
4+
var d3 = require('d3');
5+
var UndoManager = require('./undo_manager');
66

77
var manager = module.exports = {};
88

src/plots/polar/undo_manager.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use strict';
2+
3+
//Modified from https://github.com/ArthurClemens/Javascript-Undo-Manager
4+
//Copyright (c) 2010-2013 Arthur Clemens, [email protected]
5+
module.exports = function UndoManager() {
6+
var undoCommands = [],
7+
index = -1,
8+
isExecuting = false,
9+
callback;
10+
11+
function execute(command, action){
12+
if(!command) return this;
13+
14+
isExecuting = true;
15+
command[action]();
16+
isExecuting = false;
17+
18+
return this;
19+
}
20+
21+
return {
22+
add: function(command){
23+
if(isExecuting) return this;
24+
undoCommands.splice(index + 1, undoCommands.length - index);
25+
undoCommands.push(command);
26+
index = undoCommands.length - 1;
27+
return this;
28+
},
29+
setCallback: function(callbackFunc){ callback = callbackFunc; },
30+
undo: function(){
31+
var command = undoCommands[index];
32+
if(!command) return this;
33+
execute(command, 'undo');
34+
index -= 1;
35+
if(callback) callback(command.undo);
36+
return this;
37+
},
38+
redo: function(){
39+
var command = undoCommands[index + 1];
40+
if(!command) return this;
41+
execute(command, 'redo');
42+
index += 1;
43+
if(callback) callback(command.redo);
44+
return this;
45+
},
46+
clear: function(){
47+
undoCommands = [];
48+
index = -1;
49+
},
50+
hasUndo: function(){ return index !== -1; },
51+
hasRedo: function(){ return index < (undoCommands.length - 1); },
52+
getCommands: function(){ return undoCommands; },
53+
getPreviousCommand: function(){ return undoCommands[index-1]; },
54+
getIndex: function(){ return index; }
55+
};
56+
};

0 commit comments

Comments
 (0)