@raruto/leaflet-elevation 2.0.2 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -197,10 +197,10 @@ There are multiple options to achieve this:
197
197
  * check out [this example](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-theme.html)
198
198
  * Or add the following lines for custom colors.
199
199
  ```css
200
- .elevation-control.elevation .area {
200
+ .elevation-control .area {
201
201
  fill: red;
202
202
  }
203
- .elevation-control.elevation .background {
203
+ .elevation-control .background {
204
204
  background-color: white;
205
205
  ```
206
206
  </details>
@@ -244,7 +244,7 @@ var map = L.map('map', {
244
244
  - https://walkaholic.me/map
245
245
 
246
246
  </details>
247
-
247
+
248
248
  _Related: [Leaflet-UI presets](https://github.com/raruto/leaflet-ui), [QGIS Integration](https://github.com/faunalia/trackprofile2web)_
249
249
 
250
250
  ---
@@ -260,3 +260,5 @@ _Related: [Leaflet-UI presets](https://github.com/raruto/leaflet-ui), [QGIS Inte
260
260
  **Contributors:** [MrMufflon](https://github.com/MrMufflon/Leaflet.Elevation), [HostedDinner](https://github.com/HostedDinner/Leaflet.Elevation), [ADoroszlai](http://ADoroszlai.github.io/joebed/), [Raruto](https://github.com/Raruto/leaflet-elevation)
261
261
 
262
262
  ---
263
+
264
+ Check out [CONTRIBUTING.md](.github/CONTRIBUTING.md) file for more information on supporting the development of this library.
@@ -11,56 +11,44 @@
11
11
  /* prevent overlapping the .elevation-detached chart */
12
12
  }
13
13
 
14
- .elevation-detached {
15
- font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
16
- height: auto;
17
- width: 100%;
18
- position: relative;
19
- z-index: 0;
20
- }
21
-
22
- .elevation-detached .elevation {
23
- width: 100%;
24
- }
25
-
26
- .elevation-detached .background {
27
- max-width: 100%;
28
- }
29
-
30
- .elevation-control.elevation .background {
14
+ .elevation-control .background {
31
15
  background-color: var(--ele-bg, rgba(70, 130, 180, 0.2));
32
16
  border-radius: 5px;
33
17
  overflow: visible;
34
18
  display: block;
35
19
  touch-action: none;
36
20
  user-select: none;
21
+ max-width: 100%;
37
22
  }
38
23
 
39
- .elevation-control.elevation .axis .tick,
40
- .elevation-control.elevation .axis .domain {
24
+ .elevation-control .grid,
25
+ .elevation-control .area > foreignObject,
26
+ .elevation-control .axis,
27
+ .elevation-control .tooltip,
28
+ .height-focus.line {
41
29
  pointer-events: none;
42
30
  }
43
31
 
44
- .elevation-control.elevation .axis line,
45
- .elevation-control.elevation .axis path {
32
+ .elevation-control .axis line,
33
+ .elevation-control .axis path {
46
34
  stroke: var(--ele-axis, #2D1130);
47
35
  stroke-width: 1;
48
36
  fill: none;
49
37
  }
50
38
 
51
- .elevation-control.elevation .grid .tick line {
39
+ .elevation-control .grid .tick line {
52
40
  stroke: var(--ele-grid, #EEE);
53
41
  stroke-width: 1px;
54
42
  shape-rendering: crispEdges;
55
43
  }
56
44
 
57
- .elevation-control.elevation .grid path {
45
+ .elevation-control .grid path {
58
46
  stroke-width: 0;
59
- pointer-events: none;
60
47
  }
61
48
 
62
- .elevation-control.elevation .axis text,
63
- .elevation-control.elevation .point text {
49
+ .elevation-control .axis text,
50
+ .elevation-control .legend text,
51
+ .elevation-control .point text {
64
52
  fill: #000;
65
53
  font-weight: 700;
66
54
  paint-order: stroke fill;
@@ -68,181 +56,120 @@
68
56
  stroke-width: 2px
69
57
  }
70
58
 
71
- .elevation-control.elevation .y.axis text {
59
+ .elevation-control .y.axis text {
72
60
  text-anchor: end;
73
61
  }
74
62
 
75
- .elevation-control.elevation .area {
63
+ .elevation-control .area {
76
64
  fill: var(--ele-area, #4682B4);
77
65
  stroke: var(--ele-stroke, #000);
78
66
  stroke-width: 1.2;
79
67
  paint-order: stroke fill;
80
68
  }
81
69
 
82
- .elevation-detached .elevation-control.elevation .area {
83
- fill-opacity: var(--ele-alpha, 0.8);
84
- }
85
-
86
- .elevation-control.elevation .horizontal-drag-line {
87
- stroke: transparent;
70
+ .elevation-control .horizontal-drag-line {
88
71
  cursor: row-resize;
89
- stroke-width: 1.1;
72
+ stroke: transparent;
90
73
  stroke-dasharray: 5;
74
+ stroke-width: 1.1;
91
75
  }
92
76
 
93
- .elevation-control.elevation .active .horizontal-drag-line {
77
+ .elevation-control .active .horizontal-drag-line {
94
78
  stroke: #000;
95
79
  }
96
80
 
97
- .elevation-control.elevation .horizontal-drag-label {
98
- font-weight: 700;
81
+ .elevation-control .horizontal-drag-label {
99
82
  fill: #000;
83
+ font-weight: 700;
100
84
  paint-order: stroke;
101
85
  stroke: #FFF;
102
86
  stroke-width: 2px;
103
- pointer-events: none;
104
87
  }
105
88
 
106
- .elevation-control.elevation .ruler {
107
- cursor: row-resize;
89
+ .elevation-control .ruler {
108
90
  color: #000;
91
+ cursor: row-resize;
109
92
  }
110
93
 
111
- .elevation-control.elevation .mouse-focus-line {
94
+ .elevation-control .mouse-focus-line {
112
95
  stroke: #000;
113
96
  stroke-width: 1;
114
- pointer-events: none;
115
97
  }
116
98
 
117
- .elevation-control.elevation .mouse-focus-label-rect {
99
+ .elevation-control .mouse-focus-label-rect {
118
100
  fill: #000;
119
101
  fill-opacity: 0.75;
120
- pointer-events: none;
121
102
  stroke-width: 1;
122
103
  stroke: #444;
123
104
  }
124
105
 
125
- .elevation-control.elevation .mouse-focus-label-text {
106
+ .elevation-control .mouse-focus-label-text {
126
107
  fill: #FFF;
127
- pointer-events: none;
128
108
  font-size: 10px;
129
109
  }
130
110
 
131
- .elevation-control.elevation .brush .overlay {
111
+ .elevation-control .brush .overlay {
132
112
  cursor: unset;
133
113
  }
134
114
 
135
- .elevation-control.elevation .brush .selection {
115
+ .elevation-control .brush .selection {
136
116
  fill: var(--ele-brush, rgba(23, 74, 117, 0.4));
137
117
  stroke: none;
138
118
  fill-opacity: unset;
139
119
  }
140
120
 
141
- .elevation-control.elevation .elevation-toggle {
142
- cursor: pointer;
143
- box-shadow: 0 1px 7px rgba(0, 0, 0, 0.4);
144
- border-radius: 5px;
145
- width: 36px;
146
- height: 36px;
147
- background-color: #F8F8F9;
148
- }
149
-
150
121
  .elevation-summary {
151
122
  font-family: "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
152
123
  font-size: 12px;
153
- margin: 0 auto;
124
+ margin: var(--ele-sum-margin, 0 auto);
125
+ text-shadow: var(--ele-sum-shadow, 1px 0 0 #FFF, -1px 0 0 #FFF, 0 1px 0 #FFF, 0 -1px 0 #FFF, 1px 1px #FFF, -1px -1px 0 #FFF, 1px -1px 0 #FFF, -1px 1px 0 #FFF);
154
126
  }
155
127
 
156
- .leaflet-control-container .elevation-summary {
157
- text-shadow:
158
- 1.5px 0 0 #FFF,
159
- -1.5px 0 0 #FFF,
160
- 0 1.5px 0 #FFF,
161
- 0 -1.5px 0 #FFF,
162
- 1px 1px #FFF,
163
- -1px -1px 0 #FFF,
164
- 1px -1px 0 #FFF,
165
- -1px 1px 0 #FFF;
128
+ .elevation-summary>span:not(:last-child):after {
129
+ content: var(--ele-sum-sep, '');
166
130
  }
167
131
 
168
- .elevation-detached .elevation-summary {
169
- margin: 0 45px;
170
- }
171
-
172
- .elevation-summary.multiline-summary {
173
- margin-right: 30px;
174
- }
175
-
176
- .elevation-detached .elevation-summary.multiline-summary {
177
- margin-bottom: 12px;
178
- margin-top: 12px;
179
- line-height: 2;
180
- }
181
-
182
- .elevation-summary.inline-summary>span:not(:last-child):after {
183
- content: "\0020\2014\0020";
184
- }
185
-
186
- .elevation-summary.multiline-summary>span {
132
+ .multiline-summary>span {
187
133
  display: block;
188
134
  }
189
135
 
190
- .elevation-summary.multiline-summary .download {
136
+ .multiline-summary .download {
191
137
  float: right;
192
- margin-top: -2.5em;
138
+ margin-top: -3em;
139
+ margin-right: 2em;
193
140
  font-weight: bold;
194
141
  font-size: 1.2em;
195
142
  }
196
143
 
197
- .elevation-detached .elevation-summary.multiline-summary .download {
198
- margin-top: -3.5em;
199
- }
200
-
201
144
  .elevation-summary .summaryvalue {
202
145
  font-weight: bold;
203
146
  }
204
147
 
205
- .elevation-control.elevation-collapsed .background,
206
- .elevation-control.elevation-collapsed .elevation-summary {
207
- display: none;
208
- }
209
-
210
- .elevation-control.elevation-collapsed .elevation-toggle {
211
- display: block;
212
- }
213
-
214
- .elevation-control.elevation .elevation-toggle-icon {
215
- background: var(--ele-icon, url(../images/elevation-lime.svg)) no-repeat center center;
216
- }
217
-
218
- .elevation-control.elevation.elevation-expanded .elevation-toggle-icon.close-button {
219
- background: transparent;
220
- position: absolute;
148
+ .elevation-toggle-icon {
149
+ background: var(--ele-toggle-bg, var(--ele-icon, url(../images/elevation-lime.svg)) no-repeat center center);
150
+ background-color: #fff;
221
151
  right: 5px;
222
152
  top: 5px;
223
- height: 20px;
224
- width: 20px;
153
+ height: var(--ele-toggle-size, 36px);
154
+ width: var(--ele-toggle-size, 36px);
155
+ cursor: pointer;
156
+ box-shadow: 0 1px 7px rgba(0, 0, 0, 0.4);
157
+ border-radius: 5px;
158
+ display: inline-block;
159
+ position: var(--ele-toggle-pos, relative);
225
160
  }
226
161
 
227
- .elevation-control.elevation.elevation-expanded .elevation-toggle-icon.close-button:before {
162
+ .elevation-toggle-icon:before {
228
163
  content: '\2716';
229
- display: inline-block;
164
+ display: var(--ele-close-btn, none);
230
165
  color: #000;
231
- position: absolute;
232
- left: 0;
233
- right: 0;
234
- top: 0;
235
- bottom: 0;
166
+ width: 100%;
236
167
  line-height: 20px;
237
168
  text-align: center;
238
169
  font-weight: bold;
239
170
  font-size: 15px;
240
171
  }
241
172
 
242
- .elevation-control.elevation g.area > foreignObject {
243
- pointer-events: none;
244
- }
245
-
246
173
  .leaflet-elevation-pane .height-focus,
247
174
  .leaflet-overlay-pane .height-focus {
248
175
  stroke: #000;
@@ -251,7 +178,6 @@
251
178
 
252
179
  .leaflet-elevation-pane .height-focus.line,
253
180
  .leaflet-overlay-pane .height-focus.line {
254
- pointer-events: none;
255
181
  stroke-width: 2;
256
182
  }
257
183
 
@@ -271,22 +197,73 @@
271
197
  width: 100%;
272
198
  height: 100%;
273
199
  display: inline-block;
200
+ background: var(--ele-marker) no-repeat center center / contain;
274
201
  }
275
202
 
276
- .elevation-waypoint-icon:before {
277
- background: url(../images/elevation-pushpin.svg) no-repeat center center / contain;
203
+ .elevation-polyline {
204
+ stroke: var(--ele-poly, var(--ele-area, #000));
205
+ filter: drop-shadow(1px 1px 0 #FFF) drop-shadow(-1px -1px 0 #FFF) drop-shadow(1px -1px 0 #FFF) drop-shadow(-1px 1px 0 #FFF);
278
206
  }
279
207
 
280
- .elevation-position-icon:before {
281
- background: url(../images/elevation-position.svg) no-repeat center center / contain;
208
+ /* CHART STATES /////////////////////////////////////////////////// */
209
+
210
+ .elevation-detached {
211
+ font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
212
+ height: auto;
213
+ width: 100%;
214
+ position: relative;
215
+ z-index: 0;
282
216
  }
283
217
 
284
- .elevation-polyline {
285
- stroke: var(--ele-poly, var(--ele-area, #000));
286
- filter: drop-shadow(1px 1px 0 #FFF) drop-shadow(-1px -1px 0 #FFF) drop-shadow(1px -1px 0 #FFF) drop-shadow(-1px 1px 0 #FFF);
218
+ .elevation-detached .area {
219
+ fill-opacity: var(--ele-alpha, 0.8);
220
+ }
221
+
222
+ .elevation-detached.elevation-collapsed .elevation-summary {
223
+ display: block;
224
+ }
225
+
226
+ .elevation-detached.elevation-collapsed .elevation-toggle-icon {
227
+ top: 5px;
228
+ right: 9px;
229
+ bottom: 5px;
230
+ margin: auto;
231
+ }
232
+
233
+ .elevation-control.elevation-collapsed > * {
234
+ display: none;
235
+ }
236
+
237
+ .elevation-control.elevation-collapsed > .elevation-toggle-icon {
238
+ display: inline-block;
239
+ }
240
+
241
+ .elevation-detached {
242
+ --ele-sum-margin: 12px 35px;
243
+ --ele-sum-shadow: none;
244
+ --ele-toggle-pos: absolute;
245
+ }
246
+
247
+ .elevation-expanded {
248
+ --ele-close-btn: inline-block;
249
+ --ele-toggle-bg: transparent;
250
+ --ele-toggle-pos: absolute;
251
+ --ele-toggle-size: 20px;
252
+ }
253
+
254
+ .inline-summary {
255
+ --ele-sum-sep: "\0020\2014\0020";
256
+ }
257
+
258
+ .elevation-waypoint-icon {
259
+ --ele-marker: url(../images/elevation-pushpin.svg);
260
+ }
261
+
262
+ .elevation-position-icon {
263
+ --ele-marker: url(../images/elevation-position.svg);
287
264
  }
288
265
 
289
- /* LIME THEME //////////////////////////////////////////////// */
266
+ /* LIME THEME ///////////////////////////////////////////////////// */
290
267
 
291
268
  .lime-theme {
292
269
  --ele-bg: rgba(156, 194, 34, 0.2);
@@ -307,7 +284,7 @@
307
284
  --ele-icon: url(../images/elevation-steelblue.svg);
308
285
  }
309
286
 
310
- /* PURPLE THEME //////////////////////////////////////////////// */
287
+ /* PURPLE THEME /////////////////////////////////////////////////// */
311
288
 
312
289
  .purple-theme {
313
290
  --ele-bg: rgba(115, 44, 123, 0.2);
@@ -316,19 +293,19 @@
316
293
  --ele-icon: url(../images/elevation-purple.svg);
317
294
  }
318
295
 
319
- /* YELLOW THEME //////////////////////////////////////////////// */
296
+ /* YELLOW THEME /////////////////////////////////////////////////// */
320
297
 
321
298
  .yellow-theme {
322
299
  --ele-area: #FF0;
323
300
  }
324
301
 
325
- /* RED THEME //////////////////////////////////////////////// */
302
+ /* RED THEME ////////////////////////////////////////////////////// */
326
303
 
327
304
  .red-theme {
328
305
  --ele-area: #F00;
329
306
  }
330
307
 
331
- /* MAGENTA THEME //////////////////////////////////////////////// */
308
+ /* MAGENTA THEME ////////////////////////////////////////////////// */
332
309
 
333
310
  .magenta-theme {
334
311
  --ele-bg: rgba(255, 255, 255, 0.47);
@@ -344,7 +321,7 @@
344
321
  --ele-circle: #fff;
345
322
  }
346
323
 
347
- .elevation-detached .lightblue-theme.elevation-control.elevation .area {
324
+ .elevation-detached.lightblue-theme .area {
348
325
  stroke: #3366CC;
349
326
  }
350
327
 
@@ -186,9 +186,9 @@
186
186
  /**
187
187
  * Alias for some leaflet core functions
188
188
  */
189
- const { on, off } = L.DomEvent;
190
- const { throttle } = L.Util;
191
- const { hasClass } = L.DomUtil;
189
+ const { on, off } = L.DomEvent;
190
+ const { throttle, wrapNum } = L.Util;
191
+ const { hasClass } = L.DomUtil;
192
192
 
193
193
  /**
194
194
  * Limit floating point precision
@@ -236,6 +236,7 @@
236
236
  on: on,
237
237
  off: off,
238
238
  throttle: throttle,
239
+ wrapNum: wrapNum,
239
240
  hasClass: hasClass,
240
241
  round: round,
241
242
  clamp: clamp,
@@ -244,10 +245,11 @@
244
245
 
245
246
  var Options = {
246
247
  autofitBounds: true,
247
- autohide: !L.Browser.mobile,
248
+ autohide: false,
248
249
  autohideMarker: true,
249
250
  almostover: true,
250
251
  altitude: true,
252
+ closeBtn: true,
251
253
  collapsed: false,
252
254
  detached: true,
253
255
  distance: true,
@@ -308,7 +310,13 @@
308
310
  zFollow: false,
309
311
  zooming: !L.Browser.Mobile,
310
312
 
311
- // Quite uncommon and undocumented options (quite useless)
313
+ // Quite uncommon and undocumented options
314
+ margins: { top: 30, right: 30, bottom: 30, left: 40 },
315
+ height: (screen.height * 0.3) || 200,
316
+ width: (screen.width * 0.6) || 600,
317
+ xTicks: undefined,
318
+ yTicks: undefined,
319
+
312
320
  decimalsX: 2,
313
321
  decimalsY: 0,
314
322
  forceAxisBounds: false,
@@ -316,13 +324,6 @@
316
324
  skipNullZCoords: false,
317
325
  yAxisMax: undefined,
318
326
  yAxisMin: undefined,
319
-
320
- // Probably no longer functional as expected (internally overwritten)
321
- margins: { top: 30, right: 30, bottom: 30, left: 40 },
322
- height: 200,
323
- width: 600,
324
- xTicks: undefined,
325
- yTicks: undefined,
326
327
  };
327
328
 
328
329
  const Elevation = L.Control.Elevation = L.Control.extend({
@@ -330,8 +331,8 @@
330
331
  includes: L.Evented ? L.Evented.prototype : L.Mixin.Events,
331
332
 
332
333
  options: Options,
333
- __mileFactor: 0.621371, // 1 km = (0.621371 mi)
334
- __footFactor: 3.28084, // 1 m = (3.28084 ft)
334
+ __mileFactor: 0.621371, // 1 km = (0.621371 mi)
335
+ __footFactor: 3.28084, // 1 m = (3.28084 ft)
335
336
  __D3: 'https://unpkg.com/d3@6.5.0/dist/d3.min.js',
336
337
  __TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@4.6.0/dist/togeojson.umd.js',
337
338
  __LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js',
@@ -360,9 +361,9 @@
360
361
  */
361
362
  addTo: function(map) {
362
363
  if (this.options.detached) {
363
- let eleDiv = this._initElevationDiv();
364
- if (!eleDiv.isConnected) insert(map.getContainer(), eleDiv, 'afterend');
365
- append(eleDiv, this.onAdd(map));
364
+ let parent = select(this.options.elevationDiv);
365
+ let eleDiv = this.onAdd(map);
366
+ parent ? append(parent, eleDiv) : insert(map.getContainer(), eleDiv, 'afterend');
366
367
  } else {
367
368
  L.Control.prototype.addTo.call(this, map);
368
369
  }
@@ -544,7 +545,9 @@
544
545
  onAdd: function(map) {
545
546
  this._map = map;
546
547
 
547
- let container = this._container = create("div", "elevation-control elevation " + this.options.theme + " " + (this.options.detached ? '' : 'leaflet-control'));
548
+ let container = this._container = create("div", "elevation-control " + this.options.theme + " " + (this.options.detached ? 'elevation-detached' : 'leaflet-control'), this.options.detached ? { id: 'elevation-' + randomId() } : {});
549
+
550
+ if (!this.eleDiv) this.eleDiv = container;
548
551
 
549
552
  let modules = [
550
553
  "Distance",
@@ -736,21 +739,6 @@
736
739
  }
737
740
  },
738
741
 
739
- /**
740
- * Adds the control to the given "detached" div.
741
- */
742
- _initElevationDiv: function() {
743
- let eleDiv = select(this.options.elevationDiv);
744
- if (!eleDiv) {
745
- this.options.elevationDiv = '#elevation-div_' + randomId();
746
- eleDiv = create('div', 'leaflet-control elevation elevation-div', { id: this.options.elevationDiv.substr(1) });
747
- }
748
- if (this.options.detached) {
749
- replaceClass(eleDiv, 'leaflet-control', 'elevation-detached');
750
- }
751
- return this.eleDiv = eleDiv;
752
- },
753
-
754
742
  /**
755
743
  * Initialize "L.AlmostOver" and "L.DistanceMarkers"
756
744
  */
@@ -769,6 +757,7 @@
769
757
  } else if (control.options.polyline) {
770
758
  layer.addTo(map);
771
759
  }
760
+ map.invalidateSize();
772
761
  } else {
773
762
  console.warn("Undefined elevation map object"); }
774
763
  },
@@ -794,7 +783,7 @@
794
783
  let oldProto = L.Canvas.prototype._fillStroke;
795
784
  let control = this;
796
785
 
797
- let theme = this.options.theme.replace('-theme', '');
786
+ let theme = this.options.theme.split(' ')[0].replace('-theme', '');
798
787
  let color = Colors[theme] || {};
799
788
 
800
789
  L.Canvas.include({
@@ -915,10 +904,6 @@
915
904
  .on('margins_updated', this._resizeChart, this);
916
905
 
917
906
 
918
- this.fire("elechart_axis");
919
-
920
- if (this.options.legend) this.fire("elechart_legend");
921
-
922
907
  this.fire("elechart_init");
923
908
 
924
909
  map
@@ -983,23 +968,19 @@
983
968
  .disableScrollPropagation(container);
984
969
  }
985
970
 
986
- if (!this.options.detached) {
987
- let link = this._button = create('a', "elevation-toggle elevation-toggle-icon" + (this.options.autohide ? "" : " close-button"), { href: '#', title: L._('Elevation') }, container);
988
-
989
- if (this.options.collapsed) {
990
- this._collapse();
991
- if (this.options.autohide) {
992
- on(container, 'mouseover', this._expand, this);
993
- on(container, 'mouseout', this._collapse, this);
994
- } else {
995
- on(link, 'click', L.DomEvent.stop);
996
- on(link, 'click', this._toggle, this);
997
- }
971
+ this.options.collapsed ? this._collapse() : this._expand();
998
972
 
999
- on(link, 'focus', this._toggle, this);
973
+ if (this.options.autohide) {
974
+ on(container, 'mouseover', this._expand, this);
975
+ on(container, 'mouseout', this._collapse, this);
976
+ this._map.on('click', this._collapse, this);
977
+ }
1000
978
 
1001
- this._map.on('click', this._collapse, this);
1002
- }
979
+ if (this.options.closeBtn) {
980
+ let link = this._button = create('a', "elevation-toggle-icon", { href: '#', title: L._('Elevation'), }, container);
981
+ on(link, 'click', L.DomEvent.stop);
982
+ on(link, 'click', this._toggle, this);
983
+ on(link, 'focus', this._toggle, this);
1003
984
  }
1004
985
  },
1005
986
 
@@ -1526,7 +1507,6 @@
1526
1507
  _updateChart: function() {
1527
1508
  if (this._chart && this._container) {
1528
1509
  this.fire("elechart_axis");
1529
- this.fire("elechart_area");
1530
1510
 
1531
1511
  this._chart.update({ data: this._data, options: this.options });
1532
1512
 
@@ -1574,27 +1554,27 @@
1574
1554
  * Update chart summary.
1575
1555
  */
1576
1556
  _updateSummary: function() {
1577
- if (!this._summary) return;
1578
-
1579
- this._summary.reset();
1580
-
1581
- if (this.options.summary) {
1582
- this.fire("elechart_summary");
1583
- this._summary.update();
1557
+ if (this._summary) {
1558
+ this._summary.reset();
1559
+ if (this.options.summary) {
1560
+ this.fire("elechart_summary");
1561
+ this._summary.update();
1562
+ }
1563
+ if (this.options.downloadLink && this._downloadURL) { // TODO: generate dynamically file content instead of using static file urls.
1564
+ this._summary._container.innerHTML += '<span class="download"><a href="#">' + L._('Download') + '</a></span>';
1565
+ select('.download a', this._summary._container).onclick = (e) => {
1566
+ e.preventDefault();
1567
+ let event = { downloadLink: this.options.downloadLink, confirm: saveFile.bind(this, this._downloadURL) };
1568
+ if (this.options.downloadLink == 'modal' && typeof CustomEvent === "function") {
1569
+ document.dispatchEvent(new CustomEvent("eletrack_download", { detail: event }));
1570
+ } else if (this.options.downloadLink == 'link' || this.options.downloadLink === true) {
1571
+ event.confirm();
1572
+ }
1573
+ this.fire('eletrack_download', event);
1574
+ };
1575
+ }
1584
1576
  }
1585
- if (this.options.downloadLink && this._downloadURL) { // TODO: generate dynamically file content instead of using static file urls.
1586
- this._summary._container.innerHTML += '<span class="download"><a href="#">' + L._('Download') + '</a></span>';
1587
- select('.download a', this._summary._container).onclick = ({preventDefault}) => {
1588
- preventDefault();
1589
- let event = { downloadLink: this.options.downloadLink, confirm: saveFile.bind(this, this._downloadURL) };
1590
- if (this.options.downloadLink == 'modal' && typeof CustomEvent === "function") {
1591
- document.dispatchEvent(new CustomEvent("eletrack_download", { detail: event }));
1592
- } else if (this.options.downloadLink == 'link' || this.options.downloadLink === true) {
1593
- event.confirm();
1594
- }
1595
- this.fire('eletrack_download', event);
1596
- };
1597
- } },
1577
+ },
1598
1578
 
1599
1579
 
1600
1580
  /**