Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 90b5218

Browse files
committed
wip update menu
1 parent e246331 commit 90b5218

File tree

8 files changed

+576
-1
lines changed

8 files changed

+576
-1
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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+
'use strict';
10+
11+
var fontAttrs = require('../../plots/font_attributes');
12+
var colorAttrs = require('../color/attributes');
13+
var extendFlat = require('../../lib/extend').extendFlat;
14+
15+
var buttonsAttrs = {
16+
_isLinkedToArray: true,
17+
18+
method: {
19+
valType: 'enumerated',
20+
values: ['restyle', 'relayout', 'filter'],
21+
dflt: 'restyle',
22+
role: 'info',
23+
description: ''
24+
},
25+
args: {
26+
valType: 'info_array',
27+
role: 'info',
28+
items: [
29+
{ valType: 'any' },
30+
{ valType: 'any' },
31+
{ valType: 'any' }
32+
]
33+
},
34+
35+
label: {
36+
valType: 'string',
37+
role: 'info',
38+
description: 'Sets the text label to appear on the button.'
39+
}
40+
};
41+
42+
module.exports = {
43+
visible: {
44+
valType: 'boolean',
45+
role: 'info',
46+
description: [
47+
'Determines whether or not the update menu is visible.'
48+
].join(' ')
49+
},
50+
51+
buttons: buttonsAttrs,
52+
53+
x: {
54+
valType: 'number',
55+
min: -2,
56+
max: 3,
57+
role: 'style',
58+
description: 'Sets the x position (in normalized coordinates) of the update menu.'
59+
},
60+
xanchor: {
61+
valType: 'enumerated',
62+
values: ['auto', 'left', 'center', 'right'],
63+
dflt: 'left',
64+
role: 'info',
65+
description: [
66+
'Sets the update menu\'s horizontal position anchor.',
67+
'This anchor binds the `x` position to the *left*, *center*',
68+
'or *right* of the range selector.'
69+
].join(' ')
70+
},
71+
y: {
72+
valType: 'number',
73+
min: -2,
74+
max: 3,
75+
role: 'style',
76+
description: 'Sets the y position (in normalized coordinates) of the update memu.'
77+
},
78+
yanchor: {
79+
valType: 'enumerated',
80+
values: ['auto', 'top', 'middle', 'bottom'],
81+
dflt: 'bottom',
82+
role: 'info',
83+
description: [
84+
'Sets the update menu\'s vertical position anchor',
85+
'This anchor binds the `y` position to the *top*, *middle*',
86+
'or *bottom* of the range selector.'
87+
].join(' ')
88+
},
89+
90+
font: extendFlat({}, fontAttrs, {
91+
description: 'Sets the font of the update menu button text.'
92+
}),
93+
94+
bgcolor: {
95+
valType: 'color',
96+
dflt: colorAttrs.lightLine,
97+
role: 'style',
98+
description: 'Sets the background color of the update menu buttons.'
99+
},
100+
bordercolor: {
101+
valType: 'color',
102+
dflt: colorAttrs.defaultLine,
103+
role: 'style',
104+
description: 'Sets the color of the border enclosing the update menu.'
105+
},
106+
borderwidth: {
107+
valType: 'number',
108+
min: 0,
109+
dflt: 0,
110+
role: 'style',
111+
description: 'Sets the width (in px) of the border enclosing the update menu.'
112+
}
113+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
13+
module.exports = {
14+
15+
// class names
16+
containerClassName: 'updatemenu',
17+
headerClassName: 'updatemenu-header',
18+
buttonClassName: 'updatemenu-button',
19+
itemClassName: 'updatemenu-item',
20+
itemRectClassName: 'updatemenu-item-rect',
21+
itemTextClassName: 'updatemenu-item-text',
22+
buttonActiveClassName: 'updatemenu-button-active',
23+
24+
// buttons rect radii
25+
rx: 2,
26+
ry: 2,
27+
28+
// color given to active buttons
29+
// activeColor: '#d3d3d3',
30+
activeColor: 'blue',
31+
32+
// color given to hovered buttons
33+
hoverColor: 'red'
34+
};

src/components/updatemenu/defaults.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
'use strict';
10+
11+
var Lib = require('../../lib');
12+
13+
var attributes = require('./attributes');
14+
var buttonAttrs = attributes.buttons;
15+
16+
17+
module.exports = function updateMenuDefaults(layoutIn, layoutOut) {
18+
var contIn = layoutIn.updatemenu || {},
19+
contOut = layoutOut.updatemenu = {};
20+
21+
function coerce(attr, dflt) {
22+
return Lib.coerce(contIn, contOut, attributes, attr, dflt);
23+
}
24+
25+
var buttons = buttonsDefaults(contIn, contOut);
26+
27+
var visible = coerce('visible', buttons.length > 0);
28+
if(!visible) return;
29+
30+
coerce('x', 0);
31+
coerce('y', 1);
32+
Lib.noneOrAll(contIn, contOut, ['x', 'y']);
33+
34+
coerce('xanchor');
35+
coerce('yanchor');
36+
37+
Lib.coerceFont(coerce, 'font', layoutOut.font);
38+
39+
coerce('bgcolor');
40+
coerce('bordercolor');
41+
coerce('borderwidth');
42+
};
43+
44+
function buttonsDefaults(contIn, contOut) {
45+
var buttonsIn = contIn.buttons || [],
46+
buttonsOut = contOut.buttons = [];
47+
48+
var buttonIn, buttonOut;
49+
50+
function coerce(attr, dflt) {
51+
return Lib.coerce(buttonIn, buttonOut, buttonAttrs, attr, dflt);
52+
}
53+
54+
for(var i = 0; i < buttonsIn.length; i++) {
55+
buttonIn = buttonsIn[i];
56+
buttonOut = {};
57+
58+
coerce('method');
59+
coerce('args');
60+
coerce('label');
61+
62+
buttonsOut.push(buttonOut);
63+
}
64+
65+
return buttonsOut;
66+
}

0 commit comments

Comments
 (0)