ngx-trend 6.1.0 → 8.0.0

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.
@@ -1,593 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/animations'), require('@angular/core'), require('@angular/common')) :
3
- typeof define === 'function' && define.amd ? define('ngx-trend', ['exports', '@angular/animations', '@angular/core', '@angular/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['ngx-trend'] = {}, global.ng.animations, global.ng.core, global.ng.common));
5
- }(this, (function (exports, animations, core, common) { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
- var extendStatics = function (d, b) {
23
- extendStatics = Object.setPrototypeOf ||
24
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25
- function (d, b) { for (var p in b)
26
- if (b.hasOwnProperty(p))
27
- d[p] = b[p]; };
28
- return extendStatics(d, b);
29
- };
30
- function __extends(d, b) {
31
- extendStatics(d, b);
32
- function __() { this.constructor = d; }
33
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
- }
35
- var __assign = function () {
36
- __assign = Object.assign || function __assign(t) {
37
- for (var s, i = 1, n = arguments.length; i < n; i++) {
38
- s = arguments[i];
39
- for (var p in s)
40
- if (Object.prototype.hasOwnProperty.call(s, p))
41
- t[p] = s[p];
42
- }
43
- return t;
44
- };
45
- return __assign.apply(this, arguments);
46
- };
47
- function __rest(s, e) {
48
- var t = {};
49
- for (var p in s)
50
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
- t[p] = s[p];
52
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
- t[p[i]] = s[p[i]];
56
- }
57
- return t;
58
- }
59
- function __decorate(decorators, target, key, desc) {
60
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
61
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
62
- r = Reflect.decorate(decorators, target, key, desc);
63
- else
64
- for (var i = decorators.length - 1; i >= 0; i--)
65
- if (d = decorators[i])
66
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
67
- return c > 3 && r && Object.defineProperty(target, key, r), r;
68
- }
69
- function __param(paramIndex, decorator) {
70
- return function (target, key) { decorator(target, key, paramIndex); };
71
- }
72
- function __metadata(metadataKey, metadataValue) {
73
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
74
- return Reflect.metadata(metadataKey, metadataValue);
75
- }
76
- function __awaiter(thisArg, _arguments, P, generator) {
77
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
78
- return new (P || (P = Promise))(function (resolve, reject) {
79
- function fulfilled(value) { try {
80
- step(generator.next(value));
81
- }
82
- catch (e) {
83
- reject(e);
84
- } }
85
- function rejected(value) { try {
86
- step(generator["throw"](value));
87
- }
88
- catch (e) {
89
- reject(e);
90
- } }
91
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
92
- step((generator = generator.apply(thisArg, _arguments || [])).next());
93
- });
94
- }
95
- function __generator(thisArg, body) {
96
- var _ = { label: 0, sent: function () { if (t[0] & 1)
97
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
98
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
99
- function verb(n) { return function (v) { return step([n, v]); }; }
100
- function step(op) {
101
- if (f)
102
- throw new TypeError("Generator is already executing.");
103
- while (_)
104
- try {
105
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
106
- return t;
107
- if (y = 0, t)
108
- op = [op[0] & 2, t.value];
109
- switch (op[0]) {
110
- case 0:
111
- case 1:
112
- t = op;
113
- break;
114
- case 4:
115
- _.label++;
116
- return { value: op[1], done: false };
117
- case 5:
118
- _.label++;
119
- y = op[1];
120
- op = [0];
121
- continue;
122
- case 7:
123
- op = _.ops.pop();
124
- _.trys.pop();
125
- continue;
126
- default:
127
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
128
- _ = 0;
129
- continue;
130
- }
131
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
132
- _.label = op[1];
133
- break;
134
- }
135
- if (op[0] === 6 && _.label < t[1]) {
136
- _.label = t[1];
137
- t = op;
138
- break;
139
- }
140
- if (t && _.label < t[2]) {
141
- _.label = t[2];
142
- _.ops.push(op);
143
- break;
144
- }
145
- if (t[2])
146
- _.ops.pop();
147
- _.trys.pop();
148
- continue;
149
- }
150
- op = body.call(thisArg, _);
151
- }
152
- catch (e) {
153
- op = [6, e];
154
- y = 0;
155
- }
156
- finally {
157
- f = t = 0;
158
- }
159
- if (op[0] & 5)
160
- throw op[1];
161
- return { value: op[0] ? op[1] : void 0, done: true };
162
- }
163
- }
164
- var __createBinding = Object.create ? (function (o, m, k, k2) {
165
- if (k2 === undefined)
166
- k2 = k;
167
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
168
- }) : (function (o, m, k, k2) {
169
- if (k2 === undefined)
170
- k2 = k;
171
- o[k2] = m[k];
172
- });
173
- function __exportStar(m, exports) {
174
- for (var p in m)
175
- if (p !== "default" && !exports.hasOwnProperty(p))
176
- __createBinding(exports, m, p);
177
- }
178
- function __values(o) {
179
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
180
- if (m)
181
- return m.call(o);
182
- if (o && typeof o.length === "number")
183
- return {
184
- next: function () {
185
- if (o && i >= o.length)
186
- o = void 0;
187
- return { value: o && o[i++], done: !o };
188
- }
189
- };
190
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
191
- }
192
- function __read(o, n) {
193
- var m = typeof Symbol === "function" && o[Symbol.iterator];
194
- if (!m)
195
- return o;
196
- var i = m.call(o), r, ar = [], e;
197
- try {
198
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
199
- ar.push(r.value);
200
- }
201
- catch (error) {
202
- e = { error: error };
203
- }
204
- finally {
205
- try {
206
- if (r && !r.done && (m = i["return"]))
207
- m.call(i);
208
- }
209
- finally {
210
- if (e)
211
- throw e.error;
212
- }
213
- }
214
- return ar;
215
- }
216
- function __spread() {
217
- for (var ar = [], i = 0; i < arguments.length; i++)
218
- ar = ar.concat(__read(arguments[i]));
219
- return ar;
220
- }
221
- function __spreadArrays() {
222
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
223
- s += arguments[i].length;
224
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
225
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
226
- r[k] = a[j];
227
- return r;
228
- }
229
- ;
230
- function __await(v) {
231
- return this instanceof __await ? (this.v = v, this) : new __await(v);
232
- }
233
- function __asyncGenerator(thisArg, _arguments, generator) {
234
- if (!Symbol.asyncIterator)
235
- throw new TypeError("Symbol.asyncIterator is not defined.");
236
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
237
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
238
- function verb(n) { if (g[n])
239
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
240
- function resume(n, v) { try {
241
- step(g[n](v));
242
- }
243
- catch (e) {
244
- settle(q[0][3], e);
245
- } }
246
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
247
- function fulfill(value) { resume("next", value); }
248
- function reject(value) { resume("throw", value); }
249
- function settle(f, v) { if (f(v), q.shift(), q.length)
250
- resume(q[0][0], q[0][1]); }
251
- }
252
- function __asyncDelegator(o) {
253
- var i, p;
254
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
255
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
256
- }
257
- function __asyncValues(o) {
258
- if (!Symbol.asyncIterator)
259
- throw new TypeError("Symbol.asyncIterator is not defined.");
260
- var m = o[Symbol.asyncIterator], i;
261
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
262
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
263
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
264
- }
265
- function __makeTemplateObject(cooked, raw) {
266
- if (Object.defineProperty) {
267
- Object.defineProperty(cooked, "raw", { value: raw });
268
- }
269
- else {
270
- cooked.raw = raw;
271
- }
272
- return cooked;
273
- }
274
- ;
275
- var __setModuleDefault = Object.create ? (function (o, v) {
276
- Object.defineProperty(o, "default", { enumerable: true, value: v });
277
- }) : function (o, v) {
278
- o["default"] = v;
279
- };
280
- function __importStar(mod) {
281
- if (mod && mod.__esModule)
282
- return mod;
283
- var result = {};
284
- if (mod != null)
285
- for (var k in mod)
286
- if (Object.hasOwnProperty.call(mod, k))
287
- __createBinding(result, mod, k);
288
- __setModuleDefault(result, mod);
289
- return result;
290
- }
291
- function __importDefault(mod) {
292
- return (mod && mod.__esModule) ? mod : { default: mod };
293
- }
294
- function __classPrivateFieldGet(receiver, privateMap) {
295
- if (!privateMap.has(receiver)) {
296
- throw new TypeError("attempted to get private field on non-instance");
297
- }
298
- return privateMap.get(receiver);
299
- }
300
- function __classPrivateFieldSet(receiver, privateMap, value) {
301
- if (!privateMap.has(receiver)) {
302
- throw new TypeError("attempted to set private field on non-instance");
303
- }
304
- privateMap.set(receiver, value);
305
- return value;
306
- }
307
-
308
- /* eslint-disable no-restricted-properties */
309
- /** normalize
310
- * This lets us translate a value from one scale to another.
311
- *
312
- * @param value - Our initial value to translate
313
- * @param min - the current minimum value possible
314
- * @param max - the current maximum value possible
315
- * @param scaleMin - the min value of the scale we're translating to
316
- * @param scaleMax - the max value of the scale we're translating to
317
- * @returns the value on its new scale
318
- */
319
- function normalize(value, min, max, scaleMin, scaleMax) {
320
- if (scaleMin === void 0) { scaleMin = 0; }
321
- if (scaleMax === void 0) { scaleMax = 1; }
322
- // If the `min` and `max` are the same value, it means our dataset is flat.
323
- // For now, let's assume that flat data should be aligned to the bottom.
324
- if (min === max) {
325
- return scaleMin;
326
- }
327
- return scaleMin + (value - min) * (scaleMax - scaleMin) / (max - min);
328
- }
329
- /** moveTo
330
- * the coordinate that lies at a midpoint between 2 lines, based on the radius
331
- *
332
- * @param to - Our initial point
333
- * @param to.x - The x value of our initial point
334
- * @param to.y - The y value of our initial point
335
- * @param from - Our final point
336
- * @param from.x - The x value of our final point
337
- * @param from.y - The y value of our final point
338
- * @param radius - The distance away from the final point
339
- * @returns an object holding the x/y coordinates of the midpoint.
340
- */
341
- function moveTo(to, from, radius) {
342
- var length = Math.sqrt((to.x - from.x) * (to.x - from.x) + (to.y - from.y) * (to.y - from.y));
343
- var unitVector = { x: (to.x - from.x) / length, y: (to.y - from.y) / length };
344
- return {
345
- x: from.x + unitVector.x * radius,
346
- y: from.y + unitVector.y * radius,
347
- };
348
- }
349
- /** getDistanceBetween
350
- * Simple formula derived from pythagoras to calculate the distance between
351
- * 2 points on a plane.
352
- *
353
- * @param p1 - Our initial point
354
- * @param p1.x - The x value of our initial point
355
- * @param p1.y - The y value of our initial point
356
- * @param p2 - Our final point
357
- * @param p2.x - The x value of our final point
358
- * @param p2.y - The y value of our final point
359
- * @returns the distance between the points.
360
- */
361
- var getDistanceBetween = function (p1, p2) { return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)); };
362
- /** checkForCollinearPoints
363
- * Figure out if the midpoint fits perfectly on a line between the two others.
364
- *
365
- * @param p1 - Our initial point
366
- * @param p1.x - The x value of our initial point
367
- * @param p1.y - The y value of our initial point
368
- * @param p2 - Our mid-point
369
- * @param p2.x - The x value of our mid-point
370
- * @param p2.y - The y value of our mid-point
371
- * @param p3 - Our final point
372
- * @param p3.x - The x value of our final point
373
- * @param p3.y - The y value of our final point
374
- * @returns whether or not p2 sits on the line between p1 and p3.
375
- */
376
- var checkForCollinearPoints = function (p1, p2, p3) { return (p1.y - p2.y) * (p1.x - p3.x) === (p1.y - p3.y) * (p1.x - p2.x); };
377
-
378
- var buildLinearPath = function (data) { return data.reduce(function (path, point, index) {
379
- // The very first instruction needs to be a "move".
380
- // The rest will be a "line".
381
- var isFirstInstruction = index === 0;
382
- var instruction = isFirstInstruction ? 'M' : 'L';
383
- return "" + path + instruction + " " + point.x + "," + point.y + "\n";
384
- }, ''); };
385
- function buildSmoothPath(data, radius) {
386
- var _a = __read(data), firstPoint = _a[0], otherPoints = _a.slice(1);
387
- return otherPoints.reduce(function (path, point, index) {
388
- var next = otherPoints[index + 1];
389
- var prev = otherPoints[index - 1] || firstPoint;
390
- var isCollinear = next && checkForCollinearPoints(prev, point, next);
391
- if (!next || isCollinear) {
392
- // The very last line in the sequence can just be a regular line.
393
- return path + "\nL " + point.x + "," + point.y;
394
- }
395
- var distanceFromPrev = getDistanceBetween(prev, point);
396
- var distanceFromNext = getDistanceBetween(next, point);
397
- var threshold = Math.min(distanceFromPrev, distanceFromNext);
398
- var isTooCloseForRadius = threshold / 2 < radius;
399
- var radiusForPoint = isTooCloseForRadius ? threshold / 2 : radius;
400
- var before = moveTo(prev, point, radiusForPoint);
401
- var after = moveTo(next, point, radiusForPoint);
402
- return [
403
- path,
404
- "L " + before.x + "," + before.y,
405
- "S " + point.x + "," + point.y + " " + after.x + "," + after.y,
406
- ].join('\n');
407
- }, "M " + firstPoint.x + "," + firstPoint.y);
408
- }
409
-
410
- var generateId = function () { return Math.round(Math.random() * Math.pow(10, 16)); };
411
-
412
- function normalizeDataset(data, minX, maxX, minY, maxY) {
413
- // For the X axis, we want to normalize it based on its index in the array.
414
- // For the Y axis, we want to normalize it based on the element's value.
415
- //
416
- // X axis is easy: just evenly-space each item in the array.
417
- // For the Y axis, we first need to find the min and max of our array,
418
- // and then normalize those values between 0 and 1.
419
- var boundariesX = { min: 0, max: data.length - 1 };
420
- var boundariesY = { min: Math.min.apply(Math, __spread(data)), max: Math.max.apply(Math, __spread(data)) };
421
- var normalizedData = data.map(function (point, index) { return ({
422
- x: normalize(index, boundariesX.min, boundariesX.max, minX, maxX),
423
- y: normalize(point, boundariesY.min, boundariesY.max, minY, maxY),
424
- }); });
425
- // According to the SVG spec, paths with a height/width of `0` can't have
426
- // linear gradients applied. This means that our lines are invisible when
427
- // the dataset is flat (eg. [0, 0, 0, 0]).
428
- //
429
- // The hacky solution is to apply a very slight offset to the first point of
430
- // the dataset. As ugly as it is, it's the best solution we can find (there
431
- // are ways within the SVG spec of changing it, but not without causing
432
- // breaking changes).
433
- if (boundariesY.min === boundariesY.max) {
434
- normalizedData[0].y += 0.0001;
435
- }
436
- return normalizedData;
437
- }
438
-
439
- var TrendComponent = /** @class */ (function () {
440
- function TrendComponent() {
441
- this.autoDraw = false;
442
- this.autoDrawDuration = 2000;
443
- this.autoDrawEasing = 'ease';
444
- this.padding = 8;
445
- this.radius = 10;
446
- this.stroke = 'black';
447
- this.strokeLinecap = '';
448
- this.strokeWidth = 1;
449
- this.gradient = [];
450
- this.svgHeight = '25%';
451
- this.svgWidth = '100%';
452
- this.animationState = '';
453
- this.id = generateId();
454
- this.gradientId = "ngx-trend-vertical-gradient-" + this.id;
455
- }
456
- TrendComponent.prototype.ngOnChanges = function () {
457
- var _this = this;
458
- // We need at least 2 points to draw a graph.
459
- if (!this.data || this.data.length < 2) {
460
- return;
461
- }
462
- // `data` can either be an array of numbers:
463
- // [1, 2, 3]
464
- // or, an array of objects containing a value:
465
- // [{ value: 1 }, { value: 2 }, { value: 3 }]
466
- //
467
- // For now, we're just going to convert the second form to the first.
468
- // Later on, if/when we support tooltips, we may adjust.
469
- var plainValues = this.data.map(function (point) {
470
- if (typeof point === 'number') {
471
- return point;
472
- }
473
- return point.value;
474
- });
475
- // Our viewbox needs to be in absolute units, so we'll default to 300x75
476
- // Our SVG can be a %, though; this is what makes it scalable.
477
- // By defaulting to percentages, the SVG will grow to fill its parent
478
- // container, preserving a 1/4 aspect ratio.
479
- var viewBoxWidth = this.width || 300;
480
- var viewBoxHeight = this.height || 75;
481
- this.svgWidth = this.width || '100%';
482
- this.svgHeight = this.height || '25%';
483
- this.viewBox = "0 0 " + viewBoxWidth + " " + viewBoxHeight;
484
- var root = location.href.split(location.hash || '#')[0];
485
- this.pathStroke =
486
- this.gradient && this.gradient.length ? "url('" + root + "#" + this.gradientId + "')" : undefined;
487
- this.gradientTrimmed = this.gradient
488
- .slice()
489
- .reverse()
490
- .map(function (val, idx) {
491
- return {
492
- idx: idx,
493
- stopColor: val,
494
- offset: normalize(idx, 0, _this.gradient.length - 1 || 1),
495
- };
496
- });
497
- var normalizedValues = normalizeDataset(plainValues, this.padding, viewBoxWidth - this.padding,
498
- // NOTE: Because SVGs are indexed from the top left, but most data is
499
- // indexed from the bottom left, we're inverting the Y min/max.
500
- viewBoxHeight - this.padding, this.padding);
501
- if (this.autoDraw && this.animationState !== 'active') {
502
- this.animationState = 'inactive';
503
- setTimeout(function () {
504
- _this.lineLength = _this.pathEl.nativeElement.getTotalLength();
505
- _this.animationState = 'active';
506
- });
507
- }
508
- this.d = this.smooth
509
- ? buildSmoothPath(normalizedValues, this.radius)
510
- : buildLinearPath(normalizedValues);
511
- };
512
- return TrendComponent;
513
- }());
514
- TrendComponent.decorators = [
515
- { type: core.Component, args: [{
516
- selector: 'ngx-trend',
517
- template: "\n <svg\n *ngIf=\"data && data.length >= 2\"\n [attr.width]=\"svgWidth\"\n [attr.height]=\"svgHeight\"\n [attr.stroke]=\"stroke\"\n [attr.stroke-width]=\"strokeWidth\"\n [attr.stroke-linecap]=\"strokeLinecap\"\n [attr.viewBox]=\"viewBox\"\n [attr.preserveAspectRatio]=\"preserveAspectRatio\"\n >\n <defs *ngIf=\"gradient && gradient.length\">\n <linearGradient [attr.id]=\"gradientId\" x1=\"0%\" y1=\"0%\" x2=\"0%\" y2=\"100%\">\n <stop\n *ngFor=\"let g of gradientTrimmed\"\n [attr.key]=\"g.idx\"\n [attr.offset]=\"g.offset\"\n [attr.stop-color]=\"g.stopColor\"\n />\n </linearGradient>\n </defs>\n <path\n fill=\"none\"\n #pathEl\n [attr.stroke]=\"pathStroke\"\n [attr.d]=\"d\"\n [@pathAnimaiton]=\"{\n value: animationState,\n params: {\n autoDrawDuration: autoDrawDuration,\n autoDrawEasing: autoDrawEasing,\n lineLength: lineLength\n }\n }\"\n />\n </svg>\n ",
518
- animations: [
519
- animations.trigger('pathAnimaiton', [
520
- animations.state('inactive', animations.style({ display: 'none' })),
521
- animations.transition('* => active', [
522
- animations.style({ display: 'initial' }),
523
- // We do the animation using the dash array/offset trick
524
- // https://css-tricks.com/svg-line-animation-works/
525
- animations.animate('{{ autoDrawDuration }}ms {{ autoDrawEasing }}', animations.keyframes([
526
- animations.style({
527
- 'stroke-dasharray': '{{ lineLength }}px',
528
- 'stroke-dashoffset': '{{ lineLength }}px',
529
- }),
530
- animations.style({
531
- 'stroke-dasharray': '{{ lineLength }}px',
532
- 'stroke-dashoffset': 0,
533
- }),
534
- ])),
535
- // One unfortunate side-effect of the auto-draw is that the line is
536
- // actually 1 big dash, the same length as the line itself. If the
537
- // line length changes (eg. radius change, new data), that dash won't
538
- // be the same length anymore. We can fix that by removing those
539
- // properties once the auto-draw is completed.
540
- animations.style({
541
- 'stroke-dashoffset': '',
542
- 'stroke-dasharray': '',
543
- }),
544
- ]),
545
- ]),
546
- ]
547
- },] }
548
- ];
549
- TrendComponent.ctorParameters = function () { return []; };
550
- TrendComponent.propDecorators = {
551
- data: [{ type: core.Input }],
552
- smooth: [{ type: core.Input }],
553
- autoDraw: [{ type: core.Input }],
554
- autoDrawDuration: [{ type: core.Input }],
555
- autoDrawEasing: [{ type: core.Input }],
556
- width: [{ type: core.Input }],
557
- height: [{ type: core.Input }],
558
- padding: [{ type: core.Input }],
559
- radius: [{ type: core.Input }],
560
- stroke: [{ type: core.Input }],
561
- strokeLinecap: [{ type: core.Input }],
562
- strokeWidth: [{ type: core.Input }],
563
- gradient: [{ type: core.Input }],
564
- preserveAspectRatio: [{ type: core.Input }],
565
- svgHeight: [{ type: core.Input }],
566
- svgWidth: [{ type: core.Input }],
567
- pathEl: [{ type: core.ViewChild, args: ['pathEl',] }]
568
- };
569
-
570
- var TrendModule = /** @class */ (function () {
571
- function TrendModule() {
572
- }
573
- return TrendModule;
574
- }());
575
- TrendModule.decorators = [
576
- { type: core.NgModule, args: [{
577
- imports: [common.CommonModule],
578
- exports: [TrendComponent],
579
- declarations: [TrendComponent],
580
- },] }
581
- ];
582
-
583
- /**
584
- * Generated bundle index. Do not edit.
585
- */
586
-
587
- exports.TrendComponent = TrendComponent;
588
- exports.TrendModule = TrendModule;
589
-
590
- Object.defineProperty(exports, '__esModule', { value: true });
591
-
592
- })));
593
- //# sourceMappingURL=ngx-trend.umd.js.map