-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathindex.js
75 lines (57 loc) · 2.04 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* Copyright 2012-2017, 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 d3 = require('d3');
var Lib = require('../../lib');
var dragElement = require('../dragelement');
var helpers = require('./helpers');
var layoutAttributes = require('./layout_attributes');
module.exports = {
moduleType: 'component',
name: 'fx',
constants: require('./constants'),
schema: {
layout: layoutAttributes
},
attributes: require('./attributes'),
layoutAttributes: layoutAttributes,
supplyLayoutGlobalDefaults: require('./layout_global_defaults'),
supplyDefaults: require('./defaults'),
supplyLayoutDefaults: require('./layout_defaults'),
calc: require('./calc'),
getDistanceFunction: helpers.getDistanceFunction,
getClosest: helpers.getClosest,
inbox: helpers.inbox,
appendArrayPointValue: helpers.appendArrayPointValue,
castHoverOption: castHoverOption,
castHoverinfo: castHoverinfo,
hover: require('./hover').hover,
unhover: dragElement.unhover,
loneHover: require('./hover').loneHover,
loneUnhover: loneUnhover,
click: require('./click')
};
function loneUnhover(containerOrSelection) {
// duck type whether the arg is a d3 selection because ie9 doesn't
// handle instanceof like modern browsers do.
var selection = Lib.isD3Selection(containerOrSelection) ?
containerOrSelection :
d3.select(containerOrSelection);
selection.selectAll('g.hovertext').remove();
selection.selectAll('.spikeline').remove();
}
// helpers for traces that use Fx.loneHover
function castHoverOption(trace, ptNumber, attr) {
return Lib.castOption(trace, ptNumber, 'hoverlabel.' + attr);
}
function castHoverinfo(trace, fullLayout, ptNumber) {
function _coerce(val) {
return Lib.coerceHoverinfo({hoverinfo: val}, {_module: trace._module}, fullLayout);
}
return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce);
}