Skip to content

Commit f842118

Browse files
committed
make attributes files require in attributes file directly:
- do not require in Plotly when not necessary
1 parent 4181e97 commit f842118

File tree

22 files changed

+82
-156
lines changed

22 files changed

+82
-156
lines changed

src/components/annotations/attributes.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
2-
31
var Plotly = require('../../plotly');
42
var ARROWPATHS = require('./arrow_paths');
5-
6-
var extendFlat = Plotly.Lib.extendFlat;
3+
var fontAttrs = require('../../plots/plots/font_attributes');
4+
var extendFlat = require('../../lib/extend').extendFlat;
75

86
module.exports = {
97
_isLinkedToArray: true,
@@ -28,7 +26,7 @@ module.exports = {
2826
'with respect to the horizontal.'
2927
].join(' ')
3028
},
31-
font: extendFlat({}, Plotly.Plots.fontAttrs, {
29+
font: extendFlat({}, fontAttrs, {
3230
description: 'Sets the annotation text font.'
3331
}),
3432
opacity: {

src/components/colorbar/attributes.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
'use strict';
2-
3-
var Plotly = require('../../plotly');
4-
5-
var axesAttrs = Plotly.Axes.layoutAttributes;
6-
var extendFlat = Plotly.Lib.extendFlat;
1+
var axesAttrs = require('../../plots/cartesian/attributes');
2+
var fontAttrs = require('../../plots/plots/font_attributes');
3+
var extendFlat = require('../../lib/extend').extendFlat;
74

85
module.exports = {
96
// TODO: only right is supported currently
@@ -167,7 +164,7 @@ module.exports = {
167164
dflt: 'Click to enter colorscale title',
168165
description: 'Sets the title of the color bar.'
169166
},
170-
titlefont: extendFlat({}, Plotly.Plots.fontAttrs, {
167+
titlefont: extendFlat({}, fontAttrs, {
171168
description: [
172169
'Sets this color bar\'s title font.'
173170
].join(' ')

src/components/legend/attributes.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
'use strict';
2-
3-
var Plotly = require('../../plotly');
4-
var extendFlat = Plotly.Lib.extendFlat;
1+
var fontAttrs = require('../../plots/plots/font_attributes');
2+
var colorAttrs = require('../color/attributes');
3+
var extendFlat = require('../../lib/extend').extendFlat;
54

65

76
module.exports = {
@@ -12,7 +11,7 @@ module.exports = {
1211
},
1312
bordercolor: {
1413
valType: 'color',
15-
dflt: Plotly.Color.defaultLine,
14+
dflt: colorAttrs.defaultLine,
1615
role: 'style',
1716
description: 'Sets the color of the border enclosing the legend.'
1817
},
@@ -23,7 +22,7 @@ module.exports = {
2322
role: 'style',
2423
description: 'Sets the width (in px) of the border enclosing the legend.'
2524
},
26-
font: extendFlat({}, Plotly.Plots.fontAttrs, {
25+
font: extendFlat({}, fontAttrs, {
2726
description: 'Sets the font used to text the legend items.'
2827
}),
2928
traceorder: {

src/components/shapes/attributes.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
var Plotly = require('../../plotly');
1+
var annAttrs = require('../annotations/attributes');
2+
var scatterAttrs = require('../../traces/scatter/attributes');
3+
var extendFlat = require('../../lib/extend').extendFlat;
24

3-
var scatterLineAttrs = Plotly.Scatter.attributes.line;
4-
var extendFlat = Plotly.Lib.extendFlat;
5+
var scatterLineAttrs = scatterAttrs.line;
56

67
module.exports = {
78
_isLinkedToArray: true,
@@ -27,7 +28,7 @@ module.exports = {
2728
].join(' ')
2829
},
2930

30-
xref: extendFlat({}, Plotly.Annotations.layoutAttributes.xref, {
31+
xref: extendFlat({}, annAttrs.xref, {
3132
description: [
3233
'Sets the shape\'s x coordinate axis.',
3334
'If set to an x axis id (e.g. *x* or *x2*), the `x` position',
@@ -54,7 +55,7 @@ module.exports = {
5455
].join(' ')
5556
},
5657

57-
yref: extendFlat({}, Plotly.Annotations.layoutAttributes.yref, {
58+
yref: extendFlat({}, annAttrs.yref, {
5859
description: [
5960
'Sets the annotation\'s y coordinate axis.',
6061
'If set to an y axis id (e.g. *y* or *y2*), the `y` position',

src/lib/gl_format_color.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ var tinycolor = require('tinycolor2');
55
var isNumeric = require('fast-isnumeric');
66
var str2RgbaArray = require('./str2rgbarray');
77

8-
var colorDflt = Plotly.Color.defaultLine,
9-
opacityDflt = 1;
8+
var colorDflt = require('../components/color/attributes').defaultLine;
9+
var opacityDflt = 1;
1010

1111
function calculateColor(colorIn, opacityIn) {
1212
var colorOut = str2RgbaArray(colorIn);

src/plots/plots/attributes.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
var Plotly = require('../../plotly');
2-
var plots = require('./plots');
3-
41
module.exports = {
52
type: {
63
valType: 'enumerated',
74
role: 'info',
8-
values: plots.allTypes,
5+
values: [], // listed dynamically
96
dflt: 'scatter'
107
},
118
visible: {

src/plots/plots/layout_attributes.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
var Plotly = require('../../plotly');
2-
var plots = require('./plots');
2+
3+
var fontAttrs = require('./font_attributes');
4+
var colorAttrs = require('../../components/color/attributes');
35

46
var extendFlat = Plotly.Lib.extendFlat;
57

68

79
module.exports = {
810
font: {
9-
family: extendFlat({}, plots.fontAttrs.family, {
11+
family: extendFlat({}, fontAttrs.family, {
1012
dflt: '"Open sans", verdana, arial, sans-serif'
1113
}),
12-
size: extendFlat({}, plots.fontAttrs.size, {
14+
size: extendFlat({}, fontAttrs.size, {
1315
dflt: 12
1416
}),
15-
color: extendFlat({}, plots.fontAttrs.color, {
16-
dflt: Plotly.Color.defaultLine
17+
color: extendFlat({}, fontAttrs.color, {
18+
dflt: colorAttrs.defaultLine
1719
}),
1820
description: [
1921
'Sets the global font.',
@@ -29,7 +31,7 @@ module.exports = {
2931
'Sets the plot\'s title.'
3032
].join(' ')
3133
},
32-
titlefont: extendFlat({}, plots.fontAttrs, {
34+
titlefont: extendFlat({}, fontAttrs, {
3335
description: 'Sets the title font.'
3436
}),
3537
autosize: {
@@ -108,15 +110,15 @@ module.exports = {
108110
paper_bgcolor: {
109111
valType: 'color',
110112
role: 'style',
111-
dflt: Plotly.Color.background,
113+
dflt: colorAttrs.background,
112114
description: 'Sets the color of paper where the graph is drawn.'
113115
},
114116
plot_bgcolor: {
115117
// defined here, but set in Axes.supplyLayoutDefaults
116118
// because it needs to know if there are (2D) axes or not
117119
valType: 'color',
118120
role: 'style',
119-
dflt: Plotly.Color.background,
121+
dflt: colorAttrs.background,
120122
description: [
121123
'Sets the color of plotting area in-between x and y axes.'
122124
].join(' ')
@@ -183,7 +185,7 @@ module.exports = {
183185
'xaxis': 'Axes',
184186
'yaxis': 'Axes',
185187
'scene': 'Gl3dLayout', // TODO should be Scene
186-
'geo': 'GeoLayout', // TODO should be Geo
188+
'geo': 'Geo',
187189
'legend': 'Legend',
188190
'annotations': 'Annotations',
189191
'shapes': 'Shapes'

src/plots/plots/plots.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var modules = plots.modules = {},
1212
subplotsRegistry = plots.subplotsRegistry = {};
1313

1414
plots.attributes = require('./attributes');
15+
plots.attributes.type.values = allTypes;
1516
plots.fontAttrs = require('./font_attributes');
1617
plots.layoutAttributes = require('./layout_attributes');
1718

src/polar/utils/undo_manager.js

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

src/traces/bars/attributes.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
'use strict';
2-
3-
var Plotly = require('../../plotly');
4-
5-
var scatterAttrs = Plotly.Scatter.attributes,
1+
var scatterAttrs = require('../scatter/attributes'),
62
scatterMarkerAttrs = scatterAttrs.marker,
73
scatterMarkerLineAttrs = scatterMarkerAttrs.line;
84

0 commit comments

Comments
 (0)