Skip to content

Commit ef3c734

Browse files
committed
add full svg Icons to modebar button config
1 parent 5c74610 commit ef3c734

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

src/components/modebar/buttons.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
var Plotly = require('../../plotly');
1313
var Lib = require('../../lib');
1414
var Snapshot = require('../../snapshot');
15+
var Icons = require('../../../build/ploticon');
1516

1617

1718
var modebarButtons = module.exports = {};
@@ -24,7 +25,7 @@ var modebarButtons = module.exports = {};
2425
* @param {string} title
2526
* text that appears while hovering over the button
2627
* @param {string} icon
27-
* name of the svg icon associated with the button
28+
* svg icon associated with the button
2829
* @param {string} [gravity]
2930
* icon positioning
3031
* @param {function} click
@@ -43,7 +44,7 @@ var modebarButtons = module.exports = {};
4344
modebarButtons.toImage = {
4445
name: 'toImage',
4546
title: 'Download plot as a png',
46-
icon: 'camera',
47+
icon: Icons.camera,
4748
click: function(gd) {
4849
var format = 'png';
4950

@@ -95,7 +96,7 @@ modebarButtons.toImage = {
9596
modebarButtons.sendDataToCloud = {
9697
name: 'sendDataToCloud',
9798
title: 'Save and edit plot in cloud',
98-
icon: 'disk',
99+
icon: Icons.disk,
99100
click: function(gd) {
100101
Plotly.Plots.sendDataToCloud(gd);
101102
}
@@ -106,7 +107,7 @@ modebarButtons.zoom2d = {
106107
title: 'Zoom',
107108
attr: 'dragmode',
108109
val: 'zoom',
109-
icon: 'zoombox',
110+
icon: Icons.zoombox,
110111
click: handleCartesian
111112
};
112113

@@ -115,7 +116,7 @@ modebarButtons.pan2d = {
115116
title: 'Pan',
116117
attr: 'dragmode',
117118
val: 'pan',
118-
icon: 'pan',
119+
icon: Icons.pan,
119120
click: handleCartesian
120121
};
121122

@@ -124,7 +125,7 @@ modebarButtons.zoomIn2d = {
124125
title: 'Zoom in',
125126
attr: 'zoom',
126127
val: 'in',
127-
icon: 'zoom_plus',
128+
icon: Icons.zoom_plus,
128129
click: handleCartesian
129130
};
130131

@@ -133,7 +134,7 @@ modebarButtons.zoomOut2d = {
133134
title: 'Zoom out',
134135
attr: 'zoom',
135136
val: 'out',
136-
icon: 'zoom_minus',
137+
icon: Icons.zoom_minus,
137138
click: handleCartesian
138139
};
139140

@@ -142,7 +143,7 @@ modebarButtons.autoScale2d = {
142143
title: 'Autoscale',
143144
attr: 'zoom',
144145
val: 'auto',
145-
icon: 'autoscale',
146+
icon: Icons.autoscale,
146147
click: handleCartesian
147148
};
148149

@@ -151,7 +152,7 @@ modebarButtons.resetScale2d = {
151152
title: 'Reset axes',
152153
attr: 'zoom',
153154
val: 'reset',
154-
icon: 'home',
155+
icon: Icons.home,
155156
click: handleCartesian
156157
};
157158

@@ -160,7 +161,7 @@ modebarButtons.hoverClosestCartesian = {
160161
title: 'Show closest data on hover',
161162
attr: 'hovermode',
162163
val: 'closest',
163-
icon: 'tooltip_basic',
164+
icon: Icons.tooltip_basic,
164165
gravity: 'ne',
165166
click: handleCartesian
166167
};
@@ -172,7 +173,7 @@ modebarButtons.hoverCompareCartesian = {
172173
val: function(graphInfo) {
173174
return graphInfo._fullLayout._isHoriz ? 'y' : 'x';
174175
},
175-
icon: 'tooltip_compare',
176+
icon: Icons.tooltip_compare,
176177
gravity: 'ne',
177178
click: handleCartesian
178179
};
@@ -241,7 +242,7 @@ modebarButtons.zoom3d = {
241242
title: 'Zoom',
242243
attr: 'dragmode',
243244
val: 'zoom',
244-
icon: 'zoombox',
245+
icon: Icons.zoombox,
245246
click: handleDrag3d
246247
};
247248

@@ -250,7 +251,7 @@ modebarButtons.pan3d = {
250251
title: 'Pan',
251252
attr: 'dragmode',
252253
val: 'pan',
253-
icon: 'pan',
254+
icon: Icons.pan,
254255
click: handleDrag3d
255256
};
256257

@@ -259,7 +260,7 @@ modebarButtons.orbitRotation = {
259260
title: 'orbital rotation',
260261
attr: 'dragmode',
261262
val: 'orbit',
262-
icon: '3d_rotate',
263+
icon: Icons['3d_rotate'],
263264
click: handleDrag3d
264265
};
265266

@@ -268,7 +269,7 @@ modebarButtons.tableRotation = {
268269
title: 'turntable rotation',
269270
attr: 'dragmode',
270271
val: 'turntable',
271-
icon: 'z-axis',
272+
icon: Icons['z-axis'],
272273
click: handleDrag3d
273274
};
274275

@@ -291,15 +292,15 @@ modebarButtons.resetCameraDefault3d = {
291292
name: 'resetCameraDefault3d',
292293
title: 'Reset camera to default',
293294
attr: 'resetDefault',
294-
icon: 'home',
295+
icon: Icons.home,
295296
click: handleCamera3d
296297
};
297298

298299
modebarButtons.resetCameraLastSave3d = {
299300
name: 'resetCameraLastSave3d',
300301
title: 'Reset camera to last save',
301302
attr: 'resetLastSave',
302-
icon: 'movie',
303+
icon: Icons.movie,
303304
click: handleCamera3d
304305
};
305306

@@ -337,7 +338,7 @@ modebarButtons.hoverClosest3d = {
337338
attr: 'hovermode',
338339
val: null,
339340
toggle: true,
340-
icon: 'tooltip_basic',
341+
icon: Icons.tooltip_basic,
341342
gravity: 'ne',
342343
click: function(gd, ev) {
343344
var button = ev.currentTarget,
@@ -389,7 +390,7 @@ modebarButtons.zoomInGeo = {
389390
title: 'Zoom in',
390391
attr: 'zoom',
391392
val: 'in',
392-
icon: 'zoom_plus',
393+
icon: Icons.zoom_plus,
393394
click: handleGeo
394395
};
395396

@@ -398,7 +399,7 @@ modebarButtons.zoomOutGeo = {
398399
title: 'Zoom in',
399400
attr: 'zoom',
400401
val: 'out',
401-
icon: 'zoom_minus',
402+
icon: Icons.zoom_minus,
402403
click: handleGeo
403404
};
404405

@@ -407,7 +408,7 @@ modebarButtons.resetGeo = {
407408
title: 'Reset',
408409
attr: 'reset',
409410
val: null,
410-
icon: 'autoscale',
411+
icon: Icons.autoscale,
411412
click: handleGeo
412413
};
413414

@@ -417,7 +418,7 @@ modebarButtons.hoverClosestGeo = {
417418
attr: 'hovermode',
418419
val: null,
419420
toggle: true,
420-
icon: 'tooltip_basic',
421+
icon: Icons.tooltip_basic,
421422
gravity: 'ne',
422423
click: handleGeo
423424
};
@@ -450,7 +451,7 @@ modebarButtons.hoverClosestGl2d = {
450451
attr: 'hovermode',
451452
val: null,
452453
toggle: true,
453-
icon: 'tooltip_basic',
454+
icon: Icons.tooltip_basic,
454455
gravity: 'ne',
455456
click: toggleHover
456457
};
@@ -460,7 +461,7 @@ modebarButtons.hoverClosestPie = {
460461
title: 'Toggle show closest data on hover',
461462
attr: 'hovermode',
462463
val: 'closest',
463-
icon: 'tooltip_basic',
464+
icon: Icons.tooltip_basic,
464465
gravity: 'ne',
465466
click: toggleHover
466467
};

src/components/modebar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ proto.createButton = function (config) {
146146
button.setAttribute('data-toggle', config.toggle || false);
147147
if(config.toggle) button.classList.add('active');
148148

149-
button.appendChild(this.createIcon(Icons[config.icon || 'tooltip_basic']));
149+
button.appendChild(this.createIcon(config.icon || Icons.tooltip_basic));
150150

151151
return button;
152152
};

0 commit comments

Comments
 (0)