-
-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathevents.js
More file actions
70 lines (66 loc) · 2.24 KB
/
Copy pathevents.js
File metadata and controls
70 lines (66 loc) · 2.24 KB
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
// The single source of truth for the plotly.js events this wrapper forwards.
//
// The naming convention is:
// - events are attached as `'plotly_' + name.toLowerCase()`
// - react props are `'on' + name`
//
// `triggersUpdate` marks events plotly.js emits *after* changing the figure;
// the wrapper listens to those and fires `onUpdate`. Never set it on a
// cancelable event — that adds a second listener alongside the consumer's,
// and plotly keeps only the last listener's return value, so a consumer's
// `return false` could be discarded. The drill-down clicks rely on
// `plotly_animated` instead.
//
// The `on*` prop types in `factory.d.ts` are maintained by hand against this list
export const events = [
{name: 'AfterExport'},
{name: 'AfterPlot'},
{name: 'Animated', triggersUpdate: true},
{name: 'Animating'},
{name: 'AnimatingFrame'},
{name: 'AnimationInterrupted'},
{name: 'AutoSize'},
{name: 'BeforeExport'},
{name: 'BeforeHover'},
{name: 'BeforePlot'},
{name: 'ButtonClicked'},
{name: 'Click'},
{name: 'ClickAnnotation'},
{name: 'Deselect'},
{name: 'DoubleClick', triggersUpdate: true},
{name: 'Framework'},
{name: 'Hover'},
{name: 'IcicleClick'},
{name: 'LegendClick'},
{name: 'LegendDoubleClick'},
{name: 'LegendTitleClick'},
{name: 'LegendTitleDoubleClick'},
{name: 'Relayout', triggersUpdate: true},
{name: 'Relayouting', triggersUpdate: true},
{name: 'Restyle', triggersUpdate: true},
{name: 'Redraw', triggersUpdate: true},
{name: 'Selected'},
{name: 'Selecting'},
{name: 'SliderChange'},
{name: 'SliderEnd'},
{name: 'SliderStart'},
{name: 'SunburstClick'},
{name: 'Transitioned'},
{name: 'Transitioning'},
{name: 'TransitionInterrupted'},
{name: 'TreemapClick'},
{name: 'Unhover'},
{name: 'WebGlContextLost'},
];
/** The plotly.js event name a given entry is attached as. */
export function getPlotlyEventName(eventName) {
return 'plotly_' + eventName.toLowerCase();
}
/** The React prop name a given entry is read from. */
export function getPropName(eventName) {
return 'on' + eventName;
}
export const eventNames = events.map((event) => event.name);
export const updateEvents = events
.filter((event) => event.triggersUpdate)
.map((event) => getPlotlyEventName(event.name));