1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/animations'), require('@angular/cdk/portal'), require('rxjs'), require('rxjs/operators'), require('d3-selection'), require('d3-brush'), require('d3-scale'), require('d3-shape'), require('d3-array'), require('d3-interpolate'), require('d3-ease'), require('clone-deep'), require('d3-format'), require('d3-color'), require('d3-hierarchy'), require('d3-time-format')) :
|
3 | typeof define === 'function' && define.amd ? define('@swimlane/ngx-charts', ['exports', '@angular/core', '@angular/common', '@angular/animations', '@angular/cdk/portal', 'rxjs', 'rxjs/operators', 'd3-selection', 'd3-brush', 'd3-scale', 'd3-shape', 'd3-array', 'd3-interpolate', 'd3-ease', 'clone-deep', 'd3-format', 'd3-color', 'd3-hierarchy', 'd3-time-format'], factory) :
|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.swimlane = global.swimlane || {}, global.swimlane['ngx-charts'] = {}), global.ng.core, global.ng.common, global.ng.animations, global.ng.cdk.portal, global.rxjs, global.rxjs.operators, global['d3-selection'], global['d3-brush'], global['d3-scale'], global['d3-shape'], global['d3-array'], global['d3-interpolate'], global.d3Ease, global.cloneDeep, global['d3-format'], global['d3-color'], global['d3-hierarchy'], global['d3-time-format']));
|
5 | }(this, (function (exports, core, common, animations, portal, rxjs, operators, d3Selection, d3Brush, d3Scale, d3Shape, d3Array, d3Interpolate, d3Ease, cloneDeep, d3Format, d3_color, d3Hierarchy, d3TimeFormat) { 'use strict';
|
6 |
|
7 | function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
8 |
|
9 | function _interopNamespace(e) {
|
10 | if (e && e.__esModule) return e;
|
11 | var n = Object.create(null);
|
12 | if (e) {
|
13 | Object.keys(e).forEach(function (k) {
|
14 | if (k !== 'default') {
|
15 | var d = Object.getOwnPropertyDescriptor(e, k);
|
16 | Object.defineProperty(n, k, d.get ? d : {
|
17 | enumerable: true,
|
18 | get: function () {
|
19 | return e[k];
|
20 | }
|
21 | });
|
22 | }
|
23 | });
|
24 | }
|
25 | n['default'] = e;
|
26 | return Object.freeze(n);
|
27 | }
|
28 |
|
29 | var cloneDeep__default = _interopDefaultLegacy(cloneDeep);
|
30 | var d3_color__namespace = _interopNamespace(d3_color);
|
31 |
|
32 | |
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | var extendStatics = function (d, b) {
|
48 | extendStatics = Object.setPrototypeOf ||
|
49 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
50 | function (d, b) { for (var p in b)
|
51 | if (Object.prototype.hasOwnProperty.call(b, p))
|
52 | d[p] = b[p]; };
|
53 | return extendStatics(d, b);
|
54 | };
|
55 | function __extends(d, b) {
|
56 | if (typeof b !== "function" && b !== null)
|
57 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
58 | extendStatics(d, b);
|
59 | function __() { this.constructor = d; }
|
60 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
61 | }
|
62 | var __assign = function () {
|
63 | __assign = Object.assign || function __assign(t) {
|
64 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
65 | s = arguments[i];
|
66 | for (var p in s)
|
67 | if (Object.prototype.hasOwnProperty.call(s, p))
|
68 | t[p] = s[p];
|
69 | }
|
70 | return t;
|
71 | };
|
72 | return __assign.apply(this, arguments);
|
73 | };
|
74 | function __rest(s, e) {
|
75 | var t = {};
|
76 | for (var p in s)
|
77 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
78 | t[p] = s[p];
|
79 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
80 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
81 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
82 | t[p[i]] = s[p[i]];
|
83 | }
|
84 | return t;
|
85 | }
|
86 | function __decorate(decorators, target, key, desc) {
|
87 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
88 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
89 | r = Reflect.decorate(decorators, target, key, desc);
|
90 | else
|
91 | for (var i = decorators.length - 1; i >= 0; i--)
|
92 | if (d = decorators[i])
|
93 | r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
94 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
95 | }
|
96 | function __param(paramIndex, decorator) {
|
97 | return function (target, key) { decorator(target, key, paramIndex); };
|
98 | }
|
99 | function __metadata(metadataKey, metadataValue) {
|
100 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
101 | return Reflect.metadata(metadataKey, metadataValue);
|
102 | }
|
103 | function __awaiter(thisArg, _arguments, P, generator) {
|
104 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
105 | return new (P || (P = Promise))(function (resolve, reject) {
|
106 | function fulfilled(value) { try {
|
107 | step(generator.next(value));
|
108 | }
|
109 | catch (e) {
|
110 | reject(e);
|
111 | } }
|
112 | function rejected(value) { try {
|
113 | step(generator["throw"](value));
|
114 | }
|
115 | catch (e) {
|
116 | reject(e);
|
117 | } }
|
118 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
119 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
120 | });
|
121 | }
|
122 | function __generator(thisArg, body) {
|
123 | var _ = { label: 0, sent: function () { if (t[0] & 1)
|
124 | throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
125 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
126 | function verb(n) { return function (v) { return step([n, v]); }; }
|
127 | function step(op) {
|
128 | if (f)
|
129 | throw new TypeError("Generator is already executing.");
|
130 | while (_)
|
131 | try {
|
132 | 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)
|
133 | return t;
|
134 | if (y = 0, t)
|
135 | op = [op[0] & 2, t.value];
|
136 | switch (op[0]) {
|
137 | case 0:
|
138 | case 1:
|
139 | t = op;
|
140 | break;
|
141 | case 4:
|
142 | _.label++;
|
143 | return { value: op[1], done: false };
|
144 | case 5:
|
145 | _.label++;
|
146 | y = op[1];
|
147 | op = [0];
|
148 | continue;
|
149 | case 7:
|
150 | op = _.ops.pop();
|
151 | _.trys.pop();
|
152 | continue;
|
153 | default:
|
154 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
155 | _ = 0;
|
156 | continue;
|
157 | }
|
158 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
159 | _.label = op[1];
|
160 | break;
|
161 | }
|
162 | if (op[0] === 6 && _.label < t[1]) {
|
163 | _.label = t[1];
|
164 | t = op;
|
165 | break;
|
166 | }
|
167 | if (t && _.label < t[2]) {
|
168 | _.label = t[2];
|
169 | _.ops.push(op);
|
170 | break;
|
171 | }
|
172 | if (t[2])
|
173 | _.ops.pop();
|
174 | _.trys.pop();
|
175 | continue;
|
176 | }
|
177 | op = body.call(thisArg, _);
|
178 | }
|
179 | catch (e) {
|
180 | op = [6, e];
|
181 | y = 0;
|
182 | }
|
183 | finally {
|
184 | f = t = 0;
|
185 | }
|
186 | if (op[0] & 5)
|
187 | throw op[1];
|
188 | return { value: op[0] ? op[1] : void 0, done: true };
|
189 | }
|
190 | }
|
191 | var __createBinding = Object.create ? (function (o, m, k, k2) {
|
192 | if (k2 === undefined)
|
193 | k2 = k;
|
194 | Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
195 | }) : (function (o, m, k, k2) {
|
196 | if (k2 === undefined)
|
197 | k2 = k;
|
198 | o[k2] = m[k];
|
199 | });
|
200 | function __exportStar(m, o) {
|
201 | for (var p in m)
|
202 | if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
203 | __createBinding(o, m, p);
|
204 | }
|
205 | function __values(o) {
|
206 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
207 | if (m)
|
208 | return m.call(o);
|
209 | if (o && typeof o.length === "number")
|
210 | return {
|
211 | next: function () {
|
212 | if (o && i >= o.length)
|
213 | o = void 0;
|
214 | return { value: o && o[i++], done: !o };
|
215 | }
|
216 | };
|
217 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
218 | }
|
219 | function __read(o, n) {
|
220 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
221 | if (!m)
|
222 | return o;
|
223 | var i = m.call(o), r, ar = [], e;
|
224 | try {
|
225 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
226 | ar.push(r.value);
|
227 | }
|
228 | catch (error) {
|
229 | e = { error: error };
|
230 | }
|
231 | finally {
|
232 | try {
|
233 | if (r && !r.done && (m = i["return"]))
|
234 | m.call(i);
|
235 | }
|
236 | finally {
|
237 | if (e)
|
238 | throw e.error;
|
239 | }
|
240 | }
|
241 | return ar;
|
242 | }
|
243 |
|
244 | function __spread() {
|
245 | for (var ar = [], i = 0; i < arguments.length; i++)
|
246 | ar = ar.concat(__read(arguments[i]));
|
247 | return ar;
|
248 | }
|
249 |
|
250 | function __spreadArrays() {
|
251 | for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
252 | s += arguments[i].length;
|
253 | for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
254 | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
255 | r[k] = a[j];
|
256 | return r;
|
257 | }
|
258 | function __spreadArray(to, from, pack) {
|
259 | if (pack || arguments.length === 2)
|
260 | for (var i = 0, l = from.length, ar; i < l; i++) {
|
261 | if (ar || !(i in from)) {
|
262 | if (!ar)
|
263 | ar = Array.prototype.slice.call(from, 0, i);
|
264 | ar[i] = from[i];
|
265 | }
|
266 | }
|
267 | return to.concat(ar || Array.prototype.slice.call(from));
|
268 | }
|
269 | function __await(v) {
|
270 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
271 | }
|
272 | function __asyncGenerator(thisArg, _arguments, generator) {
|
273 | if (!Symbol.asyncIterator)
|
274 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
275 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
276 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
277 | function verb(n) { if (g[n])
|
278 | i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
279 | function resume(n, v) { try {
|
280 | step(g[n](v));
|
281 | }
|
282 | catch (e) {
|
283 | settle(q[0][3], e);
|
284 | } }
|
285 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
286 | function fulfill(value) { resume("next", value); }
|
287 | function reject(value) { resume("throw", value); }
|
288 | function settle(f, v) { if (f(v), q.shift(), q.length)
|
289 | resume(q[0][0], q[0][1]); }
|
290 | }
|
291 | function __asyncDelegator(o) {
|
292 | var i, p;
|
293 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
294 | 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; }
|
295 | }
|
296 | function __asyncValues(o) {
|
297 | if (!Symbol.asyncIterator)
|
298 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
299 | var m = o[Symbol.asyncIterator], i;
|
300 | 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);
|
301 | 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); }); }; }
|
302 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
303 | }
|
304 | function __makeTemplateObject(cooked, raw) {
|
305 | if (Object.defineProperty) {
|
306 | Object.defineProperty(cooked, "raw", { value: raw });
|
307 | }
|
308 | else {
|
309 | cooked.raw = raw;
|
310 | }
|
311 | return cooked;
|
312 | }
|
313 | ;
|
314 | var __setModuleDefault = Object.create ? (function (o, v) {
|
315 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
316 | }) : function (o, v) {
|
317 | o["default"] = v;
|
318 | };
|
319 | function __importStar(mod) {
|
320 | if (mod && mod.__esModule)
|
321 | return mod;
|
322 | var result = {};
|
323 | if (mod != null)
|
324 | for (var k in mod)
|
325 | if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
326 | __createBinding(result, mod, k);
|
327 | __setModuleDefault(result, mod);
|
328 | return result;
|
329 | }
|
330 | function __importDefault(mod) {
|
331 | return (mod && mod.__esModule) ? mod : { default: mod };
|
332 | }
|
333 | function __classPrivateFieldGet(receiver, state, kind, f) {
|
334 | if (kind === "a" && !f)
|
335 | throw new TypeError("Private accessor was defined without a getter");
|
336 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
337 | throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
338 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
339 | }
|
340 | function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
341 | if (kind === "m")
|
342 | throw new TypeError("Private method is not writable");
|
343 | if (kind === "a" && !f)
|
344 | throw new TypeError("Private accessor was defined without a setter");
|
345 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
346 | throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
347 | return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
348 | }
|
349 |
|
350 | function isViewContainerRef(x) {
|
351 | return x.element;
|
352 | }
|
353 | |
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 | var InjectionService = (function () {
|
361 | function InjectionService(applicationRef, componentFactoryResolver, injector) {
|
362 | this.applicationRef = applicationRef;
|
363 | this.componentFactoryResolver = componentFactoryResolver;
|
364 | this.injector = injector;
|
365 | }
|
366 | |
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 | InjectionService.setGlobalRootViewContainer = function (container) {
|
373 | InjectionService.globalRootViewContainer = container;
|
374 | };
|
375 | |
376 |
|
377 |
|
378 |
|
379 |
|
380 | InjectionService.prototype.getRootViewContainer = function () {
|
381 | if (this._container)
|
382 | return this._container;
|
383 | if (InjectionService.globalRootViewContainer)
|
384 | return InjectionService.globalRootViewContainer;
|
385 | if (this.applicationRef.components.length)
|
386 | return this.applicationRef.components[0];
|
387 | throw new Error('View Container not found! ngUpgrade needs to manually set this via setRootViewContainer or setGlobalRootViewContainer.');
|
388 | };
|
389 | |
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 | InjectionService.prototype.setRootViewContainer = function (container) {
|
398 | this._container = container;
|
399 | };
|
400 | |
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 | InjectionService.prototype.getComponentRootNode = function (component) {
|
408 | if (isViewContainerRef(component)) {
|
409 | return component.element.nativeElement;
|
410 | }
|
411 | if (component.hostView && component.hostView.rootNodes.length > 0) {
|
412 | return component.hostView.rootNodes[0];
|
413 | }
|
414 |
|
415 | return component.location.nativeElement;
|
416 | };
|
417 | |
418 |
|
419 |
|
420 |
|
421 |
|
422 | InjectionService.prototype.getRootViewContainerNode = function (component) {
|
423 | return this.getComponentRootNode(component);
|
424 | };
|
425 | |
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 | InjectionService.prototype.projectComponentBindings = function (component, bindings) {
|
434 | var e_1, _a, e_2, _b;
|
435 | if (bindings) {
|
436 | if (bindings.inputs !== undefined) {
|
437 | var bindingKeys = Object.getOwnPropertyNames(bindings.inputs);
|
438 | try {
|
439 | for (var bindingKeys_1 = __values(bindingKeys), bindingKeys_1_1 = bindingKeys_1.next(); !bindingKeys_1_1.done; bindingKeys_1_1 = bindingKeys_1.next()) {
|
440 | var bindingName = bindingKeys_1_1.value;
|
441 | component.instance[bindingName] = bindings.inputs[bindingName];
|
442 | }
|
443 | }
|
444 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
445 | finally {
|
446 | try {
|
447 | if (bindingKeys_1_1 && !bindingKeys_1_1.done && (_a = bindingKeys_1.return)) _a.call(bindingKeys_1);
|
448 | }
|
449 | finally { if (e_1) throw e_1.error; }
|
450 | }
|
451 | }
|
452 | if (bindings.outputs !== undefined) {
|
453 | var eventKeys = Object.getOwnPropertyNames(bindings.outputs);
|
454 | try {
|
455 | for (var eventKeys_1 = __values(eventKeys), eventKeys_1_1 = eventKeys_1.next(); !eventKeys_1_1.done; eventKeys_1_1 = eventKeys_1.next()) {
|
456 | var eventName = eventKeys_1_1.value;
|
457 | component.instance[eventName] = bindings.outputs[eventName];
|
458 | }
|
459 | }
|
460 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
461 | finally {
|
462 | try {
|
463 | if (eventKeys_1_1 && !eventKeys_1_1.done && (_b = eventKeys_1.return)) _b.call(eventKeys_1);
|
464 | }
|
465 | finally { if (e_2) throw e_2.error; }
|
466 | }
|
467 | }
|
468 | }
|
469 | return component;
|
470 | };
|
471 | |
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 | InjectionService.prototype.appendComponent = function (componentClass, bindings, location) {
|
481 | if (bindings === void 0) { bindings = {}; }
|
482 | if (!location)
|
483 | location = this.getRootViewContainer();
|
484 | var appendLocation = this.getComponentRootNode(location);
|
485 | var portalHost = new portal.DomPortalOutlet(appendLocation, this.componentFactoryResolver, this.applicationRef, this.injector);
|
486 | var portal$1 = new portal.ComponentPortal(componentClass);
|
487 | var componentRef = portalHost.attach(portal$1);
|
488 | this.projectComponentBindings(componentRef, bindings);
|
489 | return componentRef;
|
490 | };
|
491 | return InjectionService;
|
492 | }());
|
493 | InjectionService.globalRootViewContainer = null;
|
494 | InjectionService.decorators = [
|
495 | { type: core.Injectable }
|
496 | ];
|
497 | InjectionService.ctorParameters = function () { return [
|
498 | { type: core.ApplicationRef },
|
499 | { type: core.ComponentFactoryResolver },
|
500 | { type: core.Injector }
|
501 | ]; };
|
502 |
|
503 | |
504 |
|
505 |
|
506 |
|
507 | function throttle(func, wait, options) {
|
508 | options = options || {};
|
509 | var context;
|
510 | var args;
|
511 | var result;
|
512 | var timeout = null;
|
513 | var previous = 0;
|
514 | function later() {
|
515 | previous = options.leading === false ? 0 : +new Date();
|
516 | timeout = null;
|
517 | result = func.apply(context, args);
|
518 | }
|
519 | return function () {
|
520 | var now = +new Date();
|
521 | if (!previous && options.leading === false) {
|
522 | previous = now;
|
523 | }
|
524 | var remaining = wait - (now - previous);
|
525 | context = this;
|
526 | args = arguments;
|
527 | if (remaining <= 0) {
|
528 | clearTimeout(timeout);
|
529 | timeout = null;
|
530 | previous = now;
|
531 | result = func.apply(context, args);
|
532 | }
|
533 | else if (!timeout && options.trailing !== false) {
|
534 | timeout = setTimeout(later, remaining);
|
535 | }
|
536 | return result;
|
537 | };
|
538 | }
|
539 | |
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 | function throttleable(duration, options) {
|
548 | return function innerDecorator(target, key, descriptor) {
|
549 | return {
|
550 | configurable: true,
|
551 | enumerable: descriptor.enumerable,
|
552 | get: function getter() {
|
553 | Object.defineProperty(this, key, {
|
554 | configurable: true,
|
555 | enumerable: descriptor.enumerable,
|
556 | value: throttle(descriptor.value, duration, options)
|
557 | });
|
558 | return this[key];
|
559 | }
|
560 | };
|
561 | };
|
562 | }
|
563 |
|
564 | exports.PlacementTypes = void 0;
|
565 | (function (PlacementTypes) {
|
566 | PlacementTypes["Top"] = "top";
|
567 | PlacementTypes["Bottom"] = "bottom";
|
568 | PlacementTypes["Left"] = "left";
|
569 | PlacementTypes["Right"] = "right";
|
570 | PlacementTypes["Center"] = "center";
|
571 | })(exports.PlacementTypes || (exports.PlacementTypes = {}));
|
572 |
|
573 | var caretOffset = 7;
|
574 | function verticalPosition(elDimensions, popoverDimensions, alignment) {
|
575 | if (alignment === exports.PlacementTypes.Top) {
|
576 | return elDimensions.top - caretOffset;
|
577 | }
|
578 | if (alignment === exports.PlacementTypes.Bottom) {
|
579 | return elDimensions.top + elDimensions.height - popoverDimensions.height + caretOffset;
|
580 | }
|
581 | if (alignment === exports.PlacementTypes.Center) {
|
582 | return elDimensions.top + elDimensions.height / 2 - popoverDimensions.height / 2;
|
583 | }
|
584 | return undefined;
|
585 | }
|
586 | function horizontalPosition(elDimensions, popoverDimensions, alignment) {
|
587 | if (alignment === exports.PlacementTypes.Left) {
|
588 | return elDimensions.left - caretOffset;
|
589 | }
|
590 | if (alignment === exports.PlacementTypes.Right) {
|
591 | return elDimensions.left + elDimensions.width - popoverDimensions.width + caretOffset;
|
592 | }
|
593 | if (alignment === exports.PlacementTypes.Center) {
|
594 | return elDimensions.left + elDimensions.width / 2 - popoverDimensions.width / 2;
|
595 | }
|
596 | return undefined;
|
597 | }
|
598 | |
599 |
|
600 |
|
601 |
|
602 |
|
603 | var PositionHelper = (function () {
|
604 | function PositionHelper() {
|
605 | }
|
606 | |
607 |
|
608 |
|
609 |
|
610 |
|
611 | PositionHelper.calculateVerticalAlignment = function (elDimensions, popoverDimensions, alignment) {
|
612 | var result = verticalPosition(elDimensions, popoverDimensions, alignment);
|
613 | if (result + popoverDimensions.height > window.innerHeight) {
|
614 | result = window.innerHeight - popoverDimensions.height;
|
615 | }
|
616 | return result;
|
617 | };
|
618 | |
619 |
|
620 |
|
621 |
|
622 |
|
623 | PositionHelper.calculateVerticalCaret = function (elDimensions, popoverDimensions, caretDimensions, alignment) {
|
624 | var result;
|
625 | if (alignment === exports.PlacementTypes.Top) {
|
626 | result = elDimensions.height / 2 - caretDimensions.height / 2 + caretOffset;
|
627 | }
|
628 | if (alignment === exports.PlacementTypes.Bottom) {
|
629 | result = popoverDimensions.height - elDimensions.height / 2 - caretDimensions.height / 2 - caretOffset;
|
630 | }
|
631 | if (alignment === exports.PlacementTypes.Center) {
|
632 | result = popoverDimensions.height / 2 - caretDimensions.height / 2;
|
633 | }
|
634 | var popoverPosition = verticalPosition(elDimensions, popoverDimensions, alignment);
|
635 | if (popoverPosition + popoverDimensions.height > window.innerHeight) {
|
636 | result += popoverPosition + popoverDimensions.height - window.innerHeight;
|
637 | }
|
638 | return result;
|
639 | };
|
640 | |
641 |
|
642 |
|
643 |
|
644 |
|
645 | PositionHelper.calculateHorizontalAlignment = function (elDimensions, popoverDimensions, alignment) {
|
646 | var result = horizontalPosition(elDimensions, popoverDimensions, alignment);
|
647 | if (result + popoverDimensions.width > window.innerWidth) {
|
648 | result = window.innerWidth - popoverDimensions.width;
|
649 | }
|
650 | return result;
|
651 | };
|
652 | |
653 |
|
654 |
|
655 |
|
656 |
|
657 | PositionHelper.calculateHorizontalCaret = function (elDimensions, popoverDimensions, caretDimensions, alignment) {
|
658 | var result;
|
659 | if (alignment === exports.PlacementTypes.Left) {
|
660 | result = elDimensions.width / 2 - caretDimensions.width / 2 + caretOffset;
|
661 | }
|
662 | if (alignment === exports.PlacementTypes.Right) {
|
663 | result = popoverDimensions.width - elDimensions.width / 2 - caretDimensions.width / 2 - caretOffset;
|
664 | }
|
665 | if (alignment === exports.PlacementTypes.Center) {
|
666 | result = popoverDimensions.width / 2 - caretDimensions.width / 2;
|
667 | }
|
668 | var popoverPosition = horizontalPosition(elDimensions, popoverDimensions, alignment);
|
669 | if (popoverPosition + popoverDimensions.width > window.innerWidth) {
|
670 | result += popoverPosition + popoverDimensions.width - window.innerWidth;
|
671 | }
|
672 | return result;
|
673 | };
|
674 | |
675 |
|
676 |
|
677 |
|
678 |
|
679 | PositionHelper.shouldFlip = function (elDimensions, popoverDimensions, placement, spacing) {
|
680 | var flip = false;
|
681 | if (placement === exports.PlacementTypes.Right) {
|
682 | if (elDimensions.left + elDimensions.width + popoverDimensions.width + spacing > window.innerWidth) {
|
683 | flip = true;
|
684 | }
|
685 | }
|
686 | if (placement === exports.PlacementTypes.Left) {
|
687 | if (elDimensions.left - popoverDimensions.width - spacing < 0) {
|
688 | flip = true;
|
689 | }
|
690 | }
|
691 | if (placement === exports.PlacementTypes.Top) {
|
692 | if (elDimensions.top - popoverDimensions.height - spacing < 0) {
|
693 | flip = true;
|
694 | }
|
695 | }
|
696 | if (placement === exports.PlacementTypes.Bottom) {
|
697 | if (elDimensions.top + elDimensions.height + popoverDimensions.height + spacing > window.innerHeight) {
|
698 | flip = true;
|
699 | }
|
700 | }
|
701 | return flip;
|
702 | };
|
703 | |
704 |
|
705 |
|
706 |
|
707 |
|
708 | PositionHelper.positionCaret = function (placement, elmDim, hostDim, caretDimensions, alignment) {
|
709 | var top = 0;
|
710 | var left = 0;
|
711 | if (placement === exports.PlacementTypes.Right) {
|
712 | left = -7;
|
713 | top = PositionHelper.calculateVerticalCaret(hostDim, elmDim, caretDimensions, alignment);
|
714 | }
|
715 | else if (placement === exports.PlacementTypes.Left) {
|
716 | left = elmDim.width;
|
717 | top = PositionHelper.calculateVerticalCaret(hostDim, elmDim, caretDimensions, alignment);
|
718 | }
|
719 | else if (placement === exports.PlacementTypes.Top) {
|
720 | top = elmDim.height;
|
721 | left = PositionHelper.calculateHorizontalCaret(hostDim, elmDim, caretDimensions, alignment);
|
722 | }
|
723 | else if (placement === exports.PlacementTypes.Bottom) {
|
724 | top = -7;
|
725 | left = PositionHelper.calculateHorizontalCaret(hostDim, elmDim, caretDimensions, alignment);
|
726 | }
|
727 | return { top: top, left: left };
|
728 | };
|
729 | |
730 |
|
731 |
|
732 |
|
733 |
|
734 | PositionHelper.positionContent = function (placement, elmDim, hostDim, spacing, alignment) {
|
735 | var top = 0;
|
736 | var left = 0;
|
737 | if (placement === exports.PlacementTypes.Right) {
|
738 | left = hostDim.left + hostDim.width + spacing;
|
739 | top = PositionHelper.calculateVerticalAlignment(hostDim, elmDim, alignment);
|
740 | }
|
741 | else if (placement === exports.PlacementTypes.Left) {
|
742 | left = hostDim.left - elmDim.width - spacing;
|
743 | top = PositionHelper.calculateVerticalAlignment(hostDim, elmDim, alignment);
|
744 | }
|
745 | else if (placement === exports.PlacementTypes.Top) {
|
746 | top = hostDim.top - elmDim.height - spacing;
|
747 | left = PositionHelper.calculateHorizontalAlignment(hostDim, elmDim, alignment);
|
748 | }
|
749 | else if (placement === exports.PlacementTypes.Bottom) {
|
750 | top = hostDim.top + hostDim.height + spacing;
|
751 | left = PositionHelper.calculateHorizontalAlignment(hostDim, elmDim, alignment);
|
752 | }
|
753 | return { top: top, left: left };
|
754 | };
|
755 | |
756 |
|
757 |
|
758 |
|
759 |
|
760 | PositionHelper.determinePlacement = function (placement, elmDim, hostDim, spacing) {
|
761 | var shouldFlip = PositionHelper.shouldFlip(hostDim, elmDim, placement, spacing);
|
762 | if (shouldFlip) {
|
763 | if (placement === exports.PlacementTypes.Right) {
|
764 | return exports.PlacementTypes.Left;
|
765 | }
|
766 | else if (placement === exports.PlacementTypes.Left) {
|
767 | return exports.PlacementTypes.Right;
|
768 | }
|
769 | else if (placement === exports.PlacementTypes.Top) {
|
770 | return exports.PlacementTypes.Bottom;
|
771 | }
|
772 | else if (placement === exports.PlacementTypes.Bottom) {
|
773 | return exports.PlacementTypes.Top;
|
774 | }
|
775 | }
|
776 | return placement;
|
777 | };
|
778 | return PositionHelper;
|
779 | }());
|
780 |
|
781 | var TooltipContentComponent = (function () {
|
782 | function TooltipContentComponent(element, renderer, platformId) {
|
783 | this.element = element;
|
784 | this.renderer = renderer;
|
785 | this.platformId = platformId;
|
786 | }
|
787 | Object.defineProperty(TooltipContentComponent.prototype, "cssClasses", {
|
788 | get: function () {
|
789 | var clz = 'ngx-charts-tooltip-content';
|
790 | clz += " position-" + this.placement;
|
791 | clz += " type-" + this.type;
|
792 | clz += " " + this.cssClass;
|
793 | return clz;
|
794 | },
|
795 | enumerable: false,
|
796 | configurable: true
|
797 | });
|
798 | TooltipContentComponent.prototype.ngAfterViewInit = function () {
|
799 | setTimeout(this.position.bind(this));
|
800 | };
|
801 | TooltipContentComponent.prototype.position = function () {
|
802 | var _this = this;
|
803 | if (!common.isPlatformBrowser(this.platformId)) {
|
804 | return;
|
805 | }
|
806 | var nativeElm = this.element.nativeElement;
|
807 | var hostDim = this.host.nativeElement.getBoundingClientRect();
|
808 |
|
809 | if (!hostDim.height && !hostDim.width)
|
810 | return;
|
811 | var elmDim = nativeElm.getBoundingClientRect();
|
812 | this.checkFlip(hostDim, elmDim);
|
813 | this.positionContent(nativeElm, hostDim, elmDim);
|
814 | if (this.showCaret) {
|
815 | this.positionCaret(hostDim, elmDim);
|
816 | }
|
817 |
|
818 | setTimeout(function () { return _this.renderer.addClass(nativeElm, 'animate'); }, 1);
|
819 | };
|
820 | TooltipContentComponent.prototype.positionContent = function (nativeElm, hostDim, elmDim) {
|
821 | var _a = PositionHelper.positionContent(this.placement, elmDim, hostDim, this.spacing, this.alignment), top = _a.top, left = _a.left;
|
822 | this.renderer.setStyle(nativeElm, 'top', top + "px");
|
823 | this.renderer.setStyle(nativeElm, 'left', left + "px");
|
824 | };
|
825 | TooltipContentComponent.prototype.positionCaret = function (hostDim, elmDim) {
|
826 | var caretElm = this.caretElm.nativeElement;
|
827 | var caretDimensions = caretElm.getBoundingClientRect();
|
828 | var _a = PositionHelper.positionCaret(this.placement, elmDim, hostDim, caretDimensions, this.alignment), top = _a.top, left = _a.left;
|
829 | this.renderer.setStyle(caretElm, 'top', top + "px");
|
830 | this.renderer.setStyle(caretElm, 'left', left + "px");
|
831 | };
|
832 | TooltipContentComponent.prototype.checkFlip = function (hostDim, elmDim) {
|
833 | this.placement = PositionHelper.determinePlacement(this.placement, elmDim, hostDim, this.spacing);
|
834 | };
|
835 | TooltipContentComponent.prototype.onWindowResize = function () {
|
836 | this.position();
|
837 | };
|
838 | return TooltipContentComponent;
|
839 | }());
|
840 | TooltipContentComponent.decorators = [
|
841 | { type: core.Component, args: [{
|
842 | selector: 'ngx-tooltip-content',
|
843 | template: "\n <div>\n <span #caretElm [hidden]=\"!showCaret\" class=\"tooltip-caret position-{{ this.placement }}\"> </span>\n <div class=\"tooltip-content\">\n <span *ngIf=\"!title\">\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ model: context }\"> </ng-template>\n </span>\n <span *ngIf=\"title\" [innerHTML]=\"title\"> </span>\n </div>\n </div>\n ",
|
844 | encapsulation: core.ViewEncapsulation.None,
|
845 | styles: [".ngx-charts-tooltip-content{position:fixed;border-radius:3px;z-index:5000;display:block;font-weight:normal;opacity:0;pointer-events:none!important}.ngx-charts-tooltip-content.type-popover{background:#fff;color:#060709;border:1px solid #72809b;box-shadow:0 1px 3px #0003,0 1px 1px #00000024,0 2px 1px -1px #0000001f;font-size:13px;padding:4px}.ngx-charts-tooltip-content.type-popover .tooltip-caret{position:absolute;z-index:5001;width:0;height:0}.ngx-charts-tooltip-content.type-popover .tooltip-caret.position-left{border-top:7px solid transparent;border-bottom:7px solid transparent;border-left:7px solid #fff}.ngx-charts-tooltip-content.type-popover .tooltip-caret.position-top{border-left:7px solid transparent;border-right:7px solid transparent;border-top:7px solid #fff}.ngx-charts-tooltip-content.type-popover .tooltip-caret.position-right{border-top:7px solid transparent;border-bottom:7px solid transparent;border-right:7px solid #fff}.ngx-charts-tooltip-content.type-popover .tooltip-caret.position-bottom{border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #fff}.ngx-charts-tooltip-content.type-tooltip{color:#fff;background:rgba(0,0,0,.75);font-size:12px;padding:0 10px;text-align:center;pointer-events:auto}.ngx-charts-tooltip-content.type-tooltip .tooltip-caret.position-left{border-top:7px solid transparent;border-bottom:7px solid transparent;border-left:7px solid rgba(0,0,0,.75)}.ngx-charts-tooltip-content.type-tooltip .tooltip-caret.position-top{border-left:7px solid transparent;border-right:7px solid transparent;border-top:7px solid rgba(0,0,0,.75)}.ngx-charts-tooltip-content.type-tooltip .tooltip-caret.position-right{border-top:7px solid transparent;border-bottom:7px solid transparent;border-right:7px solid rgba(0,0,0,.75)}.ngx-charts-tooltip-content.type-tooltip .tooltip-caret.position-bottom{border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid rgba(0,0,0,.75)}.ngx-charts-tooltip-content .tooltip-label{display:block;line-height:1em;padding:8px 5px 5px;font-size:1em}.ngx-charts-tooltip-content .tooltip-val{display:block;font-size:1.3em;line-height:1em;padding:0 5px 8px}.ngx-charts-tooltip-content .tooltip-caret{position:absolute;z-index:5001;width:0;height:0}.ngx-charts-tooltip-content.position-right{transform:translate(10px)}.ngx-charts-tooltip-content.position-left{transform:translate(-10px)}.ngx-charts-tooltip-content.position-top{transform:translateY(-10px)}.ngx-charts-tooltip-content.position-bottom{transform:translateY(10px)}.ngx-charts-tooltip-content.animate{opacity:1;transition:opacity .3s,transform .3s;transform:translate(0);pointer-events:auto}.area-tooltip-container{padding:5px 0;pointer-events:none}.tooltip-item{text-align:left;line-height:1.2em;padding:5px 0}.tooltip-item .tooltip-item-color{display:inline-block;height:12px;width:12px;margin-right:5px;color:#5b646b;border-radius:3px}\n"]
|
846 | },] }
|
847 | ];
|
848 | TooltipContentComponent.ctorParameters = function () { return [
|
849 | { type: core.ElementRef },
|
850 | { type: core.Renderer2 },
|
851 | { type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
|
852 | ]; };
|
853 | TooltipContentComponent.propDecorators = {
|
854 | host: [{ type: core.Input }],
|
855 | showCaret: [{ type: core.Input }],
|
856 | type: [{ type: core.Input }],
|
857 | placement: [{ type: core.Input }],
|
858 | alignment: [{ type: core.Input }],
|
859 | spacing: [{ type: core.Input }],
|
860 | cssClass: [{ type: core.Input }],
|
861 | title: [{ type: core.Input }],
|
862 | template: [{ type: core.Input }],
|
863 | context: [{ type: core.Input }],
|
864 | caretElm: [{ type: core.ViewChild, args: ['caretElm',] }],
|
865 | cssClasses: [{ type: core.HostBinding, args: ['class',] }],
|
866 | onWindowResize: [{ type: core.HostListener, args: ['window:resize',] }]
|
867 | };
|
868 | __decorate([
|
869 | throttleable(100)
|
870 | ], TooltipContentComponent.prototype, "onWindowResize", null);
|
871 |
|
872 | var InjectionRegisteryService = (function () {
|
873 | function InjectionRegisteryService(injectionService) {
|
874 | this.injectionService = injectionService;
|
875 | this.defaults = {};
|
876 | this.components = new Map();
|
877 | }
|
878 | InjectionRegisteryService.prototype.getByType = function (type) {
|
879 | if (type === void 0) { type = this.type; }
|
880 | return this.components.get(type);
|
881 | };
|
882 | InjectionRegisteryService.prototype.create = function (bindings) {
|
883 | return this.createByType(this.type, bindings);
|
884 | };
|
885 | InjectionRegisteryService.prototype.createByType = function (type, bindings) {
|
886 | bindings = this.assignDefaults(bindings);
|
887 | var component = this.injectComponent(type, bindings);
|
888 | this.register(type, component);
|
889 | return component;
|
890 | };
|
891 | InjectionRegisteryService.prototype.destroy = function (instance) {
|
892 | var compsByType = this.components.get(instance.componentType);
|
893 | if (compsByType && compsByType.length) {
|
894 | var idx = compsByType.indexOf(instance);
|
895 | if (idx > -1) {
|
896 | var component = compsByType[idx];
|
897 | component.destroy();
|
898 | compsByType.splice(idx, 1);
|
899 | }
|
900 | }
|
901 | };
|
902 | InjectionRegisteryService.prototype.destroyAll = function () {
|
903 | this.destroyByType(this.type);
|
904 | };
|
905 | InjectionRegisteryService.prototype.destroyByType = function (type) {
|
906 | var comps = this.components.get(type);
|
907 | if (comps && comps.length) {
|
908 | var i = comps.length - 1;
|
909 | while (i >= 0) {
|
910 | this.destroy(comps[i--]);
|
911 | }
|
912 | }
|
913 | };
|
914 | InjectionRegisteryService.prototype.injectComponent = function (type, bindings) {
|
915 | return this.injectionService.appendComponent(type, bindings);
|
916 | };
|
917 | InjectionRegisteryService.prototype.assignDefaults = function (bindings) {
|
918 | var inputs = Object.assign({}, this.defaults.inputs);
|
919 | var outputs = Object.assign({}, this.defaults.outputs);
|
920 | if (!bindings.inputs && !bindings.outputs) {
|
921 | bindings = { inputs: bindings };
|
922 | }
|
923 | if (inputs) {
|
924 | bindings.inputs = Object.assign(Object.assign({}, inputs), bindings.inputs);
|
925 | }
|
926 | if (outputs) {
|
927 | bindings.outputs = Object.assign(Object.assign({}, outputs), bindings.outputs);
|
928 | }
|
929 | return bindings;
|
930 | };
|
931 | InjectionRegisteryService.prototype.register = function (type, component) {
|
932 | if (!this.components.has(type)) {
|
933 | this.components.set(type, []);
|
934 | }
|
935 | var types = this.components.get(type);
|
936 | types.push(component);
|
937 | };
|
938 | return InjectionRegisteryService;
|
939 | }());
|
940 |
|
941 | var TooltipService = (function (_super) {
|
942 | __extends(TooltipService, _super);
|
943 | function TooltipService(injectionService) {
|
944 | var _this = _super.call(this, injectionService) || this;
|
945 | _this.type = TooltipContentComponent;
|
946 | return _this;
|
947 | }
|
948 | return TooltipService;
|
949 | }(InjectionRegisteryService));
|
950 | TooltipService.decorators = [
|
951 | { type: core.Injectable }
|
952 | ];
|
953 | TooltipService.ctorParameters = function () { return [
|
954 | { type: InjectionService }
|
955 | ]; };
|
956 |
|
957 | exports.LegendPosition = void 0;
|
958 | (function (LegendPosition) {
|
959 | LegendPosition["Right"] = "right";
|
960 | LegendPosition["Below"] = "below";
|
961 | })(exports.LegendPosition || (exports.LegendPosition = {}));
|
962 | exports.LegendType = void 0;
|
963 | (function (LegendType) {
|
964 | LegendType["ScaleLegend"] = "scaleLegend";
|
965 | LegendType["Legend"] = "legend";
|
966 | })(exports.LegendType || (exports.LegendType = {}));
|
967 |
|
968 | exports.ScaleType = void 0;
|
969 | (function (ScaleType) {
|
970 | ScaleType["Time"] = "time";
|
971 | ScaleType["Linear"] = "linear";
|
972 | ScaleType["Ordinal"] = "ordinal";
|
973 | ScaleType["Quantile"] = "quantile";
|
974 | })(exports.ScaleType || (exports.ScaleType = {}));
|
975 |
|
976 | var ChartComponent = (function () {
|
977 | function ChartComponent() {
|
978 | this.showLegend = false;
|
979 | this.animations = true;
|
980 | this.legendLabelClick = new core.EventEmitter();
|
981 | this.legendLabelActivate = new core.EventEmitter();
|
982 | this.legendLabelDeactivate = new core.EventEmitter();
|
983 | this.LegendPosition = exports.LegendPosition;
|
984 | this.LegendType = exports.LegendType;
|
985 | }
|
986 | ChartComponent.prototype.ngOnChanges = function (changes) {
|
987 | this.update();
|
988 | };
|
989 | ChartComponent.prototype.update = function () {
|
990 | var legendColumns = 0;
|
991 | if (this.showLegend) {
|
992 | this.legendType = this.getLegendType();
|
993 | if (!this.legendOptions || this.legendOptions.position === exports.LegendPosition.Right) {
|
994 | if (this.legendType === exports.LegendType.ScaleLegend) {
|
995 | legendColumns = 1;
|
996 | }
|
997 | else {
|
998 | legendColumns = 2;
|
999 | }
|
1000 | }
|
1001 | }
|
1002 | var chartColumns = 12 - legendColumns;
|
1003 | this.chartWidth = Math.floor((this.view[0] * chartColumns) / 12.0);
|
1004 | this.legendWidth =
|
1005 | !this.legendOptions || this.legendOptions.position === exports.LegendPosition.Right
|
1006 | ? Math.floor((this.view[0] * legendColumns) / 12.0)
|
1007 | : this.chartWidth;
|
1008 | };
|
1009 | ChartComponent.prototype.getLegendType = function () {
|
1010 | return this.legendOptions.scaleType === exports.ScaleType.Linear ? exports.LegendType.ScaleLegend : exports.LegendType.Legend;
|
1011 | };
|
1012 | return ChartComponent;
|
1013 | }());
|
1014 | ChartComponent.decorators = [
|
1015 | { type: core.Component, args: [{
|
1016 | providers: [TooltipService],
|
1017 | selector: 'ngx-charts-chart',
|
1018 | template: "\n <div class=\"ngx-charts-outer\" [style.width.px]=\"view[0]\" [@animationState]=\"'active'\" [@.disabled]=\"!animations\">\n <svg class=\"ngx-charts\" [attr.width]=\"chartWidth\" [attr.height]=\"view[1]\">\n <ng-content></ng-content>\n </svg>\n <ngx-charts-scale-legend\n *ngIf=\"showLegend && legendType === LegendType.ScaleLegend\"\n class=\"chart-legend\"\n [horizontal]=\"legendOptions && legendOptions.position === LegendPosition.Below\"\n [valueRange]=\"legendOptions.domain\"\n [colors]=\"legendOptions.colors\"\n [height]=\"view[1]\"\n [width]=\"legendWidth\"\n >\n </ngx-charts-scale-legend>\n <ngx-charts-legend\n *ngIf=\"showLegend && legendType === LegendType.Legend\"\n class=\"chart-legend\"\n [horizontal]=\"legendOptions && legendOptions.position === LegendPosition.Below\"\n [data]=\"legendOptions.domain\"\n [title]=\"legendOptions.title\"\n [colors]=\"legendOptions.colors\"\n [height]=\"view[1]\"\n [width]=\"legendWidth\"\n [activeEntries]=\"activeEntries\"\n (labelClick)=\"legendLabelClick.emit($event)\"\n (labelActivate)=\"legendLabelActivate.emit($event)\"\n (labelDeactivate)=\"legendLabelDeactivate.emit($event)\"\n >\n </ngx-charts-legend>\n </div>\n ",
|
1019 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
1020 | animations: [
|
1021 | animations.trigger('animationState', [
|
1022 | animations.transition(':enter', [animations.style({ opacity: 0 }), animations.animate('500ms 100ms', animations.style({ opacity: 1 }))])
|
1023 | ])
|
1024 | ]
|
1025 | },] }
|
1026 | ];
|
1027 | ChartComponent.propDecorators = {
|
1028 | view: [{ type: core.Input }],
|
1029 | showLegend: [{ type: core.Input }],
|
1030 | legendOptions: [{ type: core.Input }],
|
1031 | legendType: [{ type: core.Input }],
|
1032 | activeEntries: [{ type: core.Input }],
|
1033 | animations: [{ type: core.Input }],
|
1034 | legendLabelClick: [{ type: core.Output }],
|
1035 | legendLabelActivate: [{ type: core.Output }],
|
1036 | legendLabelDeactivate: [{ type: core.Output }]
|
1037 | };
|
1038 |
|
1039 | |
1040 |
|
1041 |
|
1042 | var VisibilityObserver = (function () {
|
1043 | function VisibilityObserver(element, zone) {
|
1044 | this.element = element;
|
1045 | this.zone = zone;
|
1046 | this.visible = new core.EventEmitter();
|
1047 | this.isVisible = false;
|
1048 | this.runCheck();
|
1049 | }
|
1050 | VisibilityObserver.prototype.destroy = function () {
|
1051 | clearTimeout(this.timeout);
|
1052 | };
|
1053 | VisibilityObserver.prototype.onVisibilityChange = function () {
|
1054 | var _this = this;
|
1055 |
|
1056 | this.zone.run(function () {
|
1057 | _this.isVisible = true;
|
1058 | _this.visible.emit(true);
|
1059 | });
|
1060 | };
|
1061 | VisibilityObserver.prototype.runCheck = function () {
|
1062 | var _this = this;
|
1063 | var check = function () {
|
1064 | if (!_this.element) {
|
1065 | return;
|
1066 | }
|
1067 |
|
1068 | var _a = _this.element.nativeElement, offsetHeight = _a.offsetHeight, offsetWidth = _a.offsetWidth;
|
1069 | if (offsetHeight && offsetWidth) {
|
1070 | clearTimeout(_this.timeout);
|
1071 | _this.onVisibilityChange();
|
1072 | }
|
1073 | else {
|
1074 | clearTimeout(_this.timeout);
|
1075 | _this.zone.runOutsideAngular(function () {
|
1076 | _this.timeout = setTimeout(function () { return check(); }, 100);
|
1077 | });
|
1078 | }
|
1079 | };
|
1080 | this.zone.runOutsideAngular(function () {
|
1081 | _this.timeout = setTimeout(function () { return check(); });
|
1082 | });
|
1083 | };
|
1084 | return VisibilityObserver;
|
1085 | }());
|
1086 | VisibilityObserver.decorators = [
|
1087 | { type: core.Directive, args: [{
|
1088 | selector: 'visibility-observer'
|
1089 | },] }
|
1090 | ];
|
1091 | VisibilityObserver.ctorParameters = function () { return [
|
1092 | { type: core.ElementRef },
|
1093 | { type: core.NgZone }
|
1094 | ]; };
|
1095 | VisibilityObserver.propDecorators = {
|
1096 | visible: [{ type: core.Output }]
|
1097 | };
|
1098 |
|
1099 | function isDate(value) {
|
1100 | return toString.call(value) === '[object Date]';
|
1101 | }
|
1102 | function isNumber(value) {
|
1103 | return typeof value === 'number';
|
1104 | }
|
1105 |
|
1106 | var BaseChartComponent = (function () {
|
1107 | function BaseChartComponent(chartElement, zone, cd, platformId) {
|
1108 | this.chartElement = chartElement;
|
1109 | this.zone = zone;
|
1110 | this.cd = cd;
|
1111 | this.platformId = platformId;
|
1112 | this.scheme = 'cool';
|
1113 | this.schemeType = exports.ScaleType.Ordinal;
|
1114 | this.animations = true;
|
1115 | this.select = new core.EventEmitter();
|
1116 | }
|
1117 | BaseChartComponent.prototype.ngOnInit = function () {
|
1118 | if (common.isPlatformServer(this.platformId)) {
|
1119 | this.animations = false;
|
1120 | }
|
1121 | };
|
1122 | BaseChartComponent.prototype.ngAfterViewInit = function () {
|
1123 | this.bindWindowResizeEvent();
|
1124 |
|
1125 | this.visibilityObserver = new VisibilityObserver(this.chartElement, this.zone);
|
1126 | this.visibilityObserver.visible.subscribe(this.update.bind(this));
|
1127 | };
|
1128 | BaseChartComponent.prototype.ngOnDestroy = function () {
|
1129 | this.unbindEvents();
|
1130 | if (this.visibilityObserver) {
|
1131 | this.visibilityObserver.visible.unsubscribe();
|
1132 | this.visibilityObserver.destroy();
|
1133 | }
|
1134 | };
|
1135 | BaseChartComponent.prototype.ngOnChanges = function (changes) {
|
1136 | this.update();
|
1137 | };
|
1138 | BaseChartComponent.prototype.update = function () {
|
1139 | if (this.results) {
|
1140 | this.results = this.cloneData(this.results);
|
1141 | }
|
1142 | else {
|
1143 | this.results = [];
|
1144 | }
|
1145 | if (this.view) {
|
1146 | this.width = this.view[0];
|
1147 | this.height = this.view[1];
|
1148 | }
|
1149 | else {
|
1150 | var dims = this.getContainerDims();
|
1151 | if (dims) {
|
1152 | this.width = dims.width;
|
1153 | this.height = dims.height;
|
1154 | }
|
1155 | }
|
1156 |
|
1157 | if (!this.width) {
|
1158 | this.width = 600;
|
1159 | }
|
1160 | if (!this.height) {
|
1161 | this.height = 400;
|
1162 | }
|
1163 | this.width = Math.floor(this.width);
|
1164 | this.height = Math.floor(this.height);
|
1165 | if (this.cd) {
|
1166 | this.cd.markForCheck();
|
1167 | }
|
1168 | };
|
1169 | BaseChartComponent.prototype.getContainerDims = function () {
|
1170 | var width;
|
1171 | var height;
|
1172 | var hostElem = this.chartElement.nativeElement;
|
1173 | if (common.isPlatformBrowser(this.platformId) && hostElem.parentNode !== null) {
|
1174 |
|
1175 | var dims = hostElem.parentNode.getBoundingClientRect();
|
1176 | width = dims.width;
|
1177 | height = dims.height;
|
1178 | }
|
1179 | if (width && height) {
|
1180 | return { width: width, height: height };
|
1181 | }
|
1182 | return null;
|
1183 | };
|
1184 | |
1185 |
|
1186 |
|
1187 |
|
1188 | BaseChartComponent.prototype.formatDates = function () {
|
1189 | for (var i = 0; i < this.results.length; i++) {
|
1190 | var g = this.results[i];
|
1191 | g.label = g.name;
|
1192 | if (isDate(g.label)) {
|
1193 | g.label = g.label.toLocaleDateString();
|
1194 | }
|
1195 | if (g.series) {
|
1196 | for (var j = 0; j < g.series.length; j++) {
|
1197 | var d = g.series[j];
|
1198 | d.label = d.name;
|
1199 | if (isDate(d.label)) {
|
1200 | d.label = d.label.toLocaleDateString();
|
1201 | }
|
1202 | }
|
1203 | }
|
1204 | }
|
1205 | };
|
1206 | BaseChartComponent.prototype.unbindEvents = function () {
|
1207 | if (this.resizeSubscription) {
|
1208 | this.resizeSubscription.unsubscribe();
|
1209 | }
|
1210 | };
|
1211 | BaseChartComponent.prototype.bindWindowResizeEvent = function () {
|
1212 | var _this = this;
|
1213 | if (!common.isPlatformBrowser(this.platformId)) {
|
1214 | return;
|
1215 | }
|
1216 | var source = rxjs.fromEvent(window, 'resize');
|
1217 | var subscription = source.pipe(operators.debounceTime(200)).subscribe(function (e) {
|
1218 | _this.update();
|
1219 | if (_this.cd) {
|
1220 | _this.cd.markForCheck();
|
1221 | }
|
1222 | });
|
1223 | this.resizeSubscription = subscription;
|
1224 | };
|
1225 | |
1226 |
|
1227 |
|
1228 |
|
1229 |
|
1230 | BaseChartComponent.prototype.cloneData = function (data) {
|
1231 | var e_1, _a, e_2, _b;
|
1232 | var results = [];
|
1233 | try {
|
1234 | for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
|
1235 | var item = data_1_1.value;
|
1236 | var copy = {
|
1237 | name: item['name']
|
1238 | };
|
1239 | if (item['value'] !== undefined) {
|
1240 | copy['value'] = item['value'];
|
1241 | }
|
1242 | if (item['series'] !== undefined) {
|
1243 | copy['series'] = [];
|
1244 | try {
|
1245 | for (var _c = (e_2 = void 0, __values(item['series'])), _d = _c.next(); !_d.done; _d = _c.next()) {
|
1246 | var seriesItem = _d.value;
|
1247 | var seriesItemCopy = Object.assign({}, seriesItem);
|
1248 | copy['series'].push(seriesItemCopy);
|
1249 | }
|
1250 | }
|
1251 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
1252 | finally {
|
1253 | try {
|
1254 | if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
1255 | }
|
1256 | finally { if (e_2) throw e_2.error; }
|
1257 | }
|
1258 | }
|
1259 | if (item['extra'] !== undefined) {
|
1260 | copy['extra'] = JSON.parse(JSON.stringify(item['extra']));
|
1261 | }
|
1262 | results.push(copy);
|
1263 | }
|
1264 | }
|
1265 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
1266 | finally {
|
1267 | try {
|
1268 | if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
|
1269 | }
|
1270 | finally { if (e_1) throw e_1.error; }
|
1271 | }
|
1272 | return results;
|
1273 | };
|
1274 | return BaseChartComponent;
|
1275 | }());
|
1276 | BaseChartComponent.decorators = [
|
1277 | { type: core.Component, args: [{
|
1278 | selector: 'base-chart',
|
1279 | template: " <div></div> "
|
1280 | },] }
|
1281 | ];
|
1282 | BaseChartComponent.ctorParameters = function () { return [
|
1283 | { type: core.ElementRef },
|
1284 | { type: core.NgZone },
|
1285 | { type: core.ChangeDetectorRef },
|
1286 | { type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
|
1287 | ]; };
|
1288 | BaseChartComponent.propDecorators = {
|
1289 | results: [{ type: core.Input }],
|
1290 | view: [{ type: core.Input }],
|
1291 | scheme: [{ type: core.Input }],
|
1292 | schemeType: [{ type: core.Input }],
|
1293 | customColors: [{ type: core.Input }],
|
1294 | animations: [{ type: core.Input }],
|
1295 | select: [{ type: core.Output }]
|
1296 | };
|
1297 |
|
1298 | exports.Orientation = void 0;
|
1299 | (function (Orientation) {
|
1300 | Orientation["Top"] = "top";
|
1301 | Orientation["Bottom"] = "bottom";
|
1302 | Orientation["Left"] = "left";
|
1303 | Orientation["Right"] = "right";
|
1304 | })(exports.Orientation || (exports.Orientation = {}));
|
1305 |
|
1306 | var AxisLabelComponent = (function () {
|
1307 | function AxisLabelComponent(element) {
|
1308 | this.textHeight = 25;
|
1309 | this.margin = 5;
|
1310 | this.element = element.nativeElement;
|
1311 | }
|
1312 | AxisLabelComponent.prototype.ngOnChanges = function (changes) {
|
1313 | this.update();
|
1314 | };
|
1315 | AxisLabelComponent.prototype.update = function () {
|
1316 | this.strokeWidth = '0.01';
|
1317 | this.textAnchor = 'middle';
|
1318 | this.transform = '';
|
1319 | switch (this.orient) {
|
1320 | case exports.Orientation.Top:
|
1321 | this.y = this.offset;
|
1322 | this.x = this.width / 2;
|
1323 | break;
|
1324 | case exports.Orientation.Bottom:
|
1325 | this.y = this.offset;
|
1326 | this.x = this.width / 2;
|
1327 | break;
|
1328 | case exports.Orientation.Left:
|
1329 | this.y = -(this.offset + this.textHeight + this.margin);
|
1330 | this.x = -this.height / 2;
|
1331 | this.transform = 'rotate(270)';
|
1332 | break;
|
1333 | case exports.Orientation.Right:
|
1334 | this.y = this.offset + this.margin;
|
1335 | this.x = -this.height / 2;
|
1336 | this.transform = 'rotate(270)';
|
1337 | break;
|
1338 | default:
|
1339 | }
|
1340 | };
|
1341 | return AxisLabelComponent;
|
1342 | }());
|
1343 | AxisLabelComponent.decorators = [
|
1344 | { type: core.Component, args: [{
|
1345 | selector: 'g[ngx-charts-axis-label]',
|
1346 | template: "\n <svg:text\n [attr.stroke-width]=\"strokeWidth\"\n [attr.x]=\"x\"\n [attr.y]=\"y\"\n [attr.text-anchor]=\"textAnchor\"\n [attr.transform]=\"transform\"\n >\n {{ label }}\n </svg:text>\n ",
|
1347 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
1348 | },] }
|
1349 | ];
|
1350 | AxisLabelComponent.ctorParameters = function () { return [
|
1351 | { type: core.ElementRef }
|
1352 | ]; };
|
1353 | AxisLabelComponent.propDecorators = {
|
1354 | orient: [{ type: core.Input }],
|
1355 | label: [{ type: core.Input }],
|
1356 | offset: [{ type: core.Input }],
|
1357 | width: [{ type: core.Input }],
|
1358 | height: [{ type: core.Input }]
|
1359 | };
|
1360 |
|
1361 | function trimLabel(s, max) {
|
1362 | if (max === void 0) { max = 16; }
|
1363 | if (typeof s !== 'string') {
|
1364 | if (typeof s === 'number') {
|
1365 | return s + '';
|
1366 | }
|
1367 | else {
|
1368 | return '';
|
1369 | }
|
1370 | }
|
1371 | s = s.trim();
|
1372 | if (s.length <= max) {
|
1373 | return s;
|
1374 | }
|
1375 | else {
|
1376 | return s.slice(0, max) + "...";
|
1377 | }
|
1378 | }
|
1379 |
|
1380 | function reduceTicks(ticks, maxTicks) {
|
1381 | if (ticks.length > maxTicks) {
|
1382 | var reduced = [];
|
1383 | var modulus = Math.floor(ticks.length / maxTicks);
|
1384 | for (var i = 0; i < ticks.length; i++) {
|
1385 | if (i % modulus === 0) {
|
1386 | reduced.push(ticks[i]);
|
1387 | }
|
1388 | }
|
1389 | ticks = reduced;
|
1390 | }
|
1391 | return ticks;
|
1392 | }
|
1393 |
|
1394 | exports.TextAnchor = void 0;
|
1395 | (function (TextAnchor) {
|
1396 | TextAnchor["Start"] = "start";
|
1397 | TextAnchor["Middle"] = "middle";
|
1398 | TextAnchor["End"] = "end";
|
1399 | })(exports.TextAnchor || (exports.TextAnchor = {}));
|
1400 |
|
1401 | var XAxisTicksComponent = (function () {
|
1402 | function XAxisTicksComponent(platformId) {
|
1403 | this.platformId = platformId;
|
1404 | this.tickArguments = [5];
|
1405 | this.tickStroke = '#ccc';
|
1406 | this.trimTicks = true;
|
1407 | this.maxTickLength = 16;
|
1408 | this.showGridLines = false;
|
1409 | this.rotateTicks = true;
|
1410 | this.dimensionsChanged = new core.EventEmitter();
|
1411 | this.verticalSpacing = 20;
|
1412 | this.rotateLabels = false;
|
1413 | this.innerTickSize = 6;
|
1414 | this.outerTickSize = 6;
|
1415 | this.tickPadding = 3;
|
1416 | this.textAnchor = exports.TextAnchor.Middle;
|
1417 | this.maxTicksLength = 0;
|
1418 | this.maxAllowedLength = 16;
|
1419 | this.height = 0;
|
1420 | this.approxHeight = 10;
|
1421 | }
|
1422 | XAxisTicksComponent.prototype.ngOnChanges = function (changes) {
|
1423 | this.update();
|
1424 | };
|
1425 | XAxisTicksComponent.prototype.ngAfterViewInit = function () {
|
1426 | var _this = this;
|
1427 | setTimeout(function () { return _this.updateDims(); });
|
1428 | };
|
1429 | XAxisTicksComponent.prototype.updateDims = function () {
|
1430 | var _this = this;
|
1431 | if (!common.isPlatformBrowser(this.platformId)) {
|
1432 |
|
1433 | this.dimensionsChanged.emit({ height: this.approxHeight });
|
1434 | return;
|
1435 | }
|
1436 | var height = parseInt(this.ticksElement.nativeElement.getBoundingClientRect().height, 10);
|
1437 | if (height !== this.height) {
|
1438 | this.height = height;
|
1439 | this.dimensionsChanged.emit({ height: this.height });
|
1440 | setTimeout(function () { return _this.updateDims(); });
|
1441 | }
|
1442 | };
|
1443 | XAxisTicksComponent.prototype.update = function () {
|
1444 | var _this = this;
|
1445 | var scale = this.scale;
|
1446 | this.ticks = this.getTicks();
|
1447 | if (this.tickFormatting) {
|
1448 | this.tickFormat = this.tickFormatting;
|
1449 | }
|
1450 | else if (scale.tickFormat) {
|
1451 | this.tickFormat = scale.tickFormat.apply(scale, this.tickArguments);
|
1452 | }
|
1453 | else {
|
1454 | this.tickFormat = function (d) {
|
1455 | if (d.constructor.name === 'Date') {
|
1456 | return d.toLocaleDateString();
|
1457 | }
|
1458 | return d.toLocaleString();
|
1459 | };
|
1460 | }
|
1461 | var angle = this.rotateTicks ? this.getRotationAngle(this.ticks) : null;
|
1462 | this.adjustedScale = this.scale.bandwidth
|
1463 | ? function (d) {
|
1464 | return this.scale(d) + this.scale.bandwidth() * 0.5;
|
1465 | }
|
1466 | : this.scale;
|
1467 | this.textTransform = '';
|
1468 | if (angle && angle !== 0) {
|
1469 | this.textTransform = "rotate(" + angle + ")";
|
1470 | this.textAnchor = exports.TextAnchor.End;
|
1471 | this.verticalSpacing = 10;
|
1472 | }
|
1473 | else {
|
1474 | this.textAnchor = exports.TextAnchor.Middle;
|
1475 | }
|
1476 | setTimeout(function () { return _this.updateDims(); });
|
1477 | };
|
1478 | XAxisTicksComponent.prototype.getRotationAngle = function (ticks) {
|
1479 | var angle = 0;
|
1480 | this.maxTicksLength = 0;
|
1481 | for (var i = 0; i < ticks.length; i++) {
|
1482 | var tick = this.tickFormat(ticks[i]).toString();
|
1483 | var tickLength = tick.length;
|
1484 | if (this.trimTicks) {
|
1485 | tickLength = this.tickTrim(tick).length;
|
1486 | }
|
1487 | if (tickLength > this.maxTicksLength) {
|
1488 | this.maxTicksLength = tickLength;
|
1489 | }
|
1490 | }
|
1491 | var len = Math.min(this.maxTicksLength, this.maxAllowedLength);
|
1492 | var charWidth = 7;
|
1493 | var wordWidth = len * charWidth;
|
1494 | var baseWidth = wordWidth;
|
1495 | var maxBaseWidth = Math.floor(this.width / ticks.length);
|
1496 |
|
1497 | while (baseWidth > maxBaseWidth && angle > -90) {
|
1498 | angle -= 30;
|
1499 | baseWidth = Math.cos(angle * (Math.PI / 180)) * wordWidth;
|
1500 | }
|
1501 | this.approxHeight = Math.max(Math.abs(Math.sin(angle * (Math.PI / 180)) * wordWidth), 10);
|
1502 | return angle;
|
1503 | };
|
1504 | XAxisTicksComponent.prototype.getTicks = function () {
|
1505 | var ticks;
|
1506 | var maxTicks = this.getMaxTicks(20);
|
1507 | var maxScaleTicks = this.getMaxTicks(100);
|
1508 | if (this.tickValues) {
|
1509 | ticks = this.tickValues;
|
1510 | }
|
1511 | else if (this.scale.ticks) {
|
1512 | ticks = this.scale.ticks.apply(this.scale, [maxScaleTicks]);
|
1513 | }
|
1514 | else {
|
1515 | ticks = this.scale.domain();
|
1516 | ticks = reduceTicks(ticks, maxTicks);
|
1517 | }
|
1518 | return ticks;
|
1519 | };
|
1520 | XAxisTicksComponent.prototype.getMaxTicks = function (tickWidth) {
|
1521 | return Math.floor(this.width / tickWidth);
|
1522 | };
|
1523 | XAxisTicksComponent.prototype.tickTransform = function (tick) {
|
1524 | return 'translate(' + this.adjustedScale(tick) + ',' + this.verticalSpacing + ')';
|
1525 | };
|
1526 | XAxisTicksComponent.prototype.gridLineTransform = function () {
|
1527 | return "translate(0," + (-this.verticalSpacing - 5) + ")";
|
1528 | };
|
1529 | XAxisTicksComponent.prototype.tickTrim = function (label) {
|
1530 | return this.trimTicks ? trimLabel(label, this.maxTickLength) : label;
|
1531 | };
|
1532 | return XAxisTicksComponent;
|
1533 | }());
|
1534 | XAxisTicksComponent.decorators = [
|
1535 | { type: core.Component, args: [{
|
1536 | selector: 'g[ngx-charts-x-axis-ticks]',
|
1537 | template: "\n <svg:g #ticksel>\n <svg:g *ngFor=\"let tick of ticks\" class=\"tick\" [attr.transform]=\"tickTransform(tick)\">\n <title>{{ tickFormat(tick) }}</title>\n <svg:text\n stroke-width=\"0.01\"\n [attr.text-anchor]=\"textAnchor\"\n [attr.transform]=\"textTransform\"\n [style.font-size]=\"'12px'\"\n >\n {{ tickTrim(tickFormat(tick)) }}\n </svg:text>\n </svg:g>\n </svg:g>\n\n <svg:g *ngFor=\"let tick of ticks\" [attr.transform]=\"tickTransform(tick)\">\n <svg:g *ngIf=\"showGridLines\" [attr.transform]=\"gridLineTransform()\">\n <svg:line class=\"gridline-path gridline-path-vertical\" [attr.y1]=\"-gridLineHeight\" y2=\"0\" />\n </svg:g>\n </svg:g>\n ",
|
1538 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
1539 | },] }
|
1540 | ];
|
1541 | XAxisTicksComponent.ctorParameters = function () { return [
|
1542 | { type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
|
1543 | ]; };
|
1544 | XAxisTicksComponent.propDecorators = {
|
1545 | scale: [{ type: core.Input }],
|
1546 | orient: [{ type: core.Input }],
|
1547 | tickArguments: [{ type: core.Input }],
|
1548 | tickValues: [{ type: core.Input }],
|
1549 | tickStroke: [{ type: core.Input }],
|
1550 | trimTicks: [{ type: core.Input }],
|
1551 | maxTickLength: [{ type: core.Input }],
|
1552 | tickFormatting: [{ type: core.Input }],
|
1553 | showGridLines: [{ type: core.Input }],
|
1554 | gridLineHeight: [{ type: core.Input }],
|
1555 | width: [{ type: core.Input }],
|
1556 | rotateTicks: [{ type: core.Input }],
|
1557 | dimensionsChanged: [{ type: core.Output }],
|
1558 | ticksElement: [{ type: core.ViewChild, args: ['ticksel',] }]
|
1559 | };
|
1560 |
|
1561 | var XAxisComponent = (function () {
|
1562 | function XAxisComponent() {
|
1563 | this.rotateTicks = true;
|
1564 | this.showGridLines = false;
|
1565 | this.xOrient = exports.Orientation.Bottom;
|
1566 | this.xAxisOffset = 0;
|
1567 | this.dimensionsChanged = new core.EventEmitter();
|
1568 | this.xAxisClassName = 'x axis';
|
1569 | this.labelOffset = 0;
|
1570 | this.fill = 'none';
|
1571 | this.stroke = 'stroke';
|
1572 | this.tickStroke = '#ccc';
|
1573 | this.strokeWidth = 'none';
|
1574 | this.padding = 5;
|
1575 | this.orientation = exports.Orientation;
|
1576 | }
|
1577 | XAxisComponent.prototype.ngOnChanges = function (changes) {
|
1578 | this.update();
|
1579 | };
|
1580 | XAxisComponent.prototype.update = function () {
|
1581 | this.transform = "translate(0," + (this.xAxisOffset + this.padding + this.dims.height) + ")";
|
1582 | if (typeof this.xAxisTickCount !== 'undefined') {
|
1583 | this.tickArguments = [this.xAxisTickCount];
|
1584 | }
|
1585 | };
|
1586 | XAxisComponent.prototype.emitTicksHeight = function (_a) {
|
1587 | var _this = this;
|
1588 | var height = _a.height;
|
1589 | var newLabelOffset = height + 25 + 5;
|
1590 | if (newLabelOffset !== this.labelOffset) {
|
1591 | this.labelOffset = newLabelOffset;
|
1592 | setTimeout(function () {
|
1593 | _this.dimensionsChanged.emit({ height: height });
|
1594 | }, 0);
|
1595 | }
|
1596 | };
|
1597 | return XAxisComponent;
|
1598 | }());
|
1599 | XAxisComponent.decorators = [
|
1600 | { type: core.Component, args: [{
|
1601 | selector: 'g[ngx-charts-x-axis]',
|
1602 | template: "\n <svg:g [attr.class]=\"xAxisClassName\" [attr.transform]=\"transform\">\n <svg:g\n ngx-charts-x-axis-ticks\n *ngIf=\"xScale\"\n [trimTicks]=\"trimTicks\"\n [rotateTicks]=\"rotateTicks\"\n [maxTickLength]=\"maxTickLength\"\n [tickFormatting]=\"tickFormatting\"\n [tickArguments]=\"tickArguments\"\n [tickStroke]=\"tickStroke\"\n [scale]=\"xScale\"\n [orient]=\"xOrient\"\n [showGridLines]=\"showGridLines\"\n [gridLineHeight]=\"dims.height\"\n [width]=\"dims.width\"\n [tickValues]=\"ticks\"\n (dimensionsChanged)=\"emitTicksHeight($event)\"\n />\n <svg:g\n ngx-charts-axis-label\n *ngIf=\"showLabel\"\n [label]=\"labelText\"\n [offset]=\"labelOffset\"\n [orient]=\"orientation.Bottom\"\n [height]=\"dims.height\"\n [width]=\"dims.width\"\n ></svg:g>\n </svg:g>\n ",
|
1603 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
1604 | },] }
|
1605 | ];
|
1606 | XAxisComponent.propDecorators = {
|
1607 | xScale: [{ type: core.Input }],
|
1608 | dims: [{ type: core.Input }],
|
1609 | trimTicks: [{ type: core.Input }],
|
1610 | rotateTicks: [{ type: core.Input }],
|
1611 | maxTickLength: [{ type: core.Input }],
|
1612 | tickFormatting: [{ type: core.Input }],
|
1613 | showGridLines: [{ type: core.Input }],
|
1614 | showLabel: [{ type: core.Input }],
|
1615 | labelText: [{ type: core.Input }],
|
1616 | ticks: [{ type: core.Input }],
|
1617 | xAxisTickCount: [{ type: core.Input }],
|
1618 | xOrient: [{ type: core.Input }],
|
1619 | xAxisOffset: [{ type: core.Input }],
|
1620 | dimensionsChanged: [{ type: core.Output }],
|
1621 | ticksComponent: [{ type: core.ViewChild, args: [XAxisTicksComponent,] }]
|
1622 | };
|
1623 |
|
1624 | |
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 | function roundedRect(x, y, w, h, r, _a) {
|
1631 | var _b = __read(_a, 4), tl = _b[0], tr = _b[1], bl = _b[2], br = _b[3];
|
1632 | var retval = '';
|
1633 | w = Math.floor(w);
|
1634 | h = Math.floor(h);
|
1635 | w = w === 0 ? 1 : w;
|
1636 | h = h === 0 ? 1 : h;
|
1637 | retval = "M" + [x + r, y];
|
1638 | retval += "h" + (w - 2 * r);
|
1639 | if (tr) {
|
1640 | retval += "a" + [r, r] + " 0 0 1 " + [r, r];
|
1641 | }
|
1642 | else {
|
1643 | retval += "h" + r + "v" + r;
|
1644 | }
|
1645 | retval += "v" + (h - 2 * r);
|
1646 | if (br) {
|
1647 | retval += "a" + [r, r] + " 0 0 1 " + [-r, r];
|
1648 | }
|
1649 | else {
|
1650 | retval += "v" + r + "h" + -r;
|
1651 | }
|
1652 | retval += "h" + (2 * r - w);
|
1653 | if (bl) {
|
1654 | retval += "a" + [r, r] + " 0 0 1 " + [-r, -r];
|
1655 | }
|
1656 | else {
|
1657 | retval += "h" + -r + "v" + -r;
|
1658 | }
|
1659 | retval += "v" + (2 * r - h);
|
1660 | if (tl) {
|
1661 | retval += "a" + [r, r] + " 0 0 1 " + [r, -r];
|
1662 | }
|
1663 | else {
|
1664 | retval += "v" + -r + "h" + r;
|
1665 | }
|
1666 | retval += "z";
|
1667 | return retval;
|
1668 | }
|
1669 |
|
1670 | var YAxisTicksComponent = (function () {
|
1671 | function YAxisTicksComponent(platformId) {
|
1672 | this.platformId = platformId;
|
1673 | this.tickArguments = [5];
|
1674 | this.tickStroke = '#ccc';
|
1675 | this.trimTicks = true;
|
1676 | this.maxTickLength = 16;
|
1677 | this.showGridLines = false;
|
1678 | this.showRefLabels = false;
|
1679 | this.showRefLines = false;
|
1680 | this.dimensionsChanged = new core.EventEmitter();
|
1681 | this.innerTickSize = 6;
|
1682 | this.tickPadding = 3;
|
1683 | this.verticalSpacing = 20;
|
1684 | this.textAnchor = exports.TextAnchor.Middle;
|
1685 | this.width = 0;
|
1686 | this.outerTickSize = 6;
|
1687 | this.rotateLabels = false;
|
1688 | this.referenceLineLength = 0;
|
1689 | this.Orientation = exports.Orientation;
|
1690 | }
|
1691 | YAxisTicksComponent.prototype.ngOnChanges = function (changes) {
|
1692 | this.update();
|
1693 | };
|
1694 | YAxisTicksComponent.prototype.ngAfterViewInit = function () {
|
1695 | var _this = this;
|
1696 | setTimeout(function () { return _this.updateDims(); });
|
1697 | };
|
1698 | YAxisTicksComponent.prototype.updateDims = function () {
|
1699 | var _this = this;
|
1700 | if (!common.isPlatformBrowser(this.platformId)) {
|
1701 |
|
1702 | this.width = this.getApproximateAxisWidth();
|
1703 | this.dimensionsChanged.emit({ width: this.width });
|
1704 | return;
|
1705 | }
|
1706 | var width = parseInt(this.ticksElement.nativeElement.getBoundingClientRect().width, 10);
|
1707 | if (width !== this.width) {
|
1708 | this.width = width;
|
1709 | this.dimensionsChanged.emit({ width: width });
|
1710 | setTimeout(function () { return _this.updateDims(); });
|
1711 | }
|
1712 | };
|
1713 | YAxisTicksComponent.prototype.update = function () {
|
1714 | var _this = this;
|
1715 | var scale;
|
1716 | var sign = this.orient === exports.Orientation.Top || this.orient === exports.Orientation.Right ? -1 : 1;
|
1717 | this.tickSpacing = Math.max(this.innerTickSize, 0) + this.tickPadding;
|
1718 | scale = this.scale;
|
1719 | this.ticks = this.getTicks();
|
1720 | if (this.tickFormatting) {
|
1721 | this.tickFormat = this.tickFormatting;
|
1722 | }
|
1723 | else if (scale.tickFormat) {
|
1724 | this.tickFormat = scale.tickFormat.apply(scale, this.tickArguments);
|
1725 | }
|
1726 | else {
|
1727 | this.tickFormat = function (d) {
|
1728 | if (d.constructor.name === 'Date') {
|
1729 | return d.toLocaleDateString();
|
1730 | }
|
1731 | return d.toLocaleString();
|
1732 | };
|
1733 | }
|
1734 | this.adjustedScale = scale.bandwidth
|
1735 | ? function (d) {
|
1736 | return scale(d) + scale.bandwidth() * 0.5;
|
1737 | }
|
1738 | : scale;
|
1739 | if (this.showRefLines && this.referenceLines) {
|
1740 | this.setReferencelines();
|
1741 | }
|
1742 | switch (this.orient) {
|
1743 | case exports.Orientation.Top:
|
1744 | this.transform = function (tick) {
|
1745 | return 'translate(' + this.adjustedScale(tick) + ',0)';
|
1746 | };
|
1747 | this.textAnchor = exports.TextAnchor.Middle;
|
1748 | this.y2 = this.innerTickSize * sign;
|
1749 | this.y1 = this.tickSpacing * sign;
|
1750 | this.dy = sign < 0 ? '0em' : '.71em';
|
1751 | break;
|
1752 | case exports.Orientation.Bottom:
|
1753 | this.transform = function (tick) {
|
1754 | return 'translate(' + this.adjustedScale(tick) + ',0)';
|
1755 | };
|
1756 | this.textAnchor = exports.TextAnchor.Middle;
|
1757 | this.y2 = this.innerTickSize * sign;
|
1758 | this.y1 = this.tickSpacing * sign;
|
1759 | this.dy = sign < 0 ? '0em' : '.71em';
|
1760 | break;
|
1761 | case exports.Orientation.Left:
|
1762 | this.transform = function (tick) {
|
1763 | return 'translate(0,' + this.adjustedScale(tick) + ')';
|
1764 | };
|
1765 | this.textAnchor = exports.TextAnchor.End;
|
1766 | this.x2 = this.innerTickSize * -sign;
|
1767 | this.x1 = this.tickSpacing * -sign;
|
1768 | this.dy = '.32em';
|
1769 | break;
|
1770 | case exports.Orientation.Right:
|
1771 | this.transform = function (tick) {
|
1772 | return 'translate(0,' + this.adjustedScale(tick) + ')';
|
1773 | };
|
1774 | this.textAnchor = exports.TextAnchor.Start;
|
1775 | this.x2 = this.innerTickSize * -sign;
|
1776 | this.x1 = this.tickSpacing * -sign;
|
1777 | this.dy = '.32em';
|
1778 | break;
|
1779 | default:
|
1780 | }
|
1781 | setTimeout(function () { return _this.updateDims(); });
|
1782 | };
|
1783 | YAxisTicksComponent.prototype.setReferencelines = function () {
|
1784 | this.refMin = this.adjustedScale(Math.min.apply(null, this.referenceLines.map(function (item) { return item.value; })));
|
1785 | this.refMax = this.adjustedScale(Math.max.apply(null, this.referenceLines.map(function (item) { return item.value; })));
|
1786 | this.referenceLineLength = this.referenceLines.length;
|
1787 | this.referenceAreaPath = roundedRect(0, this.refMax, this.gridLineWidth, this.refMin - this.refMax, 0, [
|
1788 | false,
|
1789 | false,
|
1790 | false,
|
1791 | false
|
1792 | ]);
|
1793 | };
|
1794 | YAxisTicksComponent.prototype.getTicks = function () {
|
1795 | var ticks;
|
1796 | var maxTicks = this.getMaxTicks(20);
|
1797 | var maxScaleTicks = this.getMaxTicks(50);
|
1798 | if (this.tickValues) {
|
1799 | ticks = this.tickValues;
|
1800 | }
|
1801 | else if (this.scale.ticks) {
|
1802 | ticks = this.scale.ticks.apply(this.scale, [maxScaleTicks]);
|
1803 | }
|
1804 | else {
|
1805 | ticks = this.scale.domain();
|
1806 | ticks = reduceTicks(ticks, maxTicks);
|
1807 | }
|
1808 | return ticks;
|
1809 | };
|
1810 | YAxisTicksComponent.prototype.getMaxTicks = function (tickHeight) {
|
1811 | return Math.floor(this.height / tickHeight);
|
1812 | };
|
1813 | YAxisTicksComponent.prototype.tickTransform = function (tick) {
|
1814 | return "translate(" + this.adjustedScale(tick) + "," + this.verticalSpacing + ")";
|
1815 | };
|
1816 | YAxisTicksComponent.prototype.gridLineTransform = function () {
|
1817 | return "translate(5,0)";
|
1818 | };
|
1819 | YAxisTicksComponent.prototype.tickTrim = function (label) {
|
1820 | return this.trimTicks ? trimLabel(label, this.maxTickLength) : label;
|
1821 | };
|
1822 | YAxisTicksComponent.prototype.getApproximateAxisWidth = function () {
|
1823 | var _this = this;
|
1824 | var maxChars = Math.max.apply(Math, __spreadArray([], __read(this.ticks.map(function (t) { return _this.tickTrim(_this.tickFormat(t)).length; }))));
|
1825 | var charWidth = 7;
|
1826 | return maxChars * charWidth;
|
1827 | };
|
1828 | return YAxisTicksComponent;
|
1829 | }());
|
1830 | YAxisTicksComponent.decorators = [
|
1831 | { type: core.Component, args: [{
|
1832 | selector: 'g[ngx-charts-y-axis-ticks]',
|
1833 | template: "\n <svg:g #ticksel>\n <svg:g *ngFor=\"let tick of ticks\" class=\"tick\" [attr.transform]=\"transform(tick)\">\n <title>{{ tickFormat(tick) }}</title>\n <svg:text\n stroke-width=\"0.01\"\n [attr.dy]=\"dy\"\n [attr.x]=\"x1\"\n [attr.y]=\"y1\"\n [attr.text-anchor]=\"textAnchor\"\n [style.font-size]=\"'12px'\"\n >\n {{ tickTrim(tickFormat(tick)) }}\n </svg:text>\n </svg:g>\n </svg:g>\n\n <svg:path\n *ngIf=\"referenceLineLength > 1 && refMax && refMin && showRefLines\"\n class=\"reference-area\"\n [attr.d]=\"referenceAreaPath\"\n [attr.transform]=\"gridLineTransform()\"\n />\n <svg:g *ngFor=\"let tick of ticks\" [attr.transform]=\"transform(tick)\">\n <svg:g *ngIf=\"showGridLines\" [attr.transform]=\"gridLineTransform()\">\n <svg:line\n *ngIf=\"orient === Orientation.Left\"\n class=\"gridline-path gridline-path-horizontal\"\n x1=\"0\"\n [attr.x2]=\"gridLineWidth\"\n />\n <svg:line\n *ngIf=\"orient === Orientation.Right\"\n class=\"gridline-path gridline-path-horizontal\"\n x1=\"0\"\n [attr.x2]=\"-gridLineWidth\"\n />\n </svg:g>\n </svg:g>\n\n <svg:g *ngFor=\"let refLine of referenceLines\">\n <svg:g *ngIf=\"showRefLines\" [attr.transform]=\"transform(refLine.value)\">\n <svg:line\n class=\"refline-path gridline-path-horizontal\"\n x1=\"0\"\n [attr.x2]=\"gridLineWidth\"\n [attr.transform]=\"gridLineTransform()\"\n />\n <svg:g *ngIf=\"showRefLabels\">\n <title>{{ tickTrim(tickFormat(refLine.value)) }}</title>\n <svg:text\n class=\"refline-label\"\n [attr.dy]=\"dy\"\n [attr.y]=\"-6\"\n [attr.x]=\"gridLineWidth\"\n [attr.text-anchor]=\"textAnchor\"\n >\n {{ refLine.name }}\n </svg:text>\n </svg:g>\n </svg:g>\n </svg:g>\n ",
|
1834 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
1835 | },] }
|
1836 | ];
|
1837 | YAxisTicksComponent.ctorParameters = function () { return [
|
1838 | { type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
|
1839 | ]; };
|
1840 | YAxisTicksComponent.propDecorators = {
|
1841 | scale: [{ type: core.Input }],
|
1842 | orient: [{ type: core.Input }],
|
1843 | tickArguments: [{ type: core.Input }],
|
1844 | tickValues: [{ type: core.Input }],
|
1845 | tickStroke: [{ type: core.Input }],
|
1846 | trimTicks: [{ type: core.Input }],
|
1847 | maxTickLength: [{ type: core.Input }],
|
1848 | tickFormatting: [{ type: core.Input }],
|
1849 | showGridLines: [{ type: core.Input }],
|
1850 | gridLineWidth: [{ type: core.Input }],
|
1851 | height: [{ type: core.Input }],
|
1852 | referenceLines: [{ type: core.Input }],
|
1853 | showRefLabels: [{ type: core.Input }],
|
1854 | showRefLines: [{ type: core.Input }],
|
1855 | dimensionsChanged: [{ type: core.Output }],
|
1856 | ticksElement: [{ type: core.ViewChild, args: ['ticksel',] }]
|
1857 | };
|
1858 |
|
1859 | var YAxisComponent = (function () {
|
1860 | function YAxisComponent() {
|
1861 | this.showGridLines = false;
|
1862 | this.yOrient = exports.Orientation.Left;
|
1863 | this.yAxisOffset = 0;
|
1864 | this.dimensionsChanged = new core.EventEmitter();
|
1865 | this.yAxisClassName = 'y axis';
|
1866 | this.labelOffset = 15;
|
1867 | this.fill = 'none';
|
1868 | this.stroke = '#CCC';
|
1869 | this.tickStroke = '#CCC';
|
1870 | this.strokeWidth = 1;
|
1871 | this.padding = 5;
|
1872 | }
|
1873 | YAxisComponent.prototype.ngOnChanges = function (changes) {
|
1874 | this.update();
|
1875 | };
|
1876 | YAxisComponent.prototype.update = function () {
|
1877 | this.offset = -(this.yAxisOffset + this.padding);
|
1878 | if (this.yOrient === exports.Orientation.Right) {
|
1879 | this.labelOffset = 65;
|
1880 | this.transform = "translate(" + (this.offset + this.dims.width) + " , 0)";
|
1881 | }
|
1882 | else {
|
1883 | this.offset = this.offset;
|
1884 | this.transform = "translate(" + this.offset + " , 0)";
|
1885 | }
|
1886 | if (this.yAxisTickCount !== undefined) {
|
1887 | this.tickArguments = [this.yAxisTickCount];
|
1888 | }
|
1889 | };
|
1890 | YAxisComponent.prototype.emitTicksWidth = function (_a) {
|
1891 | var _this = this;
|
1892 | var width = _a.width;
|
1893 | if (width !== this.labelOffset && this.yOrient === exports.Orientation.Right) {
|
1894 | this.labelOffset = width + this.labelOffset;
|
1895 | setTimeout(function () {
|
1896 | _this.dimensionsChanged.emit({ width: width });
|
1897 | }, 0);
|
1898 | }
|
1899 | else if (width !== this.labelOffset) {
|
1900 | this.labelOffset = width;
|
1901 | setTimeout(function () {
|
1902 | _this.dimensionsChanged.emit({ width: width });
|
1903 | }, 0);
|
1904 | }
|
1905 | };
|
1906 | return YAxisComponent;
|
1907 | }());
|
1908 | YAxisComponent.decorators = [
|
1909 | { type: core.Component, args: [{
|
1910 | selector: 'g[ngx-charts-y-axis]',
|
1911 | template: "\n <svg:g [attr.class]=\"yAxisClassName\" [attr.transform]=\"transform\">\n <svg:g\n ngx-charts-y-axis-ticks\n *ngIf=\"yScale\"\n [trimTicks]=\"trimTicks\"\n [maxTickLength]=\"maxTickLength\"\n [tickFormatting]=\"tickFormatting\"\n [tickArguments]=\"tickArguments\"\n [tickValues]=\"ticks\"\n [tickStroke]=\"tickStroke\"\n [scale]=\"yScale\"\n [orient]=\"yOrient\"\n [showGridLines]=\"showGridLines\"\n [gridLineWidth]=\"dims.width\"\n [referenceLines]=\"referenceLines\"\n [showRefLines]=\"showRefLines\"\n [showRefLabels]=\"showRefLabels\"\n [height]=\"dims.height\"\n (dimensionsChanged)=\"emitTicksWidth($event)\"\n />\n\n <svg:g\n ngx-charts-axis-label\n *ngIf=\"showLabel\"\n [label]=\"labelText\"\n [offset]=\"labelOffset\"\n [orient]=\"yOrient\"\n [height]=\"dims.height\"\n [width]=\"dims.width\"\n ></svg:g>\n </svg:g>\n ",
|
1912 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
1913 | },] }
|
1914 | ];
|
1915 | YAxisComponent.propDecorators = {
|
1916 | yScale: [{ type: core.Input }],
|
1917 | dims: [{ type: core.Input }],
|
1918 | trimTicks: [{ type: core.Input }],
|
1919 | maxTickLength: [{ type: core.Input }],
|
1920 | tickFormatting: [{ type: core.Input }],
|
1921 | ticks: [{ type: core.Input }],
|
1922 | showGridLines: [{ type: core.Input }],
|
1923 | showLabel: [{ type: core.Input }],
|
1924 | labelText: [{ type: core.Input }],
|
1925 | yAxisTickCount: [{ type: core.Input }],
|
1926 | yOrient: [{ type: core.Input }],
|
1927 | referenceLines: [{ type: core.Input }],
|
1928 | showRefLines: [{ type: core.Input }],
|
1929 | showRefLabels: [{ type: core.Input }],
|
1930 | yAxisOffset: [{ type: core.Input }],
|
1931 | dimensionsChanged: [{ type: core.Output }],
|
1932 | ticksComponent: [{ type: core.ViewChild, args: [YAxisTicksComponent,] }]
|
1933 | };
|
1934 |
|
1935 | var AxesModule = (function () {
|
1936 | function AxesModule() {
|
1937 | }
|
1938 | return AxesModule;
|
1939 | }());
|
1940 | AxesModule.decorators = [
|
1941 | { type: core.NgModule, args: [{
|
1942 | imports: [common.CommonModule],
|
1943 | declarations: [AxisLabelComponent, XAxisComponent, XAxisTicksComponent, YAxisComponent, YAxisTicksComponent],
|
1944 | exports: [AxisLabelComponent, XAxisComponent, XAxisTicksComponent, YAxisComponent, YAxisTicksComponent]
|
1945 | },] }
|
1946 | ];
|
1947 |
|
1948 | exports.StyleTypes = void 0;
|
1949 | (function (StyleTypes) {
|
1950 | StyleTypes["popover"] = "popover";
|
1951 | StyleTypes["tooltip"] = "tooltip";
|
1952 | })(exports.StyleTypes || (exports.StyleTypes = {}));
|
1953 |
|
1954 | exports.ShowTypes = void 0;
|
1955 | (function (ShowTypes) {
|
1956 | ShowTypes[ShowTypes["all"] = 'all'] = "all";
|
1957 | ShowTypes[ShowTypes["focus"] = 'focus'] = "focus";
|
1958 | ShowTypes[ShowTypes["mouseover"] = 'mouseover'] = "mouseover";
|
1959 | })(exports.ShowTypes || (exports.ShowTypes = {}));
|
1960 |
|
1961 | var TooltipDirective = (function () {
|
1962 | function TooltipDirective(tooltipService, viewContainerRef, renderer) {
|
1963 | this.tooltipService = tooltipService;
|
1964 | this.viewContainerRef = viewContainerRef;
|
1965 | this.renderer = renderer;
|
1966 | this.tooltipCssClass = '';
|
1967 | this.tooltipAppendToBody = true;
|
1968 | this.tooltipSpacing = 10;
|
1969 | this.tooltipDisabled = false;
|
1970 | this.tooltipShowCaret = true;
|
1971 | this.tooltipPlacement = exports.PlacementTypes.Top;
|
1972 | this.tooltipAlignment = exports.PlacementTypes.Center;
|
1973 | this.tooltipType = exports.StyleTypes.popover;
|
1974 | this.tooltipCloseOnClickOutside = true;
|
1975 | this.tooltipCloseOnMouseLeave = true;
|
1976 | this.tooltipHideTimeout = 300;
|
1977 | this.tooltipShowTimeout = 100;
|
1978 | this.tooltipShowEvent = exports.ShowTypes.all;
|
1979 | this.tooltipImmediateExit = false;
|
1980 | this.show = new core.EventEmitter();
|
1981 | this.hide = new core.EventEmitter();
|
1982 | }
|
1983 | Object.defineProperty(TooltipDirective.prototype, "listensForFocus", {
|
1984 | get: function () {
|
1985 | return this.tooltipShowEvent === exports.ShowTypes.all || this.tooltipShowEvent === exports.ShowTypes.focus;
|
1986 | },
|
1987 | enumerable: false,
|
1988 | configurable: true
|
1989 | });
|
1990 | Object.defineProperty(TooltipDirective.prototype, "listensForHover", {
|
1991 | get: function () {
|
1992 | return this.tooltipShowEvent === exports.ShowTypes.all || this.tooltipShowEvent === exports.ShowTypes.mouseover;
|
1993 | },
|
1994 | enumerable: false,
|
1995 | configurable: true
|
1996 | });
|
1997 | TooltipDirective.prototype.ngOnDestroy = function () {
|
1998 | this.hideTooltip(true);
|
1999 | };
|
2000 | TooltipDirective.prototype.onFocus = function () {
|
2001 | if (this.listensForFocus) {
|
2002 | this.showTooltip();
|
2003 | }
|
2004 | };
|
2005 | TooltipDirective.prototype.onBlur = function () {
|
2006 | if (this.listensForFocus) {
|
2007 | this.hideTooltip(true);
|
2008 | }
|
2009 | };
|
2010 | TooltipDirective.prototype.onMouseEnter = function () {
|
2011 | if (this.listensForHover) {
|
2012 | this.showTooltip();
|
2013 | }
|
2014 | };
|
2015 | TooltipDirective.prototype.onMouseLeave = function (target) {
|
2016 | if (this.listensForHover && this.tooltipCloseOnMouseLeave) {
|
2017 | clearTimeout(this.timeout);
|
2018 | if (this.component) {
|
2019 | var contentDom = this.component.instance.element.nativeElement;
|
2020 | var contains = contentDom.contains(target);
|
2021 | if (contains)
|
2022 | return;
|
2023 | }
|
2024 | this.hideTooltip(this.tooltipImmediateExit);
|
2025 | }
|
2026 | };
|
2027 | TooltipDirective.prototype.onMouseClick = function () {
|
2028 | if (this.listensForHover) {
|
2029 | this.hideTooltip(true);
|
2030 | }
|
2031 | };
|
2032 | TooltipDirective.prototype.showTooltip = function (immediate) {
|
2033 | var _this = this;
|
2034 | if (this.component || this.tooltipDisabled)
|
2035 | return;
|
2036 | var time = immediate
|
2037 | ? 0
|
2038 | : this.tooltipShowTimeout + (navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) ? 300 : 0);
|
2039 | clearTimeout(this.timeout);
|
2040 | this.timeout = setTimeout(function () {
|
2041 | _this.tooltipService.destroyAll();
|
2042 | var options = _this.createBoundOptions();
|
2043 | _this.component = _this.tooltipService.create(options);
|
2044 |
|
2045 | setTimeout(function () {
|
2046 | if (_this.component) {
|
2047 | _this.addHideListeners(_this.component.instance.element.nativeElement);
|
2048 | }
|
2049 | }, 10);
|
2050 | _this.show.emit(true);
|
2051 | }, time);
|
2052 | };
|
2053 | TooltipDirective.prototype.addHideListeners = function (tooltip) {
|
2054 | var _this = this;
|
2055 |
|
2056 | this.mouseEnterContentEvent = this.renderer.listen(tooltip, 'mouseenter', function () {
|
2057 | clearTimeout(_this.timeout);
|
2058 | });
|
2059 |
|
2060 | if (this.tooltipCloseOnMouseLeave) {
|
2061 | this.mouseLeaveContentEvent = this.renderer.listen(tooltip, 'mouseleave', function () {
|
2062 | _this.hideTooltip(_this.tooltipImmediateExit);
|
2063 | });
|
2064 | }
|
2065 |
|
2066 | if (this.tooltipCloseOnClickOutside) {
|
2067 | this.documentClickEvent = this.renderer.listen('window', 'click', function (event) {
|
2068 | var contains = tooltip.contains(event.target);
|
2069 | if (!contains)
|
2070 | _this.hideTooltip();
|
2071 | });
|
2072 | }
|
2073 | };
|
2074 | TooltipDirective.prototype.hideTooltip = function (immediate) {
|
2075 | var _this = this;
|
2076 | if (immediate === void 0) { immediate = false; }
|
2077 | if (!this.component)
|
2078 | return;
|
2079 | var destroyFn = function () {
|
2080 |
|
2081 | if (_this.mouseLeaveContentEvent)
|
2082 | _this.mouseLeaveContentEvent();
|
2083 | if (_this.mouseEnterContentEvent)
|
2084 | _this.mouseEnterContentEvent();
|
2085 | if (_this.documentClickEvent)
|
2086 | _this.documentClickEvent();
|
2087 |
|
2088 | _this.hide.emit(true);
|
2089 |
|
2090 | _this.tooltipService.destroy(_this.component);
|
2091 | _this.component = undefined;
|
2092 | };
|
2093 | clearTimeout(this.timeout);
|
2094 | if (!immediate) {
|
2095 | this.timeout = setTimeout(destroyFn, this.tooltipHideTimeout);
|
2096 | }
|
2097 | else {
|
2098 | destroyFn();
|
2099 | }
|
2100 | };
|
2101 | TooltipDirective.prototype.createBoundOptions = function () {
|
2102 | return {
|
2103 | title: this.tooltipTitle,
|
2104 | template: this.tooltipTemplate,
|
2105 | host: this.viewContainerRef.element,
|
2106 | placement: this.tooltipPlacement,
|
2107 | alignment: this.tooltipAlignment,
|
2108 | type: this.tooltipType,
|
2109 | showCaret: this.tooltipShowCaret,
|
2110 | cssClass: this.tooltipCssClass,
|
2111 | spacing: this.tooltipSpacing,
|
2112 | context: this.tooltipContext
|
2113 | };
|
2114 | };
|
2115 | return TooltipDirective;
|
2116 | }());
|
2117 | TooltipDirective.decorators = [
|
2118 | { type: core.Directive, args: [{ selector: '[ngx-tooltip]' },] }
|
2119 | ];
|
2120 | TooltipDirective.ctorParameters = function () { return [
|
2121 | { type: TooltipService },
|
2122 | { type: core.ViewContainerRef },
|
2123 | { type: core.Renderer2 }
|
2124 | ]; };
|
2125 | TooltipDirective.propDecorators = {
|
2126 | tooltipCssClass: [{ type: core.Input }],
|
2127 | tooltipTitle: [{ type: core.Input }],
|
2128 | tooltipAppendToBody: [{ type: core.Input }],
|
2129 | tooltipSpacing: [{ type: core.Input }],
|
2130 | tooltipDisabled: [{ type: core.Input }],
|
2131 | tooltipShowCaret: [{ type: core.Input }],
|
2132 | tooltipPlacement: [{ type: core.Input }],
|
2133 | tooltipAlignment: [{ type: core.Input }],
|
2134 | tooltipType: [{ type: core.Input }],
|
2135 | tooltipCloseOnClickOutside: [{ type: core.Input }],
|
2136 | tooltipCloseOnMouseLeave: [{ type: core.Input }],
|
2137 | tooltipHideTimeout: [{ type: core.Input }],
|
2138 | tooltipShowTimeout: [{ type: core.Input }],
|
2139 | tooltipTemplate: [{ type: core.Input }],
|
2140 | tooltipShowEvent: [{ type: core.Input }],
|
2141 | tooltipContext: [{ type: core.Input }],
|
2142 | tooltipImmediateExit: [{ type: core.Input }],
|
2143 | show: [{ type: core.Output }],
|
2144 | hide: [{ type: core.Output }],
|
2145 | onFocus: [{ type: core.HostListener, args: ['focusin',] }],
|
2146 | onBlur: [{ type: core.HostListener, args: ['blur',] }],
|
2147 | onMouseEnter: [{ type: core.HostListener, args: ['mouseenter',] }],
|
2148 | onMouseLeave: [{ type: core.HostListener, args: ['mouseleave', ['$event.target'],] }],
|
2149 | onMouseClick: [{ type: core.HostListener, args: ['click',] }]
|
2150 | };
|
2151 |
|
2152 | var TooltipModule = (function () {
|
2153 | function TooltipModule() {
|
2154 | }
|
2155 | return TooltipModule;
|
2156 | }());
|
2157 | TooltipModule.decorators = [
|
2158 | { type: core.NgModule, args: [{
|
2159 | declarations: [TooltipContentComponent, TooltipDirective],
|
2160 | providers: [InjectionService, TooltipService],
|
2161 | exports: [TooltipContentComponent, TooltipDirective],
|
2162 | imports: [common.CommonModule],
|
2163 | entryComponents: [TooltipContentComponent]
|
2164 | },] }
|
2165 | ];
|
2166 |
|
2167 | |
2168 |
|
2169 |
|
2170 |
|
2171 |
|
2172 | function formatLabel(label) {
|
2173 | if (label instanceof Date) {
|
2174 | label = label.toLocaleDateString();
|
2175 | }
|
2176 | else {
|
2177 | label = label.toLocaleString();
|
2178 | }
|
2179 | return label;
|
2180 | }
|
2181 | |
2182 |
|
2183 |
|
2184 |
|
2185 |
|
2186 | function escapeLabel(label) {
|
2187 | return label.toLocaleString().replace(/[&'`"<>]/g, function (match) {
|
2188 | return {
|
2189 | '&': '&',
|
2190 |
|
2191 | "'": ''',
|
2192 | '`': '`',
|
2193 | '"': '"',
|
2194 | '<': '<',
|
2195 | '>': '>'
|
2196 | }[match];
|
2197 | });
|
2198 | }
|
2199 |
|
2200 | var cache = {};
|
2201 | |
2202 |
|
2203 |
|
2204 |
|
2205 |
|
2206 |
|
2207 |
|
2208 |
|
2209 |
|
2210 |
|
2211 | function id() {
|
2212 | var newId = ('0000' + ((Math.random() * Math.pow(36, 4)) << 0).toString(36)).slice(-4);
|
2213 |
|
2214 | newId = "a" + newId;
|
2215 |
|
2216 | if (!cache[newId]) {
|
2217 | cache[newId] = true;
|
2218 | return newId;
|
2219 | }
|
2220 | return id();
|
2221 | }
|
2222 |
|
2223 | exports.BarOrientation = void 0;
|
2224 | (function (BarOrientation) {
|
2225 | BarOrientation["Vertical"] = "vertical";
|
2226 | BarOrientation["Horizontal"] = "horizontal";
|
2227 | })(exports.BarOrientation || (exports.BarOrientation = {}));
|
2228 |
|
2229 | exports.SeriesType = void 0;
|
2230 | (function (SeriesType) {
|
2231 | SeriesType["Standard"] = "standard";
|
2232 | SeriesType["Stacked"] = "stacked";
|
2233 | })(exports.SeriesType || (exports.SeriesType = {}));
|
2234 | var CircleSeriesComponent = (function () {
|
2235 | function CircleSeriesComponent() {
|
2236 | this.type = exports.SeriesType.Standard;
|
2237 | this.tooltipDisabled = false;
|
2238 | this.select = new core.EventEmitter();
|
2239 | this.activate = new core.EventEmitter();
|
2240 | this.deactivate = new core.EventEmitter();
|
2241 | this.barVisible = false;
|
2242 | this.barOrientation = exports.BarOrientation;
|
2243 | this.placementTypes = exports.PlacementTypes;
|
2244 | this.styleTypes = exports.StyleTypes;
|
2245 | }
|
2246 | CircleSeriesComponent.prototype.ngOnInit = function () {
|
2247 | this.gradientId = 'grad' + id().toString();
|
2248 | this.gradientFill = "url(#" + this.gradientId + ")";
|
2249 | };
|
2250 | CircleSeriesComponent.prototype.ngOnChanges = function () {
|
2251 | this.update();
|
2252 | };
|
2253 | CircleSeriesComponent.prototype.update = function () {
|
2254 | this.circle = this.getActiveCircle();
|
2255 | };
|
2256 | CircleSeriesComponent.prototype.getActiveCircle = function () {
|
2257 | var _this = this;
|
2258 | var indexActiveDataPoint = this.data.series.findIndex(function (d) {
|
2259 | var label = d.name;
|
2260 | return label && _this.visibleValue && label.toString() === _this.visibleValue.toString() && d.value !== undefined;
|
2261 | });
|
2262 | if (indexActiveDataPoint === -1) {
|
2263 |
|
2264 | return undefined;
|
2265 | }
|
2266 | return this.mapDataPointToCircle(this.data.series[indexActiveDataPoint], indexActiveDataPoint);
|
2267 | };
|
2268 | CircleSeriesComponent.prototype.mapDataPointToCircle = function (d, i) {
|
2269 | var seriesName = this.data.name;
|
2270 | var value = d.value;
|
2271 | var label = d.name;
|
2272 | var tooltipLabel = formatLabel(label);
|
2273 | var cx;
|
2274 | if (this.scaleType === exports.ScaleType.Time) {
|
2275 | cx = this.xScale(label);
|
2276 | }
|
2277 | else if (this.scaleType === exports.ScaleType.Linear) {
|
2278 | cx = this.xScale(Number(label));
|
2279 | }
|
2280 | else {
|
2281 | cx = this.xScale(label);
|
2282 | }
|
2283 | var cy = this.yScale(this.type === exports.SeriesType.Standard ? value : d.d1);
|
2284 | var radius = 5;
|
2285 | var height = this.yScale.range()[0] - cy;
|
2286 | var opacity = 1;
|
2287 | var color;
|
2288 | if (this.colors.scaleType === exports.ScaleType.Linear) {
|
2289 | if (this.type === exports.SeriesType.Standard) {
|
2290 | color = this.colors.getColor(value);
|
2291 | }
|
2292 | else {
|
2293 | color = this.colors.getColor(d.d1);
|
2294 | }
|
2295 | }
|
2296 | else {
|
2297 | color = this.colors.getColor(seriesName);
|
2298 | }
|
2299 | var data = Object.assign({}, d, {
|
2300 | series: seriesName,
|
2301 | value: value,
|
2302 | name: label
|
2303 | });
|
2304 | return {
|
2305 | classNames: ["circle-data-" + i],
|
2306 | value: value,
|
2307 | label: label,
|
2308 | data: data,
|
2309 | cx: cx,
|
2310 | cy: cy,
|
2311 | radius: radius,
|
2312 | height: height,
|
2313 | tooltipLabel: tooltipLabel,
|
2314 | color: color,
|
2315 | opacity: opacity,
|
2316 | seriesName: seriesName,
|
2317 | gradientStops: this.getGradientStops(color),
|
2318 | min: d.min,
|
2319 | max: d.max
|
2320 | };
|
2321 | };
|
2322 | CircleSeriesComponent.prototype.getTooltipText = function (_a) {
|
2323 | var tooltipLabel = _a.tooltipLabel, value = _a.value, seriesName = _a.seriesName, min = _a.min, max = _a.max;
|
2324 | return "\n <span class=\"tooltip-label\">" + escapeLabel(seriesName) + " \u2022 " + escapeLabel(tooltipLabel) + "</span>\n <span class=\"tooltip-val\">" + value.toLocaleString() + this.getTooltipMinMaxText(min, max) + "</span>\n ";
|
2325 | };
|
2326 | CircleSeriesComponent.prototype.getTooltipMinMaxText = function (min, max) {
|
2327 | if (min !== undefined || max !== undefined) {
|
2328 | var result = ' (';
|
2329 | if (min !== undefined) {
|
2330 | if (max === undefined) {
|
2331 | result += '≥';
|
2332 | }
|
2333 | result += min.toLocaleString();
|
2334 | if (max !== undefined) {
|
2335 | result += ' - ';
|
2336 | }
|
2337 | }
|
2338 | else if (max !== undefined) {
|
2339 | result += '≤';
|
2340 | }
|
2341 | if (max !== undefined) {
|
2342 | result += max.toLocaleString();
|
2343 | }
|
2344 | result += ')';
|
2345 | return result;
|
2346 | }
|
2347 | else {
|
2348 | return '';
|
2349 | }
|
2350 | };
|
2351 | CircleSeriesComponent.prototype.getGradientStops = function (color) {
|
2352 | return [
|
2353 | {
|
2354 | offset: 0,
|
2355 | color: color,
|
2356 | opacity: 0.2
|
2357 | },
|
2358 | {
|
2359 | offset: 100,
|
2360 | color: color,
|
2361 | opacity: 1
|
2362 | }
|
2363 | ];
|
2364 | };
|
2365 | CircleSeriesComponent.prototype.onClick = function (data) {
|
2366 | this.select.emit(data);
|
2367 | };
|
2368 | CircleSeriesComponent.prototype.isActive = function (entry) {
|
2369 | if (!this.activeEntries)
|
2370 | return false;
|
2371 | var item = this.activeEntries.find(function (d) {
|
2372 | return entry.name === d.name;
|
2373 | });
|
2374 | return item !== undefined;
|
2375 | };
|
2376 | CircleSeriesComponent.prototype.activateCircle = function () {
|
2377 | this.barVisible = true;
|
2378 | this.activate.emit({ name: this.data.name });
|
2379 | };
|
2380 | CircleSeriesComponent.prototype.deactivateCircle = function () {
|
2381 | this.barVisible = false;
|
2382 | this.circle.opacity = 0;
|
2383 | this.deactivate.emit({ name: this.data.name });
|
2384 | };
|
2385 | return CircleSeriesComponent;
|
2386 | }());
|
2387 | CircleSeriesComponent.decorators = [
|
2388 | { type: core.Component, args: [{
|
2389 | selector: 'g[ngx-charts-circle-series]',
|
2390 | template: "\n <svg:g *ngIf=\"circle\">\n <defs>\n <svg:g\n ngx-charts-svg-linear-gradient\n [orientation]=\"barOrientation.Vertical\"\n [name]=\"gradientId\"\n [stops]=\"circle.gradientStops\"\n />\n </defs>\n <svg:rect\n *ngIf=\"barVisible && type === 'standard'\"\n [@animationState]=\"'active'\"\n [attr.x]=\"circle.cx - circle.radius\"\n [attr.y]=\"circle.cy\"\n [attr.width]=\"circle.radius * 2\"\n [attr.height]=\"circle.height\"\n [attr.fill]=\"gradientFill\"\n class=\"tooltip-bar\"\n />\n <svg:g\n ngx-charts-circle\n class=\"circle\"\n [cx]=\"circle.cx\"\n [cy]=\"circle.cy\"\n [r]=\"circle.radius\"\n [fill]=\"circle.color\"\n [class.active]=\"isActive({ name: circle.seriesName })\"\n [pointerEvents]=\"circle.value === 0 ? 'none' : 'all'\"\n [data]=\"circle.value\"\n [classNames]=\"circle.classNames\"\n (select)=\"onClick(circle.data)\"\n (activate)=\"activateCircle()\"\n (deactivate)=\"deactivateCircle()\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"placementTypes.Top\"\n [tooltipType]=\"styleTypes.tooltip\"\n [tooltipTitle]=\"tooltipTemplate ? undefined : getTooltipText(circle)\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"circle.data\"\n />\n </svg:g>\n ",
|
2391 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
2392 | animations: [
|
2393 | animations.trigger('animationState', [
|
2394 | animations.transition(':enter', [
|
2395 | animations.style({
|
2396 | opacity: 0
|
2397 | }),
|
2398 | animations.animate(250, animations.style({ opacity: 1 }))
|
2399 | ])
|
2400 | ])
|
2401 | ]
|
2402 | },] }
|
2403 | ];
|
2404 | CircleSeriesComponent.propDecorators = {
|
2405 | data: [{ type: core.Input }],
|
2406 | type: [{ type: core.Input }],
|
2407 | xScale: [{ type: core.Input }],
|
2408 | yScale: [{ type: core.Input }],
|
2409 | colors: [{ type: core.Input }],
|
2410 | scaleType: [{ type: core.Input }],
|
2411 | visibleValue: [{ type: core.Input }],
|
2412 | activeEntries: [{ type: core.Input }],
|
2413 | tooltipDisabled: [{ type: core.Input }],
|
2414 | tooltipTemplate: [{ type: core.Input }],
|
2415 | select: [{ type: core.Output }],
|
2416 | activate: [{ type: core.Output }],
|
2417 | deactivate: [{ type: core.Output }]
|
2418 | };
|
2419 |
|
2420 | var CircleComponent = (function () {
|
2421 | function CircleComponent() {
|
2422 | this.select = new core.EventEmitter();
|
2423 | this.activate = new core.EventEmitter();
|
2424 | this.deactivate = new core.EventEmitter();
|
2425 | }
|
2426 | CircleComponent.prototype.onClick = function () {
|
2427 | this.select.emit(this.data);
|
2428 | };
|
2429 | CircleComponent.prototype.onMouseEnter = function () {
|
2430 | this.activate.emit(this.data);
|
2431 | };
|
2432 | CircleComponent.prototype.onMouseLeave = function () {
|
2433 | this.deactivate.emit(this.data);
|
2434 | };
|
2435 | CircleComponent.prototype.ngOnChanges = function (changes) {
|
2436 | this.classNames = Array.isArray(this.classNames) ? this.classNames.join(' ') : '';
|
2437 | this.classNames += 'circle';
|
2438 | };
|
2439 | return CircleComponent;
|
2440 | }());
|
2441 | CircleComponent.decorators = [
|
2442 | { type: core.Component, args: [{
|
2443 | selector: 'g[ngx-charts-circle]',
|
2444 | template: "\n <svg:circle\n [attr.cx]=\"cx\"\n [attr.cy]=\"cy\"\n [attr.r]=\"r\"\n [attr.fill]=\"fill\"\n [attr.stroke]=\"stroke\"\n [attr.opacity]=\"circleOpacity\"\n [attr.class]=\"classNames\"\n [attr.pointer-events]=\"pointerEvents\"\n />\n ",
|
2445 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
2446 | },] }
|
2447 | ];
|
2448 | CircleComponent.propDecorators = {
|
2449 | cx: [{ type: core.Input }],
|
2450 | cy: [{ type: core.Input }],
|
2451 | r: [{ type: core.Input }],
|
2452 | fill: [{ type: core.Input }],
|
2453 | stroke: [{ type: core.Input }],
|
2454 | data: [{ type: core.Input }],
|
2455 | classNames: [{ type: core.Input }],
|
2456 | circleOpacity: [{ type: core.Input }],
|
2457 | pointerEvents: [{ type: core.Input }],
|
2458 | select: [{ type: core.Output }],
|
2459 | activate: [{ type: core.Output }],
|
2460 | deactivate: [{ type: core.Output }],
|
2461 | onClick: [{ type: core.HostListener, args: ['click',] }],
|
2462 | onMouseEnter: [{ type: core.HostListener, args: ['mouseenter',] }],
|
2463 | onMouseLeave: [{ type: core.HostListener, args: ['mouseleave',] }]
|
2464 | };
|
2465 |
|
2466 | var GridPanelComponent = (function () {
|
2467 | function GridPanelComponent() {
|
2468 | }
|
2469 | return GridPanelComponent;
|
2470 | }());
|
2471 | GridPanelComponent.decorators = [
|
2472 | { type: core.Component, args: [{
|
2473 | selector: 'g[ngx-charts-grid-panel]',
|
2474 | template: "\n <svg:rect [attr.height]=\"height\" [attr.width]=\"width\" [attr.x]=\"x\" [attr.y]=\"y\" stroke=\"none\" class=\"gridpanel\" />\n ",
|
2475 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
2476 | },] }
|
2477 | ];
|
2478 | GridPanelComponent.propDecorators = {
|
2479 | width: [{ type: core.Input }],
|
2480 | height: [{ type: core.Input }],
|
2481 | x: [{ type: core.Input }],
|
2482 | y: [{ type: core.Input }]
|
2483 | };
|
2484 |
|
2485 | var ClassEnum;
|
2486 | (function (ClassEnum) {
|
2487 | ClassEnum["Odd"] = "odd";
|
2488 | ClassEnum["Even"] = "even";
|
2489 | })(ClassEnum || (ClassEnum = {}));
|
2490 | var GridPanelSeriesComponent = (function () {
|
2491 | function GridPanelSeriesComponent() {
|
2492 | }
|
2493 | GridPanelSeriesComponent.prototype.ngOnChanges = function (changes) {
|
2494 | this.update();
|
2495 | };
|
2496 | GridPanelSeriesComponent.prototype.update = function () {
|
2497 | this.gridPanels = this.getGridPanels();
|
2498 | };
|
2499 | GridPanelSeriesComponent.prototype.getGridPanels = function () {
|
2500 | var _this = this;
|
2501 | return this.data.map(function (d) {
|
2502 | var offset;
|
2503 | var width;
|
2504 | var height;
|
2505 | var x;
|
2506 | var y;
|
2507 | var className = ClassEnum.Odd;
|
2508 | if (_this.orient === exports.BarOrientation.Vertical) {
|
2509 | var position = _this.xScale(d.name);
|
2510 | var positionIndex = Number.parseInt((position / _this.xScale.step()).toString(), 10);
|
2511 | if (positionIndex % 2 === 1) {
|
2512 | className = ClassEnum.Even;
|
2513 | }
|
2514 | offset = _this.xScale.bandwidth() * _this.xScale.paddingInner();
|
2515 | width = _this.xScale.bandwidth() + offset;
|
2516 | height = _this.dims.height;
|
2517 | x = _this.xScale(d.name) - offset / 2;
|
2518 | y = 0;
|
2519 | }
|
2520 | else if (_this.orient === exports.BarOrientation.Horizontal) {
|
2521 | var position = _this.yScale(d.name);
|
2522 | var positionIndex = Number.parseInt((position / _this.yScale.step()).toString(), 10);
|
2523 | if (positionIndex % 2 === 1) {
|
2524 | className = ClassEnum.Even;
|
2525 | }
|
2526 | offset = _this.yScale.bandwidth() * _this.yScale.paddingInner();
|
2527 | width = _this.dims.width;
|
2528 | height = _this.yScale.bandwidth() + offset;
|
2529 | x = 0;
|
2530 | y = _this.yScale(d.name) - offset / 2;
|
2531 | }
|
2532 | return {
|
2533 | name: d.name,
|
2534 | class: className,
|
2535 | height: height,
|
2536 | width: width,
|
2537 | x: x,
|
2538 | y: y
|
2539 | };
|
2540 | });
|
2541 | };
|
2542 | return GridPanelSeriesComponent;
|
2543 | }());
|
2544 | GridPanelSeriesComponent.decorators = [
|
2545 | { type: core.Component, args: [{
|
2546 | selector: 'g[ngx-charts-grid-panel-series]',
|
2547 | template: "\n <svg:g\n ngx-charts-grid-panel\n *ngFor=\"let gridPanel of gridPanels\"\n [height]=\"gridPanel.height\"\n [width]=\"gridPanel.width\"\n [x]=\"gridPanel.x\"\n [y]=\"gridPanel.y\"\n [class.grid-panel]=\"true\"\n [class.odd]=\"gridPanel.class === 'odd'\"\n [class.even]=\"gridPanel.class === 'even'\"\n ></svg:g>\n ",
|
2548 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
2549 | },] }
|
2550 | ];
|
2551 | GridPanelSeriesComponent.propDecorators = {
|
2552 | data: [{ type: core.Input }],
|
2553 | dims: [{ type: core.Input }],
|
2554 | xScale: [{ type: core.Input }],
|
2555 | yScale: [{ type: core.Input }],
|
2556 | orient: [{ type: core.Input }]
|
2557 | };
|
2558 |
|
2559 | var SvgLinearGradientComponent = (function () {
|
2560 | function SvgLinearGradientComponent() {
|
2561 | this.orientation = exports.BarOrientation.Vertical;
|
2562 | }
|
2563 | SvgLinearGradientComponent.prototype.ngOnChanges = function (changes) {
|
2564 | this.x1 = '0%';
|
2565 | this.x2 = '0%';
|
2566 | this.y1 = '0%';
|
2567 | this.y2 = '0%';
|
2568 | if (this.orientation === exports.BarOrientation.Horizontal) {
|
2569 | this.x2 = '100%';
|
2570 | }
|
2571 | else if (this.orientation === exports.BarOrientation.Vertical) {
|
2572 | this.y1 = '100%';
|
2573 | }
|
2574 | };
|
2575 | return SvgLinearGradientComponent;
|
2576 | }());
|
2577 | SvgLinearGradientComponent.decorators = [
|
2578 | { type: core.Component, args: [{
|
2579 | selector: 'g[ngx-charts-svg-linear-gradient]',
|
2580 | template: "\n <svg:linearGradient [id]=\"name\" [attr.x1]=\"x1\" [attr.y1]=\"y1\" [attr.x2]=\"x2\" [attr.y2]=\"y2\">\n <svg:stop\n *ngFor=\"let stop of stops\"\n [attr.offset]=\"stop.offset + '%'\"\n [style.stop-color]=\"stop.color\"\n [style.stop-opacity]=\"stop.opacity\"\n />\n </svg:linearGradient>\n ",
|
2581 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
2582 | },] }
|
2583 | ];
|
2584 | SvgLinearGradientComponent.propDecorators = {
|
2585 | orientation: [{ type: core.Input }],
|
2586 | name: [{ type: core.Input }],
|
2587 | stops: [{ type: core.Input }]
|
2588 | };
|
2589 |
|
2590 | var SvgRadialGradientComponent = (function () {
|
2591 | function SvgRadialGradientComponent() {
|
2592 | this.endOpacity = 1;
|
2593 | this.cx = 0;
|
2594 | this.cy = 0;
|
2595 | }
|
2596 | Object.defineProperty(SvgRadialGradientComponent.prototype, "stops", {
|
2597 | get: function () {
|
2598 | return this.stopsInput || this.stopsDefault;
|
2599 | },
|
2600 | set: function (value) {
|
2601 | this.stopsInput = value;
|
2602 | },
|
2603 | enumerable: false,
|
2604 | configurable: true
|
2605 | });
|
2606 | SvgRadialGradientComponent.prototype.ngOnChanges = function (changes) {
|
2607 | this.r = '30%';
|
2608 | if ('color' in changes || 'startOpacity' in changes || 'endOpacity' in changes) {
|
2609 | this.stopsDefault = [
|
2610 | {
|
2611 | offset: 0,
|
2612 | color: this.color,
|
2613 | opacity: this.startOpacity
|
2614 | },
|
2615 | {
|
2616 | offset: 100,
|
2617 | color: this.color,
|
2618 | opacity: this.endOpacity
|
2619 | }
|
2620 | ];
|
2621 | }
|
2622 | };
|
2623 | return SvgRadialGradientComponent;
|
2624 | }());
|
2625 | SvgRadialGradientComponent.decorators = [
|
2626 | { type: core.Component, args: [{
|
2627 | selector: 'g[ngx-charts-svg-radial-gradient]',
|
2628 | template: "\n <svg:radialGradient [id]=\"name\" [attr.cx]=\"cx\" [attr.cy]=\"cy\" [attr.r]=\"r\" gradientUnits=\"userSpaceOnUse\">\n <svg:stop\n *ngFor=\"let stop of stops\"\n [attr.offset]=\"stop.offset + '%'\"\n [style.stop-color]=\"stop.color\"\n [style.stop-opacity]=\"stop.opacity\"\n />\n </svg:radialGradient>\n ",
|
2629 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
2630 | },] }
|
2631 | ];
|
2632 | SvgRadialGradientComponent.propDecorators = {
|
2633 | color: [{ type: core.Input }],
|
2634 | name: [{ type: core.Input }],
|
2635 | startOpacity: [{ type: core.Input }],
|
2636 | endOpacity: [{ type: core.Input }],
|
2637 | cx: [{ type: core.Input }],
|
2638 | cy: [{ type: core.Input }],
|
2639 | stops: [{ type: core.Input }]
|
2640 | };
|
2641 |
|
2642 | var AreaComponent = (function () {
|
2643 | function AreaComponent(element) {
|
2644 | this.opacity = 1;
|
2645 | this.startOpacity = 0.5;
|
2646 | this.endOpacity = 1;
|
2647 | this.gradient = false;
|
2648 | this.animations = true;
|
2649 | this.select = new core.EventEmitter();
|
2650 | this.animationsLoaded = false;
|
2651 | this.hasGradient = false;
|
2652 | this.barOrientation = exports.BarOrientation;
|
2653 | this.element = element.nativeElement;
|
2654 | }
|
2655 | AreaComponent.prototype.ngOnChanges = function () {
|
2656 | this.update();
|
2657 | if (!this.animationsLoaded) {
|
2658 | this.loadAnimation();
|
2659 | this.animationsLoaded = true;
|
2660 | }
|
2661 | };
|
2662 | AreaComponent.prototype.update = function () {
|
2663 | this.gradientId = 'grad' + id().toString();
|
2664 | this.gradientFill = "url(#" + this.gradientId + ")";
|
2665 | if (this.gradient || this.stops) {
|
2666 | this.gradientStops = this.getGradient();
|
2667 | this.hasGradient = true;
|
2668 | }
|
2669 | else {
|
2670 | this.hasGradient = false;
|
2671 | }
|
2672 | this.updatePathEl();
|
2673 | };
|
2674 | AreaComponent.prototype.loadAnimation = function () {
|
2675 | this.areaPath = this.startingPath;
|
2676 | setTimeout(this.updatePathEl.bind(this), 100);
|
2677 | };
|
2678 | AreaComponent.prototype.updatePathEl = function () {
|
2679 | var node = d3Selection.select(this.element).select('.area');
|
2680 | if (this.animations) {
|
2681 | node.transition().duration(750).attr('d', this.path);
|
2682 | }
|
2683 | else {
|
2684 | node.attr('d', this.path);
|
2685 | }
|
2686 | };
|
2687 | AreaComponent.prototype.getGradient = function () {
|
2688 | if (this.stops) {
|
2689 | return this.stops;
|
2690 | }
|
2691 | return [
|
2692 | {
|
2693 | offset: 0,
|
2694 | color: this.fill,
|
2695 | opacity: this.startOpacity
|
2696 | },
|
2697 | {
|
2698 | offset: 100,
|
2699 | color: this.fill,
|
2700 | opacity: this.endOpacity
|
2701 | }
|
2702 | ];
|
2703 | };
|
2704 | return AreaComponent;
|
2705 | }());
|
2706 | AreaComponent.decorators = [
|
2707 | { type: core.Component, args: [{
|
2708 | selector: 'g[ngx-charts-area]',
|
2709 | template: "\n <svg:defs *ngIf=\"gradient\">\n <svg:g\n ngx-charts-svg-linear-gradient\n [orientation]=\"barOrientation.Vertical\"\n [name]=\"gradientId\"\n [stops]=\"gradientStops\"\n />\n </svg:defs>\n <svg:path class=\"area\" [attr.d]=\"areaPath\" [attr.fill]=\"gradient ? gradientFill : fill\" [style.opacity]=\"opacity\" />\n ",
|
2710 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
2711 | },] }
|
2712 | ];
|
2713 | AreaComponent.ctorParameters = function () { return [
|
2714 | { type: core.ElementRef }
|
2715 | ]; };
|
2716 | AreaComponent.propDecorators = {
|
2717 | data: [{ type: core.Input }],
|
2718 | path: [{ type: core.Input }],
|
2719 | startingPath: [{ type: core.Input }],
|
2720 | fill: [{ type: core.Input }],
|
2721 | opacity: [{ type: core.Input }],
|
2722 | startOpacity: [{ type: core.Input }],
|
2723 | endOpacity: [{ type: core.Input }],
|
2724 | gradient: [{ type: core.Input }],
|
2725 | stops: [{ type: core.Input }],
|
2726 | animations: [{ type: core.Input }],
|
2727 | select: [{ type: core.Output }]
|
2728 | };
|
2729 |
|
2730 |
|
2731 | function easeOutExpo(t, b, c, d) {
|
2732 | return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b;
|
2733 | }
|
2734 | |
2735 |
|
2736 |
|
2737 | function count(countFrom, countTo, countDecimals, countDuration, callback) {
|
2738 | var startVal = Number(countFrom);
|
2739 | var endVal = Number(countTo);
|
2740 | var countDown = startVal > endVal;
|
2741 | var decimals = Math.max(0, countDecimals);
|
2742 | var dec = Math.pow(10, decimals);
|
2743 | var duration = Number(countDuration) * 1000;
|
2744 | var startTime;
|
2745 | function runCount(timestamp) {
|
2746 | var frameVal;
|
2747 | var progress = timestamp - startTime;
|
2748 | if (countDown) {
|
2749 | frameVal = startVal - easeOutExpo(progress, 0, startVal - endVal, duration);
|
2750 | }
|
2751 | else {
|
2752 | frameVal = easeOutExpo(progress, startVal, endVal - startVal, duration);
|
2753 | }
|
2754 | if (countDown) {
|
2755 | frameVal = frameVal < endVal ? endVal : frameVal;
|
2756 | }
|
2757 | else {
|
2758 | frameVal = frameVal > endVal ? endVal : frameVal;
|
2759 | }
|
2760 | frameVal = Math.round(frameVal * dec) / dec;
|
2761 | var tick = progress < duration;
|
2762 | callback({
|
2763 | value: frameVal,
|
2764 | progress: progress,
|
2765 | timestamp: timestamp,
|
2766 | finished: !tick
|
2767 | });
|
2768 | if (tick) {
|
2769 | return requestAnimationFrame(function (val) { return runCount(val); });
|
2770 | }
|
2771 | }
|
2772 | return requestAnimationFrame(function (timestamp) {
|
2773 | startTime = timestamp;
|
2774 | return runCount(timestamp);
|
2775 | });
|
2776 | }
|
2777 | |
2778 |
|
2779 |
|
2780 |
|
2781 |
|
2782 | function decimalChecker(countTo) {
|
2783 | var endVal = Number(countTo);
|
2784 | if (endVal % 1 !== 0 && Math.abs(endVal) <= 10) {
|
2785 | return 2;
|
2786 | }
|
2787 | return 0;
|
2788 | }
|
2789 |
|
2790 | |
2791 |
|
2792 |
|
2793 |
|
2794 |
|
2795 |
|
2796 |
|
2797 |
|
2798 |
|
2799 | var CountUpDirective = (function () {
|
2800 | function CountUpDirective(cd, element) {
|
2801 | this.cd = cd;
|
2802 | this.countDuration = 1;
|
2803 | this.countPrefix = '';
|
2804 | this.countSuffix = '';
|
2805 | this.countChange = new core.EventEmitter();
|
2806 | this.countFinish = new core.EventEmitter();
|
2807 | this.value = '';
|
2808 | this._countDecimals = 0;
|
2809 | this._countTo = 0;
|
2810 | this._countFrom = 0;
|
2811 | this.nativeElement = element.nativeElement;
|
2812 | }
|
2813 | Object.defineProperty(CountUpDirective.prototype, "countDecimals", {
|
2814 | get: function () {
|
2815 | if (this._countDecimals)
|
2816 | return this._countDecimals;
|
2817 | return decimalChecker(this.countTo);
|
2818 | },
|
2819 | set: function (val) {
|
2820 | this._countDecimals = val;
|
2821 | },
|
2822 | enumerable: false,
|
2823 | configurable: true
|
2824 | });
|
2825 | Object.defineProperty(CountUpDirective.prototype, "countTo", {
|
2826 | get: function () {
|
2827 | return this._countTo;
|
2828 | },
|
2829 | set: function (val) {
|
2830 | this._countTo = parseFloat(val);
|
2831 | this.start();
|
2832 | },
|
2833 | enumerable: false,
|
2834 | configurable: true
|
2835 | });
|
2836 | Object.defineProperty(CountUpDirective.prototype, "countFrom", {
|
2837 | get: function () {
|
2838 | return this._countFrom;
|
2839 | },
|
2840 | set: function (val) {
|
2841 | this._countFrom = parseFloat(val);
|
2842 | this.start();
|
2843 | },
|
2844 | enumerable: false,
|
2845 | configurable: true
|
2846 | });
|
2847 | CountUpDirective.prototype.ngOnDestroy = function () {
|
2848 | cancelAnimationFrame(this.animationReq);
|
2849 | };
|
2850 | CountUpDirective.prototype.start = function () {
|
2851 | var _this = this;
|
2852 | cancelAnimationFrame(this.animationReq);
|
2853 | var valueFormatting = this.valueFormatting || (function (value) { return "" + _this.countPrefix + value.toLocaleString() + _this.countSuffix; });
|
2854 | var callback = function (_a) {
|
2855 | var value = _a.value, progress = _a.progress, finished = _a.finished;
|
2856 | _this.value = valueFormatting(value);
|
2857 | _this.cd.markForCheck();
|
2858 | if (!finished)
|
2859 | _this.countChange.emit({ value: _this.value, progress: progress });
|
2860 | if (finished)
|
2861 | _this.countFinish.emit({ value: _this.value, progress: progress });
|
2862 | };
|
2863 | this.animationReq = count(this.countFrom, this.countTo, this.countDecimals, this.countDuration, callback);
|
2864 | };
|
2865 | return CountUpDirective;
|
2866 | }());
|
2867 | CountUpDirective.decorators = [
|
2868 | { type: core.Component, args: [{
|
2869 | selector: '[ngx-charts-count-up]',
|
2870 | template: " {{ value }} "
|
2871 | },] }
|
2872 | ];
|
2873 | CountUpDirective.ctorParameters = function () { return [
|
2874 | { type: core.ChangeDetectorRef },
|
2875 | { type: core.ElementRef }
|
2876 | ]; };
|
2877 | CountUpDirective.propDecorators = {
|
2878 | countDuration: [{ type: core.Input }],
|
2879 | countPrefix: [{ type: core.Input }],
|
2880 | countSuffix: [{ type: core.Input }],
|
2881 | valueFormatting: [{ type: core.Input }],
|
2882 | countDecimals: [{ type: core.Input }],
|
2883 | countTo: [{ type: core.Input }],
|
2884 | countFrom: [{ type: core.Input }],
|
2885 | countChange: [{ type: core.Output }],
|
2886 | countFinish: [{ type: core.Output }]
|
2887 | };
|
2888 |
|
2889 |
|
2890 |
|
2891 | var root;
|
2892 | if (typeof window !== 'undefined') {
|
2893 | root = window;
|
2894 | }
|
2895 | else if (typeof global !== 'undefined') {
|
2896 | root = global;
|
2897 | }
|
2898 |
|
2899 | var MouseEvent = root.MouseEvent;
|
2900 | function createMouseEvent(name, bubbles, cancelable) {
|
2901 | if (bubbles === void 0) { bubbles = false; }
|
2902 | if (cancelable === void 0) { cancelable = true; }
|
2903 |
|
2904 |
|
2905 | if (typeof MouseEvent === 'function') {
|
2906 |
|
2907 | return new MouseEvent(name, { bubbles: bubbles, cancelable: cancelable });
|
2908 | }
|
2909 | else {
|
2910 |
|
2911 | var event = document.createEvent('MouseEvent');
|
2912 | event.initEvent(name, bubbles, cancelable);
|
2913 | return event;
|
2914 | }
|
2915 | }
|
2916 |
|
2917 | var TooltipArea = (function () {
|
2918 | function TooltipArea(platformId) {
|
2919 | this.platformId = platformId;
|
2920 | this.anchorOpacity = 0;
|
2921 | this.anchorPos = -1;
|
2922 | this.anchorValues = [];
|
2923 | this.placementTypes = exports.PlacementTypes;
|
2924 | this.styleTypes = exports.StyleTypes;
|
2925 | this.showPercentage = false;
|
2926 | this.tooltipDisabled = false;
|
2927 | this.hover = new core.EventEmitter();
|
2928 | }
|
2929 | TooltipArea.prototype.getValues = function (xVal) {
|
2930 | var e_1, _a;
|
2931 | var results = [];
|
2932 | try {
|
2933 | for (var _b = __values(this.results), _c = _b.next(); !_c.done; _c = _b.next()) {
|
2934 | var group = _c.value;
|
2935 | var item = group.series.find(function (d) { return d.name.toString() === xVal.toString(); });
|
2936 | var groupName = group.name;
|
2937 | if (groupName instanceof Date) {
|
2938 | groupName = groupName.toLocaleDateString();
|
2939 | }
|
2940 | if (item) {
|
2941 | var label = item.name;
|
2942 | var val = item.value;
|
2943 | if (this.showPercentage) {
|
2944 | val = (item.d1 - item.d0).toFixed(2) + '%';
|
2945 | }
|
2946 | var color = void 0;
|
2947 | if (this.colors.scaleType === exports.ScaleType.Linear) {
|
2948 | var v = val;
|
2949 | if (item.d1) {
|
2950 | v = item.d1;
|
2951 | }
|
2952 | color = this.colors.getColor(v);
|
2953 | }
|
2954 | else {
|
2955 | color = this.colors.getColor(group.name);
|
2956 | }
|
2957 | var data = Object.assign({}, item, {
|
2958 | value: val,
|
2959 | name: label,
|
2960 | series: groupName,
|
2961 | min: item.min,
|
2962 | max: item.max,
|
2963 | color: color
|
2964 | });
|
2965 | results.push(data);
|
2966 | }
|
2967 | }
|
2968 | }
|
2969 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
2970 | finally {
|
2971 | try {
|
2972 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
2973 | }
|
2974 | finally { if (e_1) throw e_1.error; }
|
2975 | }
|
2976 | return results;
|
2977 | };
|
2978 | TooltipArea.prototype.mouseMove = function (event) {
|
2979 | if (!common.isPlatformBrowser(this.platformId)) {
|
2980 | return;
|
2981 | }
|
2982 | var xPos = event.pageX - event.target.getBoundingClientRect().left;
|
2983 | var closestIndex = this.findClosestPointIndex(xPos);
|
2984 | var closestPoint = this.xSet[closestIndex];
|
2985 | this.anchorPos = this.xScale(closestPoint);
|
2986 | this.anchorPos = Math.max(0, this.anchorPos);
|
2987 | this.anchorPos = Math.min(this.dims.width, this.anchorPos);
|
2988 | this.anchorValues = this.getValues(closestPoint);
|
2989 | if (this.anchorPos !== this.lastAnchorPos) {
|
2990 | var ev = createMouseEvent('mouseleave');
|
2991 | this.tooltipAnchor.nativeElement.dispatchEvent(ev);
|
2992 | this.anchorOpacity = 0.7;
|
2993 | this.hover.emit({
|
2994 | value: closestPoint
|
2995 | });
|
2996 | this.showTooltip();
|
2997 | this.lastAnchorPos = this.anchorPos;
|
2998 | }
|
2999 | };
|
3000 | TooltipArea.prototype.findClosestPointIndex = function (xPos) {
|
3001 | var minIndex = 0;
|
3002 | var maxIndex = this.xSet.length - 1;
|
3003 | var minDiff = Number.MAX_VALUE;
|
3004 | var closestIndex = 0;
|
3005 | while (minIndex <= maxIndex) {
|
3006 | var currentIndex = ((minIndex + maxIndex) / 2) | 0;
|
3007 | var currentElement = this.xScale(this.xSet[currentIndex]);
|
3008 | var curDiff = Math.abs(currentElement - xPos);
|
3009 | if (curDiff < minDiff) {
|
3010 | minDiff = curDiff;
|
3011 | closestIndex = currentIndex;
|
3012 | }
|
3013 | if (currentElement < xPos) {
|
3014 | minIndex = currentIndex + 1;
|
3015 | }
|
3016 | else if (currentElement > xPos) {
|
3017 | maxIndex = currentIndex - 1;
|
3018 | }
|
3019 | else {
|
3020 | minDiff = 0;
|
3021 | closestIndex = currentIndex;
|
3022 | break;
|
3023 | }
|
3024 | }
|
3025 | return closestIndex;
|
3026 | };
|
3027 | TooltipArea.prototype.showTooltip = function () {
|
3028 | var event = createMouseEvent('mouseenter');
|
3029 | this.tooltipAnchor.nativeElement.dispatchEvent(event);
|
3030 | };
|
3031 | TooltipArea.prototype.hideTooltip = function () {
|
3032 | var event = createMouseEvent('mouseleave');
|
3033 | this.tooltipAnchor.nativeElement.dispatchEvent(event);
|
3034 | this.anchorOpacity = 0;
|
3035 | this.lastAnchorPos = -1;
|
3036 | };
|
3037 | TooltipArea.prototype.getToolTipText = function (tooltipItem) {
|
3038 | var result = '';
|
3039 | if (tooltipItem.series !== undefined) {
|
3040 | result += tooltipItem.series;
|
3041 | }
|
3042 | else {
|
3043 | result += '???';
|
3044 | }
|
3045 | result += ': ';
|
3046 | if (tooltipItem.value !== undefined) {
|
3047 | result += tooltipItem.value.toLocaleString();
|
3048 | }
|
3049 | if (tooltipItem.min !== undefined || tooltipItem.max !== undefined) {
|
3050 | result += ' (';
|
3051 | if (tooltipItem.min !== undefined) {
|
3052 | if (tooltipItem.max === undefined) {
|
3053 | result += '≥';
|
3054 | }
|
3055 | result += tooltipItem.min.toLocaleString();
|
3056 | if (tooltipItem.max !== undefined) {
|
3057 | result += ' - ';
|
3058 | }
|
3059 | }
|
3060 | else if (tooltipItem.max !== undefined) {
|
3061 | result += '≤';
|
3062 | }
|
3063 | if (tooltipItem.max !== undefined) {
|
3064 | result += tooltipItem.max.toLocaleString();
|
3065 | }
|
3066 | result += ')';
|
3067 | }
|
3068 | return result;
|
3069 | };
|
3070 | return TooltipArea;
|
3071 | }());
|
3072 | TooltipArea.decorators = [
|
3073 | { type: core.Component, args: [{
|
3074 | selector: 'g[ngx-charts-tooltip-area]',
|
3075 | template: "\n <svg:g>\n <svg:rect\n class=\"tooltip-area\"\n [attr.x]=\"0\"\n y=\"0\"\n [attr.width]=\"dims.width\"\n [attr.height]=\"dims.height\"\n style=\"opacity: 0; cursor: 'auto';\"\n (mousemove)=\"mouseMove($event)\"\n (mouseleave)=\"hideTooltip()\"\n />\n <ng-template #defaultTooltipTemplate let-model=\"model\">\n <xhtml:div class=\"area-tooltip-container\">\n <xhtml:div *ngFor=\"let tooltipItem of model\" class=\"tooltip-item\">\n <xhtml:span class=\"tooltip-item-color\" [style.background-color]=\"tooltipItem.color\"></xhtml:span>\n {{ getToolTipText(tooltipItem) }}\n </xhtml:div>\n </xhtml:div>\n </ng-template>\n <svg:rect\n #tooltipAnchor\n [@animationState]=\"anchorOpacity !== 0 ? 'active' : 'inactive'\"\n class=\"tooltip-anchor\"\n [attr.x]=\"anchorPos\"\n y=\"0\"\n [attr.width]=\"1\"\n [attr.height]=\"dims.height\"\n [style.opacity]=\"anchorOpacity\"\n [style.pointer-events]=\"'none'\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"placementTypes.Right\"\n [tooltipType]=\"styleTypes.tooltip\"\n [tooltipSpacing]=\"15\"\n [tooltipTemplate]=\"tooltipTemplate ? tooltipTemplate : defaultTooltipTemplate\"\n [tooltipContext]=\"anchorValues\"\n [tooltipImmediateExit]=\"true\"\n />\n </svg:g>\n ",
|
3076 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
3077 | animations: [
|
3078 | animations.trigger('animationState', [
|
3079 | animations.transition('inactive => active', [
|
3080 | animations.style({
|
3081 | opacity: 0
|
3082 | }),
|
3083 | animations.animate(250, animations.style({ opacity: 0.7 }))
|
3084 | ]),
|
3085 | animations.transition('active => inactive', [
|
3086 | animations.style({
|
3087 | opacity: 0.7
|
3088 | }),
|
3089 | animations.animate(250, animations.style({ opacity: 0 }))
|
3090 | ])
|
3091 | ])
|
3092 | ]
|
3093 | },] }
|
3094 | ];
|
3095 | TooltipArea.ctorParameters = function () { return [
|
3096 | { type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
|
3097 | ]; };
|
3098 | TooltipArea.propDecorators = {
|
3099 | dims: [{ type: core.Input }],
|
3100 | xSet: [{ type: core.Input }],
|
3101 | xScale: [{ type: core.Input }],
|
3102 | yScale: [{ type: core.Input }],
|
3103 | results: [{ type: core.Input }],
|
3104 | colors: [{ type: core.Input }],
|
3105 | showPercentage: [{ type: core.Input }],
|
3106 | tooltipDisabled: [{ type: core.Input }],
|
3107 | tooltipTemplate: [{ type: core.Input }],
|
3108 | hover: [{ type: core.Output }],
|
3109 | tooltipAnchor: [{ type: core.ViewChild, args: ['tooltipAnchor', { static: false },] }]
|
3110 | };
|
3111 |
|
3112 | var Timeline = (function () {
|
3113 | function Timeline(element, cd) {
|
3114 | this.cd = cd;
|
3115 | this.height = 50;
|
3116 | this.select = new core.EventEmitter();
|
3117 | this.onDomainChange = new core.EventEmitter();
|
3118 | this.initialized = false;
|
3119 | this.element = element.nativeElement;
|
3120 | }
|
3121 | Timeline.prototype.ngOnChanges = function (changes) {
|
3122 | this.update();
|
3123 | if (!this.initialized) {
|
3124 | this.addBrush();
|
3125 | this.initialized = true;
|
3126 | }
|
3127 | };
|
3128 | Timeline.prototype.update = function () {
|
3129 | this.dims = this.getDims();
|
3130 | this.height = this.dims.height;
|
3131 | var offsetY = this.view[1] - this.height;
|
3132 | this.xDomain = this.getXDomain();
|
3133 | this.xScale = this.getXScale();
|
3134 | if (this.brush) {
|
3135 | this.updateBrush();
|
3136 | }
|
3137 | this.transform = "translate(0 , " + offsetY + ")";
|
3138 | this.filterId = 'filter' + id().toString();
|
3139 | this.filter = "url(#" + this.filterId + ")";
|
3140 | this.cd.markForCheck();
|
3141 | };
|
3142 | Timeline.prototype.getXDomain = function () {
|
3143 | var e_1, _a, e_2, _b;
|
3144 | var values = [];
|
3145 | try {
|
3146 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
3147 | var results = _d.value;
|
3148 | try {
|
3149 | for (var _e = (e_2 = void 0, __values(results.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
3150 | var d = _f.value;
|
3151 | if (!values.includes(d.name)) {
|
3152 | values.push(d.name);
|
3153 | }
|
3154 | }
|
3155 | }
|
3156 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
3157 | finally {
|
3158 | try {
|
3159 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
3160 | }
|
3161 | finally { if (e_2) throw e_2.error; }
|
3162 | }
|
3163 | }
|
3164 | }
|
3165 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
3166 | finally {
|
3167 | try {
|
3168 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
3169 | }
|
3170 | finally { if (e_1) throw e_1.error; }
|
3171 | }
|
3172 | var domain = [];
|
3173 | if (this.scaleType === exports.ScaleType.Time) {
|
3174 | var min = Math.min.apply(Math, __spreadArray([], __read(values)));
|
3175 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
3176 | domain = [min, max];
|
3177 | }
|
3178 | else if (this.scaleType === exports.ScaleType.Linear) {
|
3179 | values = values.map(function (v) { return Number(v); });
|
3180 | var min = Math.min.apply(Math, __spreadArray([], __read(values)));
|
3181 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
3182 | domain = [min, max];
|
3183 | }
|
3184 | else {
|
3185 | domain = values;
|
3186 | }
|
3187 | return domain;
|
3188 | };
|
3189 | Timeline.prototype.getXScale = function () {
|
3190 | var scale;
|
3191 | if (this.scaleType === exports.ScaleType.Time) {
|
3192 | scale = d3Scale.scaleTime().range([0, this.dims.width]).domain(this.xDomain);
|
3193 | }
|
3194 | else if (this.scaleType === exports.ScaleType.Linear) {
|
3195 | scale = d3Scale.scaleLinear().range([0, this.dims.width]).domain(this.xDomain);
|
3196 | }
|
3197 | else if (this.scaleType === exports.ScaleType.Ordinal) {
|
3198 | scale = d3Scale.scalePoint().range([0, this.dims.width]).padding(0.1).domain(this.xDomain);
|
3199 | }
|
3200 | return scale;
|
3201 | };
|
3202 | Timeline.prototype.addBrush = function () {
|
3203 | var _this = this;
|
3204 | if (this.brush)
|
3205 | return;
|
3206 | var height = this.height;
|
3207 | var width = this.view[0];
|
3208 | this.brush = d3Brush.brushX()
|
3209 | .extent([
|
3210 | [0, 0],
|
3211 | [width, height]
|
3212 | ])
|
3213 | .on('brush end', function (_a) {
|
3214 | var selection = _a.selection;
|
3215 | var newSelection = selection || _this.xScale.range();
|
3216 | var newDomain = newSelection.map(_this.xScale.invert);
|
3217 | _this.onDomainChange.emit(newDomain);
|
3218 | _this.cd.markForCheck();
|
3219 | });
|
3220 | d3Selection.select(this.element).select('.brush').call(this.brush);
|
3221 | };
|
3222 | Timeline.prototype.updateBrush = function () {
|
3223 | if (!this.brush)
|
3224 | return;
|
3225 | var height = this.height;
|
3226 | var width = this.view[0];
|
3227 | this.brush.extent([
|
3228 | [0, 0],
|
3229 | [width, height]
|
3230 | ]);
|
3231 | d3Selection.select(this.element).select('.brush').call(this.brush);
|
3232 |
|
3233 | d3Selection.select(this.element)
|
3234 | .select('.selection')
|
3235 | .attr('fill', undefined)
|
3236 | .attr('stroke', undefined)
|
3237 | .attr('fill-opacity', undefined);
|
3238 | this.cd.markForCheck();
|
3239 | };
|
3240 | Timeline.prototype.getDims = function () {
|
3241 | var width = this.view[0];
|
3242 | var dims = {
|
3243 | width: width,
|
3244 | height: this.height
|
3245 | };
|
3246 | return dims;
|
3247 | };
|
3248 | return Timeline;
|
3249 | }());
|
3250 | Timeline.decorators = [
|
3251 | { type: core.Component, args: [{
|
3252 | selector: 'g[ngx-charts-timeline]',
|
3253 | template: "\n <svg:g class=\"timeline\" [attr.transform]=\"transform\">\n <svg:filter [attr.id]=\"filterId\">\n <svg:feColorMatrix\n in=\"SourceGraphic\"\n type=\"matrix\"\n values=\"0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\"\n />\n </svg:filter>\n <svg:g class=\"embedded-chart\">\n <ng-content></ng-content>\n </svg:g>\n <svg:rect x=\"0\" [attr.width]=\"view[0]\" y=\"0\" [attr.height]=\"height\" class=\"brush-background\" />\n <svg:g class=\"brush\"></svg:g>\n </svg:g>\n ",
|
3254 | encapsulation: core.ViewEncapsulation.None,
|
3255 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
3256 | styles: [".timeline .brush-background{fill:#0000000d}.timeline .brush .selection{fill:#0000001a;stroke-width:1px;stroke:#888}.timeline .brush .handle{fill-opacity:0}.timeline .embedded-chart{opacity:.6}\n"]
|
3257 | },] }
|
3258 | ];
|
3259 | Timeline.ctorParameters = function () { return [
|
3260 | { type: core.ElementRef },
|
3261 | { type: core.ChangeDetectorRef }
|
3262 | ]; };
|
3263 | Timeline.propDecorators = {
|
3264 | view: [{ type: core.Input }],
|
3265 | results: [{ type: core.Input }],
|
3266 | scheme: [{ type: core.Input }],
|
3267 | customColors: [{ type: core.Input }],
|
3268 | legend: [{ type: core.Input }],
|
3269 | autoScale: [{ type: core.Input }],
|
3270 | scaleType: [{ type: core.Input }],
|
3271 | height: [{ type: core.Input }],
|
3272 | select: [{ type: core.Output }],
|
3273 | onDomainChange: [{ type: core.Output }]
|
3274 | };
|
3275 |
|
3276 | var LegendComponent = (function () {
|
3277 | function LegendComponent(cd) {
|
3278 | this.cd = cd;
|
3279 | this.horizontal = false;
|
3280 | this.labelClick = new core.EventEmitter();
|
3281 | this.labelActivate = new core.EventEmitter();
|
3282 | this.labelDeactivate = new core.EventEmitter();
|
3283 | this.legendEntries = [];
|
3284 | }
|
3285 | LegendComponent.prototype.ngOnChanges = function (changes) {
|
3286 | this.update();
|
3287 | };
|
3288 | LegendComponent.prototype.update = function () {
|
3289 | this.cd.markForCheck();
|
3290 | this.legendEntries = this.getLegendEntries();
|
3291 | };
|
3292 | LegendComponent.prototype.getLegendEntries = function () {
|
3293 | var e_1, _a;
|
3294 | var items = [];
|
3295 | var _loop_1 = function (label) {
|
3296 | var formattedLabel = formatLabel(label);
|
3297 | var idx = items.findIndex(function (i) {
|
3298 | return i.label === formattedLabel;
|
3299 | });
|
3300 | if (idx === -1) {
|
3301 | items.push({
|
3302 | label: label,
|
3303 | formattedLabel: formattedLabel,
|
3304 | color: this_1.colors.getColor(label)
|
3305 | });
|
3306 | }
|
3307 | };
|
3308 | var this_1 = this;
|
3309 | try {
|
3310 | for (var _b = __values(this.data), _c = _b.next(); !_c.done; _c = _b.next()) {
|
3311 | var label = _c.value;
|
3312 | _loop_1(label);
|
3313 | }
|
3314 | }
|
3315 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
3316 | finally {
|
3317 | try {
|
3318 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
3319 | }
|
3320 | finally { if (e_1) throw e_1.error; }
|
3321 | }
|
3322 | return items;
|
3323 | };
|
3324 | LegendComponent.prototype.isActive = function (entry) {
|
3325 | if (!this.activeEntries)
|
3326 | return false;
|
3327 | var item = this.activeEntries.find(function (d) {
|
3328 | return entry.label === d.name;
|
3329 | });
|
3330 | return item !== undefined;
|
3331 | };
|
3332 | LegendComponent.prototype.activate = function (item) {
|
3333 | this.labelActivate.emit(item);
|
3334 | };
|
3335 | LegendComponent.prototype.deactivate = function (item) {
|
3336 | this.labelDeactivate.emit(item);
|
3337 | };
|
3338 | LegendComponent.prototype.trackBy = function (index, item) {
|
3339 | return item.label;
|
3340 | };
|
3341 | return LegendComponent;
|
3342 | }());
|
3343 | LegendComponent.decorators = [
|
3344 | { type: core.Component, args: [{
|
3345 | selector: 'ngx-charts-legend',
|
3346 | template: "\n <div [style.width.px]=\"width\">\n <header class=\"legend-title\" *ngIf=\"title?.length > 0\">\n <span class=\"legend-title-text\">{{ title }}</span>\n </header>\n <div class=\"legend-wrap\">\n <ul class=\"legend-labels\" [class.horizontal-legend]=\"horizontal\" [style.max-height.px]=\"height - 45\">\n <li *ngFor=\"let entry of legendEntries; trackBy: trackBy\" class=\"legend-label\">\n <ngx-charts-legend-entry\n [label]=\"entry.label\"\n [formattedLabel]=\"entry.formattedLabel\"\n [color]=\"entry.color\"\n [isActive]=\"isActive(entry)\"\n (select)=\"labelClick.emit($event)\"\n (activate)=\"activate($event)\"\n (deactivate)=\"deactivate($event)\"\n >\n </ngx-charts-legend-entry>\n </li>\n </ul>\n </div>\n </div>\n ",
|
3347 | encapsulation: core.ViewEncapsulation.None,
|
3348 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
3349 | styles: [".chart-legend{display:inline-block;padding:0;width:auto!important}.chart-legend .legend-title{white-space:nowrap;overflow:hidden;margin-left:10px;margin-bottom:5px;font-size:14px;font-weight:bold}.chart-legend ul,.chart-legend li{padding:0;margin:0;list-style:none}.chart-legend .horizontal-legend li{display:inline-block}.chart-legend .legend-wrap{width:calc(100% - 10px)}.chart-legend .legend-labels{line-height:85%;list-style:none;text-align:left;float:left;width:100%;border-radius:3px;overflow-y:auto;overflow-x:hidden;white-space:nowrap;background:rgba(0,0,0,.05)}.chart-legend .legend-label{cursor:pointer;font-size:90%;margin:8px;color:#afb7c8}.chart-legend .legend-label:hover{color:#000;transition:.2s}.chart-legend .legend-label .active .legend-label-text{color:#000}.chart-legend .legend-label-color{display:inline-block;height:15px;width:15px;margin-right:5px;color:#5b646b;border-radius:3px}.chart-legend .legend-label-text{display:inline-block;vertical-align:top;line-height:15px;font-size:12px;width:calc(100% - 20px);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.chart-legend .legend-title-text{vertical-align:bottom;display:inline-block;line-height:16px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}\n"]
|
3350 | },] }
|
3351 | ];
|
3352 | LegendComponent.ctorParameters = function () { return [
|
3353 | { type: core.ChangeDetectorRef }
|
3354 | ]; };
|
3355 | LegendComponent.propDecorators = {
|
3356 | data: [{ type: core.Input }],
|
3357 | title: [{ type: core.Input }],
|
3358 | colors: [{ type: core.Input }],
|
3359 | height: [{ type: core.Input }],
|
3360 | width: [{ type: core.Input }],
|
3361 | activeEntries: [{ type: core.Input }],
|
3362 | horizontal: [{ type: core.Input }],
|
3363 | labelClick: [{ type: core.Output }],
|
3364 | labelActivate: [{ type: core.Output }],
|
3365 | labelDeactivate: [{ type: core.Output }]
|
3366 | };
|
3367 |
|
3368 | var LegendEntryComponent = (function () {
|
3369 | function LegendEntryComponent() {
|
3370 | this.isActive = false;
|
3371 | this.select = new core.EventEmitter();
|
3372 | this.activate = new core.EventEmitter();
|
3373 | this.deactivate = new core.EventEmitter();
|
3374 | this.toggle = new core.EventEmitter();
|
3375 | }
|
3376 | Object.defineProperty(LegendEntryComponent.prototype, "trimmedLabel", {
|
3377 | get: function () {
|
3378 | return this.formattedLabel || '(empty)';
|
3379 | },
|
3380 | enumerable: false,
|
3381 | configurable: true
|
3382 | });
|
3383 | LegendEntryComponent.prototype.onMouseEnter = function () {
|
3384 | this.activate.emit({ name: this.label });
|
3385 | };
|
3386 | LegendEntryComponent.prototype.onMouseLeave = function () {
|
3387 | this.deactivate.emit({ name: this.label });
|
3388 | };
|
3389 | return LegendEntryComponent;
|
3390 | }());
|
3391 | LegendEntryComponent.decorators = [
|
3392 | { type: core.Component, args: [{
|
3393 | selector: 'ngx-charts-legend-entry',
|
3394 | template: "\n <span [title]=\"formattedLabel\" tabindex=\"-1\" [class.active]=\"isActive\" (click)=\"select.emit(formattedLabel)\">\n <span class=\"legend-label-color\" [style.background-color]=\"color\" (click)=\"toggle.emit(formattedLabel)\"> </span>\n <span class=\"legend-label-text\">\n {{ trimmedLabel }}\n </span>\n </span>\n ",
|
3395 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
3396 | },] }
|
3397 | ];
|
3398 | LegendEntryComponent.propDecorators = {
|
3399 | color: [{ type: core.Input }],
|
3400 | label: [{ type: core.Input }],
|
3401 | formattedLabel: [{ type: core.Input }],
|
3402 | isActive: [{ type: core.Input }],
|
3403 | select: [{ type: core.Output }],
|
3404 | activate: [{ type: core.Output }],
|
3405 | deactivate: [{ type: core.Output }],
|
3406 | toggle: [{ type: core.Output }],
|
3407 | onMouseEnter: [{ type: core.HostListener, args: ['mouseenter',] }],
|
3408 | onMouseLeave: [{ type: core.HostListener, args: ['mouseleave',] }]
|
3409 | };
|
3410 |
|
3411 | var ScaleLegendComponent = (function () {
|
3412 | function ScaleLegendComponent() {
|
3413 | this.horizontal = false;
|
3414 | }
|
3415 | ScaleLegendComponent.prototype.ngOnChanges = function (changes) {
|
3416 | var gradientValues = this.gradientString(this.colors.range(), this.colors.domain());
|
3417 | var direction = this.horizontal ? 'right' : 'bottom';
|
3418 | this.gradient = "linear-gradient(to " + direction + ", " + gradientValues + ")";
|
3419 | };
|
3420 | |
3421 |
|
3422 |
|
3423 |
|
3424 |
|
3425 | ScaleLegendComponent.prototype.gradientString = function (colors, splits) {
|
3426 |
|
3427 | splits.push(1);
|
3428 | var pairs = [];
|
3429 | colors.reverse().forEach(function (c, i) {
|
3430 | pairs.push(c + " " + Math.round(splits[i] * 100) + "%");
|
3431 | });
|
3432 | return pairs.join(', ');
|
3433 | };
|
3434 | return ScaleLegendComponent;
|
3435 | }());
|
3436 | ScaleLegendComponent.decorators = [
|
3437 | { type: core.Component, args: [{
|
3438 | selector: 'ngx-charts-scale-legend',
|
3439 | template: "\n <div\n class=\"scale-legend\"\n [class.horizontal-legend]=\"horizontal\"\n [style.height.px]=\"horizontal ? undefined : height\"\n [style.width.px]=\"width\"\n >\n <div class=\"scale-legend-label\">\n <span>{{ valueRange[1].toLocaleString() }}</span>\n </div>\n <div class=\"scale-legend-wrap\" [style.background]=\"gradient\"></div>\n <div class=\"scale-legend-label\">\n <span>{{ valueRange[0].toLocaleString() }}</span>\n </div>\n </div>\n ",
|
3440 | encapsulation: core.ViewEncapsulation.None,
|
3441 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
3442 | styles: [".chart-legend{display:inline-block;padding:0;width:auto!important}.chart-legend .scale-legend{text-align:center;display:flex;flex-direction:column}.chart-legend .scale-legend-wrap{display:inline-block;flex:1;width:30px;border-radius:5px;margin:0 auto}.chart-legend .scale-legend-label{font-size:12px}.chart-legend .horizontal-legend.scale-legend{flex-direction:row}.chart-legend .horizontal-legend .scale-legend-wrap{width:auto;height:30px;margin:0 16px}\n"]
|
3443 | },] }
|
3444 | ];
|
3445 | ScaleLegendComponent.propDecorators = {
|
3446 | valueRange: [{ type: core.Input }],
|
3447 | colors: [{ type: core.Input }],
|
3448 | height: [{ type: core.Input }],
|
3449 | width: [{ type: core.Input }],
|
3450 | horizontal: [{ type: core.Input }]
|
3451 | };
|
3452 |
|
3453 | var AdvancedLegendComponent = (function () {
|
3454 | function AdvancedLegendComponent() {
|
3455 | this.label = 'Total';
|
3456 | this.animations = true;
|
3457 | this.select = new core.EventEmitter();
|
3458 | this.activate = new core.EventEmitter();
|
3459 | this.deactivate = new core.EventEmitter();
|
3460 | this.legendItems = [];
|
3461 | this.labelFormatting = function (label) { return label; };
|
3462 | this.percentageFormatting = function (percentage) { return percentage; };
|
3463 | this.defaultValueFormatting = function (value) { return value.toLocaleString(); };
|
3464 | }
|
3465 | AdvancedLegendComponent.prototype.ngOnChanges = function (changes) {
|
3466 | this.update();
|
3467 | };
|
3468 | AdvancedLegendComponent.prototype.getTotal = function () {
|
3469 | return this.data.map(function (d) { return Number(d.value); }).reduce(function (sum, d) { return sum + d; }, 0);
|
3470 | };
|
3471 | AdvancedLegendComponent.prototype.update = function () {
|
3472 | this.total = this.getTotal();
|
3473 | this.roundedTotal = this.total;
|
3474 | this.legendItems = this.getLegendItems();
|
3475 | };
|
3476 | AdvancedLegendComponent.prototype.getLegendItems = function () {
|
3477 | var _this = this;
|
3478 | return this.data.map(function (d) {
|
3479 | var label = formatLabel(d.name);
|
3480 | var value = d.value;
|
3481 | var color = _this.colors.getColor(label);
|
3482 | var percentage = _this.total > 0 ? (value / _this.total) * 100 : 0;
|
3483 | var formattedLabel = typeof _this.labelFormatting === 'function' ? _this.labelFormatting(label) : label;
|
3484 | return {
|
3485 | _value: value,
|
3486 | data: d,
|
3487 | value: value,
|
3488 | color: color,
|
3489 | label: formattedLabel,
|
3490 | displayLabel: trimLabel(formattedLabel, 20),
|
3491 | origialLabel: d.name,
|
3492 | percentage: _this.percentageFormatting ? _this.percentageFormatting(percentage) : percentage.toLocaleString()
|
3493 | };
|
3494 | });
|
3495 | };
|
3496 | AdvancedLegendComponent.prototype.trackBy = function (index, item) {
|
3497 | return item.label;
|
3498 | };
|
3499 | return AdvancedLegendComponent;
|
3500 | }());
|
3501 | AdvancedLegendComponent.decorators = [
|
3502 | { type: core.Component, args: [{
|
3503 | selector: 'ngx-charts-advanced-legend',
|
3504 | template: "\n <div class=\"advanced-pie-legend\" [style.width.px]=\"width\">\n <div\n *ngIf=\"animations\"\n class=\"total-value\"\n ngx-charts-count-up\n [countTo]=\"roundedTotal\"\n [valueFormatting]=\"valueFormatting\"\n ></div>\n <div class=\"total-value\" *ngIf=\"!animations\">\n {{ valueFormatting ? valueFormatting(roundedTotal) : defaultValueFormatting(roundedTotal) }}\n </div>\n <div class=\"total-label\">\n {{ label }}\n </div>\n <div class=\"legend-items-container\">\n <div class=\"legend-items\">\n <div\n *ngFor=\"let legendItem of legendItems; trackBy: trackBy\"\n tabindex=\"-1\"\n class=\"legend-item\"\n (mouseenter)=\"activate.emit(legendItem.data)\"\n (mouseleave)=\"deactivate.emit(legendItem.data)\"\n (click)=\"select.emit(legendItem.data)\"\n >\n <div class=\"item-color\" [style.border-left-color]=\"legendItem.color\"></div>\n <div\n *ngIf=\"animations\"\n class=\"item-value\"\n ngx-charts-count-up\n [countTo]=\"legendItem._value\"\n [valueFormatting]=\"valueFormatting\"\n ></div>\n <div *ngIf=\"!animations\" class=\"item-value\">\n {{ valueFormatting ? valueFormatting(legendItem.value) : defaultValueFormatting(legendItem.value) }}\n </div>\n <div class=\"item-label\">{{ legendItem.displayLabel }}</div>\n <div\n *ngIf=\"animations\"\n class=\"item-percent\"\n ngx-charts-count-up\n [countTo]=\"legendItem.percentage\"\n [countSuffix]=\"'%'\"\n ></div>\n <div *ngIf=\"!animations\" class=\"item-percent\">{{ legendItem.percentage.toLocaleString() }}%</div>\n </div>\n </div>\n </div>\n </div>\n ",
|
3505 | encapsulation: core.ViewEncapsulation.None,
|
3506 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
3507 | styles: [".advanced-pie-legend{float:left;position:relative;top:50%;transform:translateY(-50%)}.advanced-pie-legend .total-value{font-size:36px}.advanced-pie-legend .total-label{font-size:24px;margin-bottom:19px}.advanced-pie-legend .legend-items-container{width:100%}.advanced-pie-legend .legend-items-container .legend-items{white-space:nowrap;overflow:auto}.advanced-pie-legend .legend-items-container .legend-items .legend-item{margin-right:20px;display:inline-block;cursor:pointer}.advanced-pie-legend .legend-items-container .legend-items .legend-item:focus{outline:none}.advanced-pie-legend .legend-items-container .legend-items .legend-item:hover{color:#000;transition:.2s}.advanced-pie-legend .legend-items-container .legend-items .legend-item .item-value{font-size:24px;margin-top:-6px;margin-left:11px}.advanced-pie-legend .legend-items-container .legend-items .legend-item .item-label{font-size:14px;opacity:.7;margin-left:11px;margin-top:-6px}.advanced-pie-legend .legend-items-container .legend-items .legend-item .item-percent{font-size:24px;opacity:.7;margin-left:11px}.advanced-pie-legend .legend-items-container .legend-items .legend-item .item-color{border-left:4px solid;width:4px;height:42px;float:left;margin-right:7px}\n"]
|
3508 | },] }
|
3509 | ];
|
3510 | AdvancedLegendComponent.propDecorators = {
|
3511 | width: [{ type: core.Input }],
|
3512 | data: [{ type: core.Input }],
|
3513 | colors: [{ type: core.Input }],
|
3514 | label: [{ type: core.Input }],
|
3515 | animations: [{ type: core.Input }],
|
3516 | select: [{ type: core.Output }],
|
3517 | activate: [{ type: core.Output }],
|
3518 | deactivate: [{ type: core.Output }],
|
3519 | valueFormatting: [{ type: core.Input }],
|
3520 | labelFormatting: [{ type: core.Input }],
|
3521 | percentageFormatting: [{ type: core.Input }]
|
3522 | };
|
3523 |
|
3524 | var COMPONENTS = [
|
3525 | AreaComponent,
|
3526 | BaseChartComponent,
|
3527 | CountUpDirective,
|
3528 | TooltipArea,
|
3529 | ChartComponent,
|
3530 | LegendComponent,
|
3531 | LegendEntryComponent,
|
3532 | ScaleLegendComponent,
|
3533 | CircleComponent,
|
3534 | CircleSeriesComponent,
|
3535 | GridPanelComponent,
|
3536 | GridPanelSeriesComponent,
|
3537 | SvgLinearGradientComponent,
|
3538 | SvgRadialGradientComponent,
|
3539 | Timeline,
|
3540 | AdvancedLegendComponent
|
3541 | ];
|
3542 | var ChartCommonModule = (function () {
|
3543 | function ChartCommonModule() {
|
3544 | }
|
3545 | return ChartCommonModule;
|
3546 | }());
|
3547 | ChartCommonModule.decorators = [
|
3548 | { type: core.NgModule, args: [{
|
3549 | imports: [common.CommonModule, AxesModule, TooltipModule],
|
3550 | declarations: __spreadArray(__spreadArray([], __read(COMPONENTS)), [VisibilityObserver]),
|
3551 | exports: __spreadArray(__spreadArray([common.CommonModule, AxesModule, TooltipModule], __read(COMPONENTS)), [VisibilityObserver])
|
3552 | },] }
|
3553 | ];
|
3554 |
|
3555 | function calculateViewDimensions(_a) {
|
3556 | var width = _a.width, height = _a.height, margins = _a.margins, _b = _a.showXAxis, showXAxis = _b === void 0 ? false : _b, _c = _a.showYAxis, showYAxis = _c === void 0 ? false : _c, _d = _a.xAxisHeight, xAxisHeight = _d === void 0 ? 0 : _d, _e = _a.yAxisWidth, yAxisWidth = _e === void 0 ? 0 : _e, _f = _a.showXLabel, showXLabel = _f === void 0 ? false : _f, _g = _a.showYLabel, showYLabel = _g === void 0 ? false : _g, _h = _a.showLegend, showLegend = _h === void 0 ? false : _h, _j = _a.legendType, legendType = _j === void 0 ? exports.ScaleType.Ordinal : _j, _k = _a.legendPosition, legendPosition = _k === void 0 ? exports.LegendPosition.Right : _k, _l = _a.columns, columns = _l === void 0 ? 12 : _l;
|
3557 | var xOffset = margins[3];
|
3558 | var chartWidth = width;
|
3559 | var chartHeight = height - margins[0] - margins[2];
|
3560 | if (showLegend && legendPosition === exports.LegendPosition.Right) {
|
3561 | if (legendType === exports.ScaleType.Ordinal) {
|
3562 | columns -= 2;
|
3563 | }
|
3564 | else {
|
3565 | columns -= 1;
|
3566 | }
|
3567 | }
|
3568 | chartWidth = (chartWidth * columns) / 12;
|
3569 | chartWidth = chartWidth - margins[1] - margins[3];
|
3570 | if (showXAxis) {
|
3571 | chartHeight -= 5;
|
3572 | chartHeight -= xAxisHeight;
|
3573 | if (showXLabel) {
|
3574 |
|
3575 | var offset = 25 + 5;
|
3576 | chartHeight -= offset;
|
3577 | }
|
3578 | }
|
3579 | if (showYAxis) {
|
3580 | chartWidth -= 5;
|
3581 | chartWidth -= yAxisWidth;
|
3582 | xOffset += yAxisWidth;
|
3583 | xOffset += 10;
|
3584 | if (showYLabel) {
|
3585 |
|
3586 | var offset = 25 + 5;
|
3587 | chartWidth -= offset;
|
3588 | xOffset += offset;
|
3589 | }
|
3590 | }
|
3591 | chartWidth = Math.max(0, chartWidth);
|
3592 | chartHeight = Math.max(0, chartHeight);
|
3593 | return {
|
3594 | width: Math.floor(chartWidth),
|
3595 | height: Math.floor(chartHeight),
|
3596 | xOffset: Math.floor(xOffset)
|
3597 | };
|
3598 | }
|
3599 |
|
3600 | var colorSets = [
|
3601 | {
|
3602 | name: 'vivid',
|
3603 | selectable: true,
|
3604 | group: exports.ScaleType.Ordinal,
|
3605 | domain: [
|
3606 | '#647c8a',
|
3607 | '#3f51b5',
|
3608 | '#2196f3',
|
3609 | '#00b862',
|
3610 | '#afdf0a',
|
3611 | '#a7b61a',
|
3612 | '#f3e562',
|
3613 | '#ff9800',
|
3614 | '#ff5722',
|
3615 | '#ff4514'
|
3616 | ]
|
3617 | },
|
3618 | {
|
3619 | name: 'natural',
|
3620 | selectable: true,
|
3621 | group: exports.ScaleType.Ordinal,
|
3622 | domain: [
|
3623 | '#bf9d76',
|
3624 | '#e99450',
|
3625 | '#d89f59',
|
3626 | '#f2dfa7',
|
3627 | '#a5d7c6',
|
3628 | '#7794b1',
|
3629 | '#afafaf',
|
3630 | '#707160',
|
3631 | '#ba9383',
|
3632 | '#d9d5c3'
|
3633 | ]
|
3634 | },
|
3635 | {
|
3636 | name: 'cool',
|
3637 | selectable: true,
|
3638 | group: exports.ScaleType.Ordinal,
|
3639 | domain: [
|
3640 | '#a8385d',
|
3641 | '#7aa3e5',
|
3642 | '#a27ea8',
|
3643 | '#aae3f5',
|
3644 | '#adcded',
|
3645 | '#a95963',
|
3646 | '#8796c0',
|
3647 | '#7ed3ed',
|
3648 | '#50abcc',
|
3649 | '#ad6886'
|
3650 | ]
|
3651 | },
|
3652 | {
|
3653 | name: 'fire',
|
3654 | selectable: true,
|
3655 | group: exports.ScaleType.Ordinal,
|
3656 | domain: ['#ff3d00', '#bf360c', '#ff8f00', '#ff6f00', '#ff5722', '#e65100', '#ffca28', '#ffab00']
|
3657 | },
|
3658 | {
|
3659 | name: 'solar',
|
3660 | selectable: true,
|
3661 | group: exports.ScaleType.Linear,
|
3662 | domain: [
|
3663 | '#fff8e1',
|
3664 | '#ffecb3',
|
3665 | '#ffe082',
|
3666 | '#ffd54f',
|
3667 | '#ffca28',
|
3668 | '#ffc107',
|
3669 | '#ffb300',
|
3670 | '#ffa000',
|
3671 | '#ff8f00',
|
3672 | '#ff6f00'
|
3673 | ]
|
3674 | },
|
3675 | {
|
3676 | name: 'air',
|
3677 | selectable: true,
|
3678 | group: exports.ScaleType.Linear,
|
3679 | domain: [
|
3680 | '#e1f5fe',
|
3681 | '#b3e5fc',
|
3682 | '#81d4fa',
|
3683 | '#4fc3f7',
|
3684 | '#29b6f6',
|
3685 | '#03a9f4',
|
3686 | '#039be5',
|
3687 | '#0288d1',
|
3688 | '#0277bd',
|
3689 | '#01579b'
|
3690 | ]
|
3691 | },
|
3692 | {
|
3693 | name: 'aqua',
|
3694 | selectable: true,
|
3695 | group: exports.ScaleType.Linear,
|
3696 | domain: [
|
3697 | '#e0f7fa',
|
3698 | '#b2ebf2',
|
3699 | '#80deea',
|
3700 | '#4dd0e1',
|
3701 | '#26c6da',
|
3702 | '#00bcd4',
|
3703 | '#00acc1',
|
3704 | '#0097a7',
|
3705 | '#00838f',
|
3706 | '#006064'
|
3707 | ]
|
3708 | },
|
3709 | {
|
3710 | name: 'flame',
|
3711 | selectable: false,
|
3712 | group: exports.ScaleType.Ordinal,
|
3713 | domain: [
|
3714 | '#A10A28',
|
3715 | '#D3342D',
|
3716 | '#EF6D49',
|
3717 | '#FAAD67',
|
3718 | '#FDDE90',
|
3719 | '#DBED91',
|
3720 | '#A9D770',
|
3721 | '#6CBA67',
|
3722 | '#2C9653',
|
3723 | '#146738'
|
3724 | ]
|
3725 | },
|
3726 | {
|
3727 | name: 'ocean',
|
3728 | selectable: false,
|
3729 | group: exports.ScaleType.Ordinal,
|
3730 | domain: [
|
3731 | '#1D68FB',
|
3732 | '#33C0FC',
|
3733 | '#4AFFFE',
|
3734 | '#AFFFFF',
|
3735 | '#FFFC63',
|
3736 | '#FDBD2D',
|
3737 | '#FC8A25',
|
3738 | '#FA4F1E',
|
3739 | '#FA141B',
|
3740 | '#BA38D1'
|
3741 | ]
|
3742 | },
|
3743 | {
|
3744 | name: 'forest',
|
3745 | selectable: false,
|
3746 | group: exports.ScaleType.Ordinal,
|
3747 | domain: [
|
3748 | '#55C22D',
|
3749 | '#C1F33D',
|
3750 | '#3CC099',
|
3751 | '#AFFFFF',
|
3752 | '#8CFC9D',
|
3753 | '#76CFFA',
|
3754 | '#BA60FB',
|
3755 | '#EE6490',
|
3756 | '#C42A1C',
|
3757 | '#FC9F32'
|
3758 | ]
|
3759 | },
|
3760 | {
|
3761 | name: 'horizon',
|
3762 | selectable: false,
|
3763 | group: exports.ScaleType.Ordinal,
|
3764 | domain: [
|
3765 | '#2597FB',
|
3766 | '#65EBFD',
|
3767 | '#99FDD0',
|
3768 | '#FCEE4B',
|
3769 | '#FEFCFA',
|
3770 | '#FDD6E3',
|
3771 | '#FCB1A8',
|
3772 | '#EF6F7B',
|
3773 | '#CB96E8',
|
3774 | '#EFDEE0'
|
3775 | ]
|
3776 | },
|
3777 | {
|
3778 | name: 'neons',
|
3779 | selectable: false,
|
3780 | group: exports.ScaleType.Ordinal,
|
3781 | domain: [
|
3782 | '#FF3333',
|
3783 | '#FF33FF',
|
3784 | '#CC33FF',
|
3785 | '#0000FF',
|
3786 | '#33CCFF',
|
3787 | '#33FFFF',
|
3788 | '#33FF66',
|
3789 | '#CCFF33',
|
3790 | '#FFCC00',
|
3791 | '#FF6600'
|
3792 | ]
|
3793 | },
|
3794 | {
|
3795 | name: 'picnic',
|
3796 | selectable: false,
|
3797 | group: exports.ScaleType.Ordinal,
|
3798 | domain: [
|
3799 | '#FAC51D',
|
3800 | '#66BD6D',
|
3801 | '#FAA026',
|
3802 | '#29BB9C',
|
3803 | '#E96B56',
|
3804 | '#55ACD2',
|
3805 | '#B7332F',
|
3806 | '#2C83C9',
|
3807 | '#9166B8',
|
3808 | '#92E7E8'
|
3809 | ]
|
3810 | },
|
3811 | {
|
3812 | name: 'night',
|
3813 | selectable: false,
|
3814 | group: exports.ScaleType.Ordinal,
|
3815 | domain: [
|
3816 | '#2B1B5A',
|
3817 | '#501356',
|
3818 | '#183356',
|
3819 | '#28203F',
|
3820 | '#391B3C',
|
3821 | '#1E2B3C',
|
3822 | '#120634',
|
3823 | '#2D0432',
|
3824 | '#051932',
|
3825 | '#453080',
|
3826 | '#75267D',
|
3827 | '#2C507D',
|
3828 | '#4B3880',
|
3829 | '#752F7D',
|
3830 | '#35547D'
|
3831 | ]
|
3832 | },
|
3833 | {
|
3834 | name: 'nightLights',
|
3835 | selectable: false,
|
3836 | group: exports.ScaleType.Ordinal,
|
3837 | domain: [
|
3838 | '#4e31a5',
|
3839 | '#9c25a7',
|
3840 | '#3065ab',
|
3841 | '#57468b',
|
3842 | '#904497',
|
3843 | '#46648b',
|
3844 | '#32118d',
|
3845 | '#a00fb3',
|
3846 | '#1052a2',
|
3847 | '#6e51bd',
|
3848 | '#b63cc3',
|
3849 | '#6c97cb',
|
3850 | '#8671c1',
|
3851 | '#b455be',
|
3852 | '#7496c3'
|
3853 | ]
|
3854 | }
|
3855 | ];
|
3856 |
|
3857 | var ColorHelper = (function () {
|
3858 | function ColorHelper(scheme, type, domain, customColors) {
|
3859 | if (typeof scheme === 'string') {
|
3860 | scheme = colorSets.find(function (cs) {
|
3861 | return cs.name === scheme;
|
3862 | });
|
3863 | }
|
3864 | this.colorDomain = scheme.domain;
|
3865 | this.scaleType = type;
|
3866 | this.domain = domain;
|
3867 | this.customColors = customColors;
|
3868 | this.scale = this.generateColorScheme(scheme, type, this.domain);
|
3869 | }
|
3870 | ColorHelper.prototype.generateColorScheme = function (scheme, type, domain) {
|
3871 | if (typeof scheme === 'string') {
|
3872 | scheme = colorSets.find(function (cs) {
|
3873 | return cs.name === scheme;
|
3874 | });
|
3875 | }
|
3876 | var colorScale;
|
3877 | switch (type) {
|
3878 | case exports.ScaleType.Quantile:
|
3879 | colorScale = d3Scale.scaleQuantile()
|
3880 | .range(scheme.domain)
|
3881 | .domain(domain);
|
3882 | break;
|
3883 | case exports.ScaleType.Ordinal:
|
3884 | colorScale = d3Scale.scaleOrdinal()
|
3885 | .range(scheme.domain)
|
3886 | .domain(domain);
|
3887 | break;
|
3888 | case exports.ScaleType.Linear:
|
3889 | {
|
3890 | var colorDomain = __spreadArray([], __read(scheme.domain));
|
3891 | if (colorDomain.length === 1) {
|
3892 | colorDomain.push(colorDomain[0]);
|
3893 | this.colorDomain = colorDomain;
|
3894 | }
|
3895 | var points = d3Array.range(0, 1, 1.0 / colorDomain.length);
|
3896 | colorScale = d3Scale.scaleLinear()
|
3897 | .range(colorDomain)
|
3898 | .domain(points);
|
3899 | }
|
3900 | break;
|
3901 | default:
|
3902 | break;
|
3903 | }
|
3904 | return colorScale;
|
3905 | };
|
3906 | ColorHelper.prototype.getColor = function (value) {
|
3907 | if (value === undefined || value === null) {
|
3908 | throw new Error('Value can not be null');
|
3909 | }
|
3910 | if (this.scaleType === exports.ScaleType.Linear) {
|
3911 | var valueScale = d3Scale.scaleLinear()
|
3912 | .domain(this.domain)
|
3913 | .range([0, 1]);
|
3914 | return this.scale(valueScale(value));
|
3915 | }
|
3916 | else {
|
3917 | if (typeof this.customColors === 'function') {
|
3918 | return this.customColors(value);
|
3919 | }
|
3920 | var formattedValue_1 = value.toString();
|
3921 | var found =
|
3922 | void 0;
|
3923 | if (this.customColors && this.customColors.length > 0) {
|
3924 | found = this.customColors.find(function (mapping) {
|
3925 | return mapping.name.toLowerCase() === formattedValue_1.toLowerCase();
|
3926 | });
|
3927 | }
|
3928 | if (found) {
|
3929 | return found.value;
|
3930 | }
|
3931 | else {
|
3932 | return this.scale(value);
|
3933 | }
|
3934 | }
|
3935 | };
|
3936 | ColorHelper.prototype.getLinearGradientStops = function (value, start) {
|
3937 | var e_1, _a;
|
3938 | if (start === undefined) {
|
3939 | start = this.domain[0];
|
3940 | }
|
3941 | var valueScale = d3Scale.scaleLinear()
|
3942 | .domain(this.domain)
|
3943 | .range([0, 1]);
|
3944 | var colorValueScale = d3Scale.scaleBand().domain(this.colorDomain).range([0, 1]);
|
3945 | var endColor = this.getColor(value);
|
3946 |
|
3947 | var startVal = valueScale(start);
|
3948 | var startColor = this.getColor(start);
|
3949 | var endVal = valueScale(value);
|
3950 | var i = 1;
|
3951 | var currentVal = startVal;
|
3952 | var stops = [];
|
3953 | stops.push({
|
3954 | color: startColor,
|
3955 | offset: startVal,
|
3956 | originalOffset: startVal,
|
3957 | opacity: 1
|
3958 | });
|
3959 | while (currentVal < endVal && i < this.colorDomain.length) {
|
3960 | var color = this.colorDomain[i];
|
3961 | var offset = colorValueScale(color);
|
3962 | if (offset <= startVal) {
|
3963 | i++;
|
3964 | continue;
|
3965 | }
|
3966 | if (offset.toFixed(4) >= (endVal - colorValueScale.bandwidth()).toFixed(4)) {
|
3967 | break;
|
3968 | }
|
3969 | stops.push({
|
3970 | color: color,
|
3971 | offset: offset,
|
3972 | opacity: 1
|
3973 | });
|
3974 | currentVal = offset;
|
3975 | i++;
|
3976 | }
|
3977 | if (stops[stops.length - 1].offset < 100) {
|
3978 | stops.push({
|
3979 | color: endColor,
|
3980 | offset: endVal,
|
3981 | opacity: 1
|
3982 | });
|
3983 | }
|
3984 | if (endVal === startVal) {
|
3985 | stops[0].offset = 0;
|
3986 | stops[1].offset = 100;
|
3987 | }
|
3988 | else {
|
3989 |
|
3990 | if (stops[stops.length - 1].offset !== 100) {
|
3991 | try {
|
3992 | for (var stops_1 = __values(stops), stops_1_1 = stops_1.next(); !stops_1_1.done; stops_1_1 = stops_1.next()) {
|
3993 | var s = stops_1_1.value;
|
3994 | s.offset = ((s.offset - startVal) / (endVal - startVal)) * 100;
|
3995 | }
|
3996 | }
|
3997 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
3998 | finally {
|
3999 | try {
|
4000 | if (stops_1_1 && !stops_1_1.done && (_a = stops_1.return)) _a.call(stops_1);
|
4001 | }
|
4002 | finally { if (e_1) throw e_1.error; }
|
4003 | }
|
4004 | }
|
4005 | }
|
4006 | return stops;
|
4007 | };
|
4008 | return ColorHelper;
|
4009 | }());
|
4010 |
|
4011 | |
4012 |
|
4013 |
|
4014 |
|
4015 |
|
4016 |
|
4017 | function getUniqueXDomainValues(results) {
|
4018 | var e_1, _a, e_2, _b;
|
4019 | var valueSet = new Set();
|
4020 | try {
|
4021 | for (var results_1 = __values(results), results_1_1 = results_1.next(); !results_1_1.done; results_1_1 = results_1.next()) {
|
4022 | var result = results_1_1.value;
|
4023 | try {
|
4024 | for (var _c = (e_2 = void 0, __values(result.series)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
4025 | var d = _d.value;
|
4026 | valueSet.add(d.name);
|
4027 | }
|
4028 | }
|
4029 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
4030 | finally {
|
4031 | try {
|
4032 | if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
4033 | }
|
4034 | finally { if (e_2) throw e_2.error; }
|
4035 | }
|
4036 | }
|
4037 | }
|
4038 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
4039 | finally {
|
4040 | try {
|
4041 | if (results_1_1 && !results_1_1.done && (_a = results_1.return)) _a.call(results_1);
|
4042 | }
|
4043 | finally { if (e_1) throw e_1.error; }
|
4044 | }
|
4045 | return Array.from(valueSet);
|
4046 | }
|
4047 | |
4048 |
|
4049 |
|
4050 |
|
4051 | function getScaleType(values, checkDateType) {
|
4052 | if (checkDateType === void 0) { checkDateType = true; }
|
4053 | if (checkDateType) {
|
4054 | var allDates = values.every(function (value) { return value instanceof Date; });
|
4055 | if (allDates) {
|
4056 | return exports.ScaleType.Time;
|
4057 | }
|
4058 | }
|
4059 | var allNumbers = values.every(function (value) { return typeof value === 'number'; });
|
4060 | if (allNumbers) {
|
4061 | return exports.ScaleType.Linear;
|
4062 | }
|
4063 | return exports.ScaleType.Ordinal;
|
4064 | }
|
4065 | function getXDomainArray(values, xScaleMin, xScaleMax) {
|
4066 | var scaleType = getScaleType(values);
|
4067 | var xSet = [];
|
4068 | var domain = [];
|
4069 | if (scaleType === exports.ScaleType.Linear) {
|
4070 | values = values.map(function (v) { return Number(v); });
|
4071 | }
|
4072 | var min;
|
4073 | var max;
|
4074 | if (scaleType === exports.ScaleType.Time || scaleType === exports.ScaleType.Linear) {
|
4075 | var mappedValues = values.map(function (v) { return Number(v); });
|
4076 | min = xScaleMin ? xScaleMin : Math.min.apply(Math, __spreadArray([], __read(mappedValues)));
|
4077 | max = xScaleMax ? xScaleMax : Math.max.apply(Math, __spreadArray([], __read(mappedValues)));
|
4078 | }
|
4079 | if (scaleType === exports.ScaleType.Time) {
|
4080 | domain = [new Date(min), new Date(max)];
|
4081 | xSet = __spreadArray([], __read(values)).sort(function (a, b) {
|
4082 | var aDate = a.getTime();
|
4083 | var bDate = b.getTime();
|
4084 | if (aDate > bDate)
|
4085 | return 1;
|
4086 | if (bDate > aDate)
|
4087 | return -1;
|
4088 | return 0;
|
4089 | });
|
4090 | }
|
4091 | else if (scaleType === exports.ScaleType.Linear) {
|
4092 | domain = [min, max];
|
4093 |
|
4094 | xSet = __spreadArray([], __read(values)).sort(function (a, b) { return a - b; });
|
4095 | }
|
4096 | else {
|
4097 | domain = values;
|
4098 | xSet = values;
|
4099 | }
|
4100 | return { domain: domain, xSet: xSet, scaleType: scaleType };
|
4101 | }
|
4102 |
|
4103 | var AreaChartComponent = (function (_super) {
|
4104 | __extends(AreaChartComponent, _super);
|
4105 | function AreaChartComponent() {
|
4106 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
4107 | _this.legend = false;
|
4108 | _this.legendTitle = 'Legend';
|
4109 | _this.legendPosition = exports.LegendPosition.Right;
|
4110 | _this.xAxis = false;
|
4111 | _this.yAxis = false;
|
4112 | _this.baseValue = 'auto';
|
4113 | _this.autoScale = false;
|
4114 | _this.timeline = false;
|
4115 | _this.showGridLines = true;
|
4116 | _this.curve = d3Shape.curveLinear;
|
4117 | _this.activeEntries = [];
|
4118 | _this.trimXAxisTicks = true;
|
4119 | _this.trimYAxisTicks = true;
|
4120 | _this.rotateXAxisTicks = true;
|
4121 | _this.maxXAxisTickLength = 16;
|
4122 | _this.maxYAxisTickLength = 16;
|
4123 | _this.roundDomains = false;
|
4124 | _this.tooltipDisabled = false;
|
4125 | _this.activate = new core.EventEmitter();
|
4126 | _this.deactivate = new core.EventEmitter();
|
4127 | _this.margin = [10, 20, 10, 20];
|
4128 | _this.xAxisHeight = 0;
|
4129 | _this.yAxisWidth = 0;
|
4130 | _this.timelineHeight = 50;
|
4131 | _this.timelinePadding = 10;
|
4132 | _this.trackBy = function (index, item) {
|
4133 | return item.name;
|
4134 | };
|
4135 | return _this;
|
4136 | }
|
4137 | AreaChartComponent.prototype.update = function () {
|
4138 | _super.prototype.update.call(this);
|
4139 | this.dims = calculateViewDimensions({
|
4140 | width: this.width,
|
4141 | height: this.height,
|
4142 | margins: this.margin,
|
4143 | showXAxis: this.xAxis,
|
4144 | showYAxis: this.yAxis,
|
4145 | xAxisHeight: this.xAxisHeight,
|
4146 | yAxisWidth: this.yAxisWidth,
|
4147 | showXLabel: this.showXAxisLabel,
|
4148 | showYLabel: this.showYAxisLabel,
|
4149 | showLegend: this.legend,
|
4150 | legendType: this.schemeType,
|
4151 | legendPosition: this.legendPosition
|
4152 | });
|
4153 | if (this.timeline) {
|
4154 | this.dims.height -= this.timelineHeight + this.margin[2] + this.timelinePadding;
|
4155 | }
|
4156 | this.xDomain = this.getXDomain();
|
4157 | if (this.filteredDomain) {
|
4158 | this.xDomain = this.filteredDomain;
|
4159 | }
|
4160 | this.yDomain = this.getYDomain();
|
4161 | this.seriesDomain = this.getSeriesDomain();
|
4162 | this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
4163 | this.yScale = this.getYScale(this.yDomain, this.dims.height);
|
4164 | this.updateTimeline();
|
4165 | this.setColors();
|
4166 | this.legendOptions = this.getLegendOptions();
|
4167 | this.transform = "translate(" + this.dims.xOffset + ", " + this.margin[0] + ")";
|
4168 | this.clipPathId = 'clip' + id().toString();
|
4169 | this.clipPath = "url(#" + this.clipPathId + ")";
|
4170 | };
|
4171 | AreaChartComponent.prototype.updateTimeline = function () {
|
4172 | if (this.timeline) {
|
4173 | this.timelineWidth = this.dims.width;
|
4174 | this.timelineXDomain = this.getXDomain();
|
4175 | this.timelineXScale = this.getXScale(this.timelineXDomain, this.timelineWidth);
|
4176 | this.timelineYScale = this.getYScale(this.yDomain, this.timelineHeight);
|
4177 | this.timelineTransform = "translate(" + this.dims.xOffset + ", " + -this.margin[2] + ")";
|
4178 | }
|
4179 | };
|
4180 | AreaChartComponent.prototype.getXDomain = function () {
|
4181 | var values = getUniqueXDomainValues(this.results);
|
4182 | this.scaleType = getScaleType(values);
|
4183 | var domain = [];
|
4184 | if (this.scaleType === exports.ScaleType.Linear) {
|
4185 | values = values.map(function (v) { return Number(v); });
|
4186 | }
|
4187 | var min;
|
4188 | var max;
|
4189 | if (this.scaleType === exports.ScaleType.Time || this.scaleType === exports.ScaleType.Linear) {
|
4190 | min = this.xScaleMin ? this.xScaleMin : Math.min.apply(Math, __spreadArray([], __read(values)));
|
4191 | max = this.xScaleMax ? this.xScaleMax : Math.max.apply(Math, __spreadArray([], __read(values)));
|
4192 | }
|
4193 | if (this.scaleType === exports.ScaleType.Time) {
|
4194 | domain = [new Date(min), new Date(max)];
|
4195 | this.xSet = __spreadArray([], __read(values)).sort(function (a, b) {
|
4196 | var aDate = a.getTime();
|
4197 | var bDate = b.getTime();
|
4198 | if (aDate > bDate)
|
4199 | return 1;
|
4200 | if (bDate > aDate)
|
4201 | return -1;
|
4202 | return 0;
|
4203 | });
|
4204 | }
|
4205 | else if (this.scaleType === exports.ScaleType.Linear) {
|
4206 | domain = [min, max];
|
4207 |
|
4208 | this.xSet = __spreadArray([], __read(values)).sort(function (a, b) { return a - b; });
|
4209 | }
|
4210 | else {
|
4211 | domain = values;
|
4212 | this.xSet = values;
|
4213 | }
|
4214 | return domain;
|
4215 | };
|
4216 | AreaChartComponent.prototype.getYDomain = function () {
|
4217 | var e_1, _a, e_2, _b;
|
4218 | var domain = [];
|
4219 | try {
|
4220 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
4221 | var results = _d.value;
|
4222 | try {
|
4223 | for (var _e = (e_2 = void 0, __values(results.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
4224 | var d = _f.value;
|
4225 | if (!domain.includes(d.value)) {
|
4226 | domain.push(d.value);
|
4227 | }
|
4228 | }
|
4229 | }
|
4230 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
4231 | finally {
|
4232 | try {
|
4233 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
4234 | }
|
4235 | finally { if (e_2) throw e_2.error; }
|
4236 | }
|
4237 | }
|
4238 | }
|
4239 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
4240 | finally {
|
4241 | try {
|
4242 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
4243 | }
|
4244 | finally { if (e_1) throw e_1.error; }
|
4245 | }
|
4246 | var values = __spreadArray([], __read(domain));
|
4247 | if (!this.autoScale) {
|
4248 | values.push(0);
|
4249 | }
|
4250 | if (this.baseValue !== 'auto') {
|
4251 | values.push(this.baseValue);
|
4252 | }
|
4253 | var min = this.yScaleMin ? this.yScaleMin : Math.min.apply(Math, __spreadArray([], __read(values)));
|
4254 | var max = this.yScaleMax ? this.yScaleMax : Math.max.apply(Math, __spreadArray([], __read(values)));
|
4255 | return [min, max];
|
4256 | };
|
4257 | AreaChartComponent.prototype.getSeriesDomain = function () {
|
4258 | return this.results.map(function (d) { return d.name; });
|
4259 | };
|
4260 | AreaChartComponent.prototype.getXScale = function (domain, width) {
|
4261 | var scale;
|
4262 | if (this.scaleType === exports.ScaleType.Time) {
|
4263 | scale = d3Scale.scaleTime();
|
4264 | }
|
4265 | else if (this.scaleType === exports.ScaleType.Linear) {
|
4266 | scale = d3Scale.scaleLinear();
|
4267 | }
|
4268 | else if (this.scaleType === exports.ScaleType.Ordinal) {
|
4269 | scale = d3Scale.scalePoint().padding(0.1);
|
4270 | }
|
4271 | scale.range([0, width]).domain(domain);
|
4272 | return this.roundDomains ? scale.nice() : scale;
|
4273 | };
|
4274 | AreaChartComponent.prototype.getYScale = function (domain, height) {
|
4275 | var scale = d3Scale.scaleLinear().range([height, 0]).domain(domain);
|
4276 | return this.roundDomains ? scale.nice() : scale;
|
4277 | };
|
4278 | AreaChartComponent.prototype.getScaleType = function (values) {
|
4279 | var e_3, _a;
|
4280 | var date = true;
|
4281 | var num = true;
|
4282 | try {
|
4283 | for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) {
|
4284 | var value = values_1_1.value;
|
4285 | if (isDate(value)) {
|
4286 | date = false;
|
4287 | }
|
4288 | if (isNumber(value)) {
|
4289 | num = false;
|
4290 | }
|
4291 | }
|
4292 | }
|
4293 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
4294 | finally {
|
4295 | try {
|
4296 | if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1);
|
4297 | }
|
4298 | finally { if (e_3) throw e_3.error; }
|
4299 | }
|
4300 | if (date) {
|
4301 | return exports.ScaleType.Time;
|
4302 | }
|
4303 | if (num) {
|
4304 | return exports.ScaleType.Linear;
|
4305 | }
|
4306 | return exports.ScaleType.Ordinal;
|
4307 | };
|
4308 | AreaChartComponent.prototype.updateDomain = function (domain) {
|
4309 | this.filteredDomain = domain;
|
4310 | this.xDomain = this.filteredDomain;
|
4311 | this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
4312 | };
|
4313 | AreaChartComponent.prototype.updateHoveredVertical = function (item) {
|
4314 | this.hoveredVertical = item.value;
|
4315 | this.deactivateAll();
|
4316 | };
|
4317 | AreaChartComponent.prototype.hideCircles = function () {
|
4318 | this.hoveredVertical = null;
|
4319 | this.deactivateAll();
|
4320 | };
|
4321 | AreaChartComponent.prototype.onClick = function (data, series) {
|
4322 | if (series) {
|
4323 | data.series = series.name;
|
4324 | }
|
4325 | this.select.emit(data);
|
4326 | };
|
4327 | AreaChartComponent.prototype.setColors = function () {
|
4328 | var domain;
|
4329 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
4330 | domain = this.seriesDomain;
|
4331 | }
|
4332 | else {
|
4333 | domain = this.yDomain;
|
4334 | }
|
4335 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
4336 | };
|
4337 | AreaChartComponent.prototype.getLegendOptions = function () {
|
4338 | var opts = {
|
4339 | scaleType: this.schemeType,
|
4340 | colors: undefined,
|
4341 | domain: [],
|
4342 | title: undefined,
|
4343 | position: this.legendPosition
|
4344 | };
|
4345 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
4346 | opts.domain = this.seriesDomain;
|
4347 | opts.colors = this.colors;
|
4348 | opts.title = this.legendTitle;
|
4349 | }
|
4350 | else {
|
4351 | opts.domain = this.yDomain;
|
4352 | opts.colors = this.colors.scale;
|
4353 | }
|
4354 | return opts;
|
4355 | };
|
4356 | AreaChartComponent.prototype.updateYAxisWidth = function (_a) {
|
4357 | var width = _a.width;
|
4358 | this.yAxisWidth = width;
|
4359 | this.update();
|
4360 | };
|
4361 | AreaChartComponent.prototype.updateXAxisHeight = function (_a) {
|
4362 | var height = _a.height;
|
4363 | this.xAxisHeight = height;
|
4364 | this.update();
|
4365 | };
|
4366 | AreaChartComponent.prototype.onActivate = function (item) {
|
4367 | var idx = this.activeEntries.findIndex(function (d) {
|
4368 | return d.name === item.name && d.value === item.value;
|
4369 | });
|
4370 | if (idx > -1) {
|
4371 | return;
|
4372 | }
|
4373 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
4374 | this.activate.emit({ value: item, entries: this.activeEntries });
|
4375 | };
|
4376 | AreaChartComponent.prototype.onDeactivate = function (item) {
|
4377 | var idx = this.activeEntries.findIndex(function (d) {
|
4378 | return d.name === item.name && d.value === item.value;
|
4379 | });
|
4380 | this.activeEntries.splice(idx, 1);
|
4381 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
4382 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
4383 | };
|
4384 | AreaChartComponent.prototype.deactivateAll = function () {
|
4385 | var e_4, _a;
|
4386 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
4387 | try {
|
4388 | for (var _b = __values(this.activeEntries), _c = _b.next(); !_c.done; _c = _b.next()) {
|
4389 | var entry = _c.value;
|
4390 | this.deactivate.emit({ value: entry, entries: [] });
|
4391 | }
|
4392 | }
|
4393 | catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
4394 | finally {
|
4395 | try {
|
4396 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
4397 | }
|
4398 | finally { if (e_4) throw e_4.error; }
|
4399 | }
|
4400 | this.activeEntries = [];
|
4401 | };
|
4402 | return AreaChartComponent;
|
4403 | }(BaseChartComponent));
|
4404 | AreaChartComponent.decorators = [
|
4405 | { type: core.Component, args: [{
|
4406 | selector: 'ngx-charts-area-chart',
|
4407 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event)\"\n (legendLabelDeactivate)=\"onDeactivate($event)\"\n >\n <svg:defs>\n <svg:clipPath [attr.id]=\"clipPathId\">\n <svg:rect\n [attr.width]=\"dims.width + 10\"\n [attr.height]=\"dims.height + 10\"\n [attr.transform]=\"'translate(-5, -5)'\"\n />\n </svg:clipPath>\n </svg:defs>\n <svg:g [attr.transform]=\"transform\" class=\"area-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g [attr.clip-path]=\"clipPath\">\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\">\n <svg:g\n ngx-charts-area-series\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [baseValue]=\"baseValue\"\n [colors]=\"colors\"\n [data]=\"series\"\n [activeEntries]=\"activeEntries\"\n [scaleType]=\"scaleType\"\n [gradient]=\"gradient\"\n [curve]=\"curve\"\n [animations]=\"animations\"\n />\n </svg:g>\n\n <svg:g *ngIf=\"!tooltipDisabled\" (mouseleave)=\"hideCircles()\">\n <svg:g\n ngx-charts-tooltip-area\n [dims]=\"dims\"\n [xSet]=\"xSet\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [results]=\"results\"\n [colors]=\"colors\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"seriesTooltipTemplate\"\n (hover)=\"updateHoveredVertical($event)\"\n />\n\n <svg:g *ngFor=\"let series of results\">\n <svg:g\n ngx-charts-circle-series\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [activeEntries]=\"activeEntries\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [visibleValue]=\"hoveredVertical\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n (select)=\"onClick($event, series)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n />\n </svg:g>\n </svg:g>\n </svg:g>\n </svg:g>\n <svg:g\n ngx-charts-timeline\n *ngIf=\"timeline && scaleType != 'ordinal'\"\n [attr.transform]=\"timelineTransform\"\n [results]=\"results\"\n [view]=\"[timelineWidth, height]\"\n [height]=\"timelineHeight\"\n [scheme]=\"scheme\"\n [customColors]=\"customColors\"\n [legend]=\"legend\"\n [scaleType]=\"scaleType\"\n (onDomainChange)=\"updateDomain($event)\"\n >\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\">\n <svg:g\n ngx-charts-area-series\n [xScale]=\"timelineXScale\"\n [yScale]=\"timelineYScale\"\n [baseValue]=\"baseValue\"\n [colors]=\"colors\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [gradient]=\"gradient\"\n [curve]=\"curve\"\n [animations]=\"animations\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
4408 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
4409 | encapsulation: core.ViewEncapsulation.None,
|
4410 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
4411 | },] }
|
4412 | ];
|
4413 | AreaChartComponent.propDecorators = {
|
4414 | legend: [{ type: core.Input }],
|
4415 | legendTitle: [{ type: core.Input }],
|
4416 | legendPosition: [{ type: core.Input }],
|
4417 | xAxis: [{ type: core.Input }],
|
4418 | yAxis: [{ type: core.Input }],
|
4419 | baseValue: [{ type: core.Input }],
|
4420 | autoScale: [{ type: core.Input }],
|
4421 | showXAxisLabel: [{ type: core.Input }],
|
4422 | showYAxisLabel: [{ type: core.Input }],
|
4423 | xAxisLabel: [{ type: core.Input }],
|
4424 | yAxisLabel: [{ type: core.Input }],
|
4425 | timeline: [{ type: core.Input }],
|
4426 | gradient: [{ type: core.Input }],
|
4427 | showGridLines: [{ type: core.Input }],
|
4428 | curve: [{ type: core.Input }],
|
4429 | activeEntries: [{ type: core.Input }],
|
4430 | schemeType: [{ type: core.Input }],
|
4431 | trimXAxisTicks: [{ type: core.Input }],
|
4432 | trimYAxisTicks: [{ type: core.Input }],
|
4433 | rotateXAxisTicks: [{ type: core.Input }],
|
4434 | maxXAxisTickLength: [{ type: core.Input }],
|
4435 | maxYAxisTickLength: [{ type: core.Input }],
|
4436 | xAxisTickFormatting: [{ type: core.Input }],
|
4437 | yAxisTickFormatting: [{ type: core.Input }],
|
4438 | xAxisTicks: [{ type: core.Input }],
|
4439 | yAxisTicks: [{ type: core.Input }],
|
4440 | roundDomains: [{ type: core.Input }],
|
4441 | tooltipDisabled: [{ type: core.Input }],
|
4442 | xScaleMin: [{ type: core.Input }],
|
4443 | xScaleMax: [{ type: core.Input }],
|
4444 | yScaleMin: [{ type: core.Input }],
|
4445 | yScaleMax: [{ type: core.Input }],
|
4446 | activate: [{ type: core.Output }],
|
4447 | deactivate: [{ type: core.Output }],
|
4448 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }],
|
4449 | seriesTooltipTemplate: [{ type: core.ContentChild, args: ['seriesTooltipTemplate',] }],
|
4450 | hideCircles: [{ type: core.HostListener, args: ['mouseleave',] }]
|
4451 | };
|
4452 |
|
4453 | var AreaChartNormalizedComponent = (function (_super) {
|
4454 | __extends(AreaChartNormalizedComponent, _super);
|
4455 | function AreaChartNormalizedComponent() {
|
4456 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
4457 | _this.legend = false;
|
4458 | _this.legendTitle = 'Legend';
|
4459 | _this.legendPosition = exports.LegendPosition.Right;
|
4460 | _this.showXAxisLabel = false;
|
4461 | _this.showYAxisLabel = false;
|
4462 | _this.showGridLines = true;
|
4463 | _this.curve = d3Shape.curveLinear;
|
4464 | _this.activeEntries = [];
|
4465 | _this.trimXAxisTicks = true;
|
4466 | _this.trimYAxisTicks = true;
|
4467 | _this.rotateXAxisTicks = true;
|
4468 | _this.maxXAxisTickLength = 16;
|
4469 | _this.maxYAxisTickLength = 16;
|
4470 | _this.roundDomains = false;
|
4471 | _this.tooltipDisabled = false;
|
4472 | _this.activate = new core.EventEmitter();
|
4473 | _this.deactivate = new core.EventEmitter();
|
4474 | _this.yDomain = [0, 100];
|
4475 | _this.margin = [10, 20, 10, 20];
|
4476 | _this.xAxisHeight = 0;
|
4477 | _this.yAxisWidth = 0;
|
4478 | _this.seriesType = exports.SeriesType;
|
4479 | _this.timelineHeight = 50;
|
4480 | _this.timelinePadding = 10;
|
4481 | _this.trackBy = function (index, item) {
|
4482 | return item.name;
|
4483 | };
|
4484 | return _this;
|
4485 | }
|
4486 | AreaChartNormalizedComponent.prototype.update = function () {
|
4487 | var _this = this;
|
4488 | _super.prototype.update.call(this);
|
4489 | this.dims = calculateViewDimensions({
|
4490 | width: this.width,
|
4491 | height: this.height,
|
4492 | margins: this.margin,
|
4493 | showXAxis: this.xAxis,
|
4494 | showYAxis: this.yAxis,
|
4495 | xAxisHeight: this.xAxisHeight,
|
4496 | yAxisWidth: this.yAxisWidth,
|
4497 | showXLabel: this.showXAxisLabel,
|
4498 | showYLabel: this.showYAxisLabel,
|
4499 | showLegend: this.legend,
|
4500 | legendType: this.schemeType,
|
4501 | legendPosition: this.legendPosition
|
4502 | });
|
4503 | if (this.timeline) {
|
4504 | this.dims.height -= this.timelineHeight + this.margin[2] + this.timelinePadding;
|
4505 | }
|
4506 | this.xDomain = this.getXDomain();
|
4507 | if (this.filteredDomain) {
|
4508 | this.xDomain = this.filteredDomain;
|
4509 | }
|
4510 | this.seriesDomain = this.getSeriesDomain();
|
4511 | this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
4512 | this.yScale = this.getYScale(this.yDomain, this.dims.height);
|
4513 | var _loop_1 = function (i) {
|
4514 | var e_1, _a, e_2, _b;
|
4515 | var val = this_1.xSet[i];
|
4516 | var d0 = 0;
|
4517 | var total = 0;
|
4518 | try {
|
4519 | for (var _c = (e_1 = void 0, __values(this_1.results)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
4520 | var group = _d.value;
|
4521 | var d = group.series.find(function (item) {
|
4522 | var a = item.name;
|
4523 | var b = val;
|
4524 | if (_this.scaleType === exports.ScaleType.Time) {
|
4525 | a = a.valueOf();
|
4526 | b = b.valueOf();
|
4527 | }
|
4528 | return a === b;
|
4529 | });
|
4530 | if (d) {
|
4531 | total += d.value;
|
4532 | }
|
4533 | }
|
4534 | }
|
4535 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
4536 | finally {
|
4537 | try {
|
4538 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
4539 | }
|
4540 | finally { if (e_1) throw e_1.error; }
|
4541 | }
|
4542 | try {
|
4543 | for (var _e = (e_2 = void 0, __values(this_1.results)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
4544 | var group = _f.value;
|
4545 | var d = group.series.find(function (item) {
|
4546 | var a = item.name;
|
4547 | var b = val;
|
4548 | if (_this.scaleType === exports.ScaleType.Time) {
|
4549 | a = a.valueOf();
|
4550 | b = b.valueOf();
|
4551 | }
|
4552 | return a === b;
|
4553 | });
|
4554 | if (d) {
|
4555 | d.d0 = d0;
|
4556 | d.d1 = d0 + d.value;
|
4557 | d0 += d.value;
|
4558 | }
|
4559 | else {
|
4560 | d = {
|
4561 | name: val,
|
4562 | value: 0,
|
4563 | d0: d0,
|
4564 | d1: d0
|
4565 | };
|
4566 | group.series.push(d);
|
4567 | }
|
4568 | if (total > 0) {
|
4569 | d.d0 = (d.d0 * 100) / total;
|
4570 | d.d1 = (d.d1 * 100) / total;
|
4571 | }
|
4572 | else {
|
4573 | d.d0 = 0;
|
4574 | d.d1 = 0;
|
4575 | }
|
4576 | }
|
4577 | }
|
4578 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
4579 | finally {
|
4580 | try {
|
4581 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
4582 | }
|
4583 | finally { if (e_2) throw e_2.error; }
|
4584 | }
|
4585 | };
|
4586 | var this_1 = this;
|
4587 | for (var i = 0; i < this.xSet.length; i++) {
|
4588 | _loop_1(i);
|
4589 | }
|
4590 | this.updateTimeline();
|
4591 | this.setColors();
|
4592 | this.legendOptions = this.getLegendOptions();
|
4593 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
4594 | this.clipPathId = 'clip' + id().toString();
|
4595 | this.clipPath = "url(#" + this.clipPathId + ")";
|
4596 | };
|
4597 | AreaChartNormalizedComponent.prototype.updateTimeline = function () {
|
4598 | if (this.timeline) {
|
4599 | this.timelineWidth = this.dims.width;
|
4600 | this.timelineXDomain = this.getXDomain();
|
4601 | this.timelineXScale = this.getXScale(this.timelineXDomain, this.timelineWidth);
|
4602 | this.timelineYScale = this.getYScale(this.yDomain, this.timelineHeight);
|
4603 | this.timelineTransform = "translate(" + this.dims.xOffset + ", " + -this.margin[2] + ")";
|
4604 | }
|
4605 | };
|
4606 | AreaChartNormalizedComponent.prototype.getXDomain = function () {
|
4607 | var values = getUniqueXDomainValues(this.results);
|
4608 | this.scaleType = getScaleType(values);
|
4609 | var domain = [];
|
4610 | if (this.scaleType === exports.ScaleType.Time) {
|
4611 | var min = Math.min.apply(Math, __spreadArray([], __read(values)));
|
4612 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
4613 | domain = [new Date(min), new Date(max)];
|
4614 | this.xSet = __spreadArray([], __read(values)).sort(function (a, b) {
|
4615 | var aDate = a.getTime();
|
4616 | var bDate = b.getTime();
|
4617 | if (aDate > bDate)
|
4618 | return 1;
|
4619 | if (bDate > aDate)
|
4620 | return -1;
|
4621 | return 0;
|
4622 | });
|
4623 | }
|
4624 | else if (this.scaleType === exports.ScaleType.Linear) {
|
4625 | values = values.map(function (v) { return Number(v); });
|
4626 | var min = Math.min.apply(Math, __spreadArray([], __read(values)));
|
4627 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
4628 | domain = [min, max];
|
4629 |
|
4630 | this.xSet = __spreadArray([], __read(values)).sort(function (a, b) { return a - b; });
|
4631 | }
|
4632 | else {
|
4633 | domain = values;
|
4634 | this.xSet = values;
|
4635 | }
|
4636 | return domain;
|
4637 | };
|
4638 | AreaChartNormalizedComponent.prototype.getSeriesDomain = function () {
|
4639 | return this.results.map(function (d) { return d.name; });
|
4640 | };
|
4641 | AreaChartNormalizedComponent.prototype.getXScale = function (domain, width) {
|
4642 | var scale;
|
4643 | if (this.scaleType === exports.ScaleType.Time) {
|
4644 | scale = d3Scale.scaleTime();
|
4645 | }
|
4646 | else if (this.scaleType === exports.ScaleType.Linear) {
|
4647 | scale = d3Scale.scaleLinear();
|
4648 | }
|
4649 | else if (this.scaleType === exports.ScaleType.Ordinal) {
|
4650 | scale = d3Scale.scalePoint().padding(0.1);
|
4651 | }
|
4652 | scale.range([0, width]).domain(domain);
|
4653 | return this.roundDomains ? scale.nice() : scale;
|
4654 | };
|
4655 | AreaChartNormalizedComponent.prototype.getYScale = function (domain, height) {
|
4656 | var scale = d3Scale.scaleLinear().range([height, 0]).domain(domain);
|
4657 | return this.roundDomains ? scale.nice() : scale;
|
4658 | };
|
4659 | AreaChartNormalizedComponent.prototype.updateDomain = function (domain) {
|
4660 | this.filteredDomain = domain;
|
4661 | this.xDomain = this.filteredDomain;
|
4662 | this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
4663 | };
|
4664 | AreaChartNormalizedComponent.prototype.updateHoveredVertical = function (item) {
|
4665 | this.hoveredVertical = item.value;
|
4666 | this.deactivateAll();
|
4667 | };
|
4668 | AreaChartNormalizedComponent.prototype.hideCircles = function () {
|
4669 | this.hoveredVertical = null;
|
4670 | this.deactivateAll();
|
4671 | };
|
4672 | AreaChartNormalizedComponent.prototype.onClick = function (data, series) {
|
4673 | if (series) {
|
4674 | data.series = series.name;
|
4675 | }
|
4676 | this.select.emit(data);
|
4677 | };
|
4678 | AreaChartNormalizedComponent.prototype.setColors = function () {
|
4679 | var domain;
|
4680 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
4681 | domain = this.seriesDomain;
|
4682 | }
|
4683 | else {
|
4684 | domain = this.yDomain;
|
4685 | }
|
4686 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
4687 | };
|
4688 | AreaChartNormalizedComponent.prototype.getLegendOptions = function () {
|
4689 | var opts = {
|
4690 | scaleType: this.schemeType,
|
4691 | colors: undefined,
|
4692 | domain: [],
|
4693 | title: undefined,
|
4694 | position: this.legendPosition
|
4695 | };
|
4696 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
4697 | opts.domain = this.seriesDomain;
|
4698 | opts.colors = this.colors;
|
4699 | opts.title = this.legendTitle;
|
4700 | }
|
4701 | else {
|
4702 | opts.domain = this.yDomain;
|
4703 | opts.colors = this.colors.scale;
|
4704 | }
|
4705 | return opts;
|
4706 | };
|
4707 | AreaChartNormalizedComponent.prototype.updateYAxisWidth = function (_a) {
|
4708 | var width = _a.width;
|
4709 | this.yAxisWidth = width;
|
4710 | this.update();
|
4711 | };
|
4712 | AreaChartNormalizedComponent.prototype.updateXAxisHeight = function (_a) {
|
4713 | var height = _a.height;
|
4714 | this.xAxisHeight = height;
|
4715 | this.update();
|
4716 | };
|
4717 | AreaChartNormalizedComponent.prototype.onActivate = function (item) {
|
4718 | var idx = this.activeEntries.findIndex(function (d) {
|
4719 | return d.name === item.name && d.value === item.value;
|
4720 | });
|
4721 | if (idx > -1) {
|
4722 | return;
|
4723 | }
|
4724 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
4725 | this.activate.emit({ value: item, entries: this.activeEntries });
|
4726 | };
|
4727 | AreaChartNormalizedComponent.prototype.onDeactivate = function (item) {
|
4728 | var idx = this.activeEntries.findIndex(function (d) {
|
4729 | return d.name === item.name && d.value === item.value;
|
4730 | });
|
4731 | this.activeEntries.splice(idx, 1);
|
4732 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
4733 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
4734 | };
|
4735 | AreaChartNormalizedComponent.prototype.deactivateAll = function () {
|
4736 | var e_3, _a;
|
4737 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
4738 | try {
|
4739 | for (var _b = __values(this.activeEntries), _c = _b.next(); !_c.done; _c = _b.next()) {
|
4740 | var entry = _c.value;
|
4741 | this.deactivate.emit({ value: entry, entries: [] });
|
4742 | }
|
4743 | }
|
4744 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
4745 | finally {
|
4746 | try {
|
4747 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
4748 | }
|
4749 | finally { if (e_3) throw e_3.error; }
|
4750 | }
|
4751 | this.activeEntries = [];
|
4752 | };
|
4753 | return AreaChartNormalizedComponent;
|
4754 | }(BaseChartComponent));
|
4755 | AreaChartNormalizedComponent.decorators = [
|
4756 | { type: core.Component, args: [{
|
4757 | selector: 'ngx-charts-area-chart-normalized',
|
4758 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event)\"\n (legendLabelDeactivate)=\"onDeactivate($event)\"\n >\n <svg:defs>\n <svg:clipPath [attr.id]=\"clipPathId\">\n <svg:rect\n [attr.width]=\"dims.width + 10\"\n [attr.height]=\"dims.height + 10\"\n [attr.transform]=\"'translate(-5, -5)'\"\n />\n </svg:clipPath>\n </svg:defs>\n <svg:g [attr.transform]=\"transform\" class=\"area-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g [attr.clip-path]=\"clipPath\">\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\">\n <svg:g\n ngx-charts-area-series\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [activeEntries]=\"activeEntries\"\n [gradient]=\"gradient\"\n [normalized]=\"true\"\n [curve]=\"curve\"\n [animations]=\"animations\"\n />\n </svg:g>\n\n <svg:g *ngIf=\"!tooltipDisabled\" (mouseleave)=\"hideCircles()\">\n <svg:g\n ngx-charts-tooltip-area\n [dims]=\"dims\"\n [xSet]=\"xSet\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [results]=\"results\"\n [colors]=\"colors\"\n [showPercentage]=\"true\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"seriesTooltipTemplate\"\n (hover)=\"updateHoveredVertical($event)\"\n />\n\n <svg:g *ngFor=\"let series of results\">\n <svg:g\n ngx-charts-circle-series\n [type]=\"seriesType.Stacked\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [activeEntries]=\"activeEntries\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [visibleValue]=\"hoveredVertical\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n (select)=\"onClick($event, series)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n />\n </svg:g>\n </svg:g>\n </svg:g>\n </svg:g>\n <svg:g\n ngx-charts-timeline\n *ngIf=\"timeline && scaleType != 'ordinal'\"\n [attr.transform]=\"timelineTransform\"\n [results]=\"results\"\n [view]=\"[timelineWidth, height]\"\n [height]=\"timelineHeight\"\n [scheme]=\"scheme\"\n [customColors]=\"customColors\"\n [legend]=\"legend\"\n [scaleType]=\"scaleType\"\n (onDomainChange)=\"updateDomain($event)\"\n >\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\">\n <svg:g\n ngx-charts-area-series\n [xScale]=\"timelineXScale\"\n [yScale]=\"timelineYScale\"\n [colors]=\"colors\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [gradient]=\"gradient\"\n [normalized]=\"true\"\n [curve]=\"curve\"\n [animations]=\"animations\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
4759 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
4760 | encapsulation: core.ViewEncapsulation.None,
|
4761 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
4762 | },] }
|
4763 | ];
|
4764 | AreaChartNormalizedComponent.propDecorators = {
|
4765 | legend: [{ type: core.Input }],
|
4766 | legendTitle: [{ type: core.Input }],
|
4767 | legendPosition: [{ type: core.Input }],
|
4768 | xAxis: [{ type: core.Input }],
|
4769 | yAxis: [{ type: core.Input }],
|
4770 | showXAxisLabel: [{ type: core.Input }],
|
4771 | showYAxisLabel: [{ type: core.Input }],
|
4772 | xAxisLabel: [{ type: core.Input }],
|
4773 | yAxisLabel: [{ type: core.Input }],
|
4774 | timeline: [{ type: core.Input }],
|
4775 | gradient: [{ type: core.Input }],
|
4776 | showGridLines: [{ type: core.Input }],
|
4777 | curve: [{ type: core.Input }],
|
4778 | activeEntries: [{ type: core.Input }],
|
4779 | schemeType: [{ type: core.Input }],
|
4780 | trimXAxisTicks: [{ type: core.Input }],
|
4781 | trimYAxisTicks: [{ type: core.Input }],
|
4782 | rotateXAxisTicks: [{ type: core.Input }],
|
4783 | maxXAxisTickLength: [{ type: core.Input }],
|
4784 | maxYAxisTickLength: [{ type: core.Input }],
|
4785 | xAxisTickFormatting: [{ type: core.Input }],
|
4786 | yAxisTickFormatting: [{ type: core.Input }],
|
4787 | xAxisTicks: [{ type: core.Input }],
|
4788 | yAxisTicks: [{ type: core.Input }],
|
4789 | roundDomains: [{ type: core.Input }],
|
4790 | tooltipDisabled: [{ type: core.Input }],
|
4791 | activate: [{ type: core.Output }],
|
4792 | deactivate: [{ type: core.Output }],
|
4793 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }],
|
4794 | seriesTooltipTemplate: [{ type: core.ContentChild, args: ['seriesTooltipTemplate',] }],
|
4795 | hideCircles: [{ type: core.HostListener, args: ['mouseleave',] }]
|
4796 | };
|
4797 |
|
4798 | var AreaChartStackedComponent = (function (_super) {
|
4799 | __extends(AreaChartStackedComponent, _super);
|
4800 | function AreaChartStackedComponent() {
|
4801 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
4802 | _this.legend = false;
|
4803 | _this.legendTitle = 'Legend';
|
4804 | _this.legendPosition = exports.LegendPosition.Right;
|
4805 | _this.xAxis = false;
|
4806 | _this.yAxis = false;
|
4807 | _this.timeline = false;
|
4808 | _this.showGridLines = true;
|
4809 | _this.curve = d3Shape.curveLinear;
|
4810 | _this.activeEntries = [];
|
4811 | _this.trimXAxisTicks = true;
|
4812 | _this.trimYAxisTicks = true;
|
4813 | _this.rotateXAxisTicks = true;
|
4814 | _this.maxXAxisTickLength = 16;
|
4815 | _this.maxYAxisTickLength = 16;
|
4816 | _this.roundDomains = false;
|
4817 | _this.tooltipDisabled = false;
|
4818 | _this.activate = new core.EventEmitter();
|
4819 | _this.deactivate = new core.EventEmitter();
|
4820 | _this.margin = [10, 20, 10, 20];
|
4821 | _this.xAxisHeight = 0;
|
4822 | _this.yAxisWidth = 0;
|
4823 | _this.timelineHeight = 50;
|
4824 | _this.timelinePadding = 10;
|
4825 | _this.seriesType = exports.SeriesType;
|
4826 | return _this;
|
4827 | }
|
4828 | AreaChartStackedComponent.prototype.update = function () {
|
4829 | var _this = this;
|
4830 | _super.prototype.update.call(this);
|
4831 | this.dims = calculateViewDimensions({
|
4832 | width: this.width,
|
4833 | height: this.height,
|
4834 | margins: this.margin,
|
4835 | showXAxis: this.xAxis,
|
4836 | showYAxis: this.yAxis,
|
4837 | xAxisHeight: this.xAxisHeight,
|
4838 | yAxisWidth: this.yAxisWidth,
|
4839 | showXLabel: this.showXAxisLabel,
|
4840 | showYLabel: this.showYAxisLabel,
|
4841 | showLegend: this.legend,
|
4842 | legendType: this.schemeType,
|
4843 | legendPosition: this.legendPosition
|
4844 | });
|
4845 | if (this.timeline) {
|
4846 | this.dims.height -= this.timelineHeight + this.margin[2] + this.timelinePadding;
|
4847 | }
|
4848 | this.xDomain = this.getXDomain();
|
4849 | if (this.filteredDomain) {
|
4850 | this.xDomain = this.filteredDomain;
|
4851 | }
|
4852 | this.yDomain = this.getYDomain();
|
4853 | this.seriesDomain = this.getSeriesDomain();
|
4854 | this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
4855 | this.yScale = this.getYScale(this.yDomain, this.dims.height);
|
4856 | var _loop_1 = function (i) {
|
4857 | var e_1, _a;
|
4858 | var val = this_1.xSet[i];
|
4859 | var d0 = 0;
|
4860 | try {
|
4861 | for (var _b = (e_1 = void 0, __values(this_1.results)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
4862 | var group = _c.value;
|
4863 | var d = group.series.find(function (item) {
|
4864 | var a = item.name;
|
4865 | var b = val;
|
4866 | if (_this.scaleType === exports.ScaleType.Time) {
|
4867 | a = a.valueOf();
|
4868 | b = b.valueOf();
|
4869 | }
|
4870 | return a === b;
|
4871 | });
|
4872 | if (d) {
|
4873 | d.d0 = d0;
|
4874 | d.d1 = d0 + d.value;
|
4875 | d0 += d.value;
|
4876 | }
|
4877 | else {
|
4878 | d = {
|
4879 | name: val,
|
4880 | value: 0,
|
4881 | d0: d0,
|
4882 | d1: d0
|
4883 | };
|
4884 | group.series.push(d);
|
4885 | }
|
4886 | }
|
4887 | }
|
4888 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
4889 | finally {
|
4890 | try {
|
4891 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
4892 | }
|
4893 | finally { if (e_1) throw e_1.error; }
|
4894 | }
|
4895 | };
|
4896 | var this_1 = this;
|
4897 | for (var i = 0; i < this.xSet.length; i++) {
|
4898 | _loop_1(i);
|
4899 | }
|
4900 | this.updateTimeline();
|
4901 | this.setColors();
|
4902 | this.legendOptions = this.getLegendOptions();
|
4903 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
4904 | this.clipPathId = 'clip' + id().toString();
|
4905 | this.clipPath = "url(#" + this.clipPathId + ")";
|
4906 | };
|
4907 | AreaChartStackedComponent.prototype.updateTimeline = function () {
|
4908 | if (this.timeline) {
|
4909 | this.timelineWidth = this.dims.width;
|
4910 | this.timelineXDomain = this.getXDomain();
|
4911 | this.timelineXScale = this.getXScale(this.timelineXDomain, this.timelineWidth);
|
4912 | this.timelineYScale = this.getYScale(this.yDomain, this.timelineHeight);
|
4913 | this.timelineTransform = "translate(" + this.dims.xOffset + ", " + -this.margin[2] + ")";
|
4914 | }
|
4915 | };
|
4916 | AreaChartStackedComponent.prototype.getXDomain = function () {
|
4917 | var values = getUniqueXDomainValues(this.results);
|
4918 | this.scaleType = getScaleType(values);
|
4919 | var domain = [];
|
4920 | if (this.scaleType === exports.ScaleType.Linear) {
|
4921 | values = values.map(function (v) { return Number(v); });
|
4922 | }
|
4923 | var min;
|
4924 | var max;
|
4925 | if (this.scaleType === exports.ScaleType.Time || this.scaleType === exports.ScaleType.Linear) {
|
4926 | min = this.xScaleMin ? this.xScaleMin : Math.min.apply(Math, __spreadArray([], __read(values)));
|
4927 | max = this.xScaleMax ? this.xScaleMax : Math.max.apply(Math, __spreadArray([], __read(values)));
|
4928 | }
|
4929 | if (this.scaleType === exports.ScaleType.Time) {
|
4930 | domain = [new Date(min), new Date(max)];
|
4931 | this.xSet = __spreadArray([], __read(values)).sort(function (a, b) {
|
4932 | var aDate = a.getTime();
|
4933 | var bDate = b.getTime();
|
4934 | if (aDate > bDate)
|
4935 | return 1;
|
4936 | if (bDate > aDate)
|
4937 | return -1;
|
4938 | return 0;
|
4939 | });
|
4940 | }
|
4941 | else if (this.scaleType === exports.ScaleType.Linear) {
|
4942 | domain = [min, max];
|
4943 |
|
4944 | this.xSet = __spreadArray([], __read(values)).sort(function (a, b) { return a - b; });
|
4945 | }
|
4946 | else {
|
4947 | domain = values;
|
4948 | this.xSet = values;
|
4949 | }
|
4950 | return domain;
|
4951 | };
|
4952 | AreaChartStackedComponent.prototype.getYDomain = function () {
|
4953 | var _this = this;
|
4954 | var domain = [];
|
4955 | var _loop_2 = function (i) {
|
4956 | var e_2, _a;
|
4957 | var val = this_2.xSet[i];
|
4958 | var sum = 0;
|
4959 | try {
|
4960 | for (var _b = (e_2 = void 0, __values(this_2.results)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
4961 | var group = _c.value;
|
4962 | var d = group.series.find(function (item) {
|
4963 | var a = item.name;
|
4964 | var b = val;
|
4965 | if (_this.scaleType === exports.ScaleType.Time) {
|
4966 | a = a.valueOf();
|
4967 | b = b.valueOf();
|
4968 | }
|
4969 | return a === b;
|
4970 | });
|
4971 | if (d) {
|
4972 | sum += d.value;
|
4973 | }
|
4974 | }
|
4975 | }
|
4976 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
4977 | finally {
|
4978 | try {
|
4979 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
4980 | }
|
4981 | finally { if (e_2) throw e_2.error; }
|
4982 | }
|
4983 | domain.push(sum);
|
4984 | };
|
4985 | var this_2 = this;
|
4986 | for (var i = 0; i < this.xSet.length; i++) {
|
4987 | _loop_2(i);
|
4988 | }
|
4989 | var min = this.yScaleMin ? this.yScaleMin : Math.min.apply(Math, __spreadArray([0], __read(domain)));
|
4990 | var max = this.yScaleMax ? this.yScaleMax : Math.max.apply(Math, __spreadArray([], __read(domain)));
|
4991 | return [min, max];
|
4992 | };
|
4993 | AreaChartStackedComponent.prototype.getSeriesDomain = function () {
|
4994 | return this.results.map(function (d) { return d.name; });
|
4995 | };
|
4996 | AreaChartStackedComponent.prototype.getXScale = function (domain, width) {
|
4997 | var scale;
|
4998 | if (this.scaleType === exports.ScaleType.Time) {
|
4999 | scale = d3Scale.scaleTime();
|
5000 | }
|
5001 | else if (this.scaleType === exports.ScaleType.Linear) {
|
5002 | scale = d3Scale.scaleLinear();
|
5003 | }
|
5004 | else if (this.scaleType === exports.ScaleType.Ordinal) {
|
5005 | scale = d3Scale.scalePoint().padding(0.1);
|
5006 | }
|
5007 | scale.range([0, width]).domain(domain);
|
5008 | return this.roundDomains ? scale.nice() : scale;
|
5009 | };
|
5010 | AreaChartStackedComponent.prototype.getYScale = function (domain, height) {
|
5011 | var scale = d3Scale.scaleLinear().range([height, 0]).domain(domain);
|
5012 | return this.roundDomains ? scale.nice() : scale;
|
5013 | };
|
5014 | AreaChartStackedComponent.prototype.updateDomain = function (domain) {
|
5015 | this.filteredDomain = domain;
|
5016 | this.xDomain = this.filteredDomain;
|
5017 | this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
5018 | };
|
5019 | AreaChartStackedComponent.prototype.updateHoveredVertical = function (item) {
|
5020 | this.hoveredVertical = item.value;
|
5021 | this.deactivateAll();
|
5022 | };
|
5023 | AreaChartStackedComponent.prototype.hideCircles = function () {
|
5024 | this.hoveredVertical = null;
|
5025 | this.deactivateAll();
|
5026 | };
|
5027 | AreaChartStackedComponent.prototype.onClick = function (data, series) {
|
5028 | if (series) {
|
5029 | data.series = series.name;
|
5030 | }
|
5031 | this.select.emit(data);
|
5032 | };
|
5033 | AreaChartStackedComponent.prototype.trackBy = function (index, item) {
|
5034 | return "" + item.name;
|
5035 | };
|
5036 | AreaChartStackedComponent.prototype.setColors = function () {
|
5037 | var domain;
|
5038 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
5039 | domain = this.seriesDomain;
|
5040 | }
|
5041 | else {
|
5042 | domain = this.yDomain;
|
5043 | }
|
5044 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
5045 | };
|
5046 | AreaChartStackedComponent.prototype.getLegendOptions = function () {
|
5047 | var opts = {
|
5048 | scaleType: this.schemeType,
|
5049 | colors: undefined,
|
5050 | domain: [],
|
5051 | title: undefined,
|
5052 | position: this.legendPosition
|
5053 | };
|
5054 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
5055 | opts.domain = this.seriesDomain;
|
5056 | opts.colors = this.colors;
|
5057 | opts.title = this.legendTitle;
|
5058 | }
|
5059 | else {
|
5060 | opts.domain = this.yDomain;
|
5061 | opts.colors = this.colors.scale;
|
5062 | }
|
5063 | return opts;
|
5064 | };
|
5065 | AreaChartStackedComponent.prototype.updateYAxisWidth = function (_a) {
|
5066 | var width = _a.width;
|
5067 | this.yAxisWidth = width;
|
5068 | this.update();
|
5069 | };
|
5070 | AreaChartStackedComponent.prototype.updateXAxisHeight = function (_a) {
|
5071 | var height = _a.height;
|
5072 | this.xAxisHeight = height;
|
5073 | this.update();
|
5074 | };
|
5075 | AreaChartStackedComponent.prototype.onActivate = function (item) {
|
5076 | var idx = this.activeEntries.findIndex(function (d) {
|
5077 | return d.name === item.name && d.value === item.value;
|
5078 | });
|
5079 | if (idx > -1) {
|
5080 | return;
|
5081 | }
|
5082 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
5083 | this.activate.emit({ value: item, entries: this.activeEntries });
|
5084 | };
|
5085 | AreaChartStackedComponent.prototype.onDeactivate = function (item) {
|
5086 | var idx = this.activeEntries.findIndex(function (d) {
|
5087 | return d.name === item.name && d.value === item.value;
|
5088 | });
|
5089 | this.activeEntries.splice(idx, 1);
|
5090 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
5091 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
5092 | };
|
5093 | AreaChartStackedComponent.prototype.deactivateAll = function () {
|
5094 | var e_3, _a;
|
5095 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
5096 | try {
|
5097 | for (var _b = __values(this.activeEntries), _c = _b.next(); !_c.done; _c = _b.next()) {
|
5098 | var entry = _c.value;
|
5099 | this.deactivate.emit({ value: entry, entries: [] });
|
5100 | }
|
5101 | }
|
5102 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
5103 | finally {
|
5104 | try {
|
5105 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
5106 | }
|
5107 | finally { if (e_3) throw e_3.error; }
|
5108 | }
|
5109 | this.activeEntries = [];
|
5110 | };
|
5111 | return AreaChartStackedComponent;
|
5112 | }(BaseChartComponent));
|
5113 | AreaChartStackedComponent.decorators = [
|
5114 | { type: core.Component, args: [{
|
5115 | selector: 'ngx-charts-area-chart-stacked',
|
5116 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event)\"\n (legendLabelDeactivate)=\"onDeactivate($event)\"\n >\n <svg:defs>\n <svg:clipPath [attr.id]=\"clipPathId\">\n <svg:rect\n [attr.width]=\"dims.width + 10\"\n [attr.height]=\"dims.height + 10\"\n [attr.transform]=\"'translate(-5, -5)'\"\n />\n </svg:clipPath>\n </svg:defs>\n <svg:g [attr.transform]=\"transform\" class=\"area-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g [attr.clip-path]=\"clipPath\">\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\">\n <svg:g\n ngx-charts-area-series\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [gradient]=\"gradient\"\n [activeEntries]=\"activeEntries\"\n [stacked]=\"true\"\n [curve]=\"curve\"\n [animations]=\"animations\"\n />\n </svg:g>\n\n <svg:g *ngIf=\"!tooltipDisabled\" (mouseleave)=\"hideCircles()\">\n <svg:g\n ngx-charts-tooltip-area\n [dims]=\"dims\"\n [xSet]=\"xSet\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [results]=\"results\"\n [colors]=\"colors\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"seriesTooltipTemplate\"\n (hover)=\"updateHoveredVertical($event)\"\n />\n\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\">\n <svg:g\n ngx-charts-circle-series\n [type]=\"seriesType.Stacked\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [activeEntries]=\"activeEntries\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [visibleValue]=\"hoveredVertical\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n (select)=\"onClick($event, series)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n />\n </svg:g>\n </svg:g>\n </svg:g>\n </svg:g>\n <svg:g\n ngx-charts-timeline\n *ngIf=\"timeline && scaleType != 'ordinal'\"\n [attr.transform]=\"timelineTransform\"\n [results]=\"results\"\n [view]=\"[timelineWidth, height]\"\n [height]=\"timelineHeight\"\n [scheme]=\"scheme\"\n [customColors]=\"customColors\"\n [legend]=\"legend\"\n [scaleType]=\"scaleType\"\n (onDomainChange)=\"updateDomain($event)\"\n >\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\">\n <svg:g\n ngx-charts-area-series\n [xScale]=\"timelineXScale\"\n [yScale]=\"timelineYScale\"\n [colors]=\"colors\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [gradient]=\"gradient\"\n [stacked]=\"true\"\n [curve]=\"curve\"\n [animations]=\"animations\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
5117 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
5118 | encapsulation: core.ViewEncapsulation.None,
|
5119 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
5120 | },] }
|
5121 | ];
|
5122 | AreaChartStackedComponent.propDecorators = {
|
5123 | legend: [{ type: core.Input }],
|
5124 | legendTitle: [{ type: core.Input }],
|
5125 | legendPosition: [{ type: core.Input }],
|
5126 | xAxis: [{ type: core.Input }],
|
5127 | yAxis: [{ type: core.Input }],
|
5128 | showXAxisLabel: [{ type: core.Input }],
|
5129 | showYAxisLabel: [{ type: core.Input }],
|
5130 | xAxisLabel: [{ type: core.Input }],
|
5131 | yAxisLabel: [{ type: core.Input }],
|
5132 | timeline: [{ type: core.Input }],
|
5133 | gradient: [{ type: core.Input }],
|
5134 | showGridLines: [{ type: core.Input }],
|
5135 | curve: [{ type: core.Input }],
|
5136 | activeEntries: [{ type: core.Input }],
|
5137 | schemeType: [{ type: core.Input }],
|
5138 | trimXAxisTicks: [{ type: core.Input }],
|
5139 | trimYAxisTicks: [{ type: core.Input }],
|
5140 | rotateXAxisTicks: [{ type: core.Input }],
|
5141 | maxXAxisTickLength: [{ type: core.Input }],
|
5142 | maxYAxisTickLength: [{ type: core.Input }],
|
5143 | xAxisTickFormatting: [{ type: core.Input }],
|
5144 | yAxisTickFormatting: [{ type: core.Input }],
|
5145 | xAxisTicks: [{ type: core.Input }],
|
5146 | yAxisTicks: [{ type: core.Input }],
|
5147 | roundDomains: [{ type: core.Input }],
|
5148 | tooltipDisabled: [{ type: core.Input }],
|
5149 | xScaleMin: [{ type: core.Input }],
|
5150 | xScaleMax: [{ type: core.Input }],
|
5151 | yScaleMin: [{ type: core.Input }],
|
5152 | yScaleMax: [{ type: core.Input }],
|
5153 | activate: [{ type: core.Output }],
|
5154 | deactivate: [{ type: core.Output }],
|
5155 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }],
|
5156 | seriesTooltipTemplate: [{ type: core.ContentChild, args: ['seriesTooltipTemplate',] }],
|
5157 | hideCircles: [{ type: core.HostListener, args: ['mouseleave',] }]
|
5158 | };
|
5159 |
|
5160 | function sortLinear(data, property, direction) {
|
5161 | if (direction === void 0) { direction = 'asc'; }
|
5162 | return data.sort(function (a, b) {
|
5163 | if (direction === 'asc') {
|
5164 | return a[property] - b[property];
|
5165 | }
|
5166 | else {
|
5167 | return b[property] - a[property];
|
5168 | }
|
5169 | });
|
5170 | }
|
5171 | function sortByDomain(data, property, direction, domain) {
|
5172 | if (direction === void 0) { direction = 'asc'; }
|
5173 | return data.sort(function (a, b) {
|
5174 | var aVal = a[property];
|
5175 | var bVal = b[property];
|
5176 | var aIdx = domain.indexOf(aVal);
|
5177 | var bIdx = domain.indexOf(bVal);
|
5178 | if (direction === 'asc') {
|
5179 | return aIdx - bIdx;
|
5180 | }
|
5181 | else {
|
5182 | return bIdx - aIdx;
|
5183 | }
|
5184 | });
|
5185 | }
|
5186 | function sortByTime(data, property, direction) {
|
5187 | if (direction === void 0) { direction = 'asc'; }
|
5188 | return data.sort(function (a, b) {
|
5189 | var aDate = a[property].getTime();
|
5190 | var bDate = b[property].getTime();
|
5191 | if (direction === 'asc') {
|
5192 | if (aDate > bDate)
|
5193 | return 1;
|
5194 | if (bDate > aDate)
|
5195 | return -1;
|
5196 | return 0;
|
5197 | }
|
5198 | else {
|
5199 | if (aDate > bDate)
|
5200 | return -1;
|
5201 | if (bDate > aDate)
|
5202 | return 1;
|
5203 | return 0;
|
5204 | }
|
5205 | });
|
5206 | }
|
5207 |
|
5208 | var AreaSeriesComponent = (function () {
|
5209 | function AreaSeriesComponent() {
|
5210 | this.baseValue = 'auto';
|
5211 | this.stacked = false;
|
5212 | this.normalized = false;
|
5213 | this.animations = true;
|
5214 | this.select = new core.EventEmitter();
|
5215 | }
|
5216 | AreaSeriesComponent.prototype.ngOnChanges = function (changes) {
|
5217 | this.update();
|
5218 | };
|
5219 | AreaSeriesComponent.prototype.update = function () {
|
5220 | var _this = this;
|
5221 | this.updateGradient();
|
5222 | var currentArea;
|
5223 | var startingArea;
|
5224 | var xProperty = function (d) {
|
5225 | var label = d.name;
|
5226 | return _this.xScale(label);
|
5227 | };
|
5228 | if (this.stacked || this.normalized) {
|
5229 | currentArea = d3Shape.area()
|
5230 | .x(xProperty)
|
5231 | .y0(function (d, i) { return _this.yScale(d.d0); })
|
5232 | .y1(function (d, i) { return _this.yScale(d.d1); });
|
5233 | startingArea = d3Shape.area()
|
5234 | .x(xProperty)
|
5235 | .y0(function (d) { return _this.yScale.range()[0]; })
|
5236 | .y1(function (d) { return _this.yScale.range()[0]; });
|
5237 | }
|
5238 | else {
|
5239 | currentArea = d3Shape.area()
|
5240 | .x(xProperty)
|
5241 | .y0(function () { return (_this.baseValue === 'auto' ? _this.yScale.range()[0] : _this.yScale(_this.baseValue)); })
|
5242 | .y1(function (d) { return _this.yScale(d.value); });
|
5243 | startingArea = d3Shape.area()
|
5244 | .x(xProperty)
|
5245 | .y0(function (d) { return (_this.baseValue === 'auto' ? _this.yScale.range()[0] : _this.yScale(_this.baseValue)); })
|
5246 | .y1(function (d) { return (_this.baseValue === 'auto' ? _this.yScale.range()[0] : _this.yScale(_this.baseValue)); });
|
5247 | }
|
5248 | currentArea.curve(this.curve);
|
5249 | startingArea.curve(this.curve);
|
5250 | this.opacity = 0.8;
|
5251 | var data = this.data.series;
|
5252 | if (this.scaleType === exports.ScaleType.Linear) {
|
5253 | data = sortLinear(data, 'name');
|
5254 | }
|
5255 | else if (this.scaleType === exports.ScaleType.Time) {
|
5256 | data = sortByTime(data, 'name');
|
5257 | }
|
5258 | else {
|
5259 | data = sortByDomain(data, 'name', 'asc', this.xScale.domain());
|
5260 | }
|
5261 | this.path = currentArea(data);
|
5262 | this.startingPath = startingArea(data);
|
5263 | };
|
5264 | AreaSeriesComponent.prototype.updateGradient = function () {
|
5265 | if (this.colors.scaleType === exports.ScaleType.Linear) {
|
5266 | this.hasGradient = true;
|
5267 | if (this.stacked || this.normalized) {
|
5268 | var d0values = this.data.series.map(function (d) { return d.d0; });
|
5269 | var d1values = this.data.series.map(function (d) { return d.d1; });
|
5270 | var max = Math.max.apply(Math, __spreadArray([], __read(d1values)));
|
5271 | var min = Math.min.apply(Math, __spreadArray([], __read(d0values)));
|
5272 | this.gradientStops = this.colors.getLinearGradientStops(max, min);
|
5273 | }
|
5274 | else {
|
5275 | var values = this.data.series.map(function (d) { return d.value; });
|
5276 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
5277 | this.gradientStops = this.colors.getLinearGradientStops(max);
|
5278 | }
|
5279 | }
|
5280 | else {
|
5281 | this.hasGradient = false;
|
5282 | this.gradientStops = undefined;
|
5283 | }
|
5284 | };
|
5285 | AreaSeriesComponent.prototype.isActive = function (entry) {
|
5286 | if (!this.activeEntries)
|
5287 | return false;
|
5288 | var item = this.activeEntries.find(function (d) {
|
5289 | return entry.name === d.name;
|
5290 | });
|
5291 | return item !== undefined;
|
5292 | };
|
5293 | AreaSeriesComponent.prototype.isInactive = function (entry) {
|
5294 | if (!this.activeEntries || this.activeEntries.length === 0)
|
5295 | return false;
|
5296 | var item = this.activeEntries.find(function (d) {
|
5297 | return entry.name === d.name;
|
5298 | });
|
5299 | return item === undefined;
|
5300 | };
|
5301 | return AreaSeriesComponent;
|
5302 | }());
|
5303 | AreaSeriesComponent.decorators = [
|
5304 | { type: core.Component, args: [{
|
5305 | selector: 'g[ngx-charts-area-series]',
|
5306 | template: "\n <svg:g\n ngx-charts-area\n class=\"area-series\"\n [data]=\"data\"\n [path]=\"path\"\n [fill]=\"colors.getColor(data.name)\"\n [stops]=\"gradientStops\"\n [startingPath]=\"startingPath\"\n [opacity]=\"opacity\"\n [gradient]=\"gradient || hasGradient\"\n [animations]=\"animations\"\n [class.active]=\"isActive(data)\"\n [class.inactive]=\"isInactive(data)\"\n />\n ",
|
5307 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
5308 | },] }
|
5309 | ];
|
5310 | AreaSeriesComponent.propDecorators = {
|
5311 | data: [{ type: core.Input }],
|
5312 | xScale: [{ type: core.Input }],
|
5313 | yScale: [{ type: core.Input }],
|
5314 | baseValue: [{ type: core.Input }],
|
5315 | colors: [{ type: core.Input }],
|
5316 | scaleType: [{ type: core.Input }],
|
5317 | stacked: [{ type: core.Input }],
|
5318 | normalized: [{ type: core.Input }],
|
5319 | gradient: [{ type: core.Input }],
|
5320 | curve: [{ type: core.Input }],
|
5321 | activeEntries: [{ type: core.Input }],
|
5322 | animations: [{ type: core.Input }],
|
5323 | select: [{ type: core.Output }]
|
5324 | };
|
5325 |
|
5326 | var AreaChartModule = (function () {
|
5327 | function AreaChartModule() {
|
5328 | }
|
5329 | return AreaChartModule;
|
5330 | }());
|
5331 | AreaChartModule.decorators = [
|
5332 | { type: core.NgModule, args: [{
|
5333 | imports: [ChartCommonModule],
|
5334 | declarations: [AreaChartComponent, AreaChartNormalizedComponent, AreaChartStackedComponent, AreaSeriesComponent],
|
5335 | exports: [AreaChartComponent, AreaChartNormalizedComponent, AreaChartStackedComponent, AreaSeriesComponent]
|
5336 | },] }
|
5337 | ];
|
5338 |
|
5339 | var BarComponent = (function () {
|
5340 | function BarComponent(element) {
|
5341 | this.roundEdges = true;
|
5342 | this.gradient = false;
|
5343 | this.offset = 0;
|
5344 | this.isActive = false;
|
5345 | this.animations = true;
|
5346 | this.noBarWhenZero = true;
|
5347 | this.select = new core.EventEmitter();
|
5348 | this.activate = new core.EventEmitter();
|
5349 | this.deactivate = new core.EventEmitter();
|
5350 | this.hasGradient = false;
|
5351 | this.hideBar = false;
|
5352 | this.element = element.nativeElement;
|
5353 | }
|
5354 | BarComponent.prototype.ngOnChanges = function (changes) {
|
5355 | if (changes.roundEdges) {
|
5356 | this.loadAnimation();
|
5357 | }
|
5358 | this.update();
|
5359 | };
|
5360 | BarComponent.prototype.update = function () {
|
5361 | this.gradientId = 'grad' + id().toString();
|
5362 | this.gradientFill = "url(#" + this.gradientId + ")";
|
5363 | if (this.gradient || this.stops) {
|
5364 | this.gradientStops = this.getGradient();
|
5365 | this.hasGradient = true;
|
5366 | }
|
5367 | else {
|
5368 | this.hasGradient = false;
|
5369 | }
|
5370 | this.updatePathEl();
|
5371 | this.checkToHideBar();
|
5372 | };
|
5373 | BarComponent.prototype.loadAnimation = function () {
|
5374 | this.path = this.getStartingPath();
|
5375 | setTimeout(this.update.bind(this), 100);
|
5376 | };
|
5377 | BarComponent.prototype.updatePathEl = function () {
|
5378 | var node = d3Selection.select(this.element).select('.bar');
|
5379 | var path = this.getPath();
|
5380 | if (this.animations) {
|
5381 | node.transition().duration(500).attr('d', path);
|
5382 | }
|
5383 | else {
|
5384 | node.attr('d', path);
|
5385 | }
|
5386 | };
|
5387 | BarComponent.prototype.getGradient = function () {
|
5388 | if (this.stops) {
|
5389 | return this.stops;
|
5390 | }
|
5391 | return [
|
5392 | {
|
5393 | offset: 0,
|
5394 | color: this.fill,
|
5395 | opacity: this.getStartOpacity()
|
5396 | },
|
5397 | {
|
5398 | offset: 100,
|
5399 | color: this.fill,
|
5400 | opacity: 1
|
5401 | }
|
5402 | ];
|
5403 | };
|
5404 | BarComponent.prototype.getStartingPath = function () {
|
5405 | if (!this.animations) {
|
5406 | return this.getPath();
|
5407 | }
|
5408 | var radius = this.getRadius();
|
5409 | var path;
|
5410 | if (this.roundEdges) {
|
5411 | if (this.orientation === exports.BarOrientation.Vertical) {
|
5412 | radius = Math.min(this.height, radius);
|
5413 | path = roundedRect(this.x, this.y + this.height, this.width, 1, 0, this.edges);
|
5414 | }
|
5415 | else if (this.orientation === exports.BarOrientation.Horizontal) {
|
5416 | radius = Math.min(this.width, radius);
|
5417 | path = roundedRect(this.x, this.y, 1, this.height, 0, this.edges);
|
5418 | }
|
5419 | }
|
5420 | else {
|
5421 | if (this.orientation === exports.BarOrientation.Vertical) {
|
5422 | path = roundedRect(this.x, this.y + this.height, this.width, 1, 0, this.edges);
|
5423 | }
|
5424 | else if (this.orientation === exports.BarOrientation.Horizontal) {
|
5425 | path = roundedRect(this.x, this.y, 1, this.height, 0, this.edges);
|
5426 | }
|
5427 | }
|
5428 | return path;
|
5429 | };
|
5430 | BarComponent.prototype.getPath = function () {
|
5431 | var radius = this.getRadius();
|
5432 | var path;
|
5433 | if (this.roundEdges) {
|
5434 | if (this.orientation === exports.BarOrientation.Vertical) {
|
5435 | radius = Math.min(this.height, radius);
|
5436 | path = roundedRect(this.x, this.y, this.width, this.height, radius, this.edges);
|
5437 | }
|
5438 | else if (this.orientation === exports.BarOrientation.Horizontal) {
|
5439 | radius = Math.min(this.width, radius);
|
5440 | path = roundedRect(this.x, this.y, this.width, this.height, radius, this.edges);
|
5441 | }
|
5442 | }
|
5443 | else {
|
5444 | path = roundedRect(this.x, this.y, this.width, this.height, radius, this.edges);
|
5445 | }
|
5446 | return path;
|
5447 | };
|
5448 | BarComponent.prototype.getRadius = function () {
|
5449 | var radius = 0;
|
5450 | if (this.roundEdges && this.height > 5 && this.width > 5) {
|
5451 | radius = Math.floor(Math.min(5, this.height / 2, this.width / 2));
|
5452 | }
|
5453 | return radius;
|
5454 | };
|
5455 | BarComponent.prototype.getStartOpacity = function () {
|
5456 | if (this.roundEdges) {
|
5457 | return 0.2;
|
5458 | }
|
5459 | else {
|
5460 | return 0.5;
|
5461 | }
|
5462 | };
|
5463 | Object.defineProperty(BarComponent.prototype, "edges", {
|
5464 | get: function () {
|
5465 | var edges = [false, false, false, false];
|
5466 | if (this.roundEdges) {
|
5467 | if (this.orientation === exports.BarOrientation.Vertical) {
|
5468 | if (this.data.value > 0) {
|
5469 | edges = [true, true, false, false];
|
5470 | }
|
5471 | else {
|
5472 | edges = [false, false, true, true];
|
5473 | }
|
5474 | }
|
5475 | else if (this.orientation === exports.BarOrientation.Horizontal) {
|
5476 | if (this.data.value > 0) {
|
5477 | edges = [false, true, false, true];
|
5478 | }
|
5479 | else {
|
5480 | edges = [true, false, true, false];
|
5481 | }
|
5482 | }
|
5483 | }
|
5484 | return edges;
|
5485 | },
|
5486 | enumerable: false,
|
5487 | configurable: true
|
5488 | });
|
5489 | BarComponent.prototype.onMouseEnter = function () {
|
5490 | this.activate.emit(this.data);
|
5491 | };
|
5492 | BarComponent.prototype.onMouseLeave = function () {
|
5493 | this.deactivate.emit(this.data);
|
5494 | };
|
5495 | BarComponent.prototype.checkToHideBar = function () {
|
5496 | this.hideBar =
|
5497 | this.noBarWhenZero &&
|
5498 | ((this.orientation === exports.BarOrientation.Vertical && this.height === 0) ||
|
5499 | (this.orientation === exports.BarOrientation.Horizontal && this.width === 0));
|
5500 | };
|
5501 | return BarComponent;
|
5502 | }());
|
5503 | BarComponent.decorators = [
|
5504 | { type: core.Component, args: [{
|
5505 | selector: 'g[ngx-charts-bar]',
|
5506 | template: "\n <svg:defs *ngIf=\"hasGradient\">\n <svg:g ngx-charts-svg-linear-gradient [orientation]=\"orientation\" [name]=\"gradientId\" [stops]=\"gradientStops\" />\n </svg:defs>\n <svg:path\n class=\"bar\"\n stroke=\"none\"\n role=\"img\"\n tabIndex=\"-1\"\n [class.active]=\"isActive\"\n [class.hidden]=\"hideBar\"\n [attr.d]=\"path\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.fill]=\"hasGradient ? gradientFill : fill\"\n (click)=\"select.emit(data)\"\n />\n ",
|
5507 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
5508 | },] }
|
5509 | ];
|
5510 | BarComponent.ctorParameters = function () { return [
|
5511 | { type: core.ElementRef }
|
5512 | ]; };
|
5513 | BarComponent.propDecorators = {
|
5514 | fill: [{ type: core.Input }],
|
5515 | data: [{ type: core.Input }],
|
5516 | width: [{ type: core.Input }],
|
5517 | height: [{ type: core.Input }],
|
5518 | x: [{ type: core.Input }],
|
5519 | y: [{ type: core.Input }],
|
5520 | orientation: [{ type: core.Input }],
|
5521 | roundEdges: [{ type: core.Input }],
|
5522 | gradient: [{ type: core.Input }],
|
5523 | offset: [{ type: core.Input }],
|
5524 | isActive: [{ type: core.Input }],
|
5525 | stops: [{ type: core.Input }],
|
5526 | animations: [{ type: core.Input }],
|
5527 | ariaLabel: [{ type: core.Input }],
|
5528 | noBarWhenZero: [{ type: core.Input }],
|
5529 | select: [{ type: core.Output }],
|
5530 | activate: [{ type: core.Output }],
|
5531 | deactivate: [{ type: core.Output }],
|
5532 | onMouseEnter: [{ type: core.HostListener, args: ['mouseenter',] }],
|
5533 | onMouseLeave: [{ type: core.HostListener, args: ['mouseleave',] }]
|
5534 | };
|
5535 |
|
5536 | var BarHorizontalComponent = (function (_super) {
|
5537 | __extends(BarHorizontalComponent, _super);
|
5538 | function BarHorizontalComponent() {
|
5539 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
5540 | _this.legend = false;
|
5541 | _this.legendTitle = 'Legend';
|
5542 | _this.legendPosition = exports.LegendPosition.Right;
|
5543 | _this.tooltipDisabled = false;
|
5544 | _this.showGridLines = true;
|
5545 | _this.activeEntries = [];
|
5546 | _this.trimXAxisTicks = true;
|
5547 | _this.trimYAxisTicks = true;
|
5548 | _this.rotateXAxisTicks = true;
|
5549 | _this.maxXAxisTickLength = 16;
|
5550 | _this.maxYAxisTickLength = 16;
|
5551 | _this.barPadding = 8;
|
5552 | _this.roundDomains = false;
|
5553 | _this.roundEdges = true;
|
5554 | _this.showDataLabel = false;
|
5555 | _this.noBarWhenZero = true;
|
5556 | _this.activate = new core.EventEmitter();
|
5557 | _this.deactivate = new core.EventEmitter();
|
5558 | _this.margin = [10, 20, 10, 20];
|
5559 | _this.xAxisHeight = 0;
|
5560 | _this.yAxisWidth = 0;
|
5561 | _this.dataLabelMaxWidth = { negative: 0, positive: 0 };
|
5562 | return _this;
|
5563 | }
|
5564 | BarHorizontalComponent.prototype.update = function () {
|
5565 | _super.prototype.update.call(this);
|
5566 | if (!this.showDataLabel) {
|
5567 | this.dataLabelMaxWidth = { negative: 0, positive: 0 };
|
5568 | }
|
5569 | this.margin = [10, 20 + this.dataLabelMaxWidth.positive, 10, 20 + this.dataLabelMaxWidth.negative];
|
5570 | this.dims = calculateViewDimensions({
|
5571 | width: this.width,
|
5572 | height: this.height,
|
5573 | margins: this.margin,
|
5574 | showXAxis: this.xAxis,
|
5575 | showYAxis: this.yAxis,
|
5576 | xAxisHeight: this.xAxisHeight,
|
5577 | yAxisWidth: this.yAxisWidth,
|
5578 | showXLabel: this.showXAxisLabel,
|
5579 | showYLabel: this.showYAxisLabel,
|
5580 | showLegend: this.legend,
|
5581 | legendType: this.schemeType,
|
5582 | legendPosition: this.legendPosition
|
5583 | });
|
5584 | this.formatDates();
|
5585 | this.xScale = this.getXScale();
|
5586 | this.yScale = this.getYScale();
|
5587 | this.setColors();
|
5588 | this.legendOptions = this.getLegendOptions();
|
5589 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
5590 | };
|
5591 | BarHorizontalComponent.prototype.getXScale = function () {
|
5592 | this.xDomain = this.getXDomain();
|
5593 | var scale = d3Scale.scaleLinear().range([0, this.dims.width]).domain(this.xDomain);
|
5594 | return this.roundDomains ? scale.nice() : scale;
|
5595 | };
|
5596 | BarHorizontalComponent.prototype.getYScale = function () {
|
5597 | this.yDomain = this.getYDomain();
|
5598 | var spacing = this.yDomain.length / (this.dims.height / this.barPadding + 1);
|
5599 | return d3Scale.scaleBand().rangeRound([0, this.dims.height]).paddingInner(spacing).domain(this.yDomain);
|
5600 | };
|
5601 | BarHorizontalComponent.prototype.getXDomain = function () {
|
5602 | var values = this.results.map(function (d) { return d.value; });
|
5603 | var min = this.xScaleMin ? Math.min.apply(Math, __spreadArray([this.xScaleMin], __read(values))) : Math.min.apply(Math, __spreadArray([0], __read(values)));
|
5604 | var max = this.xScaleMax ? Math.max.apply(Math, __spreadArray([this.xScaleMax], __read(values))) : Math.max.apply(Math, __spreadArray([0], __read(values)));
|
5605 | return [min, max];
|
5606 | };
|
5607 | BarHorizontalComponent.prototype.getYDomain = function () {
|
5608 | return this.results.map(function (d) { return d.label; });
|
5609 | };
|
5610 | BarHorizontalComponent.prototype.onClick = function (data) {
|
5611 | this.select.emit(data);
|
5612 | };
|
5613 | BarHorizontalComponent.prototype.setColors = function () {
|
5614 | var domain;
|
5615 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
5616 | domain = this.yDomain;
|
5617 | }
|
5618 | else {
|
5619 | domain = this.xDomain;
|
5620 | }
|
5621 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
5622 | };
|
5623 | BarHorizontalComponent.prototype.getLegendOptions = function () {
|
5624 | var opts = {
|
5625 | scaleType: this.schemeType,
|
5626 | colors: undefined,
|
5627 | domain: [],
|
5628 | title: undefined,
|
5629 | position: this.legendPosition
|
5630 | };
|
5631 | if (opts.scaleType === 'ordinal') {
|
5632 | opts.domain = this.yDomain;
|
5633 | opts.colors = this.colors;
|
5634 | opts.title = this.legendTitle;
|
5635 | }
|
5636 | else {
|
5637 | opts.domain = this.xDomain;
|
5638 | opts.colors = this.colors.scale;
|
5639 | }
|
5640 | return opts;
|
5641 | };
|
5642 | BarHorizontalComponent.prototype.updateYAxisWidth = function (_a) {
|
5643 | var width = _a.width;
|
5644 | this.yAxisWidth = width;
|
5645 | this.update();
|
5646 | };
|
5647 | BarHorizontalComponent.prototype.updateXAxisHeight = function (_a) {
|
5648 | var height = _a.height;
|
5649 | this.xAxisHeight = height;
|
5650 | this.update();
|
5651 | };
|
5652 | BarHorizontalComponent.prototype.onDataLabelMaxWidthChanged = function (event) {
|
5653 | var _this = this;
|
5654 | if (event.size.negative) {
|
5655 | this.dataLabelMaxWidth.negative = Math.max(this.dataLabelMaxWidth.negative, event.size.width);
|
5656 | }
|
5657 | else {
|
5658 | this.dataLabelMaxWidth.positive = Math.max(this.dataLabelMaxWidth.positive, event.size.width);
|
5659 | }
|
5660 | if (event.index === this.results.length - 1) {
|
5661 | setTimeout(function () { return _this.update(); });
|
5662 | }
|
5663 | };
|
5664 | BarHorizontalComponent.prototype.onActivate = function (item, fromLegend) {
|
5665 | if (fromLegend === void 0) { fromLegend = false; }
|
5666 | item = this.results.find(function (d) {
|
5667 | if (fromLegend) {
|
5668 | return d.label === item.name;
|
5669 | }
|
5670 | else {
|
5671 | return d.name === item.name;
|
5672 | }
|
5673 | });
|
5674 | var idx = this.activeEntries.findIndex(function (d) {
|
5675 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
5676 | });
|
5677 | if (idx > -1) {
|
5678 | return;
|
5679 | }
|
5680 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
5681 | this.activate.emit({ value: item, entries: this.activeEntries });
|
5682 | };
|
5683 | BarHorizontalComponent.prototype.onDeactivate = function (item, fromLegend) {
|
5684 | if (fromLegend === void 0) { fromLegend = false; }
|
5685 | item = this.results.find(function (d) {
|
5686 | if (fromLegend) {
|
5687 | return d.label === item.name;
|
5688 | }
|
5689 | else {
|
5690 | return d.name === item.name;
|
5691 | }
|
5692 | });
|
5693 | var idx = this.activeEntries.findIndex(function (d) {
|
5694 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
5695 | });
|
5696 | this.activeEntries.splice(idx, 1);
|
5697 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
5698 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
5699 | };
|
5700 | return BarHorizontalComponent;
|
5701 | }(BaseChartComponent));
|
5702 | BarHorizontalComponent.decorators = [
|
5703 | { type: core.Component, args: [{
|
5704 | selector: 'ngx-charts-bar-horizontal',
|
5705 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event, true)\"\n (legendLabelDeactivate)=\"onDeactivate($event, true)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"bar-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n [yAxisOffset]=\"dataLabelMaxWidth.negative\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-series-horizontal\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [series]=\"results\"\n [dims]=\"dims\"\n [gradient]=\"gradient\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [activeEntries]=\"activeEntries\"\n [roundEdges]=\"roundEdges\"\n [animations]=\"animations\"\n [showDataLabel]=\"showDataLabel\"\n [dataLabelFormatting]=\"dataLabelFormatting\"\n [noBarWhenZero]=\"noBarWhenZero\"\n (select)=\"onClick($event)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n (dataLabelWidthChanged)=\"onDataLabelMaxWidthChanged($event)\"\n ></svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
5706 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
5707 | encapsulation: core.ViewEncapsulation.None,
|
5708 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
5709 | },] }
|
5710 | ];
|
5711 | BarHorizontalComponent.propDecorators = {
|
5712 | legend: [{ type: core.Input }],
|
5713 | legendTitle: [{ type: core.Input }],
|
5714 | legendPosition: [{ type: core.Input }],
|
5715 | xAxis: [{ type: core.Input }],
|
5716 | yAxis: [{ type: core.Input }],
|
5717 | showXAxisLabel: [{ type: core.Input }],
|
5718 | showYAxisLabel: [{ type: core.Input }],
|
5719 | xAxisLabel: [{ type: core.Input }],
|
5720 | yAxisLabel: [{ type: core.Input }],
|
5721 | tooltipDisabled: [{ type: core.Input }],
|
5722 | gradient: [{ type: core.Input }],
|
5723 | showGridLines: [{ type: core.Input }],
|
5724 | activeEntries: [{ type: core.Input }],
|
5725 | schemeType: [{ type: core.Input }],
|
5726 | trimXAxisTicks: [{ type: core.Input }],
|
5727 | trimYAxisTicks: [{ type: core.Input }],
|
5728 | rotateXAxisTicks: [{ type: core.Input }],
|
5729 | maxXAxisTickLength: [{ type: core.Input }],
|
5730 | maxYAxisTickLength: [{ type: core.Input }],
|
5731 | xAxisTickFormatting: [{ type: core.Input }],
|
5732 | yAxisTickFormatting: [{ type: core.Input }],
|
5733 | xAxisTicks: [{ type: core.Input }],
|
5734 | yAxisTicks: [{ type: core.Input }],
|
5735 | barPadding: [{ type: core.Input }],
|
5736 | roundDomains: [{ type: core.Input }],
|
5737 | roundEdges: [{ type: core.Input }],
|
5738 | xScaleMax: [{ type: core.Input }],
|
5739 | xScaleMin: [{ type: core.Input }],
|
5740 | showDataLabel: [{ type: core.Input }],
|
5741 | dataLabelFormatting: [{ type: core.Input }],
|
5742 | noBarWhenZero: [{ type: core.Input }],
|
5743 | activate: [{ type: core.Output }],
|
5744 | deactivate: [{ type: core.Output }],
|
5745 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
5746 | };
|
5747 |
|
5748 | var BarHorizontal2DComponent = (function (_super) {
|
5749 | __extends(BarHorizontal2DComponent, _super);
|
5750 | function BarHorizontal2DComponent() {
|
5751 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
5752 | _this.legend = false;
|
5753 | _this.legendTitle = 'Legend';
|
5754 | _this.legendPosition = exports.LegendPosition.Right;
|
5755 | _this.tooltipDisabled = false;
|
5756 | _this.showGridLines = true;
|
5757 | _this.activeEntries = [];
|
5758 | _this.trimXAxisTicks = true;
|
5759 | _this.trimYAxisTicks = true;
|
5760 | _this.rotateXAxisTicks = true;
|
5761 | _this.maxXAxisTickLength = 16;
|
5762 | _this.maxYAxisTickLength = 16;
|
5763 | _this.groupPadding = 16;
|
5764 | _this.barPadding = 8;
|
5765 | _this.roundDomains = false;
|
5766 | _this.roundEdges = true;
|
5767 | _this.showDataLabel = false;
|
5768 | _this.noBarWhenZero = true;
|
5769 | _this.activate = new core.EventEmitter();
|
5770 | _this.deactivate = new core.EventEmitter();
|
5771 | _this.margin = [10, 20, 10, 20];
|
5772 | _this.xAxisHeight = 0;
|
5773 | _this.yAxisWidth = 0;
|
5774 | _this.dataLabelMaxWidth = { negative: 0, positive: 0 };
|
5775 | _this.barOrientation = exports.BarOrientation;
|
5776 | _this.trackBy = function (index, item) {
|
5777 | return item.name;
|
5778 | };
|
5779 | return _this;
|
5780 | }
|
5781 | BarHorizontal2DComponent.prototype.update = function () {
|
5782 | _super.prototype.update.call(this);
|
5783 | if (!this.showDataLabel) {
|
5784 | this.dataLabelMaxWidth = { negative: 0, positive: 0 };
|
5785 | }
|
5786 | this.margin = [10, 20 + this.dataLabelMaxWidth.positive, 10, 20 + this.dataLabelMaxWidth.negative];
|
5787 | this.dims = calculateViewDimensions({
|
5788 | width: this.width,
|
5789 | height: this.height,
|
5790 | margins: this.margin,
|
5791 | showXAxis: this.xAxis,
|
5792 | showYAxis: this.yAxis,
|
5793 | xAxisHeight: this.xAxisHeight,
|
5794 | yAxisWidth: this.yAxisWidth,
|
5795 | showXLabel: this.showXAxisLabel,
|
5796 | showYLabel: this.showYAxisLabel,
|
5797 | showLegend: this.legend,
|
5798 | legendType: this.schemeType,
|
5799 | legendPosition: this.legendPosition
|
5800 | });
|
5801 | this.formatDates();
|
5802 | this.groupDomain = this.getGroupDomain();
|
5803 | this.innerDomain = this.getInnerDomain();
|
5804 | this.valueDomain = this.getValueDomain();
|
5805 | this.groupScale = this.getGroupScale();
|
5806 | this.innerScale = this.getInnerScale();
|
5807 | this.valueScale = this.getValueScale();
|
5808 | this.setColors();
|
5809 | this.legendOptions = this.getLegendOptions();
|
5810 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
5811 | };
|
5812 | BarHorizontal2DComponent.prototype.getGroupScale = function () {
|
5813 | var spacing = this.groupDomain.length / (this.dims.height / this.groupPadding + 1);
|
5814 | return d3Scale.scaleBand()
|
5815 | .rangeRound([0, this.dims.height])
|
5816 | .paddingInner(spacing)
|
5817 | .paddingOuter(spacing / 2)
|
5818 | .domain(this.groupDomain);
|
5819 | };
|
5820 | BarHorizontal2DComponent.prototype.getInnerScale = function () {
|
5821 | var height = this.groupScale.bandwidth();
|
5822 | var spacing = this.innerDomain.length / (height / this.barPadding + 1);
|
5823 | return d3Scale.scaleBand().rangeRound([0, height]).paddingInner(spacing).domain(this.innerDomain);
|
5824 | };
|
5825 | BarHorizontal2DComponent.prototype.getValueScale = function () {
|
5826 | var scale = d3Scale.scaleLinear().range([0, this.dims.width]).domain(this.valueDomain);
|
5827 | return this.roundDomains ? scale.nice() : scale;
|
5828 | };
|
5829 | BarHorizontal2DComponent.prototype.getGroupDomain = function () {
|
5830 | var e_1, _a;
|
5831 | var domain = [];
|
5832 | try {
|
5833 | for (var _b = __values(this.results), _c = _b.next(); !_c.done; _c = _b.next()) {
|
5834 | var group = _c.value;
|
5835 | if (!domain.includes(group.label)) {
|
5836 | domain.push(group.label);
|
5837 | }
|
5838 | }
|
5839 | }
|
5840 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
5841 | finally {
|
5842 | try {
|
5843 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
5844 | }
|
5845 | finally { if (e_1) throw e_1.error; }
|
5846 | }
|
5847 | return domain;
|
5848 | };
|
5849 | BarHorizontal2DComponent.prototype.getInnerDomain = function () {
|
5850 | var e_2, _a, e_3, _b;
|
5851 | var domain = [];
|
5852 | try {
|
5853 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
5854 | var group = _d.value;
|
5855 | try {
|
5856 | for (var _e = (e_3 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
5857 | var d = _f.value;
|
5858 | if (!domain.includes(d.label)) {
|
5859 | domain.push(d.label);
|
5860 | }
|
5861 | }
|
5862 | }
|
5863 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
5864 | finally {
|
5865 | try {
|
5866 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
5867 | }
|
5868 | finally { if (e_3) throw e_3.error; }
|
5869 | }
|
5870 | }
|
5871 | }
|
5872 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
5873 | finally {
|
5874 | try {
|
5875 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
5876 | }
|
5877 | finally { if (e_2) throw e_2.error; }
|
5878 | }
|
5879 | return domain;
|
5880 | };
|
5881 | BarHorizontal2DComponent.prototype.getValueDomain = function () {
|
5882 | var e_4, _a, e_5, _b;
|
5883 | var domain = [];
|
5884 | try {
|
5885 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
5886 | var group = _d.value;
|
5887 | try {
|
5888 | for (var _e = (e_5 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
5889 | var d = _f.value;
|
5890 | if (!domain.includes(d.value)) {
|
5891 | domain.push(d.value);
|
5892 | }
|
5893 | }
|
5894 | }
|
5895 | catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
5896 | finally {
|
5897 | try {
|
5898 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
5899 | }
|
5900 | finally { if (e_5) throw e_5.error; }
|
5901 | }
|
5902 | }
|
5903 | }
|
5904 | catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
5905 | finally {
|
5906 | try {
|
5907 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
5908 | }
|
5909 | finally { if (e_4) throw e_4.error; }
|
5910 | }
|
5911 | var min = Math.min.apply(Math, __spreadArray([0], __read(domain)));
|
5912 | var max = this.xScaleMax ? Math.max.apply(Math, __spreadArray([this.xScaleMax], __read(domain))) : Math.max.apply(Math, __spreadArray([0], __read(domain)));
|
5913 | return [min, max];
|
5914 | };
|
5915 | BarHorizontal2DComponent.prototype.groupTransform = function (group) {
|
5916 | return "translate(0, " + this.groupScale(group.label) + ")";
|
5917 | };
|
5918 | BarHorizontal2DComponent.prototype.onClick = function (data, group) {
|
5919 | if (group) {
|
5920 | data.series = group.name;
|
5921 | }
|
5922 | this.select.emit(data);
|
5923 | };
|
5924 | BarHorizontal2DComponent.prototype.setColors = function () {
|
5925 | var domain;
|
5926 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
5927 | domain = this.innerDomain;
|
5928 | }
|
5929 | else {
|
5930 | domain = this.valueDomain;
|
5931 | }
|
5932 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
5933 | };
|
5934 | BarHorizontal2DComponent.prototype.getLegendOptions = function () {
|
5935 | var opts = {
|
5936 | scaleType: this.schemeType,
|
5937 | colors: undefined,
|
5938 | domain: [],
|
5939 | title: undefined,
|
5940 | position: this.legendPosition
|
5941 | };
|
5942 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
5943 | opts.domain = this.innerDomain;
|
5944 | opts.colors = this.colors;
|
5945 | opts.title = this.legendTitle;
|
5946 | }
|
5947 | else {
|
5948 | opts.domain = this.valueDomain;
|
5949 | opts.colors = this.colors.scale;
|
5950 | }
|
5951 | return opts;
|
5952 | };
|
5953 | BarHorizontal2DComponent.prototype.updateYAxisWidth = function (_a) {
|
5954 | var width = _a.width;
|
5955 | this.yAxisWidth = width;
|
5956 | this.update();
|
5957 | };
|
5958 | BarHorizontal2DComponent.prototype.updateXAxisHeight = function (_a) {
|
5959 | var height = _a.height;
|
5960 | this.xAxisHeight = height;
|
5961 | this.update();
|
5962 | };
|
5963 | BarHorizontal2DComponent.prototype.onDataLabelMaxWidthChanged = function (event, groupIndex) {
|
5964 | var _this = this;
|
5965 | if (event.size.negative) {
|
5966 | this.dataLabelMaxWidth.negative = Math.max(this.dataLabelMaxWidth.negative, event.size.width);
|
5967 | }
|
5968 | else {
|
5969 | this.dataLabelMaxWidth.positive = Math.max(this.dataLabelMaxWidth.positive, event.size.width);
|
5970 | }
|
5971 | if (groupIndex === this.results.length - 1) {
|
5972 | setTimeout(function () { return _this.update(); });
|
5973 | }
|
5974 | };
|
5975 | BarHorizontal2DComponent.prototype.onActivate = function (event, group, fromLegend) {
|
5976 | if (fromLegend === void 0) { fromLegend = false; }
|
5977 | var item = Object.assign({}, event);
|
5978 | if (group) {
|
5979 | item.series = group.name;
|
5980 | }
|
5981 | var items = this.results
|
5982 | .map(function (g) { return g.series; })
|
5983 | .flat()
|
5984 | .filter(function (i) {
|
5985 | if (fromLegend) {
|
5986 | return i.label === item.name;
|
5987 | }
|
5988 | else {
|
5989 | return i.name === item.name && i.series === item.series;
|
5990 | }
|
5991 | });
|
5992 | this.activeEntries = __spreadArray([], __read(items));
|
5993 | this.activate.emit({ value: item, entries: this.activeEntries });
|
5994 | };
|
5995 | BarHorizontal2DComponent.prototype.onDeactivate = function (event, group, fromLegend) {
|
5996 | if (fromLegend === void 0) { fromLegend = false; }
|
5997 | var item = Object.assign({}, event);
|
5998 | if (group) {
|
5999 | item.series = group.name;
|
6000 | }
|
6001 | this.activeEntries = this.activeEntries.filter(function (i) {
|
6002 | if (fromLegend) {
|
6003 | return i.label !== item.name;
|
6004 | }
|
6005 | else {
|
6006 | return !(i.name === item.name && i.series === item.series);
|
6007 | }
|
6008 | });
|
6009 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
6010 | };
|
6011 | return BarHorizontal2DComponent;
|
6012 | }(BaseChartComponent));
|
6013 | BarHorizontal2DComponent.decorators = [
|
6014 | { type: core.Component, args: [{
|
6015 | selector: 'ngx-charts-bar-horizontal-2d',
|
6016 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelActivate)=\"onActivate($event, undefined, true)\"\n (legendLabelDeactivate)=\"onDeactivate($event, undefined, true)\"\n (legendLabelClick)=\"onClick($event)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"bar-chart chart\">\n <svg:g\n ngx-charts-grid-panel-series\n [xScale]=\"valueScale\"\n [yScale]=\"groupScale\"\n [data]=\"results\"\n [dims]=\"dims\"\n [orient]=\"barOrientation.Horizontal\"\n ></svg:g>\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"valueScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"groupScale\"\n [dims]=\"dims\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n [yAxisOffset]=\"dataLabelMaxWidth.negative\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g\n *ngFor=\"let group of results; let index = index; trackBy: trackBy\"\n [@animationState]=\"'active'\"\n [attr.transform]=\"groupTransform(group)\"\n >\n <svg:g\n ngx-charts-series-horizontal\n [xScale]=\"valueScale\"\n [activeEntries]=\"activeEntries\"\n [yScale]=\"innerScale\"\n [colors]=\"colors\"\n [series]=\"group.series\"\n [dims]=\"dims\"\n [gradient]=\"gradient\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [seriesName]=\"group.name\"\n [roundEdges]=\"roundEdges\"\n [animations]=\"animations\"\n [showDataLabel]=\"showDataLabel\"\n [dataLabelFormatting]=\"dataLabelFormatting\"\n [noBarWhenZero]=\"noBarWhenZero\"\n (select)=\"onClick($event, group)\"\n (activate)=\"onActivate($event, group)\"\n (deactivate)=\"onDeactivate($event, group)\"\n (dataLabelWidthChanged)=\"onDataLabelMaxWidthChanged($event, index)\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
6017 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
6018 | encapsulation: core.ViewEncapsulation.None,
|
6019 | animations: [
|
6020 | animations.trigger('animationState', [
|
6021 | animations.transition(':leave', [
|
6022 | animations.style({
|
6023 | opacity: 1,
|
6024 | transform: '*'
|
6025 | }),
|
6026 | animations.animate(500, animations.style({ opacity: 0, transform: 'scale(0)' }))
|
6027 | ])
|
6028 | ])
|
6029 | ],
|
6030 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
6031 | },] }
|
6032 | ];
|
6033 | BarHorizontal2DComponent.propDecorators = {
|
6034 | legend: [{ type: core.Input }],
|
6035 | legendTitle: [{ type: core.Input }],
|
6036 | legendPosition: [{ type: core.Input }],
|
6037 | xAxis: [{ type: core.Input }],
|
6038 | yAxis: [{ type: core.Input }],
|
6039 | showXAxisLabel: [{ type: core.Input }],
|
6040 | showYAxisLabel: [{ type: core.Input }],
|
6041 | xAxisLabel: [{ type: core.Input }],
|
6042 | yAxisLabel: [{ type: core.Input }],
|
6043 | tooltipDisabled: [{ type: core.Input }],
|
6044 | gradient: [{ type: core.Input }],
|
6045 | showGridLines: [{ type: core.Input }],
|
6046 | activeEntries: [{ type: core.Input }],
|
6047 | schemeType: [{ type: core.Input }],
|
6048 | trimXAxisTicks: [{ type: core.Input }],
|
6049 | trimYAxisTicks: [{ type: core.Input }],
|
6050 | rotateXAxisTicks: [{ type: core.Input }],
|
6051 | maxXAxisTickLength: [{ type: core.Input }],
|
6052 | maxYAxisTickLength: [{ type: core.Input }],
|
6053 | xAxisTickFormatting: [{ type: core.Input }],
|
6054 | yAxisTickFormatting: [{ type: core.Input }],
|
6055 | xAxisTicks: [{ type: core.Input }],
|
6056 | yAxisTicks: [{ type: core.Input }],
|
6057 | groupPadding: [{ type: core.Input }],
|
6058 | barPadding: [{ type: core.Input }],
|
6059 | roundDomains: [{ type: core.Input }],
|
6060 | roundEdges: [{ type: core.Input }],
|
6061 | xScaleMax: [{ type: core.Input }],
|
6062 | showDataLabel: [{ type: core.Input }],
|
6063 | dataLabelFormatting: [{ type: core.Input }],
|
6064 | noBarWhenZero: [{ type: core.Input }],
|
6065 | activate: [{ type: core.Output }],
|
6066 | deactivate: [{ type: core.Output }],
|
6067 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
6068 | };
|
6069 |
|
6070 | exports.BarChartType = void 0;
|
6071 | (function (BarChartType) {
|
6072 | BarChartType["Standard"] = "standard";
|
6073 | BarChartType["Normalized"] = "normalized";
|
6074 | BarChartType["Stacked"] = "stacked";
|
6075 | })(exports.BarChartType || (exports.BarChartType = {}));
|
6076 |
|
6077 | var BarHorizontalNormalizedComponent = (function (_super) {
|
6078 | __extends(BarHorizontalNormalizedComponent, _super);
|
6079 | function BarHorizontalNormalizedComponent() {
|
6080 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
6081 | _this.legend = false;
|
6082 | _this.legendTitle = 'Legend';
|
6083 | _this.legendPosition = exports.LegendPosition.Right;
|
6084 | _this.tooltipDisabled = false;
|
6085 | _this.showGridLines = true;
|
6086 | _this.activeEntries = [];
|
6087 | _this.trimXAxisTicks = true;
|
6088 | _this.trimYAxisTicks = true;
|
6089 | _this.rotateXAxisTicks = true;
|
6090 | _this.maxXAxisTickLength = 16;
|
6091 | _this.maxYAxisTickLength = 16;
|
6092 | _this.barPadding = 8;
|
6093 | _this.roundDomains = false;
|
6094 | _this.noBarWhenZero = true;
|
6095 | _this.activate = new core.EventEmitter();
|
6096 | _this.deactivate = new core.EventEmitter();
|
6097 | _this.valueDomain = [0, 100];
|
6098 | _this.margin = [10, 20, 10, 20];
|
6099 | _this.xAxisHeight = 0;
|
6100 | _this.yAxisWidth = 0;
|
6101 | _this.barChartType = exports.BarChartType;
|
6102 | _this.trackBy = function (index, item) {
|
6103 | return item.name;
|
6104 | };
|
6105 | return _this;
|
6106 | }
|
6107 | BarHorizontalNormalizedComponent.prototype.update = function () {
|
6108 | _super.prototype.update.call(this);
|
6109 | this.dims = calculateViewDimensions({
|
6110 | width: this.width,
|
6111 | height: this.height,
|
6112 | margins: this.margin,
|
6113 | showXAxis: this.xAxis,
|
6114 | showYAxis: this.yAxis,
|
6115 | xAxisHeight: this.xAxisHeight,
|
6116 | yAxisWidth: this.yAxisWidth,
|
6117 | showXLabel: this.showXAxisLabel,
|
6118 | showYLabel: this.showYAxisLabel,
|
6119 | showLegend: this.legend,
|
6120 | legendType: this.schemeType,
|
6121 | legendPosition: this.legendPosition
|
6122 | });
|
6123 | this.formatDates();
|
6124 | this.groupDomain = this.getGroupDomain();
|
6125 | this.innerDomain = this.getInnerDomain();
|
6126 | this.xScale = this.getXScale();
|
6127 | this.yScale = this.getYScale();
|
6128 | this.setColors();
|
6129 | this.legendOptions = this.getLegendOptions();
|
6130 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
6131 | };
|
6132 | BarHorizontalNormalizedComponent.prototype.getGroupDomain = function () {
|
6133 | var e_1, _a;
|
6134 | var domain = [];
|
6135 | try {
|
6136 | for (var _b = __values(this.results), _c = _b.next(); !_c.done; _c = _b.next()) {
|
6137 | var group = _c.value;
|
6138 | if (!domain.includes(group.label)) {
|
6139 | domain.push(group.label);
|
6140 | }
|
6141 | }
|
6142 | }
|
6143 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
6144 | finally {
|
6145 | try {
|
6146 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
6147 | }
|
6148 | finally { if (e_1) throw e_1.error; }
|
6149 | }
|
6150 | return domain;
|
6151 | };
|
6152 | BarHorizontalNormalizedComponent.prototype.getInnerDomain = function () {
|
6153 | var e_2, _a, e_3, _b;
|
6154 | var domain = [];
|
6155 | try {
|
6156 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
6157 | var group = _d.value;
|
6158 | try {
|
6159 | for (var _e = (e_3 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
6160 | var d = _f.value;
|
6161 | if (!domain.includes(d.label)) {
|
6162 | domain.push(d.label);
|
6163 | }
|
6164 | }
|
6165 | }
|
6166 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
6167 | finally {
|
6168 | try {
|
6169 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
6170 | }
|
6171 | finally { if (e_3) throw e_3.error; }
|
6172 | }
|
6173 | }
|
6174 | }
|
6175 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
6176 | finally {
|
6177 | try {
|
6178 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
6179 | }
|
6180 | finally { if (e_2) throw e_2.error; }
|
6181 | }
|
6182 | return domain;
|
6183 | };
|
6184 | BarHorizontalNormalizedComponent.prototype.getYScale = function () {
|
6185 | var spacing = this.groupDomain.length / (this.dims.height / this.barPadding + 1);
|
6186 | return d3Scale.scaleBand().rangeRound([0, this.dims.height]).paddingInner(spacing).domain(this.groupDomain);
|
6187 | };
|
6188 | BarHorizontalNormalizedComponent.prototype.getXScale = function () {
|
6189 | var scale = d3Scale.scaleLinear().range([0, this.dims.width]).domain(this.valueDomain);
|
6190 | return this.roundDomains ? scale.nice() : scale;
|
6191 | };
|
6192 | BarHorizontalNormalizedComponent.prototype.groupTransform = function (group) {
|
6193 | return "translate(0, " + this.yScale(group.name) + ")";
|
6194 | };
|
6195 | BarHorizontalNormalizedComponent.prototype.onClick = function (data, group) {
|
6196 | if (group) {
|
6197 | data.series = group.name;
|
6198 | }
|
6199 | this.select.emit(data);
|
6200 | };
|
6201 | BarHorizontalNormalizedComponent.prototype.setColors = function () {
|
6202 | var domain;
|
6203 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
6204 | domain = this.innerDomain;
|
6205 | }
|
6206 | else {
|
6207 | domain = this.valueDomain;
|
6208 | }
|
6209 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
6210 | };
|
6211 | BarHorizontalNormalizedComponent.prototype.getLegendOptions = function () {
|
6212 | var opts = {
|
6213 | scaleType: this.schemeType,
|
6214 | colors: undefined,
|
6215 | domain: [],
|
6216 | title: undefined,
|
6217 | position: this.legendPosition
|
6218 | };
|
6219 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
6220 | opts.domain = this.innerDomain;
|
6221 | opts.colors = this.colors;
|
6222 | opts.title = this.legendTitle;
|
6223 | }
|
6224 | else {
|
6225 | opts.domain = this.valueDomain;
|
6226 | opts.colors = this.colors.scale;
|
6227 | }
|
6228 | return opts;
|
6229 | };
|
6230 | BarHorizontalNormalizedComponent.prototype.updateYAxisWidth = function (_a) {
|
6231 | var width = _a.width;
|
6232 | this.yAxisWidth = width;
|
6233 | this.update();
|
6234 | };
|
6235 | BarHorizontalNormalizedComponent.prototype.updateXAxisHeight = function (_a) {
|
6236 | var height = _a.height;
|
6237 | this.xAxisHeight = height;
|
6238 | this.update();
|
6239 | };
|
6240 | BarHorizontalNormalizedComponent.prototype.onActivate = function (event, group, fromLegend) {
|
6241 | if (fromLegend === void 0) { fromLegend = false; }
|
6242 | var item = Object.assign({}, event);
|
6243 | if (group) {
|
6244 | item.series = group.name;
|
6245 | }
|
6246 | var items = this.results
|
6247 | .map(function (g) { return g.series; })
|
6248 | .flat()
|
6249 | .filter(function (i) {
|
6250 | if (fromLegend) {
|
6251 | return i.label === item.name;
|
6252 | }
|
6253 | else {
|
6254 | return i.name === item.name && i.series === item.series;
|
6255 | }
|
6256 | });
|
6257 | this.activeEntries = __spreadArray([], __read(items));
|
6258 | this.activate.emit({ value: item, entries: this.activeEntries });
|
6259 | };
|
6260 | BarHorizontalNormalizedComponent.prototype.onDeactivate = function (event, group, fromLegend) {
|
6261 | if (fromLegend === void 0) { fromLegend = false; }
|
6262 | var item = Object.assign({}, event);
|
6263 | if (group) {
|
6264 | item.series = group.name;
|
6265 | }
|
6266 | this.activeEntries = this.activeEntries.filter(function (i) {
|
6267 | if (fromLegend) {
|
6268 | return i.label !== item.name;
|
6269 | }
|
6270 | else {
|
6271 | return !(i.name === item.name && i.series === item.series);
|
6272 | }
|
6273 | });
|
6274 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
6275 | };
|
6276 | return BarHorizontalNormalizedComponent;
|
6277 | }(BaseChartComponent));
|
6278 | BarHorizontalNormalizedComponent.decorators = [
|
6279 | { type: core.Component, args: [{
|
6280 | selector: 'ngx-charts-bar-horizontal-normalized',
|
6281 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelActivate)=\"onActivate($event, undefined, true)\"\n (legendLabelDeactivate)=\"onDeactivate($event, undefined, true)\"\n (legendLabelClick)=\"onClick($event)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"bar-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g\n *ngFor=\"let group of results; trackBy: trackBy\"\n [@animationState]=\"'active'\"\n [attr.transform]=\"groupTransform(group)\"\n >\n <svg:g\n ngx-charts-series-horizontal\n [type]=\"barChartType.Normalized\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [activeEntries]=\"activeEntries\"\n [colors]=\"colors\"\n [series]=\"group.series\"\n [dims]=\"dims\"\n [gradient]=\"gradient\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [seriesName]=\"group.name\"\n [animations]=\"animations\"\n (select)=\"onClick($event, group)\"\n (activate)=\"onActivate($event, group)\"\n (deactivate)=\"onDeactivate($event, group)\"\n [noBarWhenZero]=\"noBarWhenZero\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
6282 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
6283 | encapsulation: core.ViewEncapsulation.None,
|
6284 | animations: [
|
6285 | animations.trigger('animationState', [
|
6286 | animations.transition(':leave', [
|
6287 | animations.style({
|
6288 | opacity: 1,
|
6289 | transform: '*'
|
6290 | }),
|
6291 | animations.animate(500, animations.style({ opacity: 0, transform: 'scale(0)' }))
|
6292 | ])
|
6293 | ])
|
6294 | ],
|
6295 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
6296 | },] }
|
6297 | ];
|
6298 | BarHorizontalNormalizedComponent.propDecorators = {
|
6299 | legend: [{ type: core.Input }],
|
6300 | legendTitle: [{ type: core.Input }],
|
6301 | legendPosition: [{ type: core.Input }],
|
6302 | xAxis: [{ type: core.Input }],
|
6303 | yAxis: [{ type: core.Input }],
|
6304 | showXAxisLabel: [{ type: core.Input }],
|
6305 | showYAxisLabel: [{ type: core.Input }],
|
6306 | xAxisLabel: [{ type: core.Input }],
|
6307 | yAxisLabel: [{ type: core.Input }],
|
6308 | tooltipDisabled: [{ type: core.Input }],
|
6309 | gradient: [{ type: core.Input }],
|
6310 | showGridLines: [{ type: core.Input }],
|
6311 | activeEntries: [{ type: core.Input }],
|
6312 | schemeType: [{ type: core.Input }],
|
6313 | trimXAxisTicks: [{ type: core.Input }],
|
6314 | trimYAxisTicks: [{ type: core.Input }],
|
6315 | rotateXAxisTicks: [{ type: core.Input }],
|
6316 | maxXAxisTickLength: [{ type: core.Input }],
|
6317 | maxYAxisTickLength: [{ type: core.Input }],
|
6318 | xAxisTickFormatting: [{ type: core.Input }],
|
6319 | yAxisTickFormatting: [{ type: core.Input }],
|
6320 | xAxisTicks: [{ type: core.Input }],
|
6321 | yAxisTicks: [{ type: core.Input }],
|
6322 | barPadding: [{ type: core.Input }],
|
6323 | roundDomains: [{ type: core.Input }],
|
6324 | noBarWhenZero: [{ type: core.Input }],
|
6325 | activate: [{ type: core.Output }],
|
6326 | deactivate: [{ type: core.Output }],
|
6327 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
6328 | };
|
6329 |
|
6330 | var BarHorizontalStackedComponent = (function (_super) {
|
6331 | __extends(BarHorizontalStackedComponent, _super);
|
6332 | function BarHorizontalStackedComponent() {
|
6333 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
6334 | _this.legend = false;
|
6335 | _this.legendTitle = 'Legend';
|
6336 | _this.legendPosition = exports.LegendPosition.Right;
|
6337 | _this.tooltipDisabled = false;
|
6338 | _this.showGridLines = true;
|
6339 | _this.activeEntries = [];
|
6340 | _this.trimXAxisTicks = true;
|
6341 | _this.trimYAxisTicks = true;
|
6342 | _this.rotateXAxisTicks = true;
|
6343 | _this.maxXAxisTickLength = 16;
|
6344 | _this.maxYAxisTickLength = 16;
|
6345 | _this.barPadding = 8;
|
6346 | _this.roundDomains = false;
|
6347 | _this.showDataLabel = false;
|
6348 | _this.noBarWhenZero = true;
|
6349 | _this.activate = new core.EventEmitter();
|
6350 | _this.deactivate = new core.EventEmitter();
|
6351 | _this.margin = [10, 20, 10, 20];
|
6352 | _this.xAxisHeight = 0;
|
6353 | _this.yAxisWidth = 0;
|
6354 | _this.dataLabelMaxWidth = { negative: 0, positive: 0 };
|
6355 | _this.barChartType = exports.BarChartType;
|
6356 | _this.trackBy = function (index, item) {
|
6357 | return item.name;
|
6358 | };
|
6359 | return _this;
|
6360 | }
|
6361 | BarHorizontalStackedComponent.prototype.update = function () {
|
6362 | _super.prototype.update.call(this);
|
6363 | if (!this.showDataLabel) {
|
6364 | this.dataLabelMaxWidth = { negative: 0, positive: 0 };
|
6365 | }
|
6366 | this.margin = [10, 20 + this.dataLabelMaxWidth.positive, 10, 20 + this.dataLabelMaxWidth.negative];
|
6367 | this.dims = calculateViewDimensions({
|
6368 | width: this.width,
|
6369 | height: this.height,
|
6370 | margins: this.margin,
|
6371 | showXAxis: this.xAxis,
|
6372 | showYAxis: this.yAxis,
|
6373 | xAxisHeight: this.xAxisHeight,
|
6374 | yAxisWidth: this.yAxisWidth,
|
6375 | showXLabel: this.showXAxisLabel,
|
6376 | showYLabel: this.showYAxisLabel,
|
6377 | showLegend: this.legend,
|
6378 | legendType: this.schemeType,
|
6379 | legendPosition: this.legendPosition
|
6380 | });
|
6381 | this.formatDates();
|
6382 | this.groupDomain = this.getGroupDomain();
|
6383 | this.innerDomain = this.getInnerDomain();
|
6384 | this.valueDomain = this.getValueDomain();
|
6385 | this.xScale = this.getXScale();
|
6386 | this.yScale = this.getYScale();
|
6387 | this.setColors();
|
6388 | this.legendOptions = this.getLegendOptions();
|
6389 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
6390 | };
|
6391 | BarHorizontalStackedComponent.prototype.getGroupDomain = function () {
|
6392 | var e_1, _a;
|
6393 | var domain = [];
|
6394 | try {
|
6395 | for (var _b = __values(this.results), _c = _b.next(); !_c.done; _c = _b.next()) {
|
6396 | var group = _c.value;
|
6397 | if (!domain.includes(group.label)) {
|
6398 | domain.push(group.label);
|
6399 | }
|
6400 | }
|
6401 | }
|
6402 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
6403 | finally {
|
6404 | try {
|
6405 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
6406 | }
|
6407 | finally { if (e_1) throw e_1.error; }
|
6408 | }
|
6409 | return domain;
|
6410 | };
|
6411 | BarHorizontalStackedComponent.prototype.getInnerDomain = function () {
|
6412 | var e_2, _a, e_3, _b;
|
6413 | var domain = [];
|
6414 | try {
|
6415 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
6416 | var group = _d.value;
|
6417 | try {
|
6418 | for (var _e = (e_3 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
6419 | var d = _f.value;
|
6420 | if (!domain.includes(d.label)) {
|
6421 | domain.push(d.label);
|
6422 | }
|
6423 | }
|
6424 | }
|
6425 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
6426 | finally {
|
6427 | try {
|
6428 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
6429 | }
|
6430 | finally { if (e_3) throw e_3.error; }
|
6431 | }
|
6432 | }
|
6433 | }
|
6434 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
6435 | finally {
|
6436 | try {
|
6437 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
6438 | }
|
6439 | finally { if (e_2) throw e_2.error; }
|
6440 | }
|
6441 | return domain;
|
6442 | };
|
6443 | BarHorizontalStackedComponent.prototype.getValueDomain = function () {
|
6444 | var e_4, _a, e_5, _b;
|
6445 | var domain = [];
|
6446 | var smallest = 0;
|
6447 | var biggest = 0;
|
6448 | try {
|
6449 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
6450 | var group = _d.value;
|
6451 | var smallestSum = 0;
|
6452 | var biggestSum = 0;
|
6453 | try {
|
6454 | for (var _e = (e_5 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
6455 | var d = _f.value;
|
6456 | if (d.value < 0) {
|
6457 | smallestSum += d.value;
|
6458 | }
|
6459 | else {
|
6460 | biggestSum += d.value;
|
6461 | }
|
6462 | smallest = d.value < smallest ? d.value : smallest;
|
6463 | biggest = d.value > biggest ? d.value : biggest;
|
6464 | }
|
6465 | }
|
6466 | catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
6467 | finally {
|
6468 | try {
|
6469 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
6470 | }
|
6471 | finally { if (e_5) throw e_5.error; }
|
6472 | }
|
6473 | domain.push(smallestSum);
|
6474 | domain.push(biggestSum);
|
6475 | }
|
6476 | }
|
6477 | catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
6478 | finally {
|
6479 | try {
|
6480 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
6481 | }
|
6482 | finally { if (e_4) throw e_4.error; }
|
6483 | }
|
6484 | domain.push(smallest);
|
6485 | domain.push(biggest);
|
6486 | var min = Math.min.apply(Math, __spreadArray([0], __read(domain)));
|
6487 | var max = this.xScaleMax ? Math.max.apply(Math, __spreadArray([this.xScaleMax], __read(domain))) : Math.max.apply(Math, __spreadArray([], __read(domain)));
|
6488 | return [min, max];
|
6489 | };
|
6490 | BarHorizontalStackedComponent.prototype.getYScale = function () {
|
6491 | var spacing = this.groupDomain.length / (this.dims.height / this.barPadding + 1);
|
6492 | return d3Scale.scaleBand().rangeRound([0, this.dims.height]).paddingInner(spacing).domain(this.groupDomain);
|
6493 | };
|
6494 | BarHorizontalStackedComponent.prototype.getXScale = function () {
|
6495 | var scale = d3Scale.scaleLinear().range([0, this.dims.width]).domain(this.valueDomain);
|
6496 | return this.roundDomains ? scale.nice() : scale;
|
6497 | };
|
6498 | BarHorizontalStackedComponent.prototype.groupTransform = function (group) {
|
6499 | return "translate(0, " + this.yScale(group.name) + ")";
|
6500 | };
|
6501 | BarHorizontalStackedComponent.prototype.onClick = function (data, group) {
|
6502 | if (group) {
|
6503 | data.series = group.name;
|
6504 | }
|
6505 | this.select.emit(data);
|
6506 | };
|
6507 | BarHorizontalStackedComponent.prototype.setColors = function () {
|
6508 | var domain;
|
6509 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
6510 | domain = this.innerDomain;
|
6511 | }
|
6512 | else {
|
6513 | domain = this.valueDomain;
|
6514 | }
|
6515 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
6516 | };
|
6517 | BarHorizontalStackedComponent.prototype.getLegendOptions = function () {
|
6518 | var opts = {
|
6519 | scaleType: this.schemeType,
|
6520 | colors: undefined,
|
6521 | domain: [],
|
6522 | title: undefined,
|
6523 | position: this.legendPosition
|
6524 | };
|
6525 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
6526 | opts.domain = this.innerDomain;
|
6527 | opts.colors = this.colors;
|
6528 | opts.title = this.legendTitle;
|
6529 | }
|
6530 | else {
|
6531 | opts.domain = this.valueDomain;
|
6532 | opts.colors = this.colors.scale;
|
6533 | }
|
6534 | return opts;
|
6535 | };
|
6536 | BarHorizontalStackedComponent.prototype.updateYAxisWidth = function (_a) {
|
6537 | var width = _a.width;
|
6538 | this.yAxisWidth = width;
|
6539 | this.update();
|
6540 | };
|
6541 | BarHorizontalStackedComponent.prototype.updateXAxisHeight = function (_a) {
|
6542 | var height = _a.height;
|
6543 | this.xAxisHeight = height;
|
6544 | this.update();
|
6545 | };
|
6546 | BarHorizontalStackedComponent.prototype.onDataLabelMaxWidthChanged = function (event, groupIndex) {
|
6547 | var _this = this;
|
6548 | if (event.size.negative) {
|
6549 | this.dataLabelMaxWidth.negative = Math.max(this.dataLabelMaxWidth.negative, event.size.width);
|
6550 | }
|
6551 | else {
|
6552 | this.dataLabelMaxWidth.positive = Math.max(this.dataLabelMaxWidth.positive, event.size.width);
|
6553 | }
|
6554 | if (groupIndex === this.results.length - 1) {
|
6555 | setTimeout(function () { return _this.update(); });
|
6556 | }
|
6557 | };
|
6558 | BarHorizontalStackedComponent.prototype.onActivate = function (event, group, fromLegend) {
|
6559 | if (fromLegend === void 0) { fromLegend = false; }
|
6560 | var item = Object.assign({}, event);
|
6561 | if (group) {
|
6562 | item.series = group.name;
|
6563 | }
|
6564 | var items = this.results
|
6565 | .map(function (g) { return g.series; })
|
6566 | .flat()
|
6567 | .filter(function (i) {
|
6568 | if (fromLegend) {
|
6569 | return i.label === item.name;
|
6570 | }
|
6571 | else {
|
6572 | return i.name === item.name && i.series === item.series;
|
6573 | }
|
6574 | });
|
6575 | this.activeEntries = __spreadArray([], __read(items));
|
6576 | this.activate.emit({ value: item, entries: this.activeEntries });
|
6577 | };
|
6578 | BarHorizontalStackedComponent.prototype.onDeactivate = function (event, group, fromLegend) {
|
6579 | if (fromLegend === void 0) { fromLegend = false; }
|
6580 | var item = Object.assign({}, event);
|
6581 | if (group) {
|
6582 | item.series = group.name;
|
6583 | }
|
6584 | this.activeEntries = this.activeEntries.filter(function (i) {
|
6585 | if (fromLegend) {
|
6586 | return i.label !== item.name;
|
6587 | }
|
6588 | else {
|
6589 | return !(i.name === item.name && i.series === item.series);
|
6590 | }
|
6591 | });
|
6592 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
6593 | };
|
6594 | return BarHorizontalStackedComponent;
|
6595 | }(BaseChartComponent));
|
6596 | BarHorizontalStackedComponent.decorators = [
|
6597 | { type: core.Component, args: [{
|
6598 | selector: 'ngx-charts-bar-horizontal-stacked',
|
6599 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelActivate)=\"onActivate($event, undefined, true)\"\n (legendLabelDeactivate)=\"onDeactivate($event, undefined, true)\"\n (legendLabelClick)=\"onClick($event)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"bar-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n [yAxisOffset]=\"dataLabelMaxWidth.negative\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g\n *ngFor=\"let group of results; let index = index; trackBy: trackBy\"\n [@animationState]=\"'active'\"\n [attr.transform]=\"groupTransform(group)\"\n >\n <svg:g\n ngx-charts-series-horizontal\n [type]=\"barChartType.Stacked\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [series]=\"group.series\"\n [activeEntries]=\"activeEntries\"\n [dims]=\"dims\"\n [gradient]=\"gradient\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [seriesName]=\"group.name\"\n [animations]=\"animations\"\n [showDataLabel]=\"showDataLabel\"\n [dataLabelFormatting]=\"dataLabelFormatting\"\n [noBarWhenZero]=\"noBarWhenZero\"\n (select)=\"onClick($event, group)\"\n (activate)=\"onActivate($event, group)\"\n (deactivate)=\"onDeactivate($event, group)\"\n (dataLabelWidthChanged)=\"onDataLabelMaxWidthChanged($event, index)\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
6600 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
6601 | encapsulation: core.ViewEncapsulation.None,
|
6602 | animations: [
|
6603 | animations.trigger('animationState', [
|
6604 | animations.transition(':leave', [
|
6605 | animations.style({
|
6606 | opacity: 1,
|
6607 | transform: '*'
|
6608 | }),
|
6609 | animations.animate(500, animations.style({ opacity: 0, transform: 'scale(0)' }))
|
6610 | ])
|
6611 | ])
|
6612 | ],
|
6613 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
6614 | },] }
|
6615 | ];
|
6616 | BarHorizontalStackedComponent.propDecorators = {
|
6617 | legend: [{ type: core.Input }],
|
6618 | legendTitle: [{ type: core.Input }],
|
6619 | legendPosition: [{ type: core.Input }],
|
6620 | xAxis: [{ type: core.Input }],
|
6621 | yAxis: [{ type: core.Input }],
|
6622 | showXAxisLabel: [{ type: core.Input }],
|
6623 | showYAxisLabel: [{ type: core.Input }],
|
6624 | xAxisLabel: [{ type: core.Input }],
|
6625 | yAxisLabel: [{ type: core.Input }],
|
6626 | tooltipDisabled: [{ type: core.Input }],
|
6627 | gradient: [{ type: core.Input }],
|
6628 | showGridLines: [{ type: core.Input }],
|
6629 | activeEntries: [{ type: core.Input }],
|
6630 | schemeType: [{ type: core.Input }],
|
6631 | trimXAxisTicks: [{ type: core.Input }],
|
6632 | trimYAxisTicks: [{ type: core.Input }],
|
6633 | rotateXAxisTicks: [{ type: core.Input }],
|
6634 | maxXAxisTickLength: [{ type: core.Input }],
|
6635 | maxYAxisTickLength: [{ type: core.Input }],
|
6636 | xAxisTickFormatting: [{ type: core.Input }],
|
6637 | yAxisTickFormatting: [{ type: core.Input }],
|
6638 | xAxisTicks: [{ type: core.Input }],
|
6639 | yAxisTicks: [{ type: core.Input }],
|
6640 | barPadding: [{ type: core.Input }],
|
6641 | roundDomains: [{ type: core.Input }],
|
6642 | xScaleMax: [{ type: core.Input }],
|
6643 | showDataLabel: [{ type: core.Input }],
|
6644 | dataLabelFormatting: [{ type: core.Input }],
|
6645 | noBarWhenZero: [{ type: core.Input }],
|
6646 | activate: [{ type: core.Output }],
|
6647 | deactivate: [{ type: core.Output }],
|
6648 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
6649 | };
|
6650 |
|
6651 | var BarVerticalComponent = (function (_super) {
|
6652 | __extends(BarVerticalComponent, _super);
|
6653 | function BarVerticalComponent() {
|
6654 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
6655 | _this.legend = false;
|
6656 | _this.legendTitle = 'Legend';
|
6657 | _this.legendPosition = exports.LegendPosition.Right;
|
6658 | _this.tooltipDisabled = false;
|
6659 | _this.showGridLines = true;
|
6660 | _this.activeEntries = [];
|
6661 | _this.trimXAxisTicks = true;
|
6662 | _this.trimYAxisTicks = true;
|
6663 | _this.rotateXAxisTicks = true;
|
6664 | _this.maxXAxisTickLength = 16;
|
6665 | _this.maxYAxisTickLength = 16;
|
6666 | _this.barPadding = 8;
|
6667 | _this.roundDomains = false;
|
6668 | _this.roundEdges = true;
|
6669 | _this.showDataLabel = false;
|
6670 | _this.noBarWhenZero = true;
|
6671 | _this.activate = new core.EventEmitter();
|
6672 | _this.deactivate = new core.EventEmitter();
|
6673 | _this.margin = [10, 20, 10, 20];
|
6674 | _this.xAxisHeight = 0;
|
6675 | _this.yAxisWidth = 0;
|
6676 | _this.dataLabelMaxHeight = { negative: 0, positive: 0 };
|
6677 | return _this;
|
6678 | }
|
6679 | BarVerticalComponent.prototype.update = function () {
|
6680 | _super.prototype.update.call(this);
|
6681 | if (!this.showDataLabel) {
|
6682 | this.dataLabelMaxHeight = { negative: 0, positive: 0 };
|
6683 | }
|
6684 | this.margin = [10 + this.dataLabelMaxHeight.positive, 20, 10 + this.dataLabelMaxHeight.negative, 20];
|
6685 | this.dims = calculateViewDimensions({
|
6686 | width: this.width,
|
6687 | height: this.height,
|
6688 | margins: this.margin,
|
6689 | showXAxis: this.xAxis,
|
6690 | showYAxis: this.yAxis,
|
6691 | xAxisHeight: this.xAxisHeight,
|
6692 | yAxisWidth: this.yAxisWidth,
|
6693 | showXLabel: this.showXAxisLabel,
|
6694 | showYLabel: this.showYAxisLabel,
|
6695 | showLegend: this.legend,
|
6696 | legendType: this.schemeType,
|
6697 | legendPosition: this.legendPosition
|
6698 | });
|
6699 | this.formatDates();
|
6700 | if (this.showDataLabel) {
|
6701 | this.dims.height -= this.dataLabelMaxHeight.negative;
|
6702 | }
|
6703 | this.xScale = this.getXScale();
|
6704 | this.yScale = this.getYScale();
|
6705 | this.setColors();
|
6706 | this.legendOptions = this.getLegendOptions();
|
6707 | this.transform = "translate(" + this.dims.xOffset + " , " + (this.margin[0] + this.dataLabelMaxHeight.negative) + ")";
|
6708 | };
|
6709 | BarVerticalComponent.prototype.getXScale = function () {
|
6710 | this.xDomain = this.getXDomain();
|
6711 | var spacing = this.xDomain.length / (this.dims.width / this.barPadding + 1);
|
6712 | return d3Scale.scaleBand().range([0, this.dims.width]).paddingInner(spacing).domain(this.xDomain);
|
6713 | };
|
6714 | BarVerticalComponent.prototype.getYScale = function () {
|
6715 | this.yDomain = this.getYDomain();
|
6716 | var scale = d3Scale.scaleLinear().range([this.dims.height, 0]).domain(this.yDomain);
|
6717 | return this.roundDomains ? scale.nice() : scale;
|
6718 | };
|
6719 | BarVerticalComponent.prototype.getXDomain = function () {
|
6720 | return this.results.map(function (d) { return d.label; });
|
6721 | };
|
6722 | BarVerticalComponent.prototype.getYDomain = function () {
|
6723 | var values = this.results.map(function (d) { return d.value; });
|
6724 | var min = this.yScaleMin ? Math.min.apply(Math, __spreadArray([this.yScaleMin], __read(values))) : Math.min.apply(Math, __spreadArray([0], __read(values)));
|
6725 | if (this.yAxisTicks && !this.yAxisTicks.some(isNaN)) {
|
6726 | min = Math.min.apply(Math, __spreadArray([min], __read(this.yAxisTicks)));
|
6727 | }
|
6728 | var max = this.yScaleMax ? Math.max.apply(Math, __spreadArray([this.yScaleMax], __read(values))) : Math.max.apply(Math, __spreadArray([0], __read(values)));
|
6729 | if (this.yAxisTicks && !this.yAxisTicks.some(isNaN)) {
|
6730 | max = Math.max.apply(Math, __spreadArray([max], __read(this.yAxisTicks)));
|
6731 | }
|
6732 | return [min, max];
|
6733 | };
|
6734 | BarVerticalComponent.prototype.onClick = function (data) {
|
6735 | this.select.emit(data);
|
6736 | };
|
6737 | BarVerticalComponent.prototype.setColors = function () {
|
6738 | var domain;
|
6739 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
6740 | domain = this.xDomain;
|
6741 | }
|
6742 | else {
|
6743 | domain = this.yDomain;
|
6744 | }
|
6745 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
6746 | };
|
6747 | BarVerticalComponent.prototype.getLegendOptions = function () {
|
6748 | var opts = {
|
6749 | scaleType: this.schemeType,
|
6750 | colors: undefined,
|
6751 | domain: [],
|
6752 | title: undefined,
|
6753 | position: this.legendPosition
|
6754 | };
|
6755 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
6756 | opts.domain = this.xDomain;
|
6757 | opts.colors = this.colors;
|
6758 | opts.title = this.legendTitle;
|
6759 | }
|
6760 | else {
|
6761 | opts.domain = this.yDomain;
|
6762 | opts.colors = this.colors.scale;
|
6763 | }
|
6764 | return opts;
|
6765 | };
|
6766 | BarVerticalComponent.prototype.updateYAxisWidth = function (_a) {
|
6767 | var width = _a.width;
|
6768 | this.yAxisWidth = width;
|
6769 | this.update();
|
6770 | };
|
6771 | BarVerticalComponent.prototype.updateXAxisHeight = function (_a) {
|
6772 | var height = _a.height;
|
6773 | this.xAxisHeight = height;
|
6774 | this.update();
|
6775 | };
|
6776 | BarVerticalComponent.prototype.onDataLabelMaxHeightChanged = function (event) {
|
6777 | var _this = this;
|
6778 | if (event.size.negative) {
|
6779 | this.dataLabelMaxHeight.negative = Math.max(this.dataLabelMaxHeight.negative, event.size.height);
|
6780 | }
|
6781 | else {
|
6782 | this.dataLabelMaxHeight.positive = Math.max(this.dataLabelMaxHeight.positive, event.size.height);
|
6783 | }
|
6784 | if (event.index === this.results.length - 1) {
|
6785 | setTimeout(function () { return _this.update(); });
|
6786 | }
|
6787 | };
|
6788 | BarVerticalComponent.prototype.onActivate = function (item, fromLegend) {
|
6789 | if (fromLegend === void 0) { fromLegend = false; }
|
6790 | item = this.results.find(function (d) {
|
6791 | if (fromLegend) {
|
6792 | return d.label === item.name;
|
6793 | }
|
6794 | else {
|
6795 | return d.name === item.name;
|
6796 | }
|
6797 | });
|
6798 | var idx = this.activeEntries.findIndex(function (d) {
|
6799 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
6800 | });
|
6801 | if (idx > -1) {
|
6802 | return;
|
6803 | }
|
6804 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
6805 | this.activate.emit({ value: item, entries: this.activeEntries });
|
6806 | };
|
6807 | BarVerticalComponent.prototype.onDeactivate = function (item, fromLegend) {
|
6808 | if (fromLegend === void 0) { fromLegend = false; }
|
6809 | item = this.results.find(function (d) {
|
6810 | if (fromLegend) {
|
6811 | return d.label === item.name;
|
6812 | }
|
6813 | else {
|
6814 | return d.name === item.name;
|
6815 | }
|
6816 | });
|
6817 | var idx = this.activeEntries.findIndex(function (d) {
|
6818 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
6819 | });
|
6820 | this.activeEntries.splice(idx, 1);
|
6821 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
6822 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
6823 | };
|
6824 | return BarVerticalComponent;
|
6825 | }(BaseChartComponent));
|
6826 | BarVerticalComponent.decorators = [
|
6827 | { type: core.Component, args: [{
|
6828 | selector: 'ngx-charts-bar-vertical',
|
6829 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event, true)\"\n (legendLabelDeactivate)=\"onDeactivate($event, true)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"bar-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n [xAxisOffset]=\"dataLabelMaxHeight.negative\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-series-vertical\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [series]=\"results\"\n [dims]=\"dims\"\n [gradient]=\"gradient\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [showDataLabel]=\"showDataLabel\"\n [dataLabelFormatting]=\"dataLabelFormatting\"\n [activeEntries]=\"activeEntries\"\n [roundEdges]=\"roundEdges\"\n [animations]=\"animations\"\n [noBarWhenZero]=\"noBarWhenZero\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n (select)=\"onClick($event)\"\n (dataLabelHeightChanged)=\"onDataLabelMaxHeightChanged($event)\"\n ></svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
6830 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
6831 | encapsulation: core.ViewEncapsulation.None,
|
6832 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
6833 | },] }
|
6834 | ];
|
6835 | BarVerticalComponent.propDecorators = {
|
6836 | legend: [{ type: core.Input }],
|
6837 | legendTitle: [{ type: core.Input }],
|
6838 | legendPosition: [{ type: core.Input }],
|
6839 | xAxis: [{ type: core.Input }],
|
6840 | yAxis: [{ type: core.Input }],
|
6841 | showXAxisLabel: [{ type: core.Input }],
|
6842 | showYAxisLabel: [{ type: core.Input }],
|
6843 | xAxisLabel: [{ type: core.Input }],
|
6844 | yAxisLabel: [{ type: core.Input }],
|
6845 | tooltipDisabled: [{ type: core.Input }],
|
6846 | gradient: [{ type: core.Input }],
|
6847 | showGridLines: [{ type: core.Input }],
|
6848 | activeEntries: [{ type: core.Input }],
|
6849 | schemeType: [{ type: core.Input }],
|
6850 | trimXAxisTicks: [{ type: core.Input }],
|
6851 | trimYAxisTicks: [{ type: core.Input }],
|
6852 | rotateXAxisTicks: [{ type: core.Input }],
|
6853 | maxXAxisTickLength: [{ type: core.Input }],
|
6854 | maxYAxisTickLength: [{ type: core.Input }],
|
6855 | xAxisTickFormatting: [{ type: core.Input }],
|
6856 | yAxisTickFormatting: [{ type: core.Input }],
|
6857 | xAxisTicks: [{ type: core.Input }],
|
6858 | yAxisTicks: [{ type: core.Input }],
|
6859 | barPadding: [{ type: core.Input }],
|
6860 | roundDomains: [{ type: core.Input }],
|
6861 | roundEdges: [{ type: core.Input }],
|
6862 | yScaleMax: [{ type: core.Input }],
|
6863 | yScaleMin: [{ type: core.Input }],
|
6864 | showDataLabel: [{ type: core.Input }],
|
6865 | dataLabelFormatting: [{ type: core.Input }],
|
6866 | noBarWhenZero: [{ type: core.Input }],
|
6867 | activate: [{ type: core.Output }],
|
6868 | deactivate: [{ type: core.Output }],
|
6869 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
6870 | };
|
6871 |
|
6872 | var BarVertical2DComponent = (function (_super) {
|
6873 | __extends(BarVertical2DComponent, _super);
|
6874 | function BarVertical2DComponent() {
|
6875 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
6876 | _this.legend = false;
|
6877 | _this.legendTitle = 'Legend';
|
6878 | _this.legendPosition = exports.LegendPosition.Right;
|
6879 | _this.tooltipDisabled = false;
|
6880 | _this.scaleType = exports.ScaleType.Ordinal;
|
6881 | _this.showGridLines = true;
|
6882 | _this.activeEntries = [];
|
6883 | _this.trimXAxisTicks = true;
|
6884 | _this.trimYAxisTicks = true;
|
6885 | _this.rotateXAxisTicks = true;
|
6886 | _this.maxXAxisTickLength = 16;
|
6887 | _this.maxYAxisTickLength = 16;
|
6888 | _this.groupPadding = 16;
|
6889 | _this.barPadding = 8;
|
6890 | _this.roundDomains = false;
|
6891 | _this.roundEdges = true;
|
6892 | _this.showDataLabel = false;
|
6893 | _this.noBarWhenZero = true;
|
6894 | _this.activate = new core.EventEmitter();
|
6895 | _this.deactivate = new core.EventEmitter();
|
6896 | _this.margin = [10, 20, 10, 20];
|
6897 | _this.xAxisHeight = 0;
|
6898 | _this.yAxisWidth = 0;
|
6899 | _this.dataLabelMaxHeight = { negative: 0, positive: 0 };
|
6900 | _this.barOrientation = exports.BarOrientation;
|
6901 | _this.trackBy = function (index, item) {
|
6902 | return item.name;
|
6903 | };
|
6904 | return _this;
|
6905 | }
|
6906 | BarVertical2DComponent.prototype.update = function () {
|
6907 | _super.prototype.update.call(this);
|
6908 | if (!this.showDataLabel) {
|
6909 | this.dataLabelMaxHeight = { negative: 0, positive: 0 };
|
6910 | }
|
6911 | this.margin = [10 + this.dataLabelMaxHeight.positive, 20, 10 + this.dataLabelMaxHeight.negative, 20];
|
6912 | this.dims = calculateViewDimensions({
|
6913 | width: this.width,
|
6914 | height: this.height,
|
6915 | margins: this.margin,
|
6916 | showXAxis: this.xAxis,
|
6917 | showYAxis: this.yAxis,
|
6918 | xAxisHeight: this.xAxisHeight,
|
6919 | yAxisWidth: this.yAxisWidth,
|
6920 | showXLabel: this.showXAxisLabel,
|
6921 | showYLabel: this.showYAxisLabel,
|
6922 | showLegend: this.legend,
|
6923 | legendType: this.schemeType,
|
6924 | legendPosition: this.legendPosition
|
6925 | });
|
6926 | if (this.showDataLabel) {
|
6927 | this.dims.height -= this.dataLabelMaxHeight.negative;
|
6928 | }
|
6929 | this.formatDates();
|
6930 | this.groupDomain = this.getGroupDomain();
|
6931 | this.innerDomain = this.getInnerDomain();
|
6932 | this.valueDomain = this.getValueDomain();
|
6933 | this.groupScale = this.getGroupScale();
|
6934 | this.innerScale = this.getInnerScale();
|
6935 | this.valueScale = this.getValueScale();
|
6936 | this.setColors();
|
6937 | this.legendOptions = this.getLegendOptions();
|
6938 | this.transform = "translate(" + this.dims.xOffset + " , " + (this.margin[0] + this.dataLabelMaxHeight.negative) + ")";
|
6939 | };
|
6940 | BarVertical2DComponent.prototype.onDataLabelMaxHeightChanged = function (event, groupIndex) {
|
6941 | var _this = this;
|
6942 | if (event.size.negative) {
|
6943 | this.dataLabelMaxHeight.negative = Math.max(this.dataLabelMaxHeight.negative, event.size.height);
|
6944 | }
|
6945 | else {
|
6946 | this.dataLabelMaxHeight.positive = Math.max(this.dataLabelMaxHeight.positive, event.size.height);
|
6947 | }
|
6948 | if (groupIndex === this.results.length - 1) {
|
6949 | setTimeout(function () { return _this.update(); });
|
6950 | }
|
6951 | };
|
6952 | BarVertical2DComponent.prototype.getGroupScale = function () {
|
6953 | var spacing = this.groupDomain.length / (this.dims.height / this.groupPadding + 1);
|
6954 | return d3Scale.scaleBand()
|
6955 | .rangeRound([0, this.dims.width])
|
6956 | .paddingInner(spacing)
|
6957 | .paddingOuter(spacing / 2)
|
6958 | .domain(this.groupDomain);
|
6959 | };
|
6960 | BarVertical2DComponent.prototype.getInnerScale = function () {
|
6961 | var width = this.groupScale.bandwidth();
|
6962 | var spacing = this.innerDomain.length / (width / this.barPadding + 1);
|
6963 | return d3Scale.scaleBand().rangeRound([0, width]).paddingInner(spacing).domain(this.innerDomain);
|
6964 | };
|
6965 | BarVertical2DComponent.prototype.getValueScale = function () {
|
6966 | var scale = d3Scale.scaleLinear().range([this.dims.height, 0]).domain(this.valueDomain);
|
6967 | return this.roundDomains ? scale.nice() : scale;
|
6968 | };
|
6969 | BarVertical2DComponent.prototype.getGroupDomain = function () {
|
6970 | var e_1, _a;
|
6971 | var domain = [];
|
6972 | try {
|
6973 | for (var _b = __values(this.results), _c = _b.next(); !_c.done; _c = _b.next()) {
|
6974 | var group = _c.value;
|
6975 | if (!domain.includes(group.label)) {
|
6976 | domain.push(group.label);
|
6977 | }
|
6978 | }
|
6979 | }
|
6980 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
6981 | finally {
|
6982 | try {
|
6983 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
6984 | }
|
6985 | finally { if (e_1) throw e_1.error; }
|
6986 | }
|
6987 | return domain;
|
6988 | };
|
6989 | BarVertical2DComponent.prototype.getInnerDomain = function () {
|
6990 | var e_2, _a, e_3, _b;
|
6991 | var domain = [];
|
6992 | try {
|
6993 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
6994 | var group = _d.value;
|
6995 | try {
|
6996 | for (var _e = (e_3 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
6997 | var d = _f.value;
|
6998 | if (!domain.includes(d.label)) {
|
6999 | domain.push(d.label);
|
7000 | }
|
7001 | }
|
7002 | }
|
7003 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
7004 | finally {
|
7005 | try {
|
7006 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
7007 | }
|
7008 | finally { if (e_3) throw e_3.error; }
|
7009 | }
|
7010 | }
|
7011 | }
|
7012 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
7013 | finally {
|
7014 | try {
|
7015 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
7016 | }
|
7017 | finally { if (e_2) throw e_2.error; }
|
7018 | }
|
7019 | return domain;
|
7020 | };
|
7021 | BarVertical2DComponent.prototype.getValueDomain = function () {
|
7022 | var e_4, _a, e_5, _b;
|
7023 | var domain = [];
|
7024 | try {
|
7025 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
7026 | var group = _d.value;
|
7027 | try {
|
7028 | for (var _e = (e_5 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
7029 | var d = _f.value;
|
7030 | if (!domain.includes(d.value)) {
|
7031 | domain.push(d.value);
|
7032 | }
|
7033 | }
|
7034 | }
|
7035 | catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
7036 | finally {
|
7037 | try {
|
7038 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
7039 | }
|
7040 | finally { if (e_5) throw e_5.error; }
|
7041 | }
|
7042 | }
|
7043 | }
|
7044 | catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
7045 | finally {
|
7046 | try {
|
7047 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
7048 | }
|
7049 | finally { if (e_4) throw e_4.error; }
|
7050 | }
|
7051 | var min = Math.min.apply(Math, __spreadArray([0], __read(domain)));
|
7052 | var max = this.yScaleMax ? Math.max.apply(Math, __spreadArray([this.yScaleMax], __read(domain))) : Math.max.apply(Math, __spreadArray([0], __read(domain)));
|
7053 | return [min, max];
|
7054 | };
|
7055 | BarVertical2DComponent.prototype.groupTransform = function (group) {
|
7056 | return "translate(" + this.groupScale(group.label) + ", 0)";
|
7057 | };
|
7058 | BarVertical2DComponent.prototype.onClick = function (data, group) {
|
7059 | if (group) {
|
7060 | data.series = group.name;
|
7061 | }
|
7062 | this.select.emit(data);
|
7063 | };
|
7064 | BarVertical2DComponent.prototype.setColors = function () {
|
7065 | var domain;
|
7066 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
7067 | domain = this.innerDomain;
|
7068 | }
|
7069 | else {
|
7070 | domain = this.valueDomain;
|
7071 | }
|
7072 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
7073 | };
|
7074 | BarVertical2DComponent.prototype.getLegendOptions = function () {
|
7075 | var opts = {
|
7076 | scaleType: this.schemeType,
|
7077 | colors: undefined,
|
7078 | domain: [],
|
7079 | title: undefined,
|
7080 | position: this.legendPosition
|
7081 | };
|
7082 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
7083 | opts.domain = this.innerDomain;
|
7084 | opts.colors = this.colors;
|
7085 | opts.title = this.legendTitle;
|
7086 | }
|
7087 | else {
|
7088 | opts.domain = this.valueDomain;
|
7089 | opts.colors = this.colors.scale;
|
7090 | }
|
7091 | return opts;
|
7092 | };
|
7093 | BarVertical2DComponent.prototype.updateYAxisWidth = function (_a) {
|
7094 | var width = _a.width;
|
7095 | this.yAxisWidth = width;
|
7096 | this.update();
|
7097 | };
|
7098 | BarVertical2DComponent.prototype.updateXAxisHeight = function (_a) {
|
7099 | var height = _a.height;
|
7100 | this.xAxisHeight = height;
|
7101 | this.update();
|
7102 | };
|
7103 | BarVertical2DComponent.prototype.onActivate = function (event, group, fromLegend) {
|
7104 | if (fromLegend === void 0) { fromLegend = false; }
|
7105 | var item = Object.assign({}, event);
|
7106 | if (group) {
|
7107 | item.series = group.name;
|
7108 | }
|
7109 | var items = this.results
|
7110 | .map(function (g) { return g.series; })
|
7111 | .flat()
|
7112 | .filter(function (i) {
|
7113 | if (fromLegend) {
|
7114 | return i.label === item.name;
|
7115 | }
|
7116 | else {
|
7117 | return i.name === item.name && i.series === item.series;
|
7118 | }
|
7119 | });
|
7120 | this.activeEntries = __spreadArray([], __read(items));
|
7121 | this.activate.emit({ value: item, entries: this.activeEntries });
|
7122 | };
|
7123 | BarVertical2DComponent.prototype.onDeactivate = function (event, group, fromLegend) {
|
7124 | if (fromLegend === void 0) { fromLegend = false; }
|
7125 | var item = Object.assign({}, event);
|
7126 | if (group) {
|
7127 | item.series = group.name;
|
7128 | }
|
7129 | this.activeEntries = this.activeEntries.filter(function (i) {
|
7130 | if (fromLegend) {
|
7131 | return i.label !== item.name;
|
7132 | }
|
7133 | else {
|
7134 | return !(i.name === item.name && i.series === item.series);
|
7135 | }
|
7136 | });
|
7137 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
7138 | };
|
7139 | return BarVertical2DComponent;
|
7140 | }(BaseChartComponent));
|
7141 | BarVertical2DComponent.decorators = [
|
7142 | { type: core.Component, args: [{
|
7143 | selector: 'ngx-charts-bar-vertical-2d',
|
7144 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelActivate)=\"onActivate($event, undefined, true)\"\n (legendLabelDeactivate)=\"onDeactivate($event, undefined, true)\"\n (legendLabelClick)=\"onClick($event)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"bar-chart chart\">\n <svg:g\n ngx-charts-grid-panel-series\n [xScale]=\"groupScale\"\n [yScale]=\"valueScale\"\n [data]=\"results\"\n [dims]=\"dims\"\n [orient]=\"barOrientation.Vertical\"\n ></svg:g>\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"groupScale\"\n [dims]=\"dims\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n [xAxisOffset]=\"dataLabelMaxHeight.negative\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"valueScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-series-vertical\n *ngFor=\"let group of results; let index = index; trackBy: trackBy\"\n [@animationState]=\"'active'\"\n [attr.transform]=\"groupTransform(group)\"\n [activeEntries]=\"activeEntries\"\n [xScale]=\"innerScale\"\n [yScale]=\"valueScale\"\n [colors]=\"colors\"\n [series]=\"group.series\"\n [dims]=\"dims\"\n [gradient]=\"gradient\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [showDataLabel]=\"showDataLabel\"\n [dataLabelFormatting]=\"dataLabelFormatting\"\n [seriesName]=\"group.name\"\n [roundEdges]=\"roundEdges\"\n [animations]=\"animations\"\n [noBarWhenZero]=\"noBarWhenZero\"\n (select)=\"onClick($event, group)\"\n (activate)=\"onActivate($event, group)\"\n (deactivate)=\"onDeactivate($event, group)\"\n (dataLabelHeightChanged)=\"onDataLabelMaxHeightChanged($event, index)\"\n />\n </svg:g>\n </ngx-charts-chart>\n ",
|
7145 | encapsulation: core.ViewEncapsulation.None,
|
7146 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
7147 | animations: [
|
7148 | animations.trigger('animationState', [
|
7149 | animations.transition(':leave', [
|
7150 | animations.style({
|
7151 | opacity: 1,
|
7152 | transform: '*'
|
7153 | }),
|
7154 | animations.animate(500, animations.style({ opacity: 0, transform: 'scale(0)' }))
|
7155 | ])
|
7156 | ])
|
7157 | ],
|
7158 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
7159 | },] }
|
7160 | ];
|
7161 | BarVertical2DComponent.propDecorators = {
|
7162 | legend: [{ type: core.Input }],
|
7163 | legendTitle: [{ type: core.Input }],
|
7164 | legendPosition: [{ type: core.Input }],
|
7165 | xAxis: [{ type: core.Input }],
|
7166 | yAxis: [{ type: core.Input }],
|
7167 | showXAxisLabel: [{ type: core.Input }],
|
7168 | showYAxisLabel: [{ type: core.Input }],
|
7169 | xAxisLabel: [{ type: core.Input }],
|
7170 | yAxisLabel: [{ type: core.Input }],
|
7171 | tooltipDisabled: [{ type: core.Input }],
|
7172 | scaleType: [{ type: core.Input }],
|
7173 | gradient: [{ type: core.Input }],
|
7174 | showGridLines: [{ type: core.Input }],
|
7175 | activeEntries: [{ type: core.Input }],
|
7176 | schemeType: [{ type: core.Input }],
|
7177 | trimXAxisTicks: [{ type: core.Input }],
|
7178 | trimYAxisTicks: [{ type: core.Input }],
|
7179 | rotateXAxisTicks: [{ type: core.Input }],
|
7180 | maxXAxisTickLength: [{ type: core.Input }],
|
7181 | maxYAxisTickLength: [{ type: core.Input }],
|
7182 | xAxisTickFormatting: [{ type: core.Input }],
|
7183 | yAxisTickFormatting: [{ type: core.Input }],
|
7184 | xAxisTicks: [{ type: core.Input }],
|
7185 | yAxisTicks: [{ type: core.Input }],
|
7186 | groupPadding: [{ type: core.Input }],
|
7187 | barPadding: [{ type: core.Input }],
|
7188 | roundDomains: [{ type: core.Input }],
|
7189 | roundEdges: [{ type: core.Input }],
|
7190 | yScaleMax: [{ type: core.Input }],
|
7191 | showDataLabel: [{ type: core.Input }],
|
7192 | dataLabelFormatting: [{ type: core.Input }],
|
7193 | noBarWhenZero: [{ type: core.Input }],
|
7194 | activate: [{ type: core.Output }],
|
7195 | deactivate: [{ type: core.Output }],
|
7196 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
7197 | };
|
7198 |
|
7199 | var BarVerticalNormalizedComponent = (function (_super) {
|
7200 | __extends(BarVerticalNormalizedComponent, _super);
|
7201 | function BarVerticalNormalizedComponent() {
|
7202 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
7203 | _this.legend = false;
|
7204 | _this.legendTitle = 'Legend';
|
7205 | _this.legendPosition = exports.LegendPosition.Right;
|
7206 | _this.tooltipDisabled = false;
|
7207 | _this.showGridLines = true;
|
7208 | _this.activeEntries = [];
|
7209 | _this.trimXAxisTicks = true;
|
7210 | _this.trimYAxisTicks = true;
|
7211 | _this.rotateXAxisTicks = true;
|
7212 | _this.maxXAxisTickLength = 16;
|
7213 | _this.maxYAxisTickLength = 16;
|
7214 | _this.barPadding = 8;
|
7215 | _this.roundDomains = false;
|
7216 | _this.noBarWhenZero = true;
|
7217 | _this.activate = new core.EventEmitter();
|
7218 | _this.deactivate = new core.EventEmitter();
|
7219 | _this.valueDomain = [0, 100];
|
7220 | _this.margin = [10, 20, 10, 20];
|
7221 | _this.xAxisHeight = 0;
|
7222 | _this.yAxisWidth = 0;
|
7223 | _this.barChartType = exports.BarChartType;
|
7224 | _this.trackBy = function (index, item) {
|
7225 | return item.name;
|
7226 | };
|
7227 | return _this;
|
7228 | }
|
7229 | BarVerticalNormalizedComponent.prototype.update = function () {
|
7230 | _super.prototype.update.call(this);
|
7231 | this.dims = calculateViewDimensions({
|
7232 | width: this.width,
|
7233 | height: this.height,
|
7234 | margins: this.margin,
|
7235 | showXAxis: this.xAxis,
|
7236 | showYAxis: this.yAxis,
|
7237 | xAxisHeight: this.xAxisHeight,
|
7238 | yAxisWidth: this.yAxisWidth,
|
7239 | showXLabel: this.showXAxisLabel,
|
7240 | showYLabel: this.showYAxisLabel,
|
7241 | showLegend: this.legend,
|
7242 | legendType: this.schemeType,
|
7243 | legendPosition: this.legendPosition
|
7244 | });
|
7245 | this.formatDates();
|
7246 | this.groupDomain = this.getGroupDomain();
|
7247 | this.innerDomain = this.getInnerDomain();
|
7248 | this.xScale = this.getXScale();
|
7249 | this.yScale = this.getYScale();
|
7250 | this.setColors();
|
7251 | this.legendOptions = this.getLegendOptions();
|
7252 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
7253 | };
|
7254 | BarVerticalNormalizedComponent.prototype.getGroupDomain = function () {
|
7255 | var e_1, _a;
|
7256 | var domain = [];
|
7257 | try {
|
7258 | for (var _b = __values(this.results), _c = _b.next(); !_c.done; _c = _b.next()) {
|
7259 | var group = _c.value;
|
7260 | if (!domain.includes(group.label)) {
|
7261 | domain.push(group.label);
|
7262 | }
|
7263 | }
|
7264 | }
|
7265 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
7266 | finally {
|
7267 | try {
|
7268 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
7269 | }
|
7270 | finally { if (e_1) throw e_1.error; }
|
7271 | }
|
7272 | return domain;
|
7273 | };
|
7274 | BarVerticalNormalizedComponent.prototype.getInnerDomain = function () {
|
7275 | var e_2, _a, e_3, _b;
|
7276 | var domain = [];
|
7277 | try {
|
7278 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
7279 | var group = _d.value;
|
7280 | try {
|
7281 | for (var _e = (e_3 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
7282 | var d = _f.value;
|
7283 | if (!domain.includes(d.label)) {
|
7284 | domain.push(d.label);
|
7285 | }
|
7286 | }
|
7287 | }
|
7288 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
7289 | finally {
|
7290 | try {
|
7291 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
7292 | }
|
7293 | finally { if (e_3) throw e_3.error; }
|
7294 | }
|
7295 | }
|
7296 | }
|
7297 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
7298 | finally {
|
7299 | try {
|
7300 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
7301 | }
|
7302 | finally { if (e_2) throw e_2.error; }
|
7303 | }
|
7304 | return domain;
|
7305 | };
|
7306 | BarVerticalNormalizedComponent.prototype.getXScale = function () {
|
7307 | var spacing = this.groupDomain.length / (this.dims.width / this.barPadding + 1);
|
7308 | return d3Scale.scaleBand().rangeRound([0, this.dims.width]).paddingInner(spacing).domain(this.groupDomain);
|
7309 | };
|
7310 | BarVerticalNormalizedComponent.prototype.getYScale = function () {
|
7311 | var scale = d3Scale.scaleLinear().range([this.dims.height, 0]).domain(this.valueDomain);
|
7312 | return this.roundDomains ? scale.nice() : scale;
|
7313 | };
|
7314 | BarVerticalNormalizedComponent.prototype.groupTransform = function (group) {
|
7315 | return "translate(" + this.xScale(group.name) + ", 0)";
|
7316 | };
|
7317 | BarVerticalNormalizedComponent.prototype.onClick = function (data, group) {
|
7318 | if (group) {
|
7319 | data.series = group.name;
|
7320 | }
|
7321 | this.select.emit(data);
|
7322 | };
|
7323 | BarVerticalNormalizedComponent.prototype.setColors = function () {
|
7324 | var domain;
|
7325 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
7326 | domain = this.innerDomain;
|
7327 | }
|
7328 | else {
|
7329 | domain = this.valueDomain;
|
7330 | }
|
7331 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
7332 | };
|
7333 | BarVerticalNormalizedComponent.prototype.getLegendOptions = function () {
|
7334 | var opts = {
|
7335 | scaleType: this.schemeType,
|
7336 | colors: undefined,
|
7337 | domain: [],
|
7338 | title: undefined,
|
7339 | position: this.legendPosition
|
7340 | };
|
7341 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
7342 | opts.domain = this.innerDomain;
|
7343 | opts.colors = this.colors;
|
7344 | opts.title = this.legendTitle;
|
7345 | }
|
7346 | else {
|
7347 | opts.domain = this.valueDomain;
|
7348 | opts.colors = this.colors.scale;
|
7349 | }
|
7350 | return opts;
|
7351 | };
|
7352 | BarVerticalNormalizedComponent.prototype.updateYAxisWidth = function (_a) {
|
7353 | var width = _a.width;
|
7354 | this.yAxisWidth = width;
|
7355 | this.update();
|
7356 | };
|
7357 | BarVerticalNormalizedComponent.prototype.updateXAxisHeight = function (_a) {
|
7358 | var height = _a.height;
|
7359 | this.xAxisHeight = height;
|
7360 | this.update();
|
7361 | };
|
7362 | BarVerticalNormalizedComponent.prototype.onActivate = function (event, group, fromLegend) {
|
7363 | if (fromLegend === void 0) { fromLegend = false; }
|
7364 | var item = Object.assign({}, event);
|
7365 | if (group) {
|
7366 | item.series = group.name;
|
7367 | }
|
7368 | var items = this.results
|
7369 | .map(function (g) { return g.series; })
|
7370 | .flat()
|
7371 | .filter(function (i) {
|
7372 | if (fromLegend) {
|
7373 | return i.label === item.name;
|
7374 | }
|
7375 | else {
|
7376 | return i.name === item.name && i.series === item.series;
|
7377 | }
|
7378 | });
|
7379 | this.activeEntries = __spreadArray([], __read(items));
|
7380 | this.activate.emit({ value: item, entries: this.activeEntries });
|
7381 | };
|
7382 | BarVerticalNormalizedComponent.prototype.onDeactivate = function (event, group, fromLegend) {
|
7383 | if (fromLegend === void 0) { fromLegend = false; }
|
7384 | var item = Object.assign({}, event);
|
7385 | if (group) {
|
7386 | item.series = group.name;
|
7387 | }
|
7388 | this.activeEntries = this.activeEntries.filter(function (i) {
|
7389 | if (fromLegend) {
|
7390 | return i.label !== item.name;
|
7391 | }
|
7392 | else {
|
7393 | return !(i.name === item.name && i.series === item.series);
|
7394 | }
|
7395 | });
|
7396 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
7397 | };
|
7398 | return BarVerticalNormalizedComponent;
|
7399 | }(BaseChartComponent));
|
7400 | BarVerticalNormalizedComponent.decorators = [
|
7401 | { type: core.Component, args: [{
|
7402 | selector: 'ngx-charts-bar-vertical-normalized',
|
7403 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelActivate)=\"onActivate($event, undefined, true)\"\n (legendLabelDeactivate)=\"onDeactivate($event, undefined, true)\"\n (legendLabelClick)=\"onClick($event)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"bar-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g\n *ngFor=\"let group of results; trackBy: trackBy\"\n [@animationState]=\"'active'\"\n [attr.transform]=\"groupTransform(group)\"\n >\n <svg:g\n ngx-charts-series-vertical\n [type]=\"barChartType.Normalized\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [activeEntries]=\"activeEntries\"\n [colors]=\"colors\"\n [series]=\"group.series\"\n [dims]=\"dims\"\n [gradient]=\"gradient\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [seriesName]=\"group.name\"\n [animations]=\"animations\"\n [noBarWhenZero]=\"noBarWhenZero\"\n (select)=\"onClick($event, group)\"\n (activate)=\"onActivate($event, group)\"\n (deactivate)=\"onDeactivate($event, group)\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
7404 | encapsulation: core.ViewEncapsulation.None,
|
7405 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
7406 | animations: [
|
7407 | animations.trigger('animationState', [
|
7408 | animations.transition(':leave', [
|
7409 | animations.style({
|
7410 | opacity: 1,
|
7411 | transform: '*'
|
7412 | }),
|
7413 | animations.animate(500, animations.style({ opacity: 0, transform: 'scale(0)' }))
|
7414 | ])
|
7415 | ])
|
7416 | ],
|
7417 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
7418 | },] }
|
7419 | ];
|
7420 | BarVerticalNormalizedComponent.propDecorators = {
|
7421 | legend: [{ type: core.Input }],
|
7422 | legendTitle: [{ type: core.Input }],
|
7423 | legendPosition: [{ type: core.Input }],
|
7424 | xAxis: [{ type: core.Input }],
|
7425 | yAxis: [{ type: core.Input }],
|
7426 | showXAxisLabel: [{ type: core.Input }],
|
7427 | showYAxisLabel: [{ type: core.Input }],
|
7428 | xAxisLabel: [{ type: core.Input }],
|
7429 | yAxisLabel: [{ type: core.Input }],
|
7430 | tooltipDisabled: [{ type: core.Input }],
|
7431 | gradient: [{ type: core.Input }],
|
7432 | showGridLines: [{ type: core.Input }],
|
7433 | activeEntries: [{ type: core.Input }],
|
7434 | schemeType: [{ type: core.Input }],
|
7435 | trimXAxisTicks: [{ type: core.Input }],
|
7436 | trimYAxisTicks: [{ type: core.Input }],
|
7437 | rotateXAxisTicks: [{ type: core.Input }],
|
7438 | maxXAxisTickLength: [{ type: core.Input }],
|
7439 | maxYAxisTickLength: [{ type: core.Input }],
|
7440 | xAxisTickFormatting: [{ type: core.Input }],
|
7441 | yAxisTickFormatting: [{ type: core.Input }],
|
7442 | xAxisTicks: [{ type: core.Input }],
|
7443 | yAxisTicks: [{ type: core.Input }],
|
7444 | barPadding: [{ type: core.Input }],
|
7445 | roundDomains: [{ type: core.Input }],
|
7446 | noBarWhenZero: [{ type: core.Input }],
|
7447 | activate: [{ type: core.Output }],
|
7448 | deactivate: [{ type: core.Output }],
|
7449 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
7450 | };
|
7451 |
|
7452 | var BarVerticalStackedComponent = (function (_super) {
|
7453 | __extends(BarVerticalStackedComponent, _super);
|
7454 | function BarVerticalStackedComponent() {
|
7455 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
7456 | _this.legend = false;
|
7457 | _this.legendTitle = 'Legend';
|
7458 | _this.legendPosition = exports.LegendPosition.Right;
|
7459 | _this.tooltipDisabled = false;
|
7460 | _this.showGridLines = true;
|
7461 | _this.activeEntries = [];
|
7462 | _this.trimXAxisTicks = true;
|
7463 | _this.trimYAxisTicks = true;
|
7464 | _this.rotateXAxisTicks = true;
|
7465 | _this.maxXAxisTickLength = 16;
|
7466 | _this.maxYAxisTickLength = 16;
|
7467 | _this.barPadding = 8;
|
7468 | _this.roundDomains = false;
|
7469 | _this.showDataLabel = false;
|
7470 | _this.noBarWhenZero = true;
|
7471 | _this.activate = new core.EventEmitter();
|
7472 | _this.deactivate = new core.EventEmitter();
|
7473 | _this.margin = [10, 20, 10, 20];
|
7474 | _this.xAxisHeight = 0;
|
7475 | _this.yAxisWidth = 0;
|
7476 | _this.dataLabelMaxHeight = { negative: 0, positive: 0 };
|
7477 | _this.barChartType = exports.BarChartType;
|
7478 | _this.trackBy = function (index, item) {
|
7479 | return item.name;
|
7480 | };
|
7481 | return _this;
|
7482 | }
|
7483 | BarVerticalStackedComponent.prototype.update = function () {
|
7484 | _super.prototype.update.call(this);
|
7485 | if (!this.showDataLabel) {
|
7486 | this.dataLabelMaxHeight = { negative: 0, positive: 0 };
|
7487 | }
|
7488 | this.margin = [10 + this.dataLabelMaxHeight.positive, 20, 10 + this.dataLabelMaxHeight.negative, 20];
|
7489 | this.dims = calculateViewDimensions({
|
7490 | width: this.width,
|
7491 | height: this.height,
|
7492 | margins: this.margin,
|
7493 | showXAxis: this.xAxis,
|
7494 | showYAxis: this.yAxis,
|
7495 | xAxisHeight: this.xAxisHeight,
|
7496 | yAxisWidth: this.yAxisWidth,
|
7497 | showXLabel: this.showXAxisLabel,
|
7498 | showYLabel: this.showYAxisLabel,
|
7499 | showLegend: this.legend,
|
7500 | legendType: this.schemeType,
|
7501 | legendPosition: this.legendPosition
|
7502 | });
|
7503 | if (this.showDataLabel) {
|
7504 | this.dims.height -= this.dataLabelMaxHeight.negative;
|
7505 | }
|
7506 | this.formatDates();
|
7507 | this.groupDomain = this.getGroupDomain();
|
7508 | this.innerDomain = this.getInnerDomain();
|
7509 | this.valueDomain = this.getValueDomain();
|
7510 | this.xScale = this.getXScale();
|
7511 | this.yScale = this.getYScale();
|
7512 | this.setColors();
|
7513 | this.legendOptions = this.getLegendOptions();
|
7514 | this.transform = "translate(" + this.dims.xOffset + " , " + (this.margin[0] + this.dataLabelMaxHeight.negative) + ")";
|
7515 | };
|
7516 | BarVerticalStackedComponent.prototype.getGroupDomain = function () {
|
7517 | var e_1, _a;
|
7518 | var domain = [];
|
7519 | try {
|
7520 | for (var _b = __values(this.results), _c = _b.next(); !_c.done; _c = _b.next()) {
|
7521 | var group = _c.value;
|
7522 | if (!domain.includes(group.label)) {
|
7523 | domain.push(group.label);
|
7524 | }
|
7525 | }
|
7526 | }
|
7527 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
7528 | finally {
|
7529 | try {
|
7530 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
7531 | }
|
7532 | finally { if (e_1) throw e_1.error; }
|
7533 | }
|
7534 | return domain;
|
7535 | };
|
7536 | BarVerticalStackedComponent.prototype.getInnerDomain = function () {
|
7537 | var e_2, _a, e_3, _b;
|
7538 | var domain = [];
|
7539 | try {
|
7540 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
7541 | var group = _d.value;
|
7542 | try {
|
7543 | for (var _e = (e_3 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
7544 | var d = _f.value;
|
7545 | if (!domain.includes(d.label)) {
|
7546 | domain.push(d.label);
|
7547 | }
|
7548 | }
|
7549 | }
|
7550 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
7551 | finally {
|
7552 | try {
|
7553 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
7554 | }
|
7555 | finally { if (e_3) throw e_3.error; }
|
7556 | }
|
7557 | }
|
7558 | }
|
7559 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
7560 | finally {
|
7561 | try {
|
7562 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
7563 | }
|
7564 | finally { if (e_2) throw e_2.error; }
|
7565 | }
|
7566 | return domain;
|
7567 | };
|
7568 | BarVerticalStackedComponent.prototype.getValueDomain = function () {
|
7569 | var e_4, _a, e_5, _b;
|
7570 | var domain = [];
|
7571 | var smallest = 0;
|
7572 | var biggest = 0;
|
7573 | try {
|
7574 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
7575 | var group = _d.value;
|
7576 | var smallestSum = 0;
|
7577 | var biggestSum = 0;
|
7578 | try {
|
7579 | for (var _e = (e_5 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
7580 | var d = _f.value;
|
7581 | if (d.value < 0) {
|
7582 | smallestSum += d.value;
|
7583 | }
|
7584 | else {
|
7585 | biggestSum += d.value;
|
7586 | }
|
7587 | smallest = d.value < smallest ? d.value : smallest;
|
7588 | biggest = d.value > biggest ? d.value : biggest;
|
7589 | }
|
7590 | }
|
7591 | catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
7592 | finally {
|
7593 | try {
|
7594 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
7595 | }
|
7596 | finally { if (e_5) throw e_5.error; }
|
7597 | }
|
7598 | domain.push(smallestSum);
|
7599 | domain.push(biggestSum);
|
7600 | }
|
7601 | }
|
7602 | catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
7603 | finally {
|
7604 | try {
|
7605 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
7606 | }
|
7607 | finally { if (e_4) throw e_4.error; }
|
7608 | }
|
7609 | domain.push(smallest);
|
7610 | domain.push(biggest);
|
7611 | var min = Math.min.apply(Math, __spreadArray([0], __read(domain)));
|
7612 | var max = this.yScaleMax ? Math.max.apply(Math, __spreadArray([this.yScaleMax], __read(domain))) : Math.max.apply(Math, __spreadArray([], __read(domain)));
|
7613 | return [min, max];
|
7614 | };
|
7615 | BarVerticalStackedComponent.prototype.getXScale = function () {
|
7616 | var spacing = this.groupDomain.length / (this.dims.width / this.barPadding + 1);
|
7617 | return d3Scale.scaleBand().rangeRound([0, this.dims.width]).paddingInner(spacing).domain(this.groupDomain);
|
7618 | };
|
7619 | BarVerticalStackedComponent.prototype.getYScale = function () {
|
7620 | var scale = d3Scale.scaleLinear().range([this.dims.height, 0]).domain(this.valueDomain);
|
7621 | return this.roundDomains ? scale.nice() : scale;
|
7622 | };
|
7623 | BarVerticalStackedComponent.prototype.onDataLabelMaxHeightChanged = function (event, groupIndex) {
|
7624 | var _this = this;
|
7625 | if (event.size.negative) {
|
7626 | this.dataLabelMaxHeight.negative = Math.max(this.dataLabelMaxHeight.negative, event.size.height);
|
7627 | }
|
7628 | else {
|
7629 | this.dataLabelMaxHeight.positive = Math.max(this.dataLabelMaxHeight.positive, event.size.height);
|
7630 | }
|
7631 | if (groupIndex === this.results.length - 1) {
|
7632 | setTimeout(function () { return _this.update(); });
|
7633 | }
|
7634 | };
|
7635 | BarVerticalStackedComponent.prototype.groupTransform = function (group) {
|
7636 | return "translate(" + (this.xScale(group.name) || 0) + ", 0)";
|
7637 | };
|
7638 | BarVerticalStackedComponent.prototype.onClick = function (data, group) {
|
7639 | if (group) {
|
7640 | data.series = group.name;
|
7641 | }
|
7642 | this.select.emit(data);
|
7643 | };
|
7644 | BarVerticalStackedComponent.prototype.setColors = function () {
|
7645 | var domain;
|
7646 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
7647 | domain = this.innerDomain;
|
7648 | }
|
7649 | else {
|
7650 | domain = this.valueDomain;
|
7651 | }
|
7652 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
7653 | };
|
7654 | BarVerticalStackedComponent.prototype.getLegendOptions = function () {
|
7655 | var opts = {
|
7656 | scaleType: this.schemeType,
|
7657 | colors: undefined,
|
7658 | domain: [],
|
7659 | title: undefined,
|
7660 | position: this.legendPosition
|
7661 | };
|
7662 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
7663 | opts.domain = this.innerDomain;
|
7664 | opts.colors = this.colors;
|
7665 | opts.title = this.legendTitle;
|
7666 | }
|
7667 | else {
|
7668 | opts.domain = this.valueDomain;
|
7669 | opts.colors = this.colors.scale;
|
7670 | }
|
7671 | return opts;
|
7672 | };
|
7673 | BarVerticalStackedComponent.prototype.updateYAxisWidth = function (_a) {
|
7674 | var width = _a.width;
|
7675 | this.yAxisWidth = width;
|
7676 | this.update();
|
7677 | };
|
7678 | BarVerticalStackedComponent.prototype.updateXAxisHeight = function (_a) {
|
7679 | var height = _a.height;
|
7680 | this.xAxisHeight = height;
|
7681 | this.update();
|
7682 | };
|
7683 | BarVerticalStackedComponent.prototype.onActivate = function (event, group, fromLegend) {
|
7684 | if (fromLegend === void 0) { fromLegend = false; }
|
7685 | var item = Object.assign({}, event);
|
7686 | if (group) {
|
7687 | item.series = group.name;
|
7688 | }
|
7689 | var items = this.results
|
7690 | .map(function (g) { return g.series; })
|
7691 | .flat()
|
7692 | .filter(function (i) {
|
7693 | if (fromLegend) {
|
7694 | return i.label === item.name;
|
7695 | }
|
7696 | else {
|
7697 | return i.name === item.name && i.series === item.series;
|
7698 | }
|
7699 | });
|
7700 | this.activeEntries = __spreadArray([], __read(items));
|
7701 | this.activate.emit({ value: item, entries: this.activeEntries });
|
7702 | };
|
7703 | BarVerticalStackedComponent.prototype.onDeactivate = function (event, group, fromLegend) {
|
7704 | if (fromLegend === void 0) { fromLegend = false; }
|
7705 | var item = Object.assign({}, event);
|
7706 | if (group) {
|
7707 | item.series = group.name;
|
7708 | }
|
7709 | this.activeEntries = this.activeEntries.filter(function (i) {
|
7710 | if (fromLegend) {
|
7711 | return i.label !== item.name;
|
7712 | }
|
7713 | else {
|
7714 | return !(i.name === item.name && i.series === item.series);
|
7715 | }
|
7716 | });
|
7717 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
7718 | };
|
7719 | return BarVerticalStackedComponent;
|
7720 | }(BaseChartComponent));
|
7721 | BarVerticalStackedComponent.decorators = [
|
7722 | { type: core.Component, args: [{
|
7723 | selector: 'ngx-charts-bar-vertical-stacked',
|
7724 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelActivate)=\"onActivate($event, undefined, true)\"\n (legendLabelDeactivate)=\"onDeactivate($event, undefined, true)\"\n (legendLabelClick)=\"onClick($event)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"bar-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n [xAxisOffset]=\"dataLabelMaxHeight.negative\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g\n *ngFor=\"let group of results; let index = index; trackBy: trackBy\"\n [@animationState]=\"'active'\"\n [attr.transform]=\"groupTransform(group)\"\n >\n <svg:g\n ngx-charts-series-vertical\n [type]=\"barChartType.Stacked\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [activeEntries]=\"activeEntries\"\n [colors]=\"colors\"\n [series]=\"group.series\"\n [dims]=\"dims\"\n [gradient]=\"gradient\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [showDataLabel]=\"showDataLabel\"\n [dataLabelFormatting]=\"dataLabelFormatting\"\n [seriesName]=\"group.name\"\n [animations]=\"animations\"\n [noBarWhenZero]=\"noBarWhenZero\"\n (select)=\"onClick($event, group)\"\n (activate)=\"onActivate($event, group)\"\n (deactivate)=\"onDeactivate($event, group)\"\n (dataLabelHeightChanged)=\"onDataLabelMaxHeightChanged($event, index)\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
7725 | encapsulation: core.ViewEncapsulation.None,
|
7726 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
7727 | animations: [
|
7728 | animations.trigger('animationState', [
|
7729 | animations.transition(':leave', [
|
7730 | animations.style({
|
7731 | opacity: 1,
|
7732 | transform: '*'
|
7733 | }),
|
7734 | animations.animate(500, animations.style({ opacity: 0, transform: 'scale(0)' }))
|
7735 | ])
|
7736 | ])
|
7737 | ],
|
7738 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
7739 | },] }
|
7740 | ];
|
7741 | BarVerticalStackedComponent.propDecorators = {
|
7742 | legend: [{ type: core.Input }],
|
7743 | legendTitle: [{ type: core.Input }],
|
7744 | legendPosition: [{ type: core.Input }],
|
7745 | xAxis: [{ type: core.Input }],
|
7746 | yAxis: [{ type: core.Input }],
|
7747 | showXAxisLabel: [{ type: core.Input }],
|
7748 | showYAxisLabel: [{ type: core.Input }],
|
7749 | xAxisLabel: [{ type: core.Input }],
|
7750 | yAxisLabel: [{ type: core.Input }],
|
7751 | tooltipDisabled: [{ type: core.Input }],
|
7752 | gradient: [{ type: core.Input }],
|
7753 | showGridLines: [{ type: core.Input }],
|
7754 | activeEntries: [{ type: core.Input }],
|
7755 | schemeType: [{ type: core.Input }],
|
7756 | trimXAxisTicks: [{ type: core.Input }],
|
7757 | trimYAxisTicks: [{ type: core.Input }],
|
7758 | rotateXAxisTicks: [{ type: core.Input }],
|
7759 | maxXAxisTickLength: [{ type: core.Input }],
|
7760 | maxYAxisTickLength: [{ type: core.Input }],
|
7761 | xAxisTickFormatting: [{ type: core.Input }],
|
7762 | yAxisTickFormatting: [{ type: core.Input }],
|
7763 | xAxisTicks: [{ type: core.Input }],
|
7764 | yAxisTicks: [{ type: core.Input }],
|
7765 | barPadding: [{ type: core.Input }],
|
7766 | roundDomains: [{ type: core.Input }],
|
7767 | yScaleMax: [{ type: core.Input }],
|
7768 | showDataLabel: [{ type: core.Input }],
|
7769 | dataLabelFormatting: [{ type: core.Input }],
|
7770 | noBarWhenZero: [{ type: core.Input }],
|
7771 | activate: [{ type: core.Output }],
|
7772 | deactivate: [{ type: core.Output }],
|
7773 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
7774 | };
|
7775 |
|
7776 | exports.D0Types = void 0;
|
7777 | (function (D0Types) {
|
7778 | D0Types["positive"] = "positive";
|
7779 | D0Types["negative"] = "negative";
|
7780 | })(exports.D0Types || (exports.D0Types = {}));
|
7781 |
|
7782 | var SeriesHorizontal = (function () {
|
7783 | function SeriesHorizontal() {
|
7784 | this.type = exports.BarChartType.Standard;
|
7785 | this.tooltipDisabled = false;
|
7786 | this.animations = true;
|
7787 | this.showDataLabel = false;
|
7788 | this.noBarWhenZero = true;
|
7789 | this.select = new core.EventEmitter();
|
7790 | this.activate = new core.EventEmitter();
|
7791 | this.deactivate = new core.EventEmitter();
|
7792 | this.dataLabelWidthChanged = new core.EventEmitter();
|
7793 | this.barsForDataLabels = [];
|
7794 | this.barOrientation = exports.BarOrientation;
|
7795 | }
|
7796 | SeriesHorizontal.prototype.ngOnChanges = function (changes) {
|
7797 | this.update();
|
7798 | };
|
7799 | SeriesHorizontal.prototype.update = function () {
|
7800 | var _b;
|
7801 | var _this = this;
|
7802 | this.updateTooltipSettings();
|
7803 | var d0 = (_b = {},
|
7804 | _b[exports.D0Types.positive] = 0,
|
7805 | _b[exports.D0Types.negative] = 0,
|
7806 | _b);
|
7807 | var d0Type;
|
7808 | d0Type = exports.D0Types.positive;
|
7809 | var total;
|
7810 | if (this.type === exports.BarChartType.Normalized) {
|
7811 | total = this.series.map(function (d) { return d.value; }).reduce(function (sum, d) { return sum + d; }, 0);
|
7812 | }
|
7813 | var xScaleMin = Math.max(this.xScale.domain()[0], 0);
|
7814 | this.bars = this.series.map(function (d) {
|
7815 | var value = d.value;
|
7816 | var label = _this.getLabel(d);
|
7817 | var formattedLabel = formatLabel(label);
|
7818 | var roundEdges = _this.roundEdges;
|
7819 | d0Type = value > 0 ? exports.D0Types.positive : exports.D0Types.negative;
|
7820 | var bar = {
|
7821 | value: value,
|
7822 | label: label,
|
7823 | roundEdges: roundEdges,
|
7824 | data: d,
|
7825 | formattedLabel: formattedLabel
|
7826 | };
|
7827 | bar.height = _this.yScale.bandwidth();
|
7828 | if (_this.type === exports.BarChartType.Standard) {
|
7829 | bar.width = Math.abs(_this.xScale(value) - _this.xScale(xScaleMin));
|
7830 | if (value < 0) {
|
7831 | bar.x = _this.xScale(value);
|
7832 | }
|
7833 | else {
|
7834 | bar.x = _this.xScale(xScaleMin);
|
7835 | }
|
7836 | bar.y = _this.yScale(label);
|
7837 | }
|
7838 | else if (_this.type === exports.BarChartType.Stacked) {
|
7839 | var offset0 = d0[d0Type];
|
7840 | var offset1 = offset0 + value;
|
7841 | d0[d0Type] += value;
|
7842 | bar.width = _this.xScale(offset1) - _this.xScale(offset0);
|
7843 | bar.x = _this.xScale(offset0);
|
7844 | bar.y = 0;
|
7845 | bar.offset0 = offset0;
|
7846 | bar.offset1 = offset1;
|
7847 | }
|
7848 | else if (_this.type === exports.BarChartType.Normalized) {
|
7849 | var offset0 = d0[d0Type];
|
7850 | var offset1 = offset0 + value;
|
7851 | d0[d0Type] += value;
|
7852 | if (total > 0) {
|
7853 | offset0 = (offset0 * 100) / total;
|
7854 | offset1 = (offset1 * 100) / total;
|
7855 | }
|
7856 | else {
|
7857 | offset0 = 0;
|
7858 | offset1 = 0;
|
7859 | }
|
7860 | bar.width = _this.xScale(offset1) - _this.xScale(offset0);
|
7861 | bar.x = _this.xScale(offset0);
|
7862 | bar.y = 0;
|
7863 | bar.offset0 = offset0;
|
7864 | bar.offset1 = offset1;
|
7865 | value = (offset1 - offset0).toFixed(2) + '%';
|
7866 | }
|
7867 | if (_this.colors.scaleType === exports.ScaleType.Ordinal) {
|
7868 | bar.color = _this.colors.getColor(label);
|
7869 | }
|
7870 | else {
|
7871 | if (_this.type === exports.BarChartType.Standard) {
|
7872 | bar.color = _this.colors.getColor(value);
|
7873 | bar.gradientStops = _this.colors.getLinearGradientStops(value);
|
7874 | }
|
7875 | else {
|
7876 | bar.color = _this.colors.getColor(bar.offset1);
|
7877 | bar.gradientStops = _this.colors.getLinearGradientStops(bar.offset1, bar.offset0);
|
7878 | }
|
7879 | }
|
7880 | var tooltipLabel = formattedLabel;
|
7881 | bar.ariaLabel = formattedLabel + ' ' + value.toLocaleString();
|
7882 | if (_this.seriesName !== null && _this.seriesName !== undefined) {
|
7883 | tooltipLabel = _this.seriesName + " \u2022 " + formattedLabel;
|
7884 | bar.data.series = _this.seriesName;
|
7885 | bar.ariaLabel = _this.seriesName + ' ' + bar.ariaLabel;
|
7886 | }
|
7887 | bar.tooltipText = _this.tooltipDisabled
|
7888 | ? undefined
|
7889 | : "\n <span class=\"tooltip-label\">" + escapeLabel(tooltipLabel) + "</span>\n <span class=\"tooltip-val\">" + (_this.dataLabelFormatting ? _this.dataLabelFormatting(value) : value.toLocaleString()) + "</span>\n ";
|
7890 | return bar;
|
7891 | });
|
7892 | this.updateDataLabels();
|
7893 | };
|
7894 | SeriesHorizontal.prototype.updateDataLabels = function () {
|
7895 | var _this = this;
|
7896 | if (this.type === exports.BarChartType.Stacked) {
|
7897 | this.barsForDataLabels = [];
|
7898 | var section = {};
|
7899 | section.series = this.seriesName;
|
7900 | var totalPositive = this.series.map(function (d) { return d.value; }).reduce(function (sum, d) { return (d > 0 ? sum + d : sum); }, 0);
|
7901 | var totalNegative = this.series.map(function (d) { return d.value; }).reduce(function (sum, d) { return (d < 0 ? sum + d : sum); }, 0);
|
7902 | section.total = totalPositive + totalNegative;
|
7903 | section.x = 0;
|
7904 | section.y = 0;
|
7905 |
|
7906 | if (section.total > 0) {
|
7907 | section.width = this.xScale(totalPositive);
|
7908 | }
|
7909 | else {
|
7910 | section.width = this.xScale(totalNegative);
|
7911 | }
|
7912 | section.height = this.yScale.bandwidth();
|
7913 | this.barsForDataLabels.push(section);
|
7914 | }
|
7915 | else {
|
7916 | this.barsForDataLabels = this.series.map(function (d) {
|
7917 | var _a;
|
7918 | var section = {};
|
7919 | section.series = (_a = _this.seriesName) !== null && _a !== void 0 ? _a : d.label;
|
7920 | section.total = d.value;
|
7921 | section.x = _this.xScale(0);
|
7922 | section.y = _this.yScale(d.label);
|
7923 | section.width = _this.xScale(section.total) - _this.xScale(0);
|
7924 | section.height = _this.yScale.bandwidth();
|
7925 | return section;
|
7926 | });
|
7927 | }
|
7928 | };
|
7929 | SeriesHorizontal.prototype.updateTooltipSettings = function () {
|
7930 | this.tooltipPlacement = this.tooltipDisabled ? undefined : exports.PlacementTypes.Top;
|
7931 | this.tooltipType = this.tooltipDisabled ? undefined : exports.StyleTypes.tooltip;
|
7932 | };
|
7933 | SeriesHorizontal.prototype.isActive = function (entry) {
|
7934 | if (!this.activeEntries)
|
7935 | return false;
|
7936 | var item = this.activeEntries.find(function (active) {
|
7937 | return entry.name === active.name && entry.value === active.value;
|
7938 | });
|
7939 | return item !== undefined;
|
7940 | };
|
7941 | SeriesHorizontal.prototype.getLabel = function (dataItem) {
|
7942 | if (dataItem.label) {
|
7943 | return dataItem.label;
|
7944 | }
|
7945 | return dataItem.name;
|
7946 | };
|
7947 | SeriesHorizontal.prototype.trackBy = function (index, bar) {
|
7948 | return bar.label;
|
7949 | };
|
7950 | SeriesHorizontal.prototype.trackDataLabelBy = function (index, barLabel) {
|
7951 | return index + '#' + barLabel.series + '#' + barLabel.total;
|
7952 | };
|
7953 | SeriesHorizontal.prototype.click = function (data) {
|
7954 | this.select.emit(data);
|
7955 | };
|
7956 | return SeriesHorizontal;
|
7957 | }());
|
7958 | SeriesHorizontal.decorators = [
|
7959 | { type: core.Component, args: [{
|
7960 | selector: 'g[ngx-charts-series-horizontal]',
|
7961 | template: "\n <svg:g\n ngx-charts-bar\n *ngFor=\"let bar of bars; trackBy: trackBy\"\n [@animationState]=\"'active'\"\n [width]=\"bar.width\"\n [height]=\"bar.height\"\n [x]=\"bar.x\"\n [y]=\"bar.y\"\n [fill]=\"bar.color\"\n [stops]=\"bar.gradientStops\"\n [data]=\"bar.data\"\n [orientation]=\"barOrientation.Horizontal\"\n [roundEdges]=\"bar.roundEdges\"\n (select)=\"click($event)\"\n [gradient]=\"gradient\"\n [isActive]=\"isActive(bar.data)\"\n [ariaLabel]=\"bar.ariaLabel\"\n [animations]=\"animations\"\n (activate)=\"activate.emit($event)\"\n (deactivate)=\"deactivate.emit($event)\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"tooltipPlacement\"\n [tooltipType]=\"tooltipType\"\n [tooltipTitle]=\"tooltipTemplate ? undefined : bar.tooltipText\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"bar.data\"\n [noBarWhenZero]=\"noBarWhenZero\"\n ></svg:g>\n <svg:g *ngIf=\"showDataLabel\">\n <svg:g\n ngx-charts-bar-label\n *ngFor=\"let b of barsForDataLabels; let i = index; trackBy: trackDataLabelBy\"\n [barX]=\"b.x\"\n [barY]=\"b.y\"\n [barWidth]=\"b.width\"\n [barHeight]=\"b.height\"\n [value]=\"b.total\"\n [valueFormatting]=\"dataLabelFormatting\"\n [orientation]=\"barOrientation.Horizontal\"\n (dimensionsChanged)=\"dataLabelWidthChanged.emit({ size: $event, index: i })\"\n />\n </svg:g>\n ",
|
7962 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
7963 | animations: [
|
7964 | animations.trigger('animationState', [
|
7965 | animations.transition(':leave', [
|
7966 | animations.style({
|
7967 | opacity: 1
|
7968 | }),
|
7969 | animations.animate(500, animations.style({ opacity: 0 }))
|
7970 | ])
|
7971 | ])
|
7972 | ]
|
7973 | },] }
|
7974 | ];
|
7975 | SeriesHorizontal.propDecorators = {
|
7976 | dims: [{ type: core.Input }],
|
7977 | type: [{ type: core.Input }],
|
7978 | series: [{ type: core.Input }],
|
7979 | xScale: [{ type: core.Input }],
|
7980 | yScale: [{ type: core.Input }],
|
7981 | colors: [{ type: core.Input }],
|
7982 | tooltipDisabled: [{ type: core.Input }],
|
7983 | gradient: [{ type: core.Input }],
|
7984 | activeEntries: [{ type: core.Input }],
|
7985 | seriesName: [{ type: core.Input }],
|
7986 | tooltipTemplate: [{ type: core.Input }],
|
7987 | roundEdges: [{ type: core.Input }],
|
7988 | animations: [{ type: core.Input }],
|
7989 | showDataLabel: [{ type: core.Input }],
|
7990 | dataLabelFormatting: [{ type: core.Input }],
|
7991 | noBarWhenZero: [{ type: core.Input }],
|
7992 | select: [{ type: core.Output }],
|
7993 | activate: [{ type: core.Output }],
|
7994 | deactivate: [{ type: core.Output }],
|
7995 | dataLabelWidthChanged: [{ type: core.Output }]
|
7996 | };
|
7997 |
|
7998 | var SeriesVerticalComponent = (function () {
|
7999 | function SeriesVerticalComponent() {
|
8000 | this.type = exports.BarChartType.Standard;
|
8001 | this.tooltipDisabled = false;
|
8002 | this.animations = true;
|
8003 | this.showDataLabel = false;
|
8004 | this.noBarWhenZero = true;
|
8005 | this.select = new core.EventEmitter();
|
8006 | this.activate = new core.EventEmitter();
|
8007 | this.deactivate = new core.EventEmitter();
|
8008 | this.dataLabelHeightChanged = new core.EventEmitter();
|
8009 | this.barsForDataLabels = [];
|
8010 | this.barOrientation = exports.BarOrientation;
|
8011 | }
|
8012 | SeriesVerticalComponent.prototype.ngOnChanges = function (changes) {
|
8013 | this.update();
|
8014 | };
|
8015 | SeriesVerticalComponent.prototype.update = function () {
|
8016 | var _b;
|
8017 | var _this = this;
|
8018 | this.updateTooltipSettings();
|
8019 | var width;
|
8020 | if (this.series.length) {
|
8021 | width = this.xScale.bandwidth();
|
8022 | }
|
8023 | width = Math.round(width);
|
8024 | var yScaleMin = Math.max(this.yScale.domain()[0], 0);
|
8025 | var d0 = (_b = {},
|
8026 | _b[exports.D0Types.positive] = 0,
|
8027 | _b[exports.D0Types.negative] = 0,
|
8028 | _b);
|
8029 | var d0Type = exports.D0Types.positive;
|
8030 | var total;
|
8031 | if (this.type === exports.BarChartType.Normalized) {
|
8032 | total = this.series.map(function (d) { return d.value; }).reduce(function (sum, d) { return sum + d; }, 0);
|
8033 | }
|
8034 | this.bars = this.series.map(function (d, index) {
|
8035 | var value = d.value;
|
8036 | var label = _this.getLabel(d);
|
8037 | var formattedLabel = formatLabel(label);
|
8038 | var roundEdges = _this.roundEdges;
|
8039 | d0Type = value > 0 ? exports.D0Types.positive : exports.D0Types.negative;
|
8040 | var bar = {
|
8041 | value: value,
|
8042 | label: label,
|
8043 | roundEdges: roundEdges,
|
8044 | data: d,
|
8045 | width: width,
|
8046 | formattedLabel: formattedLabel,
|
8047 | height: 0,
|
8048 | x: 0,
|
8049 | y: 0
|
8050 | };
|
8051 | if (_this.type === exports.BarChartType.Standard) {
|
8052 | bar.height = Math.abs(_this.yScale(value) - _this.yScale(yScaleMin));
|
8053 | bar.x = _this.xScale(label);
|
8054 | if (value < 0) {
|
8055 | bar.y = _this.yScale(0);
|
8056 | }
|
8057 | else {
|
8058 | bar.y = _this.yScale(value);
|
8059 | }
|
8060 | }
|
8061 | else if (_this.type === exports.BarChartType.Stacked) {
|
8062 | var offset0 = d0[d0Type];
|
8063 | var offset1 = offset0 + value;
|
8064 | d0[d0Type] += value;
|
8065 | bar.height = _this.yScale(offset0) - _this.yScale(offset1);
|
8066 | bar.x = 0;
|
8067 | bar.y = _this.yScale(offset1);
|
8068 | bar.offset0 = offset0;
|
8069 | bar.offset1 = offset1;
|
8070 | }
|
8071 | else if (_this.type === exports.BarChartType.Normalized) {
|
8072 | var offset0 = d0[d0Type];
|
8073 | var offset1 = offset0 + value;
|
8074 | d0[d0Type] += value;
|
8075 | if (total > 0) {
|
8076 | offset0 = (offset0 * 100) / total;
|
8077 | offset1 = (offset1 * 100) / total;
|
8078 | }
|
8079 | else {
|
8080 | offset0 = 0;
|
8081 | offset1 = 0;
|
8082 | }
|
8083 | bar.height = _this.yScale(offset0) - _this.yScale(offset1);
|
8084 | bar.x = 0;
|
8085 | bar.y = _this.yScale(offset1);
|
8086 | bar.offset0 = offset0;
|
8087 | bar.offset1 = offset1;
|
8088 | value = (offset1 - offset0).toFixed(2) + '%';
|
8089 | }
|
8090 | if (_this.colors.scaleType === exports.ScaleType.Ordinal) {
|
8091 | bar.color = _this.colors.getColor(label);
|
8092 | }
|
8093 | else {
|
8094 | if (_this.type === exports.BarChartType.Standard) {
|
8095 | bar.color = _this.colors.getColor(value);
|
8096 | bar.gradientStops = _this.colors.getLinearGradientStops(value);
|
8097 | }
|
8098 | else {
|
8099 | bar.color = _this.colors.getColor(bar.offset1);
|
8100 | bar.gradientStops = _this.colors.getLinearGradientStops(bar.offset1, bar.offset0);
|
8101 | }
|
8102 | }
|
8103 | var tooltipLabel = formattedLabel;
|
8104 | bar.ariaLabel = formattedLabel + ' ' + value.toLocaleString();
|
8105 | if (_this.seriesName !== null && _this.seriesName !== undefined) {
|
8106 | tooltipLabel = _this.seriesName + " \u2022 " + formattedLabel;
|
8107 | bar.data.series = _this.seriesName;
|
8108 | bar.ariaLabel = _this.seriesName + ' ' + bar.ariaLabel;
|
8109 | }
|
8110 | bar.tooltipText = _this.tooltipDisabled
|
8111 | ? undefined
|
8112 | : "\n <span class=\"tooltip-label\">" + escapeLabel(tooltipLabel) + "</span>\n <span class=\"tooltip-val\">" + (_this.dataLabelFormatting ? _this.dataLabelFormatting(value) : value.toLocaleString()) + "</span>\n ";
|
8113 | return bar;
|
8114 | });
|
8115 | this.updateDataLabels();
|
8116 | };
|
8117 | SeriesVerticalComponent.prototype.updateDataLabels = function () {
|
8118 | var _this = this;
|
8119 | if (this.type === exports.BarChartType.Stacked) {
|
8120 | this.barsForDataLabels = [];
|
8121 | var section = {};
|
8122 | section.series = this.seriesName;
|
8123 | var totalPositive = this.series.map(function (d) { return d.value; }).reduce(function (sum, d) { return (d > 0 ? sum + d : sum); }, 0);
|
8124 | var totalNegative = this.series.map(function (d) { return d.value; }).reduce(function (sum, d) { return (d < 0 ? sum + d : sum); }, 0);
|
8125 | section.total = totalPositive + totalNegative;
|
8126 | section.x = 0;
|
8127 | section.y = 0;
|
8128 | if (section.total > 0) {
|
8129 | section.height = this.yScale(totalPositive);
|
8130 | }
|
8131 | else {
|
8132 | section.height = this.yScale(totalNegative);
|
8133 | }
|
8134 | section.width = this.xScale.bandwidth();
|
8135 | this.barsForDataLabels.push(section);
|
8136 | }
|
8137 | else {
|
8138 | this.barsForDataLabels = this.series.map(function (d) {
|
8139 | var _a;
|
8140 | var section = {};
|
8141 | section.series = (_a = _this.seriesName) !== null && _a !== void 0 ? _a : d.label;
|
8142 | section.total = d.value;
|
8143 | section.x = _this.xScale(d.label);
|
8144 | section.y = _this.yScale(0);
|
8145 | section.height = _this.yScale(section.total) - _this.yScale(0);
|
8146 | section.width = _this.xScale.bandwidth();
|
8147 | return section;
|
8148 | });
|
8149 | }
|
8150 | };
|
8151 | SeriesVerticalComponent.prototype.updateTooltipSettings = function () {
|
8152 | this.tooltipPlacement = this.tooltipDisabled ? undefined : exports.PlacementTypes.Top;
|
8153 | this.tooltipType = this.tooltipDisabled ? undefined : exports.StyleTypes.tooltip;
|
8154 | };
|
8155 | SeriesVerticalComponent.prototype.isActive = function (entry) {
|
8156 | if (!this.activeEntries)
|
8157 | return false;
|
8158 | var item = this.activeEntries.find(function (active) {
|
8159 | return entry.name === active.name && entry.value === active.value;
|
8160 | });
|
8161 | return item !== undefined;
|
8162 | };
|
8163 | SeriesVerticalComponent.prototype.onClick = function (data) {
|
8164 | this.select.emit(data);
|
8165 | };
|
8166 | SeriesVerticalComponent.prototype.getLabel = function (dataItem) {
|
8167 | if (dataItem.label) {
|
8168 | return dataItem.label;
|
8169 | }
|
8170 | return dataItem.name;
|
8171 | };
|
8172 | SeriesVerticalComponent.prototype.trackBy = function (index, bar) {
|
8173 | return bar.label;
|
8174 | };
|
8175 | SeriesVerticalComponent.prototype.trackDataLabelBy = function (index, barLabel) {
|
8176 | return index + '#' + barLabel.series + '#' + barLabel.total;
|
8177 | };
|
8178 | return SeriesVerticalComponent;
|
8179 | }());
|
8180 | SeriesVerticalComponent.decorators = [
|
8181 | { type: core.Component, args: [{
|
8182 | selector: 'g[ngx-charts-series-vertical]',
|
8183 | template: "\n <svg:g\n ngx-charts-bar\n *ngFor=\"let bar of bars; trackBy: trackBy\"\n [@animationState]=\"'active'\"\n [@.disabled]=\"!animations\"\n [width]=\"bar.width\"\n [height]=\"bar.height\"\n [x]=\"bar.x\"\n [y]=\"bar.y\"\n [fill]=\"bar.color\"\n [stops]=\"bar.gradientStops\"\n [data]=\"bar.data\"\n [orientation]=\"barOrientation.Vertical\"\n [roundEdges]=\"bar.roundEdges\"\n [gradient]=\"gradient\"\n [ariaLabel]=\"bar.ariaLabel\"\n [isActive]=\"isActive(bar.data)\"\n (select)=\"onClick($event)\"\n (activate)=\"activate.emit($event)\"\n (deactivate)=\"deactivate.emit($event)\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"tooltipPlacement\"\n [tooltipType]=\"tooltipType\"\n [tooltipTitle]=\"tooltipTemplate ? undefined : bar.tooltipText\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"bar.data\"\n [noBarWhenZero]=\"noBarWhenZero\"\n [animations]=\"animations\"\n ></svg:g>\n <svg:g *ngIf=\"showDataLabel\">\n <svg:g\n ngx-charts-bar-label\n *ngFor=\"let b of barsForDataLabels; let i = index; trackBy: trackDataLabelBy\"\n [barX]=\"b.x\"\n [barY]=\"b.y\"\n [barWidth]=\"b.width\"\n [barHeight]=\"b.height\"\n [value]=\"b.total\"\n [valueFormatting]=\"dataLabelFormatting\"\n [orientation]=\"barOrientation.Vertical\"\n (dimensionsChanged)=\"dataLabelHeightChanged.emit({ size: $event, index: i })\"\n />\n </svg:g>\n ",
|
8184 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
8185 | animations: [
|
8186 | animations.trigger('animationState', [
|
8187 | animations.transition(':leave', [
|
8188 | animations.style({
|
8189 | opacity: 1
|
8190 | }),
|
8191 | animations.animate(500, animations.style({ opacity: 0 }))
|
8192 | ])
|
8193 | ])
|
8194 | ]
|
8195 | },] }
|
8196 | ];
|
8197 | SeriesVerticalComponent.propDecorators = {
|
8198 | dims: [{ type: core.Input }],
|
8199 | type: [{ type: core.Input }],
|
8200 | series: [{ type: core.Input }],
|
8201 | xScale: [{ type: core.Input }],
|
8202 | yScale: [{ type: core.Input }],
|
8203 | colors: [{ type: core.Input }],
|
8204 | gradient: [{ type: core.Input }],
|
8205 | activeEntries: [{ type: core.Input }],
|
8206 | seriesName: [{ type: core.Input }],
|
8207 | tooltipDisabled: [{ type: core.Input }],
|
8208 | tooltipTemplate: [{ type: core.Input }],
|
8209 | roundEdges: [{ type: core.Input }],
|
8210 | animations: [{ type: core.Input }],
|
8211 | showDataLabel: [{ type: core.Input }],
|
8212 | dataLabelFormatting: [{ type: core.Input }],
|
8213 | noBarWhenZero: [{ type: core.Input }],
|
8214 | select: [{ type: core.Output }],
|
8215 | activate: [{ type: core.Output }],
|
8216 | deactivate: [{ type: core.Output }],
|
8217 | dataLabelHeightChanged: [{ type: core.Output }]
|
8218 | };
|
8219 |
|
8220 | var BarLabelComponent = (function () {
|
8221 | function BarLabelComponent(element) {
|
8222 | this.dimensionsChanged = new core.EventEmitter();
|
8223 | this.horizontalPadding = 2;
|
8224 | this.verticalPadding = 5;
|
8225 | this.element = element.nativeElement;
|
8226 | }
|
8227 | BarLabelComponent.prototype.ngOnChanges = function (changes) {
|
8228 | this.update();
|
8229 | };
|
8230 | BarLabelComponent.prototype.getSize = function () {
|
8231 | var h = this.element.getBoundingClientRect().height;
|
8232 | var w = this.element.getBoundingClientRect().width;
|
8233 | return { height: h, width: w, negative: this.value < 0 };
|
8234 | };
|
8235 | BarLabelComponent.prototype.ngAfterViewInit = function () {
|
8236 | this.dimensionsChanged.emit(this.getSize());
|
8237 | };
|
8238 | BarLabelComponent.prototype.update = function () {
|
8239 | if (this.valueFormatting) {
|
8240 | this.formatedValue = this.valueFormatting(this.value);
|
8241 | }
|
8242 | else {
|
8243 | this.formatedValue = formatLabel(this.value);
|
8244 | }
|
8245 | if (this.orientation === 'horizontal') {
|
8246 | this.x = this.barX + this.barWidth;
|
8247 |
|
8248 |
|
8249 | if (this.value < 0) {
|
8250 | this.x = this.x - this.horizontalPadding;
|
8251 | this.textAnchor = 'end';
|
8252 | }
|
8253 | else {
|
8254 | this.x = this.x + this.horizontalPadding;
|
8255 | this.textAnchor = 'start';
|
8256 | }
|
8257 | this.y = this.barY + this.barHeight / 2;
|
8258 | }
|
8259 | else {
|
8260 |
|
8261 | this.x = this.barX + this.barWidth / 2;
|
8262 | this.y = this.barY + this.barHeight;
|
8263 | if (this.value < 0) {
|
8264 | this.y = this.y + this.verticalPadding;
|
8265 | this.textAnchor = 'end';
|
8266 | }
|
8267 | else {
|
8268 | this.y = this.y - this.verticalPadding;
|
8269 | this.textAnchor = 'start';
|
8270 | }
|
8271 | this.transform = "rotate(-45, " + this.x + " , " + this.y + ")";
|
8272 | }
|
8273 | };
|
8274 | return BarLabelComponent;
|
8275 | }());
|
8276 | BarLabelComponent.decorators = [
|
8277 | { type: core.Component, args: [{
|
8278 | selector: 'g[ngx-charts-bar-label]',
|
8279 | template: "\n <svg:text\n class=\"textDataLabel\"\n alignment-baseline=\"middle\"\n [attr.text-anchor]=\"textAnchor\"\n [attr.transform]=\"transform\"\n [attr.x]=\"x\"\n [attr.y]=\"y\"\n >\n {{ formatedValue }}\n </svg:text>\n ",
|
8280 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
8281 | styles: [".textDataLabel{font-size:11px}\n"]
|
8282 | },] }
|
8283 | ];
|
8284 | BarLabelComponent.ctorParameters = function () { return [
|
8285 | { type: core.ElementRef }
|
8286 | ]; };
|
8287 | BarLabelComponent.propDecorators = {
|
8288 | value: [{ type: core.Input }],
|
8289 | valueFormatting: [{ type: core.Input }],
|
8290 | barX: [{ type: core.Input }],
|
8291 | barY: [{ type: core.Input }],
|
8292 | barWidth: [{ type: core.Input }],
|
8293 | barHeight: [{ type: core.Input }],
|
8294 | orientation: [{ type: core.Input }],
|
8295 | dimensionsChanged: [{ type: core.Output }]
|
8296 | };
|
8297 |
|
8298 | var BarChartModule = (function () {
|
8299 | function BarChartModule() {
|
8300 | }
|
8301 | return BarChartModule;
|
8302 | }());
|
8303 | BarChartModule.decorators = [
|
8304 | { type: core.NgModule, args: [{
|
8305 | imports: [ChartCommonModule],
|
8306 | declarations: [
|
8307 | BarComponent,
|
8308 | BarHorizontalComponent,
|
8309 | BarHorizontal2DComponent,
|
8310 | BarHorizontalNormalizedComponent,
|
8311 | BarHorizontalStackedComponent,
|
8312 | BarVerticalComponent,
|
8313 | BarVertical2DComponent,
|
8314 | BarVerticalNormalizedComponent,
|
8315 | BarVerticalStackedComponent,
|
8316 | BarLabelComponent,
|
8317 | SeriesHorizontal,
|
8318 | SeriesVerticalComponent
|
8319 | ],
|
8320 | exports: [
|
8321 | BarComponent,
|
8322 | BarHorizontalComponent,
|
8323 | BarHorizontal2DComponent,
|
8324 | BarHorizontalNormalizedComponent,
|
8325 | BarHorizontalStackedComponent,
|
8326 | BarVerticalComponent,
|
8327 | BarVertical2DComponent,
|
8328 | BarVerticalNormalizedComponent,
|
8329 | BarVerticalStackedComponent,
|
8330 | BarLabelComponent,
|
8331 | SeriesHorizontal,
|
8332 | SeriesVerticalComponent
|
8333 | ]
|
8334 | },] }
|
8335 | ];
|
8336 |
|
8337 | var BoxChartComponent = (function (_super) {
|
8338 | __extends(BoxChartComponent, _super);
|
8339 | function BoxChartComponent() {
|
8340 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
8341 |
|
8342 | _this.legend = false;
|
8343 | _this.legendPosition = exports.LegendPosition.Right;
|
8344 | _this.legendTitle = 'Legend';
|
8345 | _this.showGridLines = true;
|
8346 | _this.xAxis = true;
|
8347 | _this.yAxis = true;
|
8348 | _this.showXAxisLabel = true;
|
8349 | _this.showYAxisLabel = true;
|
8350 | _this.roundDomains = false;
|
8351 | _this.roundEdges = true;
|
8352 | _this.strokeColor = '#FFFFFF';
|
8353 | _this.strokeWidth = 2;
|
8354 | _this.tooltipDisabled = false;
|
8355 | _this.select = new core.EventEmitter();
|
8356 | _this.activate = new core.EventEmitter();
|
8357 | _this.deactivate = new core.EventEmitter();
|
8358 |
|
8359 | _this.margin = [10, 20, 10, 20];
|
8360 |
|
8361 | _this.xAxisHeight = 0;
|
8362 |
|
8363 | _this.yAxisWidth = 0;
|
8364 | return _this;
|
8365 | }
|
8366 | BoxChartComponent.prototype.trackBy = function (index, item) {
|
8367 | return item.name;
|
8368 | };
|
8369 | BoxChartComponent.prototype.update = function () {
|
8370 | _super.prototype.update.call(this);
|
8371 | this.dims = calculateViewDimensions({
|
8372 | width: this.width,
|
8373 | height: this.height,
|
8374 | margins: this.margin,
|
8375 | showXAxis: this.xAxis,
|
8376 | showYAxis: this.yAxis,
|
8377 | xAxisHeight: this.xAxisHeight,
|
8378 | yAxisWidth: this.yAxisWidth,
|
8379 | showXLabel: this.showXAxisLabel,
|
8380 | showYLabel: this.showYAxisLabel,
|
8381 | showLegend: this.legend,
|
8382 | legendPosition: this.legendPosition
|
8383 | });
|
8384 | this.xDomain = this.getXDomain();
|
8385 | this.yDomain = this.getYDomain();
|
8386 | this.seriesDomain = this.getSeriesDomain();
|
8387 | this.setScales();
|
8388 | this.setColors();
|
8389 | this.legendOptions = this.getLegendOptions();
|
8390 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
8391 | };
|
8392 | BoxChartComponent.prototype.setColors = function () {
|
8393 | var domain = [];
|
8394 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
8395 | domain = this.seriesDomain;
|
8396 | }
|
8397 | else {
|
8398 | domain = this.yDomain;
|
8399 | }
|
8400 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
8401 | };
|
8402 | BoxChartComponent.prototype.setScales = function () {
|
8403 | this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
8404 | this.yScale = this.getYScale(this.yDomain, this.dims.height);
|
8405 | };
|
8406 | BoxChartComponent.prototype.getXScale = function (domain, width) {
|
8407 | var scale = d3Scale.scaleBand()
|
8408 | .domain(domain.map(function (d) { return d.toString(); }))
|
8409 | .rangeRound([0, width])
|
8410 | .padding(0.5);
|
8411 | return scale;
|
8412 | };
|
8413 | BoxChartComponent.prototype.getYScale = function (domain, height) {
|
8414 | var scale = d3Scale.scaleLinear().domain(domain).range([height, 0]);
|
8415 | return this.roundDomains ? scale.nice() : scale;
|
8416 | };
|
8417 | BoxChartComponent.prototype.getUniqueBoxChartXDomainValues = function (results) {
|
8418 | var e_1, _a;
|
8419 | var valueSet = new Set();
|
8420 | try {
|
8421 | for (var results_1 = __values(results), results_1_1 = results_1.next(); !results_1_1.done; results_1_1 = results_1.next()) {
|
8422 | var result = results_1_1.value;
|
8423 | valueSet.add(result.name);
|
8424 | }
|
8425 | }
|
8426 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
8427 | finally {
|
8428 | try {
|
8429 | if (results_1_1 && !results_1_1.done && (_a = results_1.return)) _a.call(results_1);
|
8430 | }
|
8431 | finally { if (e_1) throw e_1.error; }
|
8432 | }
|
8433 | return Array.from(valueSet);
|
8434 | };
|
8435 | BoxChartComponent.prototype.getXDomain = function () {
|
8436 | var domain = [];
|
8437 | var values = this.getUniqueBoxChartXDomainValues(this.results);
|
8438 | var min;
|
8439 | var max;
|
8440 | if (typeof values[0] === 'string') {
|
8441 | domain = values.map(function (val) { return val.toString(); });
|
8442 | }
|
8443 | else if (typeof values[0] === 'number') {
|
8444 | var mappedValues = values.map(function (v) { return Number(v); });
|
8445 | min = Math.min.apply(Math, __spreadArray([], __read(mappedValues)));
|
8446 | max = Math.max.apply(Math, __spreadArray([], __read(mappedValues)));
|
8447 | domain = [min, max];
|
8448 | }
|
8449 | else {
|
8450 | var mappedValues = values.map(function (v) { return Number(new Date(v)); });
|
8451 | min = Math.min.apply(Math, __spreadArray([], __read(mappedValues)));
|
8452 | max = Math.max.apply(Math, __spreadArray([], __read(mappedValues)));
|
8453 | domain = [new Date(min), new Date(max)];
|
8454 | }
|
8455 | return domain;
|
8456 | };
|
8457 | BoxChartComponent.prototype.getYDomain = function () {
|
8458 | var e_2, _a, e_3, _b;
|
8459 | var domain = [];
|
8460 | try {
|
8461 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
8462 | var results = _d.value;
|
8463 | try {
|
8464 | for (var _e = (e_3 = void 0, __values(results.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
8465 | var d = _f.value;
|
8466 | if (domain.indexOf(d.value) < 0) {
|
8467 | domain.push(d.value);
|
8468 | }
|
8469 | }
|
8470 | }
|
8471 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
8472 | finally {
|
8473 | try {
|
8474 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
8475 | }
|
8476 | finally { if (e_3) throw e_3.error; }
|
8477 | }
|
8478 | }
|
8479 | }
|
8480 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
8481 | finally {
|
8482 | try {
|
8483 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
8484 | }
|
8485 | finally { if (e_2) throw e_2.error; }
|
8486 | }
|
8487 | var values = __spreadArray([], __read(domain));
|
8488 | var mappedValues = values.map(function (v) { return Number(v); });
|
8489 | var min = Math.min.apply(Math, __spreadArray([], __read(mappedValues)));
|
8490 | var max = Math.max.apply(Math, __spreadArray([], __read(mappedValues)));
|
8491 | return [min, max];
|
8492 | };
|
8493 | BoxChartComponent.prototype.getSeriesDomain = function () {
|
8494 | return this.results.map(function (d) { return "" + d.name; });
|
8495 | };
|
8496 | BoxChartComponent.prototype.updateYAxisWidth = function (_a) {
|
8497 | var width = _a.width;
|
8498 | this.yAxisWidth = width;
|
8499 | this.update();
|
8500 | };
|
8501 | BoxChartComponent.prototype.updateXAxisHeight = function (_a) {
|
8502 | var height = _a.height;
|
8503 | this.xAxisHeight = height;
|
8504 | this.update();
|
8505 | };
|
8506 | BoxChartComponent.prototype.onClick = function (data) {
|
8507 | this.select.emit(data);
|
8508 | };
|
8509 | BoxChartComponent.prototype.onActivate = function (data) {
|
8510 | this.activate.emit(data);
|
8511 | };
|
8512 | BoxChartComponent.prototype.onDeactivate = function (data) {
|
8513 | this.deactivate.emit(data);
|
8514 | };
|
8515 | BoxChartComponent.prototype.getLegendOptions = function () {
|
8516 | var legendOpts = {
|
8517 | scaleType: this.schemeType,
|
8518 | colors: this.colors,
|
8519 | domain: [],
|
8520 | position: this.legendPosition,
|
8521 | title: this.legendTitle
|
8522 | };
|
8523 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
8524 | legendOpts.domain = this.xDomain;
|
8525 | legendOpts.colors = this.colors;
|
8526 | }
|
8527 | else {
|
8528 | legendOpts.domain = this.yDomain;
|
8529 | legendOpts.colors = this.colors.scale;
|
8530 | }
|
8531 | return legendOpts;
|
8532 | };
|
8533 | return BoxChartComponent;
|
8534 | }(BaseChartComponent));
|
8535 | BoxChartComponent.decorators = [
|
8536 | { type: core.Component, args: [{
|
8537 | selector: 'ngx-charts-box-chart',
|
8538 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event)\"\n (legendLabelDeactivate)=\"onDeactivate($event)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"box-chart chart\">\n <svg:g\n ngx-charts-x-axis\n [showGridLines]=\"showGridLines\"\n [dims]=\"dims\"\n [xScale]=\"xScale\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n />\n <svg:g\n ngx-charts-y-axis\n [showGridLines]=\"showGridLines\"\n [dims]=\"dims\"\n [yScale]=\"yScale\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n />\n </svg:g>\n <svg:g [attr.transform]=\"transform\">\n <svg:g *ngFor=\"let result of results; trackBy: trackBy\">\n <svg:g\n ngx-charts-box-series\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [roundEdges]=\"roundEdges\"\n [strokeColor]=\"strokeColor\"\n [strokeWidth]=\"strokeWidth\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [series]=\"result\"\n [dims]=\"dims\"\n [animations]=\"animations\"\n [gradient]=\"gradient\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n (select)=\"onClick($event)\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
8539 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
8540 | encapsulation: core.ViewEncapsulation.None,
|
8541 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
8542 | },] }
|
8543 | ];
|
8544 | BoxChartComponent.propDecorators = {
|
8545 | legend: [{ type: core.Input }],
|
8546 | legendPosition: [{ type: core.Input }],
|
8547 | legendTitle: [{ type: core.Input }],
|
8548 | legendOptionsConfig: [{ type: core.Input }],
|
8549 | showGridLines: [{ type: core.Input }],
|
8550 | xAxis: [{ type: core.Input }],
|
8551 | yAxis: [{ type: core.Input }],
|
8552 | showXAxisLabel: [{ type: core.Input }],
|
8553 | showYAxisLabel: [{ type: core.Input }],
|
8554 | roundDomains: [{ type: core.Input }],
|
8555 | xAxisLabel: [{ type: core.Input }],
|
8556 | yAxisLabel: [{ type: core.Input }],
|
8557 | roundEdges: [{ type: core.Input }],
|
8558 | strokeColor: [{ type: core.Input }],
|
8559 | strokeWidth: [{ type: core.Input }],
|
8560 | tooltipDisabled: [{ type: core.Input }],
|
8561 | gradient: [{ type: core.Input }],
|
8562 | select: [{ type: core.Output }],
|
8563 | activate: [{ type: core.Output }],
|
8564 | deactivate: [{ type: core.Output }],
|
8565 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate', { static: false },] }]
|
8566 | };
|
8567 |
|
8568 | var BoxSeriesComponent = (function () {
|
8569 | function BoxSeriesComponent() {
|
8570 | this.animations = true;
|
8571 | this.tooltipDisabled = false;
|
8572 | this.gradient = false;
|
8573 | this.select = new core.EventEmitter();
|
8574 | this.activate = new core.EventEmitter();
|
8575 | this.deactivate = new core.EventEmitter();
|
8576 | }
|
8577 | BoxSeriesComponent.prototype.ngOnChanges = function (changes) {
|
8578 | this.update();
|
8579 | };
|
8580 | BoxSeriesComponent.prototype.onClick = function (data) {
|
8581 | this.select.emit(data);
|
8582 | };
|
8583 | BoxSeriesComponent.prototype.update = function () {
|
8584 | this.updateTooltipSettings();
|
8585 | var width = this.series && this.series.series.length ? Math.round(this.xScale.bandwidth()) : null;
|
8586 | var seriesName = this.series.name;
|
8587 |
|
8588 | this.counts = this.series.series;
|
8589 | var mappedCounts = this.counts.map(function (serie) { return Number(serie.value); });
|
8590 | this.whiskers = [d3Array.min(mappedCounts), d3Array.max(mappedCounts)];
|
8591 |
|
8592 | var groupCounts = this.counts.map(function (item) { return item.value; }).sort(function (a, b) { return Number(a) - Number(b); });
|
8593 | this.quartiles = this.getBoxQuantiles(groupCounts);
|
8594 | this.lineCoordinates = this.getLinesCoordinates(seriesName.toString(), this.whiskers, this.quartiles, width);
|
8595 | var value = this.quartiles[1];
|
8596 | var formattedLabel = formatLabel(seriesName);
|
8597 | var box = {
|
8598 | value: value,
|
8599 | data: this.counts,
|
8600 | label: seriesName,
|
8601 | formattedLabel: formattedLabel,
|
8602 | width: width,
|
8603 | height: 0,
|
8604 | x: 0,
|
8605 | y: 0,
|
8606 | roundEdges: this.roundEdges,
|
8607 | quartiles: this.quartiles,
|
8608 | lineCoordinates: this.lineCoordinates
|
8609 | };
|
8610 | box.height = Math.abs(this.yScale(this.quartiles[0]) - this.yScale(this.quartiles[2]));
|
8611 | box.x = this.xScale(seriesName.toString());
|
8612 | box.y = this.yScale(this.quartiles[2]);
|
8613 | box.ariaLabel = formattedLabel + ' - Median: ' + value.toLocaleString();
|
8614 | if (this.colors.scaleType === exports.ScaleType.Ordinal) {
|
8615 | box.color = this.colors.getColor(seriesName);
|
8616 | }
|
8617 | else {
|
8618 | box.color = this.colors.getColor(this.quartiles[1]);
|
8619 | box.gradientStops = this.colors.getLinearGradientStops(this.quartiles[0], this.quartiles[2]);
|
8620 | }
|
8621 | var tooltipLabel = formattedLabel;
|
8622 | var formattedTooltipLabel = "\n <span class=\"tooltip-label\">" + escapeLabel(tooltipLabel) + "</span>\n <span class=\"tooltip-val\">\n \u2022 Q1: " + this.quartiles[0] + " \u2022 Q2: " + this.quartiles[1] + " \u2022 Q3: " + this.quartiles[2] + "<br>\n \u2022 Min: " + this.whiskers[0] + " \u2022 Max: " + this.whiskers[1] + "\n </span>";
|
8623 | box.tooltipText = this.tooltipDisabled ? undefined : formattedTooltipLabel;
|
8624 | this.tooltipTitle = this.tooltipDisabled ? undefined : box.tooltipText;
|
8625 | this.box = box;
|
8626 | };
|
8627 | BoxSeriesComponent.prototype.getBoxQuantiles = function (inputData) {
|
8628 | return [d3Array.quantile(inputData, 0.25), d3Array.quantile(inputData, 0.5), d3Array.quantile(inputData, 0.75)];
|
8629 | };
|
8630 | BoxSeriesComponent.prototype.getLinesCoordinates = function (seriesName, whiskers, quartiles, barWidth) {
|
8631 |
|
8632 | var commonX = this.xScale(seriesName);
|
8633 | var offsetX = commonX + barWidth / 2;
|
8634 | var medianLineWidth = Math.max(barWidth + 4 * this.strokeWidth, 1);
|
8635 | var whiskerLineWidth = Math.max(barWidth / 3, 1);
|
8636 | var whiskerZero = this.yScale(whiskers[0]);
|
8637 | var whiskerOne = this.yScale(whiskers[1]);
|
8638 | var median = this.yScale(quartiles[1]);
|
8639 | var topLine = {
|
8640 | v1: { x: offsetX + whiskerLineWidth / 2, y: whiskerZero },
|
8641 | v2: { x: offsetX - whiskerLineWidth / 2, y: whiskerZero }
|
8642 | };
|
8643 | var medianLine = {
|
8644 | v1: { x: offsetX + medianLineWidth / 2, y: median },
|
8645 | v2: { x: offsetX - medianLineWidth / 2, y: median }
|
8646 | };
|
8647 | var bottomLine = {
|
8648 | v1: { x: offsetX + whiskerLineWidth / 2, y: whiskerOne },
|
8649 | v2: { x: offsetX - whiskerLineWidth / 2, y: whiskerOne }
|
8650 | };
|
8651 | var verticalLine = {
|
8652 | v1: { x: offsetX, y: whiskerZero },
|
8653 | v2: { x: offsetX, y: whiskerOne }
|
8654 | };
|
8655 | return [verticalLine, topLine, medianLine, bottomLine];
|
8656 | };
|
8657 | BoxSeriesComponent.prototype.updateTooltipSettings = function () {
|
8658 | if (this.tooltipDisabled) {
|
8659 | this.tooltipPlacement = undefined;
|
8660 | this.tooltipType = undefined;
|
8661 | }
|
8662 | else {
|
8663 | if (!this.tooltipPlacement) {
|
8664 | this.tooltipPlacement = exports.PlacementTypes.Top;
|
8665 | }
|
8666 | if (!this.tooltipType) {
|
8667 | this.tooltipType = exports.StyleTypes.tooltip;
|
8668 | }
|
8669 | }
|
8670 | };
|
8671 | return BoxSeriesComponent;
|
8672 | }());
|
8673 | BoxSeriesComponent.decorators = [
|
8674 | { type: core.Component, args: [{
|
8675 | selector: 'g[ngx-charts-box-series]',
|
8676 | template: "\n <svg:g\n ngx-charts-box\n [@animationState]=\"'active'\"\n [@.disabled]=\"!animations\"\n [width]=\"box.width\"\n [height]=\"box.height\"\n [x]=\"box.x\"\n [y]=\"box.y\"\n [roundEdges]=\"box.roundEdges\"\n [fill]=\"box.color\"\n [gradientStops]=\"box.gradientStops\"\n [strokeColor]=\"strokeColor\"\n [strokeWidth]=\"strokeWidth\"\n [data]=\"box.data\"\n [lineCoordinates]=\"box.lineCoordinates\"\n [gradient]=\"gradient\"\n [ariaLabel]=\"box.ariaLabel\"\n (select)=\"onClick($event)\"\n (activate)=\"activate.emit($event)\"\n (deactivate)=\"deactivate.emit($event)\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"tooltipPlacement\"\n [tooltipType]=\"tooltipType\"\n [tooltipTitle]=\"tooltipTitle\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"box.data\"\n [animations]=\"animations\"\n ></svg:g>\n ",
|
8677 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
8678 | animations: [
|
8679 | animations.trigger('animationState', [
|
8680 | animations.transition(':leave', [
|
8681 | animations.style({
|
8682 | opacity: 1
|
8683 | }),
|
8684 | animations.animate(500, animations.style({ opacity: 0 }))
|
8685 | ])
|
8686 | ])
|
8687 | ]
|
8688 | },] }
|
8689 | ];
|
8690 | BoxSeriesComponent.propDecorators = {
|
8691 | dims: [{ type: core.Input }],
|
8692 | series: [{ type: core.Input }],
|
8693 | xScale: [{ type: core.Input }],
|
8694 | yScale: [{ type: core.Input }],
|
8695 | colors: [{ type: core.Input }],
|
8696 | animations: [{ type: core.Input }],
|
8697 | strokeColor: [{ type: core.Input }],
|
8698 | strokeWidth: [{ type: core.Input }],
|
8699 | tooltipDisabled: [{ type: core.Input }],
|
8700 | tooltipTemplate: [{ type: core.Input }],
|
8701 | tooltipPlacement: [{ type: core.Input }],
|
8702 | tooltipType: [{ type: core.Input }],
|
8703 | roundEdges: [{ type: core.Input }],
|
8704 | gradient: [{ type: core.Input }],
|
8705 | select: [{ type: core.Output }],
|
8706 | activate: [{ type: core.Output }],
|
8707 | deactivate: [{ type: core.Output }]
|
8708 | };
|
8709 |
|
8710 | var BoxComponent = (function () {
|
8711 | function BoxComponent(element, cd) {
|
8712 | this.cd = cd;
|
8713 | this.roundEdges = true;
|
8714 | this.gradient = false;
|
8715 | this.offset = 0;
|
8716 | this.isActive = false;
|
8717 | this.animations = true;
|
8718 | this.noBarWhenZero = true;
|
8719 | this.select = new core.EventEmitter();
|
8720 | this.activate = new core.EventEmitter();
|
8721 | this.deactivate = new core.EventEmitter();
|
8722 | this.BarOrientation = exports.BarOrientation;
|
8723 | this.initialized = false;
|
8724 | this.hasGradient = false;
|
8725 | this.hideBar = false;
|
8726 | this.nativeElm = element.nativeElement;
|
8727 | }
|
8728 | BoxComponent.prototype.ngOnChanges = function (changes) {
|
8729 | if (!this.initialized) {
|
8730 | this.loadAnimation();
|
8731 | this.initialized = true;
|
8732 | }
|
8733 | else {
|
8734 | this.update();
|
8735 | }
|
8736 | };
|
8737 | BoxComponent.prototype.update = function () {
|
8738 | this.boxStrokeWidth = Math.max(this.strokeWidth, 1);
|
8739 | this.whiskerStrokeWidth = Math.max(this.strokeWidth / 2, 1);
|
8740 | this.medianLineWidth = 1.5 * this.strokeWidth;
|
8741 | this.gradientId = 'grad' + id().toString();
|
8742 | this.gradientFill = "url(#" + this.gradientId + ")";
|
8743 | if (this.gradient) {
|
8744 | this.gradientStops = this.getGradient();
|
8745 | this.hasGradient = true;
|
8746 | }
|
8747 | else {
|
8748 | this.hasGradient = false;
|
8749 | }
|
8750 | this.updateLineEl();
|
8751 | this.updatePathEl();
|
8752 | this.checkToHideBar();
|
8753 | this.maskLineId = 'mask' + id().toString();
|
8754 | this.maskLine = "url(#" + this.maskLineId + ")";
|
8755 | if (this.cd) {
|
8756 | this.cd.markForCheck();
|
8757 | }
|
8758 | };
|
8759 | BoxComponent.prototype.loadAnimation = function () {
|
8760 | this.boxPath = this.oldPath = this.getStartingPath();
|
8761 | this.oldLineCoordinates = this.getStartingLineCoordinates();
|
8762 | setTimeout(this.update.bind(this), 100);
|
8763 | };
|
8764 | BoxComponent.prototype.updatePathEl = function () {
|
8765 | var nodeBar = d3Selection.select(this.nativeElm).selectAll('.bar');
|
8766 | var path = this.getPath();
|
8767 | if (this.animations) {
|
8768 | nodeBar
|
8769 | .attr('d', this.oldPath)
|
8770 | .transition()
|
8771 | .ease(d3Ease.easeSinInOut)
|
8772 | .duration(500)
|
8773 | .attrTween('d', this.pathTween(path, 4));
|
8774 | }
|
8775 | else {
|
8776 | nodeBar.attr('d', path);
|
8777 | }
|
8778 | this.oldPath = path;
|
8779 | };
|
8780 | BoxComponent.prototype.updateLineEl = function () {
|
8781 | var lineEl = d3Selection.select(this.nativeElm).selectAll('.bar-line');
|
8782 | var lineCoordinates = this.lineCoordinates;
|
8783 | var oldLineCoordinates = this.oldLineCoordinates;
|
8784 | if (this.animations) {
|
8785 | lineEl
|
8786 | .attr('x1', function (_, index) { return oldLineCoordinates[index].v1.x; })
|
8787 | .attr('y1', function (_, index) { return oldLineCoordinates[index].v1.y; })
|
8788 | .attr('x2', function (_, index) { return oldLineCoordinates[index].v2.x; })
|
8789 | .attr('y2', function (_, index) { return oldLineCoordinates[index].v2.y; })
|
8790 | .transition()
|
8791 | .ease(d3Ease.easeSinInOut)
|
8792 | .duration(500)
|
8793 | .attr('x1', function (_, index) { return lineCoordinates[index].v1.x; })
|
8794 | .attr('y1', function (_, index) { return lineCoordinates[index].v1.y; })
|
8795 | .attr('x2', function (_, index) { return lineCoordinates[index].v2.x; })
|
8796 | .attr('y2', function (_, index) { return lineCoordinates[index].v2.y; });
|
8797 | }
|
8798 | else {
|
8799 | lineEl
|
8800 | .attr('x1', function (_, index) { return lineCoordinates[index].v1.x; })
|
8801 | .attr('y1', function (_, index) { return lineCoordinates[index].v1.y; })
|
8802 | .attr('x2', function (_, index) { return lineCoordinates[index].v2.x; })
|
8803 | .attr('y2', function (_, index) { return lineCoordinates[index].v2.y; });
|
8804 | }
|
8805 | this.oldLineCoordinates = __spreadArray([], __read(lineCoordinates));
|
8806 | };
|
8807 | |
8808 |
|
8809 |
|
8810 |
|
8811 |
|
8812 |
|
8813 | BoxComponent.prototype.lineTween = function (attr, d, index, node) {
|
8814 | var nodeLineEl = node[index];
|
8815 | return nodeLineEl[attr].baseVal.value;
|
8816 | };
|
8817 |
|
8818 | BoxComponent.prototype.pathTween = function (d1, precision) {
|
8819 | return function () {
|
8820 |
|
8821 | var path0 = this;
|
8822 | var path1 = this.cloneNode();
|
8823 | path1.setAttribute('d', d1);
|
8824 | var n0 = path0 === null || path0 === void 0 ? void 0 : path0.getTotalLength();
|
8825 | var n1 = path1 === null || path1 === void 0 ? void 0 : path1.getTotalLength();
|
8826 |
|
8827 | var distances = [0];
|
8828 | var i = 0;
|
8829 | var dt = precision / Math.max(n0, n1);
|
8830 | while (i < 1) {
|
8831 | distances.push(i);
|
8832 | i += dt;
|
8833 | }
|
8834 | distances.push(1);
|
8835 |
|
8836 | var points = distances.map(function (t) {
|
8837 | var p0 = path0.getPointAtLength(t * n0);
|
8838 | var p1 = path1.getPointAtLength(t * n1);
|
8839 | return d3Interpolate.interpolate([p0.x, p0.y], [p1.x, p1.y]);
|
8840 | });
|
8841 |
|
8842 | return function (t) {
|
8843 | return t < 1 ? 'M' + points.map(function (p) { return p(t); }).join('L') : d1;
|
8844 | };
|
8845 | };
|
8846 | };
|
8847 | BoxComponent.prototype.getStartingPath = function () {
|
8848 | if (!this.animations) {
|
8849 | return this.getPath();
|
8850 | }
|
8851 | var radius = this.roundEdges ? 1 : 0;
|
8852 | var _a = this.lineCoordinates[2].v1, x = _a.x, y = _a.y;
|
8853 | return roundedRect(x - this.width, y - 1, this.width, 2, radius, this.edges);
|
8854 | };
|
8855 | BoxComponent.prototype.getPath = function () {
|
8856 | var radius = this.getRadius();
|
8857 | var path = '';
|
8858 | path = roundedRect(this.x, this.y, this.width, this.height, Math.min(this.height, radius), this.edges);
|
8859 | return path;
|
8860 | };
|
8861 | BoxComponent.prototype.getStartingLineCoordinates = function () {
|
8862 | if (!this.animations) {
|
8863 | return __spreadArray([], __read(this.lineCoordinates));
|
8864 | }
|
8865 | var lineCoordinates = cloneDeep__default['default'](this.lineCoordinates);
|
8866 | lineCoordinates[1].v1.y = lineCoordinates[1].v2.y = lineCoordinates[3].v1.y = lineCoordinates[3].v2.y = lineCoordinates[0].v1.y = lineCoordinates[0].v2.y =
|
8867 | lineCoordinates[2].v1.y;
|
8868 | return lineCoordinates;
|
8869 | };
|
8870 | BoxComponent.prototype.getRadius = function () {
|
8871 | var radius = 0;
|
8872 | if (this.roundEdges && this.height > 5 && this.width > 5) {
|
8873 | radius = Math.floor(Math.min(5, this.height / 2, this.width / 2));
|
8874 | }
|
8875 | return radius;
|
8876 | };
|
8877 | BoxComponent.prototype.getGradient = function () {
|
8878 | return [
|
8879 | {
|
8880 | offset: 0,
|
8881 | color: this.fill,
|
8882 | opacity: this.getStartOpacity()
|
8883 | },
|
8884 | {
|
8885 | offset: 100,
|
8886 | color: this.fill,
|
8887 | opacity: 1
|
8888 | }
|
8889 | ];
|
8890 | };
|
8891 | BoxComponent.prototype.getStartOpacity = function () {
|
8892 | if (this.roundEdges) {
|
8893 | return 0.2;
|
8894 | }
|
8895 | else {
|
8896 | return 0.5;
|
8897 | }
|
8898 | };
|
8899 | Object.defineProperty(BoxComponent.prototype, "edges", {
|
8900 | get: function () {
|
8901 | var edges = [false, false, false, false];
|
8902 | if (this.roundEdges) {
|
8903 | edges = [true, true, true, true];
|
8904 | }
|
8905 | return edges;
|
8906 | },
|
8907 | enumerable: false,
|
8908 | configurable: true
|
8909 | });
|
8910 | BoxComponent.prototype.onMouseEnter = function () {
|
8911 | this.activate.emit(this.data);
|
8912 | };
|
8913 | BoxComponent.prototype.onMouseLeave = function () {
|
8914 | this.deactivate.emit(this.data);
|
8915 | };
|
8916 | BoxComponent.prototype.checkToHideBar = function () {
|
8917 | this.hideBar = this.noBarWhenZero && this.height === 0;
|
8918 | };
|
8919 | return BoxComponent;
|
8920 | }());
|
8921 | BoxComponent.decorators = [
|
8922 | { type: core.Component, args: [{
|
8923 | selector: 'g[ngx-charts-box]',
|
8924 | template: "\n <svg:defs>\n <svg:g\n *ngIf=\"hasGradient\"\n ngx-charts-svg-linear-gradient\n [orientation]=\"BarOrientation.Vertical\"\n [name]=\"gradientId\"\n [stops]=\"gradientStops\"\n />\n <svg:mask [attr.id]=\"maskLineId\">\n <svg:g>\n <rect height=\"100%\" width=\"100%\" fill=\"white\" fill-opacity=\"1\" />\n <path class=\"bar\" [attr.d]=\"boxPath\" fill=\"black\" fill-opacity=\"1\" />\n </svg:g>\n </svg:mask>\n </svg:defs>\n <svg:g>\n <svg:path\n class=\"bar\"\n role=\"img\"\n tabIndex=\"-1\"\n [class.active]=\"isActive\"\n [class.hidden]=\"hideBar\"\n [attr.d]=\"boxPath\"\n [attr.stroke]=\"strokeColor\"\n [attr.stroke-width]=\"boxStrokeWidth\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.fill]=\"hasGradient ? gradientFill : fill\"\n (click)=\"select.emit(data)\"\n />\n <svg:line\n *ngFor=\"let line of lineCoordinates; let i = index\"\n class=\"bar-line\"\n [class.hidden]=\"hideBar\"\n [attr.x1]=\"line.v1.x\"\n [attr.y1]=\"line.v1.y\"\n [attr.x2]=\"line.v2.x\"\n [attr.y2]=\"line.v2.y\"\n [attr.stroke]=\"strokeColor\"\n [attr.stroke-width]=\"i === 2 ? medianLineWidth : whiskerStrokeWidth\"\n [attr.mask]=\"i ? undefined : maskLine\"\n fill=\"none\"\n />\n </svg:g>\n ",
|
8925 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
8926 | },] }
|
8927 | ];
|
8928 | BoxComponent.ctorParameters = function () { return [
|
8929 | { type: core.ElementRef },
|
8930 | { type: core.ChangeDetectorRef }
|
8931 | ]; };
|
8932 | BoxComponent.propDecorators = {
|
8933 | strokeColor: [{ type: core.Input }],
|
8934 | strokeWidth: [{ type: core.Input }],
|
8935 | fill: [{ type: core.Input }],
|
8936 | data: [{ type: core.Input }],
|
8937 | width: [{ type: core.Input }],
|
8938 | height: [{ type: core.Input }],
|
8939 | x: [{ type: core.Input }],
|
8940 | y: [{ type: core.Input }],
|
8941 | lineCoordinates: [{ type: core.Input }],
|
8942 | roundEdges: [{ type: core.Input }],
|
8943 | gradient: [{ type: core.Input }],
|
8944 | gradientStops: [{ type: core.Input }],
|
8945 | offset: [{ type: core.Input }],
|
8946 | isActive: [{ type: core.Input }],
|
8947 | animations: [{ type: core.Input }],
|
8948 | ariaLabel: [{ type: core.Input }],
|
8949 | noBarWhenZero: [{ type: core.Input }],
|
8950 | select: [{ type: core.Output }],
|
8951 | activate: [{ type: core.Output }],
|
8952 | deactivate: [{ type: core.Output }],
|
8953 | onMouseEnter: [{ type: core.HostListener, args: ['mouseenter',] }],
|
8954 | onMouseLeave: [{ type: core.HostListener, args: ['mouseleave',] }]
|
8955 | };
|
8956 |
|
8957 | var BoxChartModule = (function () {
|
8958 | function BoxChartModule() {
|
8959 | }
|
8960 | return BoxChartModule;
|
8961 | }());
|
8962 | BoxChartModule.decorators = [
|
8963 | { type: core.NgModule, args: [{
|
8964 | imports: [ChartCommonModule],
|
8965 | declarations: [BoxChartComponent, BoxSeriesComponent, BoxComponent],
|
8966 | exports: [BoxChartComponent, BoxSeriesComponent, BoxComponent]
|
8967 | },] }
|
8968 | ];
|
8969 |
|
8970 | function getDomain(values, scaleType, autoScale, minVal, maxVal) {
|
8971 | var domain = [];
|
8972 | if (scaleType === exports.ScaleType.Linear) {
|
8973 | values = values.map(function (v) { return Number(v); });
|
8974 | if (!autoScale) {
|
8975 | values.push(0);
|
8976 | }
|
8977 | }
|
8978 | if (scaleType === exports.ScaleType.Time || scaleType === exports.ScaleType.Linear) {
|
8979 | var min = minVal ? minVal : Math.min.apply(Math, __spreadArray([], __read(values)));
|
8980 | var max = maxVal ? maxVal : Math.max.apply(Math, __spreadArray([], __read(values)));
|
8981 | domain = [min, max];
|
8982 | }
|
8983 | else {
|
8984 | domain = values;
|
8985 | }
|
8986 | return domain;
|
8987 | }
|
8988 | function getScale(domain, range, scaleType, roundDomains) {
|
8989 | switch (scaleType) {
|
8990 | case exports.ScaleType.Time:
|
8991 | return d3Scale.scaleTime().range(range).domain(domain);
|
8992 | case exports.ScaleType.Linear: {
|
8993 | var scale = d3Scale.scaleLinear().range(range).domain(domain);
|
8994 | if (roundDomains) {
|
8995 | return scale.nice();
|
8996 | }
|
8997 | return scale;
|
8998 | }
|
8999 | case exports.ScaleType.Ordinal:
|
9000 | return d3Scale.scalePoint()
|
9001 | .range([range[0], range[1]])
|
9002 | .domain(domain.map(function (r) { return r.toString(); }));
|
9003 | default:
|
9004 | return undefined;
|
9005 | }
|
9006 | }
|
9007 |
|
9008 | var BubbleChartComponent = (function (_super) {
|
9009 | __extends(BubbleChartComponent, _super);
|
9010 | function BubbleChartComponent() {
|
9011 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
9012 | _this.showGridLines = true;
|
9013 | _this.legend = false;
|
9014 | _this.legendTitle = 'Legend';
|
9015 | _this.legendPosition = exports.LegendPosition.Right;
|
9016 | _this.xAxis = true;
|
9017 | _this.yAxis = true;
|
9018 | _this.trimXAxisTicks = true;
|
9019 | _this.trimYAxisTicks = true;
|
9020 | _this.rotateXAxisTicks = true;
|
9021 | _this.maxXAxisTickLength = 16;
|
9022 | _this.maxYAxisTickLength = 16;
|
9023 | _this.roundDomains = false;
|
9024 | _this.maxRadius = 10;
|
9025 | _this.minRadius = 3;
|
9026 | _this.schemeType = exports.ScaleType.Ordinal;
|
9027 | _this.tooltipDisabled = false;
|
9028 | _this.activate = new core.EventEmitter();
|
9029 | _this.deactivate = new core.EventEmitter();
|
9030 | _this.scaleType = exports.ScaleType.Linear;
|
9031 | _this.margin = [10, 20, 10, 20];
|
9032 | _this.bubblePadding = [0, 0, 0, 0];
|
9033 | _this.xAxisHeight = 0;
|
9034 | _this.yAxisWidth = 0;
|
9035 | _this.activeEntries = [];
|
9036 | return _this;
|
9037 | }
|
9038 | BubbleChartComponent.prototype.update = function () {
|
9039 | _super.prototype.update.call(this);
|
9040 | this.dims = calculateViewDimensions({
|
9041 | width: this.width,
|
9042 | height: this.height,
|
9043 | margins: this.margin,
|
9044 | showXAxis: this.xAxis,
|
9045 | showYAxis: this.yAxis,
|
9046 | xAxisHeight: this.xAxisHeight,
|
9047 | yAxisWidth: this.yAxisWidth,
|
9048 | showXLabel: this.showXAxisLabel,
|
9049 | showYLabel: this.showYAxisLabel,
|
9050 | showLegend: this.legend,
|
9051 | legendType: this.schemeType,
|
9052 | legendPosition: this.legendPosition
|
9053 | });
|
9054 | this.seriesDomain = this.results.map(function (d) { return d.name; });
|
9055 | this.rDomain = this.getRDomain();
|
9056 | this.xDomain = this.getXDomain();
|
9057 | this.yDomain = this.getYDomain();
|
9058 | this.transform = "translate(" + this.dims.xOffset + "," + this.margin[0] + ")";
|
9059 | var colorDomain = this.schemeType === exports.ScaleType.Ordinal ? this.seriesDomain : this.rDomain;
|
9060 | this.colors = new ColorHelper(this.scheme, this.schemeType, colorDomain, this.customColors);
|
9061 | this.data = this.results;
|
9062 | this.minRadius = Math.max(this.minRadius, 1);
|
9063 | this.maxRadius = Math.max(this.maxRadius, 1);
|
9064 | this.rScale = this.getRScale(this.rDomain, [this.minRadius, this.maxRadius]);
|
9065 | this.bubblePadding = [0, 0, 0, 0];
|
9066 | this.setScales();
|
9067 | this.bubblePadding = this.getBubblePadding();
|
9068 | this.setScales();
|
9069 | this.legendOptions = this.getLegendOptions();
|
9070 | this.clipPathId = 'clip' + id().toString();
|
9071 | this.clipPath = "url(#" + this.clipPathId + ")";
|
9072 | };
|
9073 | BubbleChartComponent.prototype.hideCircles = function () {
|
9074 | this.deactivateAll();
|
9075 | };
|
9076 | BubbleChartComponent.prototype.onClick = function (data, series) {
|
9077 | if (series) {
|
9078 | data.series = series.name;
|
9079 | }
|
9080 | this.select.emit(data);
|
9081 | };
|
9082 | BubbleChartComponent.prototype.getBubblePadding = function () {
|
9083 | var e_1, _a, e_2, _b;
|
9084 | var yMin = 0;
|
9085 | var xMin = 0;
|
9086 | var yMax = this.dims.height;
|
9087 | var xMax = this.dims.width;
|
9088 | try {
|
9089 | for (var _c = __values(this.data), _d = _c.next(); !_d.done; _d = _c.next()) {
|
9090 | var s = _d.value;
|
9091 | try {
|
9092 | for (var _e = (e_2 = void 0, __values(s.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
9093 | var d = _f.value;
|
9094 | var r = this.rScale(d.r);
|
9095 | var cx = this.xScaleType === exports.ScaleType.Linear ? this.xScale(Number(d.x)) : this.xScale(d.x);
|
9096 | var cy = this.yScaleType === exports.ScaleType.Linear ? this.yScale(Number(d.y)) : this.yScale(d.y);
|
9097 | xMin = Math.max(r - cx, xMin);
|
9098 | yMin = Math.max(r - cy, yMin);
|
9099 | yMax = Math.max(cy + r, yMax);
|
9100 | xMax = Math.max(cx + r, xMax);
|
9101 | }
|
9102 | }
|
9103 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
9104 | finally {
|
9105 | try {
|
9106 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
9107 | }
|
9108 | finally { if (e_2) throw e_2.error; }
|
9109 | }
|
9110 | }
|
9111 | }
|
9112 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
9113 | finally {
|
9114 | try {
|
9115 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
9116 | }
|
9117 | finally { if (e_1) throw e_1.error; }
|
9118 | }
|
9119 | xMax = Math.max(xMax - this.dims.width, 0);
|
9120 | yMax = Math.max(yMax - this.dims.height, 0);
|
9121 | return [yMin, xMax, yMax, xMin];
|
9122 | };
|
9123 | BubbleChartComponent.prototype.setScales = function () {
|
9124 | var width = this.dims.width;
|
9125 | if (this.xScaleMin === undefined && this.xScaleMax === undefined) {
|
9126 | width = width - this.bubblePadding[1];
|
9127 | }
|
9128 | var height = this.dims.height;
|
9129 | if (this.yScaleMin === undefined && this.yScaleMax === undefined) {
|
9130 | height = height - this.bubblePadding[2];
|
9131 | }
|
9132 | this.xScale = this.getXScale(this.xDomain, width);
|
9133 | this.yScale = this.getYScale(this.yDomain, height);
|
9134 | };
|
9135 | BubbleChartComponent.prototype.getYScale = function (domain, height) {
|
9136 | return getScale(domain, [height, this.bubblePadding[0]], this.yScaleType, this.roundDomains);
|
9137 | };
|
9138 | BubbleChartComponent.prototype.getXScale = function (domain, width) {
|
9139 | return getScale(domain, [this.bubblePadding[3], width], this.xScaleType, this.roundDomains);
|
9140 | };
|
9141 | BubbleChartComponent.prototype.getRScale = function (domain, range) {
|
9142 | var scale = d3Scale.scaleLinear().range(range).domain(domain);
|
9143 | return this.roundDomains ? scale.nice() : scale;
|
9144 | };
|
9145 | BubbleChartComponent.prototype.getLegendOptions = function () {
|
9146 | var opts = {
|
9147 | scaleType: this.schemeType,
|
9148 | colors: undefined,
|
9149 | domain: [],
|
9150 | position: this.legendPosition,
|
9151 | title: undefined
|
9152 | };
|
9153 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
9154 | opts.domain = this.seriesDomain;
|
9155 | opts.colors = this.colors;
|
9156 | opts.title = this.legendTitle;
|
9157 | }
|
9158 | else {
|
9159 | opts.domain = this.rDomain;
|
9160 | opts.colors = this.colors.scale;
|
9161 | }
|
9162 | return opts;
|
9163 | };
|
9164 | BubbleChartComponent.prototype.getXDomain = function () {
|
9165 | var e_3, _a, e_4, _b;
|
9166 | var values = [];
|
9167 | try {
|
9168 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
9169 | var results = _d.value;
|
9170 | try {
|
9171 | for (var _e = (e_4 = void 0, __values(results.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
9172 | var d = _f.value;
|
9173 | if (!values.includes(d.x)) {
|
9174 | values.push(d.x);
|
9175 | }
|
9176 | }
|
9177 | }
|
9178 | catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
9179 | finally {
|
9180 | try {
|
9181 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
9182 | }
|
9183 | finally { if (e_4) throw e_4.error; }
|
9184 | }
|
9185 | }
|
9186 | }
|
9187 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
9188 | finally {
|
9189 | try {
|
9190 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
9191 | }
|
9192 | finally { if (e_3) throw e_3.error; }
|
9193 | }
|
9194 | this.xScaleType = getScaleType(values);
|
9195 | return getDomain(values, this.xScaleType, this.autoScale, this.xScaleMin, this.xScaleMax);
|
9196 | };
|
9197 | BubbleChartComponent.prototype.getYDomain = function () {
|
9198 | var e_5, _a, e_6, _b;
|
9199 | var values = [];
|
9200 | try {
|
9201 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
9202 | var results = _d.value;
|
9203 | try {
|
9204 | for (var _e = (e_6 = void 0, __values(results.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
9205 | var d = _f.value;
|
9206 | if (!values.includes(d.y)) {
|
9207 | values.push(d.y);
|
9208 | }
|
9209 | }
|
9210 | }
|
9211 | catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
9212 | finally {
|
9213 | try {
|
9214 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
9215 | }
|
9216 | finally { if (e_6) throw e_6.error; }
|
9217 | }
|
9218 | }
|
9219 | }
|
9220 | catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
9221 | finally {
|
9222 | try {
|
9223 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
9224 | }
|
9225 | finally { if (e_5) throw e_5.error; }
|
9226 | }
|
9227 | this.yScaleType = getScaleType(values);
|
9228 | return getDomain(values, this.yScaleType, this.autoScale, this.yScaleMin, this.yScaleMax);
|
9229 | };
|
9230 | BubbleChartComponent.prototype.getRDomain = function () {
|
9231 | var e_7, _a, e_8, _b;
|
9232 | var min = Infinity;
|
9233 | var max = -Infinity;
|
9234 | try {
|
9235 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
9236 | var results = _d.value;
|
9237 | try {
|
9238 | for (var _e = (e_8 = void 0, __values(results.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
9239 | var d = _f.value;
|
9240 | var value = Number(d.r) || 1;
|
9241 | min = Math.min(min, value);
|
9242 | max = Math.max(max, value);
|
9243 | }
|
9244 | }
|
9245 | catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
9246 | finally {
|
9247 | try {
|
9248 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
9249 | }
|
9250 | finally { if (e_8) throw e_8.error; }
|
9251 | }
|
9252 | }
|
9253 | }
|
9254 | catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
9255 | finally {
|
9256 | try {
|
9257 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
9258 | }
|
9259 | finally { if (e_7) throw e_7.error; }
|
9260 | }
|
9261 | return [min, max];
|
9262 | };
|
9263 | BubbleChartComponent.prototype.updateYAxisWidth = function (_a) {
|
9264 | var width = _a.width;
|
9265 | this.yAxisWidth = width;
|
9266 | this.update();
|
9267 | };
|
9268 | BubbleChartComponent.prototype.updateXAxisHeight = function (_a) {
|
9269 | var height = _a.height;
|
9270 | this.xAxisHeight = height;
|
9271 | this.update();
|
9272 | };
|
9273 | BubbleChartComponent.prototype.onActivate = function (item) {
|
9274 | var idx = this.activeEntries.findIndex(function (d) {
|
9275 | return d.name === item.name;
|
9276 | });
|
9277 | if (idx > -1) {
|
9278 | return;
|
9279 | }
|
9280 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
9281 | this.activate.emit({ value: item, entries: this.activeEntries });
|
9282 | };
|
9283 | BubbleChartComponent.prototype.onDeactivate = function (item) {
|
9284 | var idx = this.activeEntries.findIndex(function (d) {
|
9285 | return d.name === item.name;
|
9286 | });
|
9287 | this.activeEntries.splice(idx, 1);
|
9288 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
9289 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
9290 | };
|
9291 | BubbleChartComponent.prototype.deactivateAll = function () {
|
9292 | var e_9, _a;
|
9293 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
9294 | try {
|
9295 | for (var _b = __values(this.activeEntries), _c = _b.next(); !_c.done; _c = _b.next()) {
|
9296 | var entry = _c.value;
|
9297 | this.deactivate.emit({ value: entry, entries: [] });
|
9298 | }
|
9299 | }
|
9300 | catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
9301 | finally {
|
9302 | try {
|
9303 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
9304 | }
|
9305 | finally { if (e_9) throw e_9.error; }
|
9306 | }
|
9307 | this.activeEntries = [];
|
9308 | };
|
9309 | BubbleChartComponent.prototype.trackBy = function (index, item) {
|
9310 | return "" + item.name;
|
9311 | };
|
9312 | return BubbleChartComponent;
|
9313 | }(BaseChartComponent));
|
9314 | BubbleChartComponent.decorators = [
|
9315 | { type: core.Component, args: [{
|
9316 | selector: 'ngx-charts-bubble-chart',
|
9317 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [activeEntries]=\"activeEntries\"\n [legendOptions]=\"legendOptions\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event)\"\n (legendLabelDeactivate)=\"onDeactivate($event)\"\n >\n <svg:defs>\n <svg:clipPath [attr.id]=\"clipPathId\">\n <svg:rect\n [attr.width]=\"dims.width + 10\"\n [attr.height]=\"dims.height + 10\"\n [attr.transform]=\"'translate(-5, -5)'\"\n />\n </svg:clipPath>\n </svg:defs>\n <svg:g [attr.transform]=\"transform\" class=\"bubble-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [showGridLines]=\"showGridLines\"\n [dims]=\"dims\"\n [xScale]=\"xScale\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n />\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [showGridLines]=\"showGridLines\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n />\n <svg:rect\n class=\"bubble-chart-area\"\n x=\"0\"\n y=\"0\"\n [attr.width]=\"dims.width\"\n [attr.height]=\"dims.height\"\n style=\"fill: rgb(255, 0, 0); opacity: 0; cursor: 'auto';\"\n (mouseenter)=\"deactivateAll()\"\n />\n <svg:g [attr.clip-path]=\"clipPath\">\n <svg:g *ngFor=\"let series of data; trackBy: trackBy\" [@animationState]=\"'active'\">\n <svg:g\n ngx-charts-bubble-series\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [rScale]=\"rScale\"\n [xScaleType]=\"xScaleType\"\n [yScaleType]=\"yScaleType\"\n [xAxisLabel]=\"xAxisLabel\"\n [yAxisLabel]=\"yAxisLabel\"\n [colors]=\"colors\"\n [data]=\"series\"\n [activeEntries]=\"activeEntries\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n (select)=\"onClick($event, series)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n />\n </svg:g>\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
9318 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
9319 | encapsulation: core.ViewEncapsulation.None,
|
9320 | animations: [
|
9321 | animations.trigger('animationState', [
|
9322 | animations.transition(':leave', [
|
9323 | animations.style({
|
9324 | opacity: 1
|
9325 | }),
|
9326 | animations.animate(500, animations.style({
|
9327 | opacity: 0
|
9328 | }))
|
9329 | ])
|
9330 | ])
|
9331 | ],
|
9332 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
9333 | },] }
|
9334 | ];
|
9335 | BubbleChartComponent.propDecorators = {
|
9336 | showGridLines: [{ type: core.Input }],
|
9337 | legend: [{ type: core.Input }],
|
9338 | legendTitle: [{ type: core.Input }],
|
9339 | legendPosition: [{ type: core.Input }],
|
9340 | xAxis: [{ type: core.Input }],
|
9341 | yAxis: [{ type: core.Input }],
|
9342 | showXAxisLabel: [{ type: core.Input }],
|
9343 | showYAxisLabel: [{ type: core.Input }],
|
9344 | xAxisLabel: [{ type: core.Input }],
|
9345 | yAxisLabel: [{ type: core.Input }],
|
9346 | trimXAxisTicks: [{ type: core.Input }],
|
9347 | trimYAxisTicks: [{ type: core.Input }],
|
9348 | rotateXAxisTicks: [{ type: core.Input }],
|
9349 | maxXAxisTickLength: [{ type: core.Input }],
|
9350 | maxYAxisTickLength: [{ type: core.Input }],
|
9351 | xAxisTickFormatting: [{ type: core.Input }],
|
9352 | yAxisTickFormatting: [{ type: core.Input }],
|
9353 | xAxisTicks: [{ type: core.Input }],
|
9354 | yAxisTicks: [{ type: core.Input }],
|
9355 | roundDomains: [{ type: core.Input }],
|
9356 | maxRadius: [{ type: core.Input }],
|
9357 | minRadius: [{ type: core.Input }],
|
9358 | autoScale: [{ type: core.Input }],
|
9359 | schemeType: [{ type: core.Input }],
|
9360 | tooltipDisabled: [{ type: core.Input }],
|
9361 | xScaleMin: [{ type: core.Input }],
|
9362 | xScaleMax: [{ type: core.Input }],
|
9363 | yScaleMin: [{ type: core.Input }],
|
9364 | yScaleMax: [{ type: core.Input }],
|
9365 | activate: [{ type: core.Output }],
|
9366 | deactivate: [{ type: core.Output }],
|
9367 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }],
|
9368 | hideCircles: [{ type: core.HostListener, args: ['mouseleave',] }]
|
9369 | };
|
9370 |
|
9371 | var BubbleSeriesComponent = (function () {
|
9372 | function BubbleSeriesComponent() {
|
9373 | this.tooltipDisabled = false;
|
9374 | this.select = new core.EventEmitter();
|
9375 | this.activate = new core.EventEmitter();
|
9376 | this.deactivate = new core.EventEmitter();
|
9377 | this.placementTypes = exports.PlacementTypes;
|
9378 | this.styleTypes = exports.StyleTypes;
|
9379 | }
|
9380 | BubbleSeriesComponent.prototype.ngOnChanges = function (changes) {
|
9381 | this.update();
|
9382 | };
|
9383 | BubbleSeriesComponent.prototype.update = function () {
|
9384 | this.circles = this.getCircles();
|
9385 | };
|
9386 | BubbleSeriesComponent.prototype.getCircles = function () {
|
9387 | var _this = this;
|
9388 | var seriesName = this.data.name;
|
9389 | return this.data.series
|
9390 | .map(function (d, i) {
|
9391 | if (typeof d.y !== 'undefined' && typeof d.x !== 'undefined') {
|
9392 | var y = d.y;
|
9393 | var x = d.x;
|
9394 | var r = d.r;
|
9395 | var radius = _this.rScale(r || 1);
|
9396 | var tooltipLabel = formatLabel(d.name);
|
9397 | var cx = _this.xScaleType === exports.ScaleType.Linear ? _this.xScale(Number(x)) : _this.xScale(x);
|
9398 | var cy = _this.yScaleType === exports.ScaleType.Linear ? _this.yScale(Number(y)) : _this.yScale(y);
|
9399 | var color = _this.colors.scaleType === exports.ScaleType.Linear ? _this.colors.getColor(r) : _this.colors.getColor(seriesName);
|
9400 | var isActive = !_this.activeEntries.length ? true : _this.isActive({ name: seriesName });
|
9401 | var opacity = isActive ? 1 : 0.3;
|
9402 | var data = Object.assign({}, d, {
|
9403 | series: seriesName,
|
9404 | name: d.name,
|
9405 | value: d.y,
|
9406 | x: d.x,
|
9407 | radius: d.r
|
9408 | });
|
9409 | return {
|
9410 | data: data,
|
9411 | x: x,
|
9412 | y: y,
|
9413 | r: r,
|
9414 | classNames: ["circle-data-" + i],
|
9415 | value: y,
|
9416 | label: x,
|
9417 | cx: cx,
|
9418 | cy: cy,
|
9419 | radius: radius,
|
9420 | tooltipLabel: tooltipLabel,
|
9421 | color: color,
|
9422 | opacity: opacity,
|
9423 | seriesName: seriesName,
|
9424 | isActive: isActive,
|
9425 | transform: "translate(" + cx + "," + cy + ")"
|
9426 | };
|
9427 | }
|
9428 | })
|
9429 | .filter(function (circle) { return circle !== undefined; });
|
9430 | };
|
9431 | BubbleSeriesComponent.prototype.getTooltipText = function (circle) {
|
9432 | var hasRadius = typeof circle.r !== 'undefined';
|
9433 | var hasTooltipLabel = circle.tooltipLabel && circle.tooltipLabel.length;
|
9434 | var hasSeriesName = circle.seriesName && circle.seriesName.length;
|
9435 | var radiusValue = hasRadius ? formatLabel(circle.r) : '';
|
9436 | var xAxisLabel = this.xAxisLabel && this.xAxisLabel !== '' ? this.xAxisLabel + ":" : '';
|
9437 | var yAxisLabel = this.yAxisLabel && this.yAxisLabel !== '' ? this.yAxisLabel + ":" : '';
|
9438 | var x = formatLabel(circle.x);
|
9439 | var y = formatLabel(circle.y);
|
9440 | var name = hasSeriesName && hasTooltipLabel
|
9441 | ? circle.seriesName + " \u2022 " + circle.tooltipLabel
|
9442 | : circle.seriesName + circle.tooltipLabel;
|
9443 | var tooltipTitle = hasSeriesName || hasTooltipLabel ? "<span class=\"tooltip-label\">" + escapeLabel(name) + "</span>" : '';
|
9444 | return "\n " + tooltipTitle + "\n <span class=\"tooltip-label\">\n <label>" + escapeLabel(xAxisLabel) + "</label> " + escapeLabel(x) + "<br />\n <label>" + escapeLabel(yAxisLabel) + "</label> " + escapeLabel(y) + "\n </span>\n <span class=\"tooltip-val\">\n " + escapeLabel(radiusValue) + "\n </span>\n ";
|
9445 | };
|
9446 | BubbleSeriesComponent.prototype.onClick = function (data) {
|
9447 | this.select.emit(data);
|
9448 | };
|
9449 | BubbleSeriesComponent.prototype.isActive = function (entry) {
|
9450 | if (!this.activeEntries)
|
9451 | return false;
|
9452 | var item = this.activeEntries.find(function (d) {
|
9453 | return entry.name === d.name;
|
9454 | });
|
9455 | return item !== undefined;
|
9456 | };
|
9457 | BubbleSeriesComponent.prototype.isVisible = function (circle) {
|
9458 | if (this.activeEntries.length > 0) {
|
9459 | return this.isActive({ name: circle.seriesName });
|
9460 | }
|
9461 | return circle.opacity !== 0;
|
9462 | };
|
9463 | BubbleSeriesComponent.prototype.activateCircle = function (circle) {
|
9464 | circle.barVisible = true;
|
9465 | this.activate.emit({ name: this.data.name });
|
9466 | };
|
9467 | BubbleSeriesComponent.prototype.deactivateCircle = function (circle) {
|
9468 | circle.barVisible = false;
|
9469 | this.deactivate.emit({ name: this.data.name });
|
9470 | };
|
9471 | BubbleSeriesComponent.prototype.trackBy = function (index, circle) {
|
9472 | return circle.data.series + " " + circle.data.name;
|
9473 | };
|
9474 | return BubbleSeriesComponent;
|
9475 | }());
|
9476 | BubbleSeriesComponent.decorators = [
|
9477 | { type: core.Component, args: [{
|
9478 | selector: 'g[ngx-charts-bubble-series]',
|
9479 | template: "\n <svg:g *ngFor=\"let circle of circles; trackBy: trackBy\">\n <svg:g [attr.transform]=\"circle.transform\">\n <svg:g\n ngx-charts-circle\n [@animationState]=\"'active'\"\n class=\"circle\"\n [cx]=\"0\"\n [cy]=\"0\"\n [r]=\"circle.radius\"\n [fill]=\"circle.color\"\n [style.opacity]=\"circle.opacity\"\n [class.active]=\"circle.isActive\"\n [pointerEvents]=\"'all'\"\n [data]=\"circle.value\"\n [classNames]=\"circle.classNames\"\n (select)=\"onClick(circle.data)\"\n (activate)=\"activateCircle(circle)\"\n (deactivate)=\"deactivateCircle(circle)\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"placementTypes.Top\"\n [tooltipType]=\"styleTypes.tooltip\"\n [tooltipTitle]=\"tooltipTemplate ? undefined : getTooltipText(circle)\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"circle.data\"\n />\n </svg:g>\n </svg:g>\n ",
|
9480 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
9481 | animations: [
|
9482 | animations.trigger('animationState', [
|
9483 | animations.transition(':enter', [
|
9484 | animations.style({
|
9485 | opacity: 0,
|
9486 | transform: 'scale(0)'
|
9487 | }),
|
9488 | animations.animate(250, animations.style({ opacity: 1, transform: 'scale(1)' }))
|
9489 | ])
|
9490 | ])
|
9491 | ]
|
9492 | },] }
|
9493 | ];
|
9494 | BubbleSeriesComponent.propDecorators = {
|
9495 | data: [{ type: core.Input }],
|
9496 | xScale: [{ type: core.Input }],
|
9497 | yScale: [{ type: core.Input }],
|
9498 | rScale: [{ type: core.Input }],
|
9499 | xScaleType: [{ type: core.Input }],
|
9500 | yScaleType: [{ type: core.Input }],
|
9501 | colors: [{ type: core.Input }],
|
9502 | visibleValue: [{ type: core.Input }],
|
9503 | activeEntries: [{ type: core.Input }],
|
9504 | xAxisLabel: [{ type: core.Input }],
|
9505 | yAxisLabel: [{ type: core.Input }],
|
9506 | tooltipDisabled: [{ type: core.Input }],
|
9507 | tooltipTemplate: [{ type: core.Input }],
|
9508 | select: [{ type: core.Output }],
|
9509 | activate: [{ type: core.Output }],
|
9510 | deactivate: [{ type: core.Output }]
|
9511 | };
|
9512 |
|
9513 | var BubbleChartModule = (function () {
|
9514 | function BubbleChartModule() {
|
9515 | }
|
9516 | return BubbleChartModule;
|
9517 | }());
|
9518 | BubbleChartModule.decorators = [
|
9519 | { type: core.NgModule, args: [{
|
9520 | imports: [ChartCommonModule],
|
9521 | declarations: [BubbleChartComponent, BubbleSeriesComponent],
|
9522 | exports: [BubbleChartComponent, BubbleSeriesComponent]
|
9523 | },] }
|
9524 | ];
|
9525 |
|
9526 | var HeatMapCellComponent = (function () {
|
9527 | function HeatMapCellComponent(element) {
|
9528 | this.gradient = false;
|
9529 | this.animations = true;
|
9530 | this.select = new core.EventEmitter();
|
9531 | this.activate = new core.EventEmitter();
|
9532 | this.deactivate = new core.EventEmitter();
|
9533 | this.barOrientation = exports.BarOrientation;
|
9534 | this.element = element.nativeElement;
|
9535 | }
|
9536 | HeatMapCellComponent.prototype.ngOnChanges = function (changes) {
|
9537 | this.transform = "translate(" + this.x + " , " + this.y + ")";
|
9538 | this.startOpacity = 0.3;
|
9539 | this.gradientId = 'grad' + id().toString();
|
9540 | this.gradientUrl = "url(#" + this.gradientId + ")";
|
9541 | this.gradientStops = this.getGradientStops();
|
9542 | if (this.animations) {
|
9543 | this.loadAnimation();
|
9544 | }
|
9545 | };
|
9546 | HeatMapCellComponent.prototype.getGradientStops = function () {
|
9547 | return [
|
9548 | {
|
9549 | offset: 0,
|
9550 | color: this.fill,
|
9551 | opacity: this.startOpacity
|
9552 | },
|
9553 | {
|
9554 | offset: 100,
|
9555 | color: this.fill,
|
9556 | opacity: 1
|
9557 | }
|
9558 | ];
|
9559 | };
|
9560 | HeatMapCellComponent.prototype.loadAnimation = function () {
|
9561 | var node = d3Selection.select(this.element).select('.cell');
|
9562 | node.attr('opacity', 0);
|
9563 | this.animateToCurrentForm();
|
9564 | };
|
9565 | HeatMapCellComponent.prototype.animateToCurrentForm = function () {
|
9566 | var node = d3Selection.select(this.element).select('.cell');
|
9567 | node.transition().duration(750).attr('opacity', 1);
|
9568 | };
|
9569 | HeatMapCellComponent.prototype.onClick = function () {
|
9570 | this.select.emit(this.data);
|
9571 | };
|
9572 | HeatMapCellComponent.prototype.onMouseEnter = function () {
|
9573 | this.activate.emit(this.data);
|
9574 | };
|
9575 | HeatMapCellComponent.prototype.onMouseLeave = function () {
|
9576 | this.deactivate.emit(this.data);
|
9577 | };
|
9578 | return HeatMapCellComponent;
|
9579 | }());
|
9580 | HeatMapCellComponent.decorators = [
|
9581 | { type: core.Component, args: [{
|
9582 | selector: 'g[ngx-charts-heat-map-cell]',
|
9583 | template: "\n <svg:g [attr.transform]=\"transform\" class=\"cell\">\n <defs *ngIf=\"gradient\">\n <svg:g\n ngx-charts-svg-linear-gradient\n [orientation]=\"barOrientation.Vertical\"\n [name]=\"gradientId\"\n [stops]=\"gradientStops\"\n />\n </defs>\n <svg:rect\n [attr.fill]=\"gradient ? gradientUrl : fill\"\n rx=\"3\"\n [attr.width]=\"width\"\n [attr.height]=\"height\"\n class=\"cell\"\n (click)=\"onClick()\"\n />\n </svg:g>\n ",
|
9584 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
9585 | },] }
|
9586 | ];
|
9587 | HeatMapCellComponent.ctorParameters = function () { return [
|
9588 | { type: core.ElementRef }
|
9589 | ]; };
|
9590 | HeatMapCellComponent.propDecorators = {
|
9591 | fill: [{ type: core.Input }],
|
9592 | x: [{ type: core.Input }],
|
9593 | y: [{ type: core.Input }],
|
9594 | width: [{ type: core.Input }],
|
9595 | height: [{ type: core.Input }],
|
9596 | data: [{ type: core.Input }],
|
9597 | gradient: [{ type: core.Input }],
|
9598 | animations: [{ type: core.Input }],
|
9599 | select: [{ type: core.Output }],
|
9600 | activate: [{ type: core.Output }],
|
9601 | deactivate: [{ type: core.Output }],
|
9602 | onMouseEnter: [{ type: core.HostListener, args: ['mouseenter',] }],
|
9603 | onMouseLeave: [{ type: core.HostListener, args: ['mouseleave',] }]
|
9604 | };
|
9605 |
|
9606 | var HeatCellSeriesComponent = (function () {
|
9607 | function HeatCellSeriesComponent() {
|
9608 | this.tooltipDisabled = false;
|
9609 | this.animations = true;
|
9610 | this.select = new core.EventEmitter();
|
9611 | this.activate = new core.EventEmitter();
|
9612 | this.deactivate = new core.EventEmitter();
|
9613 | this.placementTypes = exports.PlacementTypes;
|
9614 | this.styleTypes = exports.StyleTypes;
|
9615 | }
|
9616 | HeatCellSeriesComponent.prototype.ngOnInit = function () {
|
9617 | if (!this.tooltipText) {
|
9618 | this.tooltipText = this.getTooltipText;
|
9619 | }
|
9620 | };
|
9621 | HeatCellSeriesComponent.prototype.ngOnChanges = function (changes) {
|
9622 | this.update();
|
9623 | };
|
9624 | HeatCellSeriesComponent.prototype.update = function () {
|
9625 | this.cells = this.getCells();
|
9626 | };
|
9627 | HeatCellSeriesComponent.prototype.getCells = function () {
|
9628 | var _this = this;
|
9629 | var cells = [];
|
9630 | this.data.map(function (row) {
|
9631 | row.series.map(function (cell) {
|
9632 | var value = cell.value;
|
9633 | cell.series = row.name;
|
9634 | cells.push({
|
9635 | row: row,
|
9636 | cell: cell,
|
9637 | x: _this.xScale(row.name),
|
9638 | y: _this.yScale(cell.name),
|
9639 | width: _this.xScale.bandwidth(),
|
9640 | height: _this.yScale.bandwidth(),
|
9641 | fill: _this.colors.getColor(value),
|
9642 | data: value,
|
9643 | label: formatLabel(cell.name),
|
9644 | series: row.name
|
9645 | });
|
9646 | });
|
9647 | });
|
9648 | return cells;
|
9649 | };
|
9650 | HeatCellSeriesComponent.prototype.getTooltipText = function (_a) {
|
9651 | var label = _a.label, data = _a.data, series = _a.series;
|
9652 | return "\n <span class=\"tooltip-label\">" + escapeLabel(series) + " \u2022 " + escapeLabel(label) + "</span>\n <span class=\"tooltip-val\">" + data.toLocaleString() + "</span>\n ";
|
9653 | };
|
9654 | HeatCellSeriesComponent.prototype.trackBy = function (index, item) {
|
9655 | return item.label;
|
9656 | };
|
9657 | HeatCellSeriesComponent.prototype.onClick = function (data) {
|
9658 | this.select.emit(data);
|
9659 | };
|
9660 | return HeatCellSeriesComponent;
|
9661 | }());
|
9662 | HeatCellSeriesComponent.decorators = [
|
9663 | { type: core.Component, args: [{
|
9664 | selector: 'g[ngx-charts-heat-map-cell-series]',
|
9665 | template: "\n <svg:g\n ngx-charts-heat-map-cell\n *ngFor=\"let c of cells; trackBy: trackBy\"\n [x]=\"c.x\"\n [y]=\"c.y\"\n [width]=\"c.width\"\n [height]=\"c.height\"\n [fill]=\"c.fill\"\n [data]=\"c.data\"\n (select)=\"onClick(c.cell)\"\n (activate)=\"activate.emit(c.cell)\"\n (deactivate)=\"deactivate.emit(c.cell)\"\n [gradient]=\"gradient\"\n [animations]=\"animations\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"placementTypes.Top\"\n [tooltipType]=\"styleTypes.tooltip\"\n [tooltipTitle]=\"tooltipTemplate ? undefined : tooltipText(c)\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"{ series: c.series, name: c.label, value: c.data }\"\n ></svg:g>\n ",
|
9666 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
9667 | },] }
|
9668 | ];
|
9669 | HeatCellSeriesComponent.propDecorators = {
|
9670 | data: [{ type: core.Input }],
|
9671 | colors: [{ type: core.Input }],
|
9672 | xScale: [{ type: core.Input }],
|
9673 | yScale: [{ type: core.Input }],
|
9674 | gradient: [{ type: core.Input }],
|
9675 | tooltipDisabled: [{ type: core.Input }],
|
9676 | tooltipText: [{ type: core.Input }],
|
9677 | tooltipTemplate: [{ type: core.Input }],
|
9678 | animations: [{ type: core.Input }],
|
9679 | select: [{ type: core.Output }],
|
9680 | activate: [{ type: core.Output }],
|
9681 | deactivate: [{ type: core.Output }]
|
9682 | };
|
9683 |
|
9684 | var HeatMapComponent = (function (_super) {
|
9685 | __extends(HeatMapComponent, _super);
|
9686 | function HeatMapComponent() {
|
9687 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
9688 | _this.legendTitle = 'Legend';
|
9689 | _this.legendPosition = exports.LegendPosition.Right;
|
9690 | _this.innerPadding = 8;
|
9691 | _this.trimXAxisTicks = true;
|
9692 | _this.trimYAxisTicks = true;
|
9693 | _this.rotateXAxisTicks = true;
|
9694 | _this.maxXAxisTickLength = 16;
|
9695 | _this.maxYAxisTickLength = 16;
|
9696 | _this.tooltipDisabled = false;
|
9697 | _this.activeEntries = [];
|
9698 | _this.activate = new core.EventEmitter();
|
9699 | _this.deactivate = new core.EventEmitter();
|
9700 | _this.margin = [10, 20, 10, 20];
|
9701 | _this.xAxisHeight = 0;
|
9702 | _this.yAxisWidth = 0;
|
9703 | _this.scaleType = exports.ScaleType.Linear;
|
9704 | return _this;
|
9705 | }
|
9706 | HeatMapComponent.prototype.update = function () {
|
9707 | _super.prototype.update.call(this);
|
9708 | this.formatDates();
|
9709 | this.xDomain = this.getXDomain();
|
9710 | this.yDomain = this.getYDomain();
|
9711 | this.valueDomain = this.getValueDomain();
|
9712 | this.scaleType = getScaleType(this.valueDomain, false);
|
9713 | this.dims = calculateViewDimensions({
|
9714 | width: this.width,
|
9715 | height: this.height,
|
9716 | margins: this.margin,
|
9717 | showXAxis: this.xAxis,
|
9718 | showYAxis: this.yAxis,
|
9719 | xAxisHeight: this.xAxisHeight,
|
9720 | yAxisWidth: this.yAxisWidth,
|
9721 | showXLabel: this.showXAxisLabel,
|
9722 | showYLabel: this.showYAxisLabel,
|
9723 | showLegend: this.legend,
|
9724 | legendType: this.scaleType,
|
9725 | legendPosition: this.legendPosition
|
9726 | });
|
9727 | if (this.scaleType === exports.ScaleType.Linear) {
|
9728 | var min = this.min;
|
9729 | var max = this.max;
|
9730 | if (!this.min) {
|
9731 | min = Math.min.apply(Math, __spreadArray([0], __read(this.valueDomain)));
|
9732 | }
|
9733 | if (!this.max) {
|
9734 | max = Math.max.apply(Math, __spreadArray([], __read(this.valueDomain)));
|
9735 | }
|
9736 | this.valueDomain = [min, max];
|
9737 | }
|
9738 | this.xScale = this.getXScale();
|
9739 | this.yScale = this.getYScale();
|
9740 | this.setColors();
|
9741 | this.legendOptions = this.getLegendOptions();
|
9742 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
9743 | this.rects = this.getRects();
|
9744 | };
|
9745 | HeatMapComponent.prototype.getXDomain = function () {
|
9746 | var e_1, _a;
|
9747 | var domain = [];
|
9748 | try {
|
9749 | for (var _b = __values(this.results), _c = _b.next(); !_c.done; _c = _b.next()) {
|
9750 | var group = _c.value;
|
9751 | if (!domain.includes(group.name)) {
|
9752 | domain.push(group.name);
|
9753 | }
|
9754 | }
|
9755 | }
|
9756 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
9757 | finally {
|
9758 | try {
|
9759 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
9760 | }
|
9761 | finally { if (e_1) throw e_1.error; }
|
9762 | }
|
9763 | return domain;
|
9764 | };
|
9765 | HeatMapComponent.prototype.getYDomain = function () {
|
9766 | var e_2, _a, e_3, _b;
|
9767 | var domain = [];
|
9768 | try {
|
9769 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
9770 | var group = _d.value;
|
9771 | try {
|
9772 | for (var _e = (e_3 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
9773 | var d = _f.value;
|
9774 | if (!domain.includes(d.name)) {
|
9775 | domain.push(d.name);
|
9776 | }
|
9777 | }
|
9778 | }
|
9779 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
9780 | finally {
|
9781 | try {
|
9782 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
9783 | }
|
9784 | finally { if (e_3) throw e_3.error; }
|
9785 | }
|
9786 | }
|
9787 | }
|
9788 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
9789 | finally {
|
9790 | try {
|
9791 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
9792 | }
|
9793 | finally { if (e_2) throw e_2.error; }
|
9794 | }
|
9795 | return domain;
|
9796 | };
|
9797 | HeatMapComponent.prototype.getValueDomain = function () {
|
9798 | var e_4, _a, e_5, _b;
|
9799 | var domain = [];
|
9800 | try {
|
9801 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
9802 | var group = _d.value;
|
9803 | try {
|
9804 | for (var _e = (e_5 = void 0, __values(group.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
9805 | var d = _f.value;
|
9806 | if (!domain.includes(d.value)) {
|
9807 | domain.push(d.value);
|
9808 | }
|
9809 | }
|
9810 | }
|
9811 | catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
9812 | finally {
|
9813 | try {
|
9814 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
9815 | }
|
9816 | finally { if (e_5) throw e_5.error; }
|
9817 | }
|
9818 | }
|
9819 | }
|
9820 | catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
9821 | finally {
|
9822 | try {
|
9823 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
9824 | }
|
9825 | finally { if (e_4) throw e_4.error; }
|
9826 | }
|
9827 | return domain;
|
9828 | };
|
9829 | |
9830 |
|
9831 |
|
9832 |
|
9833 |
|
9834 |
|
9835 |
|
9836 |
|
9837 |
|
9838 |
|
9839 | HeatMapComponent.prototype.getDimension = function (value, index, N, L) {
|
9840 | if (index === void 0) { index = 0; }
|
9841 | if (typeof value === 'string') {
|
9842 | value = value
|
9843 | .replace('[', '')
|
9844 | .replace(']', '')
|
9845 | .replace('px', '')
|
9846 |
|
9847 | .replace("'", '');
|
9848 | if (value.includes(',')) {
|
9849 | value = value.split(',');
|
9850 | }
|
9851 | }
|
9852 | if (Array.isArray(value) && typeof index === 'number') {
|
9853 | return this.getDimension(value[index], null, N, L);
|
9854 | }
|
9855 | if (typeof value === 'string' && value.includes('%')) {
|
9856 | return +value.replace('%', '') / 100;
|
9857 | }
|
9858 | return N / (L / +value + 1);
|
9859 | };
|
9860 | HeatMapComponent.prototype.getXScale = function () {
|
9861 | var f = this.getDimension(this.innerPadding, 0, this.xDomain.length, this.dims.width);
|
9862 | return d3Scale.scaleBand().rangeRound([0, this.dims.width]).domain(this.xDomain).paddingInner(f);
|
9863 | };
|
9864 | HeatMapComponent.prototype.getYScale = function () {
|
9865 | var f = this.getDimension(this.innerPadding, 1, this.yDomain.length, this.dims.height);
|
9866 | return d3Scale.scaleBand().rangeRound([this.dims.height, 0]).domain(this.yDomain).paddingInner(f);
|
9867 | };
|
9868 | HeatMapComponent.prototype.getRects = function () {
|
9869 | var _this = this;
|
9870 | var rects = [];
|
9871 | this.xDomain.map(function (xVal) {
|
9872 | _this.yDomain.map(function (yVal) {
|
9873 | rects.push({
|
9874 | x: _this.xScale(xVal),
|
9875 | y: _this.yScale(yVal),
|
9876 | rx: 3,
|
9877 | width: _this.xScale.bandwidth(),
|
9878 | height: _this.yScale.bandwidth(),
|
9879 | fill: 'rgba(200,200,200,0.03)'
|
9880 | });
|
9881 | });
|
9882 | });
|
9883 | return rects;
|
9884 | };
|
9885 | HeatMapComponent.prototype.onClick = function (data) {
|
9886 | this.select.emit(data);
|
9887 | };
|
9888 | HeatMapComponent.prototype.setColors = function () {
|
9889 | this.colors = new ColorHelper(this.scheme, this.scaleType, this.valueDomain);
|
9890 | };
|
9891 | HeatMapComponent.prototype.getLegendOptions = function () {
|
9892 | return {
|
9893 | scaleType: this.scaleType,
|
9894 | domain: this.valueDomain,
|
9895 | colors: this.scaleType === exports.ScaleType.Ordinal ? this.colors : this.colors.scale,
|
9896 | title: this.scaleType === exports.ScaleType.Ordinal ? this.legendTitle : undefined,
|
9897 | position: this.legendPosition
|
9898 | };
|
9899 | };
|
9900 | HeatMapComponent.prototype.updateYAxisWidth = function (_a) {
|
9901 | var width = _a.width;
|
9902 | this.yAxisWidth = width;
|
9903 | this.update();
|
9904 | };
|
9905 | HeatMapComponent.prototype.updateXAxisHeight = function (_a) {
|
9906 | var height = _a.height;
|
9907 | this.xAxisHeight = height;
|
9908 | this.update();
|
9909 | };
|
9910 | HeatMapComponent.prototype.onActivate = function (event, group, fromLegend) {
|
9911 | if (fromLegend === void 0) { fromLegend = false; }
|
9912 | var item = Object.assign({}, event);
|
9913 | if (group) {
|
9914 | item.series = group.name;
|
9915 | }
|
9916 | var items = this.results
|
9917 | .map(function (g) { return g.series; })
|
9918 | .flat()
|
9919 | .filter(function (i) {
|
9920 | if (fromLegend) {
|
9921 | return i.label === item.name;
|
9922 | }
|
9923 | else {
|
9924 | return i.name === item.name && i.series === item.series;
|
9925 | }
|
9926 | });
|
9927 | this.activeEntries = __spreadArray([], __read(items));
|
9928 | this.activate.emit({ value: item, entries: this.activeEntries });
|
9929 | };
|
9930 | HeatMapComponent.prototype.onDeactivate = function (event, group, fromLegend) {
|
9931 | if (fromLegend === void 0) { fromLegend = false; }
|
9932 | var item = Object.assign({}, event);
|
9933 | if (group) {
|
9934 | item.series = group.name;
|
9935 | }
|
9936 | this.activeEntries = this.activeEntries.filter(function (i) {
|
9937 | if (fromLegend) {
|
9938 | return i.label !== item.name;
|
9939 | }
|
9940 | else {
|
9941 | return !(i.name === item.name && i.series === item.series);
|
9942 | }
|
9943 | });
|
9944 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
9945 | };
|
9946 | return HeatMapComponent;
|
9947 | }(BaseChartComponent));
|
9948 | HeatMapComponent.decorators = [
|
9949 | { type: core.Component, args: [{
|
9950 | selector: 'ngx-charts-heat-map',
|
9951 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [animations]=\"animations\"\n [legendOptions]=\"legendOptions\"\n (legendLabelClick)=\"onClick($event)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"heat-map chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:rect\n *ngFor=\"let rect of rects\"\n [attr.x]=\"rect.x\"\n [attr.y]=\"rect.y\"\n [attr.rx]=\"rect.rx\"\n [attr.width]=\"rect.width\"\n [attr.height]=\"rect.height\"\n [attr.fill]=\"rect.fill\"\n />\n <svg:g\n ngx-charts-heat-map-cell-series\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [data]=\"results\"\n [gradient]=\"gradient\"\n [animations]=\"animations\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipText]=\"tooltipText\"\n (select)=\"onClick($event)\"\n (activate)=\"onActivate($event, undefined)\"\n (deactivate)=\"onDeactivate($event, undefined)\"\n />\n </svg:g>\n </ngx-charts-chart>\n ",
|
9952 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
9953 | encapsulation: core.ViewEncapsulation.None,
|
9954 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
9955 | },] }
|
9956 | ];
|
9957 | HeatMapComponent.propDecorators = {
|
9958 | legend: [{ type: core.Input }],
|
9959 | legendTitle: [{ type: core.Input }],
|
9960 | legendPosition: [{ type: core.Input }],
|
9961 | xAxis: [{ type: core.Input }],
|
9962 | yAxis: [{ type: core.Input }],
|
9963 | showXAxisLabel: [{ type: core.Input }],
|
9964 | showYAxisLabel: [{ type: core.Input }],
|
9965 | xAxisLabel: [{ type: core.Input }],
|
9966 | yAxisLabel: [{ type: core.Input }],
|
9967 | gradient: [{ type: core.Input }],
|
9968 | innerPadding: [{ type: core.Input }],
|
9969 | trimXAxisTicks: [{ type: core.Input }],
|
9970 | trimYAxisTicks: [{ type: core.Input }],
|
9971 | rotateXAxisTicks: [{ type: core.Input }],
|
9972 | maxXAxisTickLength: [{ type: core.Input }],
|
9973 | maxYAxisTickLength: [{ type: core.Input }],
|
9974 | xAxisTickFormatting: [{ type: core.Input }],
|
9975 | yAxisTickFormatting: [{ type: core.Input }],
|
9976 | xAxisTicks: [{ type: core.Input }],
|
9977 | yAxisTicks: [{ type: core.Input }],
|
9978 | tooltipDisabled: [{ type: core.Input }],
|
9979 | tooltipText: [{ type: core.Input }],
|
9980 | min: [{ type: core.Input }],
|
9981 | max: [{ type: core.Input }],
|
9982 | activeEntries: [{ type: core.Input }],
|
9983 | activate: [{ type: core.Output }],
|
9984 | deactivate: [{ type: core.Output }],
|
9985 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
9986 | };
|
9987 |
|
9988 | var HeatMapModule = (function () {
|
9989 | function HeatMapModule() {
|
9990 | }
|
9991 | return HeatMapModule;
|
9992 | }());
|
9993 | HeatMapModule.decorators = [
|
9994 | { type: core.NgModule, args: [{
|
9995 | imports: [ChartCommonModule],
|
9996 | declarations: [HeatMapCellComponent, HeatCellSeriesComponent, HeatMapComponent],
|
9997 | exports: [HeatMapCellComponent, HeatCellSeriesComponent, HeatMapComponent]
|
9998 | },] }
|
9999 | ];
|
10000 |
|
10001 | var LineComponent = (function () {
|
10002 | function LineComponent(element) {
|
10003 | this.element = element;
|
10004 | this.fill = 'none';
|
10005 | this.animations = true;
|
10006 |
|
10007 | this.initialized = false;
|
10008 | }
|
10009 | LineComponent.prototype.ngOnChanges = function (changes) {
|
10010 | if (!this.initialized) {
|
10011 | this.initialized = true;
|
10012 | this.initialPath = this.path;
|
10013 | }
|
10014 | else {
|
10015 | this.updatePathEl();
|
10016 | }
|
10017 | };
|
10018 | LineComponent.prototype.updatePathEl = function () {
|
10019 | var node = d3Selection.select(this.element.nativeElement).select('.line');
|
10020 | if (this.animations) {
|
10021 | node.transition().duration(750).attr('d', this.path);
|
10022 | }
|
10023 | else {
|
10024 | node.attr('d', this.path);
|
10025 | }
|
10026 | };
|
10027 | return LineComponent;
|
10028 | }());
|
10029 | LineComponent.decorators = [
|
10030 | { type: core.Component, args: [{
|
10031 | selector: 'g[ngx-charts-line]',
|
10032 | template: "\n <svg:path\n [@animationState]=\"'active'\"\n class=\"line\"\n [attr.d]=\"initialPath\"\n [attr.fill]=\"fill\"\n [attr.stroke]=\"stroke\"\n stroke-width=\"1.5px\"\n />\n ",
|
10033 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
10034 | animations: [
|
10035 | animations.trigger('animationState', [
|
10036 | animations.transition(':enter', [
|
10037 | animations.style({
|
10038 | strokeDasharray: 2000,
|
10039 | strokeDashoffset: 2000
|
10040 | }),
|
10041 | animations.animate(1000, animations.style({
|
10042 | strokeDashoffset: 0
|
10043 | }))
|
10044 | ])
|
10045 | ])
|
10046 | ]
|
10047 | },] }
|
10048 | ];
|
10049 | LineComponent.ctorParameters = function () { return [
|
10050 | { type: core.ElementRef }
|
10051 | ]; };
|
10052 | LineComponent.propDecorators = {
|
10053 | path: [{ type: core.Input }],
|
10054 | stroke: [{ type: core.Input }],
|
10055 | data: [{ type: core.Input }],
|
10056 | fill: [{ type: core.Input }],
|
10057 | animations: [{ type: core.Input }]
|
10058 | };
|
10059 |
|
10060 | var LineChartComponent = (function (_super) {
|
10061 | __extends(LineChartComponent, _super);
|
10062 | function LineChartComponent() {
|
10063 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
10064 | _this.legendTitle = 'Legend';
|
10065 | _this.legendPosition = exports.LegendPosition.Right;
|
10066 | _this.showGridLines = true;
|
10067 | _this.curve = d3Shape.curveLinear;
|
10068 | _this.activeEntries = [];
|
10069 | _this.trimXAxisTicks = true;
|
10070 | _this.trimYAxisTicks = true;
|
10071 | _this.rotateXAxisTicks = true;
|
10072 | _this.maxXAxisTickLength = 16;
|
10073 | _this.maxYAxisTickLength = 16;
|
10074 | _this.roundDomains = false;
|
10075 | _this.tooltipDisabled = false;
|
10076 | _this.showRefLines = false;
|
10077 | _this.showRefLabels = true;
|
10078 | _this.activate = new core.EventEmitter();
|
10079 | _this.deactivate = new core.EventEmitter();
|
10080 | _this.margin = [10, 20, 10, 20];
|
10081 | _this.xAxisHeight = 0;
|
10082 | _this.yAxisWidth = 0;
|
10083 | _this.timelineHeight = 50;
|
10084 | _this.timelinePadding = 10;
|
10085 | return _this;
|
10086 | }
|
10087 | LineChartComponent.prototype.update = function () {
|
10088 | _super.prototype.update.call(this);
|
10089 | this.dims = calculateViewDimensions({
|
10090 | width: this.width,
|
10091 | height: this.height,
|
10092 | margins: this.margin,
|
10093 | showXAxis: this.xAxis,
|
10094 | showYAxis: this.yAxis,
|
10095 | xAxisHeight: this.xAxisHeight,
|
10096 | yAxisWidth: this.yAxisWidth,
|
10097 | showXLabel: this.showXAxisLabel,
|
10098 | showYLabel: this.showYAxisLabel,
|
10099 | showLegend: this.legend,
|
10100 | legendType: this.schemeType,
|
10101 | legendPosition: this.legendPosition
|
10102 | });
|
10103 | if (this.timeline) {
|
10104 | this.dims.height -= this.timelineHeight + this.margin[2] + this.timelinePadding;
|
10105 | }
|
10106 | this.xDomain = this.getXDomain();
|
10107 | if (this.filteredDomain) {
|
10108 | this.xDomain = this.filteredDomain;
|
10109 | }
|
10110 | this.yDomain = this.getYDomain();
|
10111 | this.seriesDomain = this.getSeriesDomain();
|
10112 | this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
10113 | this.yScale = this.getYScale(this.yDomain, this.dims.height);
|
10114 | this.updateTimeline();
|
10115 | this.setColors();
|
10116 | this.legendOptions = this.getLegendOptions();
|
10117 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
10118 | this.clipPathId = 'clip' + id().toString();
|
10119 | this.clipPath = "url(#" + this.clipPathId + ")";
|
10120 | };
|
10121 | LineChartComponent.prototype.updateTimeline = function () {
|
10122 | if (this.timeline) {
|
10123 | this.timelineWidth = this.dims.width;
|
10124 | this.timelineXDomain = this.getXDomain();
|
10125 | this.timelineXScale = this.getXScale(this.timelineXDomain, this.timelineWidth);
|
10126 | this.timelineYScale = this.getYScale(this.yDomain, this.timelineHeight);
|
10127 | this.timelineTransform = "translate(" + this.dims.xOffset + ", " + -this.margin[2] + ")";
|
10128 | }
|
10129 | };
|
10130 | LineChartComponent.prototype.getXDomain = function () {
|
10131 | var values = getUniqueXDomainValues(this.results);
|
10132 | this.scaleType = getScaleType(values);
|
10133 | var domain = [];
|
10134 | if (this.scaleType === exports.ScaleType.Linear) {
|
10135 | values = values.map(function (v) { return Number(v); });
|
10136 | }
|
10137 | var min;
|
10138 | var max;
|
10139 | if (this.scaleType === exports.ScaleType.Time || this.scaleType === exports.ScaleType.Linear) {
|
10140 | min = this.xScaleMin ? this.xScaleMin : Math.min.apply(Math, __spreadArray([], __read(values)));
|
10141 | max = this.xScaleMax ? this.xScaleMax : Math.max.apply(Math, __spreadArray([], __read(values)));
|
10142 | }
|
10143 | if (this.scaleType === exports.ScaleType.Time) {
|
10144 | domain = [new Date(min), new Date(max)];
|
10145 | this.xSet = __spreadArray([], __read(values)).sort(function (a, b) {
|
10146 | var aDate = a.getTime();
|
10147 | var bDate = b.getTime();
|
10148 | if (aDate > bDate)
|
10149 | return 1;
|
10150 | if (bDate > aDate)
|
10151 | return -1;
|
10152 | return 0;
|
10153 | });
|
10154 | }
|
10155 | else if (this.scaleType === exports.ScaleType.Linear) {
|
10156 | domain = [min, max];
|
10157 |
|
10158 | this.xSet = __spreadArray([], __read(values)).sort(function (a, b) { return a - b; });
|
10159 | }
|
10160 | else {
|
10161 | domain = values;
|
10162 | this.xSet = values;
|
10163 | }
|
10164 | return domain;
|
10165 | };
|
10166 | LineChartComponent.prototype.getYDomain = function () {
|
10167 | var e_1, _a, e_2, _b;
|
10168 | var domain = [];
|
10169 | try {
|
10170 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
10171 | var results = _d.value;
|
10172 | try {
|
10173 | for (var _e = (e_2 = void 0, __values(results.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
10174 | var d = _f.value;
|
10175 | if (domain.indexOf(d.value) < 0) {
|
10176 | domain.push(d.value);
|
10177 | }
|
10178 | if (d.min !== undefined) {
|
10179 | this.hasRange = true;
|
10180 | if (domain.indexOf(d.min) < 0) {
|
10181 | domain.push(d.min);
|
10182 | }
|
10183 | }
|
10184 | if (d.max !== undefined) {
|
10185 | this.hasRange = true;
|
10186 | if (domain.indexOf(d.max) < 0) {
|
10187 | domain.push(d.max);
|
10188 | }
|
10189 | }
|
10190 | }
|
10191 | }
|
10192 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
10193 | finally {
|
10194 | try {
|
10195 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
10196 | }
|
10197 | finally { if (e_2) throw e_2.error; }
|
10198 | }
|
10199 | }
|
10200 | }
|
10201 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
10202 | finally {
|
10203 | try {
|
10204 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
10205 | }
|
10206 | finally { if (e_1) throw e_1.error; }
|
10207 | }
|
10208 | var values = __spreadArray([], __read(domain));
|
10209 | if (!this.autoScale) {
|
10210 | values.push(0);
|
10211 | }
|
10212 | var min = this.yScaleMin ? this.yScaleMin : Math.min.apply(Math, __spreadArray([], __read(values)));
|
10213 | var max = this.yScaleMax ? this.yScaleMax : Math.max.apply(Math, __spreadArray([], __read(values)));
|
10214 | return [min, max];
|
10215 | };
|
10216 | LineChartComponent.prototype.getSeriesDomain = function () {
|
10217 | return this.results.map(function (d) { return d.name; });
|
10218 | };
|
10219 | LineChartComponent.prototype.getXScale = function (domain, width) {
|
10220 | var scale;
|
10221 | if (this.scaleType === exports.ScaleType.Time) {
|
10222 | scale = d3Scale.scaleTime().range([0, width]).domain(domain);
|
10223 | }
|
10224 | else if (this.scaleType === exports.ScaleType.Linear) {
|
10225 | scale = d3Scale.scaleLinear().range([0, width]).domain(domain);
|
10226 | if (this.roundDomains) {
|
10227 | scale = scale.nice();
|
10228 | }
|
10229 | }
|
10230 | else if (this.scaleType === exports.ScaleType.Ordinal) {
|
10231 | scale = d3Scale.scalePoint().range([0, width]).padding(0.1).domain(domain);
|
10232 | }
|
10233 | return scale;
|
10234 | };
|
10235 | LineChartComponent.prototype.getYScale = function (domain, height) {
|
10236 | var scale = d3Scale.scaleLinear().range([height, 0]).domain(domain);
|
10237 | return this.roundDomains ? scale.nice() : scale;
|
10238 | };
|
10239 | LineChartComponent.prototype.updateDomain = function (domain) {
|
10240 | this.filteredDomain = domain;
|
10241 | this.xDomain = this.filteredDomain;
|
10242 | this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
10243 | };
|
10244 | LineChartComponent.prototype.updateHoveredVertical = function (item) {
|
10245 | this.hoveredVertical = item.value;
|
10246 | this.deactivateAll();
|
10247 | };
|
10248 | LineChartComponent.prototype.hideCircles = function () {
|
10249 | this.hoveredVertical = null;
|
10250 | this.deactivateAll();
|
10251 | };
|
10252 | LineChartComponent.prototype.onClick = function (data) {
|
10253 | this.select.emit(data);
|
10254 | };
|
10255 | LineChartComponent.prototype.trackBy = function (index, item) {
|
10256 | return "" + item.name;
|
10257 | };
|
10258 | LineChartComponent.prototype.setColors = function () {
|
10259 | var domain;
|
10260 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
10261 | domain = this.seriesDomain;
|
10262 | }
|
10263 | else {
|
10264 | domain = this.yDomain;
|
10265 | }
|
10266 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
10267 | };
|
10268 | LineChartComponent.prototype.getLegendOptions = function () {
|
10269 | var opts = {
|
10270 | scaleType: this.schemeType,
|
10271 | colors: undefined,
|
10272 | domain: [],
|
10273 | title: undefined,
|
10274 | position: this.legendPosition
|
10275 | };
|
10276 | if (opts.scaleType === exports.ScaleType.Ordinal) {
|
10277 | opts.domain = this.seriesDomain;
|
10278 | opts.colors = this.colors;
|
10279 | opts.title = this.legendTitle;
|
10280 | }
|
10281 | else {
|
10282 | opts.domain = this.yDomain;
|
10283 | opts.colors = this.colors.scale;
|
10284 | }
|
10285 | return opts;
|
10286 | };
|
10287 | LineChartComponent.prototype.updateYAxisWidth = function (_a) {
|
10288 | var width = _a.width;
|
10289 | this.yAxisWidth = width;
|
10290 | this.update();
|
10291 | };
|
10292 | LineChartComponent.prototype.updateXAxisHeight = function (_a) {
|
10293 | var height = _a.height;
|
10294 | this.xAxisHeight = height;
|
10295 | this.update();
|
10296 | };
|
10297 | LineChartComponent.prototype.onActivate = function (item) {
|
10298 | this.deactivateAll();
|
10299 | var idx = this.activeEntries.findIndex(function (d) {
|
10300 | return d.name === item.name && d.value === item.value;
|
10301 | });
|
10302 | if (idx > -1) {
|
10303 | return;
|
10304 | }
|
10305 | this.activeEntries = [item];
|
10306 | this.activate.emit({ value: item, entries: this.activeEntries });
|
10307 | };
|
10308 | LineChartComponent.prototype.onDeactivate = function (item) {
|
10309 | var idx = this.activeEntries.findIndex(function (d) {
|
10310 | return d.name === item.name && d.value === item.value;
|
10311 | });
|
10312 | this.activeEntries.splice(idx, 1);
|
10313 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
10314 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
10315 | };
|
10316 | LineChartComponent.prototype.deactivateAll = function () {
|
10317 | var e_3, _a;
|
10318 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
10319 | try {
|
10320 | for (var _b = __values(this.activeEntries), _c = _b.next(); !_c.done; _c = _b.next()) {
|
10321 | var entry = _c.value;
|
10322 | this.deactivate.emit({ value: entry, entries: [] });
|
10323 | }
|
10324 | }
|
10325 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
10326 | finally {
|
10327 | try {
|
10328 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
10329 | }
|
10330 | finally { if (e_3) throw e_3.error; }
|
10331 | }
|
10332 | this.activeEntries = [];
|
10333 | };
|
10334 | return LineChartComponent;
|
10335 | }(BaseChartComponent));
|
10336 | LineChartComponent.decorators = [
|
10337 | { type: core.Component, args: [{
|
10338 | selector: 'ngx-charts-line-chart',
|
10339 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event)\"\n (legendLabelDeactivate)=\"onDeactivate($event)\"\n >\n <svg:defs>\n <svg:clipPath [attr.id]=\"clipPathId\">\n <svg:rect\n [attr.width]=\"dims.width + 10\"\n [attr.height]=\"dims.height + 10\"\n [attr.transform]=\"'translate(-5, -5)'\"\n />\n </svg:clipPath>\n </svg:defs>\n <svg:g [attr.transform]=\"transform\" class=\"line-chart chart\">\n <svg:g\n ngx-charts-x-axis\n *ngIf=\"xAxis\"\n [xScale]=\"xScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showXAxisLabel\"\n [labelText]=\"xAxisLabel\"\n [trimTicks]=\"trimXAxisTicks\"\n [rotateTicks]=\"rotateXAxisTicks\"\n [maxTickLength]=\"maxXAxisTickLength\"\n [tickFormatting]=\"xAxisTickFormatting\"\n [ticks]=\"xAxisTicks\"\n (dimensionsChanged)=\"updateXAxisHeight($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-y-axis\n *ngIf=\"yAxis\"\n [yScale]=\"yScale\"\n [dims]=\"dims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n [ticks]=\"yAxisTicks\"\n [referenceLines]=\"referenceLines\"\n [showRefLines]=\"showRefLines\"\n [showRefLabels]=\"showRefLabels\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g [attr.clip-path]=\"clipPath\">\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\" [@animationState]=\"'active'\">\n <svg:g\n ngx-charts-line-series\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [data]=\"series\"\n [activeEntries]=\"activeEntries\"\n [scaleType]=\"scaleType\"\n [curve]=\"curve\"\n [rangeFillOpacity]=\"rangeFillOpacity\"\n [hasRange]=\"hasRange\"\n [animations]=\"animations\"\n />\n </svg:g>\n\n <svg:g *ngIf=\"!tooltipDisabled\" (mouseleave)=\"hideCircles()\">\n <svg:g\n ngx-charts-tooltip-area\n [dims]=\"dims\"\n [xSet]=\"xSet\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [results]=\"results\"\n [colors]=\"colors\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"seriesTooltipTemplate\"\n (hover)=\"updateHoveredVertical($event)\"\n />\n\n <svg:g *ngFor=\"let series of results\">\n <svg:g\n ngx-charts-circle-series\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [visibleValue]=\"hoveredVertical\"\n [activeEntries]=\"activeEntries\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n (select)=\"onClick($event)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n />\n </svg:g>\n </svg:g>\n </svg:g>\n </svg:g>\n <svg:g\n ngx-charts-timeline\n *ngIf=\"timeline && scaleType != 'ordinal'\"\n [attr.transform]=\"timelineTransform\"\n [results]=\"results\"\n [view]=\"[timelineWidth, height]\"\n [height]=\"timelineHeight\"\n [scheme]=\"scheme\"\n [customColors]=\"customColors\"\n [scaleType]=\"scaleType\"\n [legend]=\"legend\"\n (onDomainChange)=\"updateDomain($event)\"\n >\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\">\n <svg:g\n ngx-charts-line-series\n [xScale]=\"timelineXScale\"\n [yScale]=\"timelineYScale\"\n [colors]=\"colors\"\n [data]=\"series\"\n [scaleType]=\"scaleType\"\n [curve]=\"curve\"\n [hasRange]=\"hasRange\"\n [animations]=\"animations\"\n />\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
10340 | encapsulation: core.ViewEncapsulation.None,
|
10341 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
10342 | animations: [
|
10343 | animations.trigger('animationState', [
|
10344 | animations.transition(':leave', [
|
10345 | animations.style({
|
10346 | opacity: 1
|
10347 | }),
|
10348 | animations.animate(500, animations.style({
|
10349 | opacity: 0
|
10350 | }))
|
10351 | ])
|
10352 | ])
|
10353 | ],
|
10354 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n"]
|
10355 | },] }
|
10356 | ];
|
10357 | LineChartComponent.propDecorators = {
|
10358 | legend: [{ type: core.Input }],
|
10359 | legendTitle: [{ type: core.Input }],
|
10360 | legendPosition: [{ type: core.Input }],
|
10361 | xAxis: [{ type: core.Input }],
|
10362 | yAxis: [{ type: core.Input }],
|
10363 | showXAxisLabel: [{ type: core.Input }],
|
10364 | showYAxisLabel: [{ type: core.Input }],
|
10365 | xAxisLabel: [{ type: core.Input }],
|
10366 | yAxisLabel: [{ type: core.Input }],
|
10367 | autoScale: [{ type: core.Input }],
|
10368 | timeline: [{ type: core.Input }],
|
10369 | gradient: [{ type: core.Input }],
|
10370 | showGridLines: [{ type: core.Input }],
|
10371 | curve: [{ type: core.Input }],
|
10372 | activeEntries: [{ type: core.Input }],
|
10373 | schemeType: [{ type: core.Input }],
|
10374 | rangeFillOpacity: [{ type: core.Input }],
|
10375 | trimXAxisTicks: [{ type: core.Input }],
|
10376 | trimYAxisTicks: [{ type: core.Input }],
|
10377 | rotateXAxisTicks: [{ type: core.Input }],
|
10378 | maxXAxisTickLength: [{ type: core.Input }],
|
10379 | maxYAxisTickLength: [{ type: core.Input }],
|
10380 | xAxisTickFormatting: [{ type: core.Input }],
|
10381 | yAxisTickFormatting: [{ type: core.Input }],
|
10382 | xAxisTicks: [{ type: core.Input }],
|
10383 | yAxisTicks: [{ type: core.Input }],
|
10384 | roundDomains: [{ type: core.Input }],
|
10385 | tooltipDisabled: [{ type: core.Input }],
|
10386 | showRefLines: [{ type: core.Input }],
|
10387 | referenceLines: [{ type: core.Input }],
|
10388 | showRefLabels: [{ type: core.Input }],
|
10389 | xScaleMin: [{ type: core.Input }],
|
10390 | xScaleMax: [{ type: core.Input }],
|
10391 | yScaleMin: [{ type: core.Input }],
|
10392 | yScaleMax: [{ type: core.Input }],
|
10393 | activate: [{ type: core.Output }],
|
10394 | deactivate: [{ type: core.Output }],
|
10395 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }],
|
10396 | seriesTooltipTemplate: [{ type: core.ContentChild, args: ['seriesTooltipTemplate',] }],
|
10397 | hideCircles: [{ type: core.HostListener, args: ['mouseleave',] }]
|
10398 | };
|
10399 |
|
10400 | var LineSeriesComponent = (function () {
|
10401 | function LineSeriesComponent() {
|
10402 | this.animations = true;
|
10403 | this.barOrientation = exports.BarOrientation;
|
10404 | }
|
10405 | LineSeriesComponent.prototype.ngOnChanges = function (changes) {
|
10406 | this.update();
|
10407 | };
|
10408 | LineSeriesComponent.prototype.update = function () {
|
10409 | this.updateGradients();
|
10410 | var data = this.sortData(this.data.series);
|
10411 | var lineGen = this.getLineGenerator();
|
10412 | this.path = lineGen(data) || '';
|
10413 | var areaGen = this.getAreaGenerator();
|
10414 | this.areaPath = areaGen(data) || '';
|
10415 | if (this.hasRange) {
|
10416 | var range = this.getRangeGenerator();
|
10417 | this.outerPath = range(data) || '';
|
10418 | }
|
10419 | if (this.hasGradient) {
|
10420 | this.stroke = this.gradientUrl;
|
10421 | var values = this.data.series.map(function (d) { return d.value; });
|
10422 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
10423 | var min = Math.min.apply(Math, __spreadArray([], __read(values)));
|
10424 | if (max === min) {
|
10425 | this.stroke = this.colors.getColor(max);
|
10426 | }
|
10427 | }
|
10428 | else {
|
10429 | this.stroke = this.colors.getColor(this.data.name);
|
10430 | }
|
10431 | };
|
10432 | LineSeriesComponent.prototype.getLineGenerator = function () {
|
10433 | var _this = this;
|
10434 | return d3Shape.line()
|
10435 | .x(function (d) {
|
10436 | var label = d.name;
|
10437 | var value;
|
10438 | if (_this.scaleType === exports.ScaleType.Time) {
|
10439 | value = _this.xScale(label);
|
10440 | }
|
10441 | else if (_this.scaleType === exports.ScaleType.Linear) {
|
10442 | value = _this.xScale(Number(label));
|
10443 | }
|
10444 | else {
|
10445 | value = _this.xScale(label);
|
10446 | }
|
10447 | return value;
|
10448 | })
|
10449 | .y(function (d) { return _this.yScale(d.value); })
|
10450 | .curve(this.curve);
|
10451 | };
|
10452 | LineSeriesComponent.prototype.getRangeGenerator = function () {
|
10453 | var _this = this;
|
10454 | return d3Shape.area()
|
10455 | .x(function (d) {
|
10456 | var label = d.name;
|
10457 | var value;
|
10458 | if (_this.scaleType === exports.ScaleType.Time) {
|
10459 | value = _this.xScale(label);
|
10460 | }
|
10461 | else if (_this.scaleType === exports.ScaleType.Linear) {
|
10462 | value = _this.xScale(Number(label));
|
10463 | }
|
10464 | else {
|
10465 | value = _this.xScale(label);
|
10466 | }
|
10467 | return value;
|
10468 | })
|
10469 | .y0(function (d) { return _this.yScale(typeof d.min === 'number' ? d.min : d.value); })
|
10470 | .y1(function (d) { return _this.yScale(typeof d.max === 'number' ? d.max : d.value); })
|
10471 | .curve(this.curve);
|
10472 | };
|
10473 | LineSeriesComponent.prototype.getAreaGenerator = function () {
|
10474 | var _this = this;
|
10475 | var xProperty = function (d) {
|
10476 | var label = d.name;
|
10477 | return _this.xScale(label);
|
10478 | };
|
10479 | return d3Shape.area()
|
10480 | .x(xProperty)
|
10481 | .y0(function () { return _this.yScale.range()[0]; })
|
10482 | .y1(function (d) { return _this.yScale(d.value); })
|
10483 | .curve(this.curve);
|
10484 | };
|
10485 | LineSeriesComponent.prototype.sortData = function (data) {
|
10486 | if (this.scaleType === exports.ScaleType.Linear) {
|
10487 | data = sortLinear(data, 'name');
|
10488 | }
|
10489 | else if (this.scaleType === exports.ScaleType.Time) {
|
10490 | data = sortByTime(data, 'name');
|
10491 | }
|
10492 | else {
|
10493 | data = sortByDomain(data, 'name', 'asc', this.xScale.domain());
|
10494 | }
|
10495 | return data;
|
10496 | };
|
10497 | LineSeriesComponent.prototype.updateGradients = function () {
|
10498 | if (this.colors.scaleType === exports.ScaleType.Linear) {
|
10499 | this.hasGradient = true;
|
10500 | this.gradientId = 'grad' + id().toString();
|
10501 | this.gradientUrl = "url(#" + this.gradientId + ")";
|
10502 | var values = this.data.series.map(function (d) { return d.value; });
|
10503 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
10504 | var min = Math.min.apply(Math, __spreadArray([], __read(values)));
|
10505 | this.gradientStops = this.colors.getLinearGradientStops(max, min);
|
10506 | this.areaGradientStops = this.colors.getLinearGradientStops(max);
|
10507 | }
|
10508 | else {
|
10509 | this.hasGradient = false;
|
10510 | this.gradientStops = undefined;
|
10511 | this.areaGradientStops = undefined;
|
10512 | }
|
10513 | };
|
10514 | LineSeriesComponent.prototype.isActive = function (entry) {
|
10515 | if (!this.activeEntries)
|
10516 | return false;
|
10517 | var item = this.activeEntries.find(function (d) {
|
10518 | return entry.name === d.name;
|
10519 | });
|
10520 | return item !== undefined;
|
10521 | };
|
10522 | LineSeriesComponent.prototype.isInactive = function (entry) {
|
10523 | if (!this.activeEntries || this.activeEntries.length === 0)
|
10524 | return false;
|
10525 | var item = this.activeEntries.find(function (d) {
|
10526 | return entry.name === d.name;
|
10527 | });
|
10528 | return item === undefined;
|
10529 | };
|
10530 | return LineSeriesComponent;
|
10531 | }());
|
10532 | LineSeriesComponent.decorators = [
|
10533 | { type: core.Component, args: [{
|
10534 | selector: 'g[ngx-charts-line-series]',
|
10535 | template: "\n <svg:g>\n <defs>\n <svg:g\n ngx-charts-svg-linear-gradient\n *ngIf=\"hasGradient\"\n [orientation]=\"barOrientation.Vertical\"\n [name]=\"gradientId\"\n [stops]=\"gradientStops\"\n />\n </defs>\n <svg:g\n ngx-charts-area\n class=\"line-highlight\"\n [data]=\"data\"\n [path]=\"areaPath\"\n [fill]=\"hasGradient ? gradientUrl : colors.getColor(data.name)\"\n [opacity]=\"0.25\"\n [startOpacity]=\"0\"\n [gradient]=\"true\"\n [stops]=\"areaGradientStops\"\n [class.active]=\"isActive(data)\"\n [class.inactive]=\"isInactive(data)\"\n [animations]=\"animations\"\n />\n <svg:g\n ngx-charts-line\n class=\"line-series\"\n [data]=\"data\"\n [path]=\"path\"\n [stroke]=\"stroke\"\n [animations]=\"animations\"\n [class.active]=\"isActive(data)\"\n [class.inactive]=\"isInactive(data)\"\n />\n <svg:g\n ngx-charts-area\n *ngIf=\"hasRange\"\n class=\"line-series-range\"\n [data]=\"data\"\n [path]=\"outerPath\"\n [fill]=\"hasGradient ? gradientUrl : colors.getColor(data.name)\"\n [class.active]=\"isActive(data)\"\n [class.inactive]=\"isInactive(data)\"\n [opacity]=\"rangeFillOpacity\"\n [animations]=\"animations\"\n />\n </svg:g>\n ",
|
10536 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
10537 | },] }
|
10538 | ];
|
10539 | LineSeriesComponent.propDecorators = {
|
10540 | data: [{ type: core.Input }],
|
10541 | xScale: [{ type: core.Input }],
|
10542 | yScale: [{ type: core.Input }],
|
10543 | colors: [{ type: core.Input }],
|
10544 | scaleType: [{ type: core.Input }],
|
10545 | curve: [{ type: core.Input }],
|
10546 | activeEntries: [{ type: core.Input }],
|
10547 | rangeFillOpacity: [{ type: core.Input }],
|
10548 | hasRange: [{ type: core.Input }],
|
10549 | animations: [{ type: core.Input }]
|
10550 | };
|
10551 |
|
10552 | var LineChartModule = (function () {
|
10553 | function LineChartModule() {
|
10554 | }
|
10555 | return LineChartModule;
|
10556 | }());
|
10557 | LineChartModule.decorators = [
|
10558 | { type: core.NgModule, args: [{
|
10559 | imports: [ChartCommonModule],
|
10560 | declarations: [LineComponent, LineChartComponent, LineSeriesComponent],
|
10561 | exports: [LineComponent, LineChartComponent, LineSeriesComponent]
|
10562 | },] }
|
10563 | ];
|
10564 |
|
10565 | var twoPI = 2 * Math.PI;
|
10566 | var PolarChartComponent = (function (_super) {
|
10567 | __extends(PolarChartComponent, _super);
|
10568 | function PolarChartComponent() {
|
10569 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
10570 | _this.legendTitle = 'Legend';
|
10571 | _this.legendPosition = exports.LegendPosition.Right;
|
10572 | _this.showGridLines = true;
|
10573 | _this.curve = d3Shape.curveCardinalClosed;
|
10574 | _this.activeEntries = [];
|
10575 | _this.rangeFillOpacity = 0.15;
|
10576 | _this.trimYAxisTicks = true;
|
10577 | _this.maxYAxisTickLength = 16;
|
10578 | _this.roundDomains = false;
|
10579 | _this.tooltipDisabled = false;
|
10580 | _this.showSeriesOnHover = true;
|
10581 | _this.gradient = false;
|
10582 | _this.yAxisMinScale = 0;
|
10583 | _this.labelTrim = true;
|
10584 | _this.labelTrimSize = 10;
|
10585 | _this.activate = new core.EventEmitter();
|
10586 | _this.deactivate = new core.EventEmitter();
|
10587 |
|
10588 | _this.margin = [10, 20, 10, 20];
|
10589 | _this.xAxisHeight = 0;
|
10590 | _this.yAxisWidth = 0;
|
10591 | _this.orientation = exports.Orientation;
|
10592 | return _this;
|
10593 | }
|
10594 | PolarChartComponent.prototype.update = function () {
|
10595 | _super.prototype.update.call(this);
|
10596 | this.setDims();
|
10597 | this.setScales();
|
10598 | this.setColors();
|
10599 | this.legendOptions = this.getLegendOptions();
|
10600 | this.setTicks();
|
10601 | };
|
10602 | PolarChartComponent.prototype.setDims = function () {
|
10603 | this.dims = calculateViewDimensions({
|
10604 | width: this.width,
|
10605 | height: this.height,
|
10606 | margins: this.margin,
|
10607 | showXAxis: this.xAxis,
|
10608 | showYAxis: this.yAxis,
|
10609 | xAxisHeight: this.xAxisHeight,
|
10610 | yAxisWidth: this.yAxisWidth,
|
10611 | showXLabel: this.showXAxisLabel,
|
10612 | showYLabel: this.showYAxisLabel,
|
10613 | showLegend: this.legend,
|
10614 | legendType: this.schemeType,
|
10615 | legendPosition: this.legendPosition
|
10616 | });
|
10617 | var halfWidth = Math.floor(this.dims.width / 2);
|
10618 | var halfHeight = Math.floor(this.dims.height / 2);
|
10619 | var outerRadius = (this.outerRadius = Math.min(halfHeight / 1.5, halfWidth / 1.5));
|
10620 | var yOffset = Math.max(0, halfHeight - outerRadius);
|
10621 | this.yAxisDims = Object.assign(Object.assign({}, this.dims), { width: halfWidth });
|
10622 | this.transform = "translate(" + this.dims.xOffset + ", " + this.margin[0] + ")";
|
10623 | this.transformYAxis = "translate(0, " + yOffset + ")";
|
10624 | this.labelOffset = this.dims.height + 40;
|
10625 | this.transformPlot = "translate(" + halfWidth + ", " + halfHeight + ")";
|
10626 | };
|
10627 | PolarChartComponent.prototype.setScales = function () {
|
10628 | var xValues = this.getXValues();
|
10629 | this.scaleType = getScaleType(xValues);
|
10630 | this.xDomain = this.filteredDomain || this.getXDomain(xValues);
|
10631 | this.yDomain = this.getYDomain();
|
10632 | this.seriesDomain = this.getSeriesDomain();
|
10633 | this.xScale = this.getXScale(this.xDomain, twoPI);
|
10634 | this.yScale = this.getYScale(this.yDomain, this.outerRadius);
|
10635 | this.yAxisScale = this.getYScale(this.yDomain.reverse(), this.outerRadius);
|
10636 | };
|
10637 | PolarChartComponent.prototype.setTicks = function () {
|
10638 | var _this = this;
|
10639 | var tickFormat;
|
10640 | if (this.xAxisTickFormatting) {
|
10641 | tickFormat = this.xAxisTickFormatting;
|
10642 | }
|
10643 | else if (this.xScale.tickFormat) {
|
10644 | tickFormat = this.xScale.tickFormat.apply(this.xScale, [5]);
|
10645 | }
|
10646 | else {
|
10647 | tickFormat = function (d) {
|
10648 | if (isDate(d)) {
|
10649 | return d.toLocaleDateString();
|
10650 | }
|
10651 | return d.toLocaleString();
|
10652 | };
|
10653 | }
|
10654 | var outerRadius = this.outerRadius;
|
10655 | var s = 1.1;
|
10656 | this.thetaTicks = this.xDomain.map(function (d) {
|
10657 | var startAngle = _this.xScale(d);
|
10658 | var dd = s * outerRadius * (startAngle > Math.PI ? -1 : 1);
|
10659 | var label = tickFormat(d);
|
10660 | var startPos = [outerRadius * Math.sin(startAngle), -outerRadius * Math.cos(startAngle)];
|
10661 | var pos = [dd, s * startPos[1]];
|
10662 | return {
|
10663 | innerRadius: 0,
|
10664 | outerRadius: outerRadius,
|
10665 | startAngle: startAngle,
|
10666 | endAngle: startAngle,
|
10667 | value: outerRadius,
|
10668 | label: label,
|
10669 | startPos: startPos,
|
10670 | pos: pos
|
10671 | };
|
10672 | });
|
10673 | var minDistance = 10;
|
10674 |
|
10675 | for (var i = 0; i < this.thetaTicks.length - 1; i++) {
|
10676 | var a = this.thetaTicks[i];
|
10677 | for (var j = i + 1; j < this.thetaTicks.length; j++) {
|
10678 | var b = this.thetaTicks[j];
|
10679 |
|
10680 | if (b.pos[0] * a.pos[0] > 0) {
|
10681 |
|
10682 | var o = minDistance - Math.abs(b.pos[1] - a.pos[1]);
|
10683 | if (o > 0) {
|
10684 |
|
10685 | b.pos[1] += Math.sign(b.pos[0]) * o;
|
10686 | }
|
10687 | }
|
10688 | }
|
10689 | }
|
10690 | this.radiusTicks = this.yAxisScale.ticks(Math.floor(this.dims.height / 50)).map(function (d) { return _this.yScale(d); });
|
10691 | };
|
10692 | PolarChartComponent.prototype.getXValues = function () {
|
10693 | var e_1, _a, e_2, _b;
|
10694 | var values = [];
|
10695 | try {
|
10696 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
10697 | var results = _d.value;
|
10698 | try {
|
10699 | for (var _e = (e_2 = void 0, __values(results.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
10700 | var d = _f.value;
|
10701 | if (!values.includes(d.name)) {
|
10702 | values.push(d.name);
|
10703 | }
|
10704 | }
|
10705 | }
|
10706 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
10707 | finally {
|
10708 | try {
|
10709 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
10710 | }
|
10711 | finally { if (e_2) throw e_2.error; }
|
10712 | }
|
10713 | }
|
10714 | }
|
10715 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
10716 | finally {
|
10717 | try {
|
10718 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
10719 | }
|
10720 | finally { if (e_1) throw e_1.error; }
|
10721 | }
|
10722 | return values;
|
10723 | };
|
10724 | PolarChartComponent.prototype.getXDomain = function (values) {
|
10725 | if (values === void 0) { values = this.getXValues(); }
|
10726 | if (this.scaleType === exports.ScaleType.Time) {
|
10727 | var min = Math.min.apply(Math, __spreadArray([], __read(values)));
|
10728 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
10729 | return [min, max];
|
10730 | }
|
10731 | else if (this.scaleType === exports.ScaleType.Linear) {
|
10732 | values = values.map(function (v) { return Number(v); });
|
10733 | var min = Math.min.apply(Math, __spreadArray([], __read(values)));
|
10734 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
10735 | return [min, max];
|
10736 | }
|
10737 | return values;
|
10738 | };
|
10739 | PolarChartComponent.prototype.getYValues = function () {
|
10740 | var e_3, _a, e_4, _b;
|
10741 | var domain = [];
|
10742 | try {
|
10743 | for (var _c = __values(this.results), _d = _c.next(); !_d.done; _d = _c.next()) {
|
10744 | var results = _d.value;
|
10745 | try {
|
10746 | for (var _e = (e_4 = void 0, __values(results.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
10747 | var d = _f.value;
|
10748 | if (domain.indexOf(d.value) < 0) {
|
10749 | domain.push(d.value);
|
10750 | }
|
10751 | if (d.min !== undefined) {
|
10752 | if (domain.indexOf(d.min) < 0) {
|
10753 | domain.push(d.min);
|
10754 | }
|
10755 | }
|
10756 | if (d.max !== undefined) {
|
10757 | if (domain.indexOf(d.max) < 0) {
|
10758 | domain.push(d.max);
|
10759 | }
|
10760 | }
|
10761 | }
|
10762 | }
|
10763 | catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
10764 | finally {
|
10765 | try {
|
10766 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
10767 | }
|
10768 | finally { if (e_4) throw e_4.error; }
|
10769 | }
|
10770 | }
|
10771 | }
|
10772 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
10773 | finally {
|
10774 | try {
|
10775 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
10776 | }
|
10777 | finally { if (e_3) throw e_3.error; }
|
10778 | }
|
10779 | return domain;
|
10780 | };
|
10781 | PolarChartComponent.prototype.getYDomain = function (domain) {
|
10782 | if (domain === void 0) { domain = this.getYValues(); }
|
10783 | var min = Math.min.apply(Math, __spreadArray([], __read(domain)));
|
10784 | var max = Math.max.apply(Math, __spreadArray([this.yAxisMinScale], __read(domain)));
|
10785 | min = Math.max(0, min);
|
10786 | if (!this.autoScale) {
|
10787 | min = Math.min(0, min);
|
10788 | }
|
10789 | return [min, max];
|
10790 | };
|
10791 | PolarChartComponent.prototype.getSeriesDomain = function () {
|
10792 | return this.results.map(function (d) { return d.name; });
|
10793 | };
|
10794 | PolarChartComponent.prototype.getXScale = function (domain, width) {
|
10795 | switch (this.scaleType) {
|
10796 | case exports.ScaleType.Time:
|
10797 | return d3Scale.scaleTime().range([0, width]).domain(domain);
|
10798 | case exports.ScaleType.Linear:
|
10799 | var scale = d3Scale.scaleLinear().range([0, width]).domain(domain);
|
10800 | return this.roundDomains ? scale.nice() : scale;
|
10801 | default:
|
10802 | return d3Scale.scalePoint()
|
10803 | .range([0, width - twoPI / domain.length])
|
10804 | .padding(0)
|
10805 | .domain(domain);
|
10806 | }
|
10807 | };
|
10808 | PolarChartComponent.prototype.getYScale = function (domain, height) {
|
10809 | var scale = d3Scale.scaleLinear().range([0, height]).domain(domain);
|
10810 | return this.roundDomains ? scale.nice() : scale;
|
10811 | };
|
10812 | PolarChartComponent.prototype.onClick = function (data, series) {
|
10813 | if (series) {
|
10814 | data.series = series.name;
|
10815 | }
|
10816 | this.select.emit(data);
|
10817 | };
|
10818 | PolarChartComponent.prototype.setColors = function () {
|
10819 | var domain = this.schemeType === exports.ScaleType.Ordinal ? this.seriesDomain : this.yDomain.reverse();
|
10820 | this.colors = new ColorHelper(this.scheme, this.schemeType, domain, this.customColors);
|
10821 | };
|
10822 | PolarChartComponent.prototype.getLegendOptions = function () {
|
10823 | if (this.schemeType === exports.ScaleType.Ordinal) {
|
10824 | return {
|
10825 | scaleType: this.schemeType,
|
10826 | colors: this.colors,
|
10827 | domain: this.seriesDomain,
|
10828 | title: this.legendTitle,
|
10829 | position: this.legendPosition
|
10830 | };
|
10831 | }
|
10832 | return {
|
10833 | scaleType: this.schemeType,
|
10834 | colors: this.colors.scale,
|
10835 | domain: this.yDomain,
|
10836 | title: undefined,
|
10837 | position: this.legendPosition
|
10838 | };
|
10839 | };
|
10840 | PolarChartComponent.prototype.updateYAxisWidth = function (_a) {
|
10841 | var width = _a.width;
|
10842 | this.yAxisWidth = width;
|
10843 | this.update();
|
10844 | };
|
10845 | PolarChartComponent.prototype.updateXAxisHeight = function (_a) {
|
10846 | var height = _a.height;
|
10847 | this.xAxisHeight = height;
|
10848 | this.update();
|
10849 | };
|
10850 | PolarChartComponent.prototype.onActivate = function (item) {
|
10851 | var idx = this.activeEntries.findIndex(function (d) {
|
10852 | return d.name === item.name && d.value === item.value;
|
10853 | });
|
10854 | if (idx > -1) {
|
10855 | return;
|
10856 | }
|
10857 | this.activeEntries = this.showSeriesOnHover ? __spreadArray([item], __read(this.activeEntries)) : this.activeEntries;
|
10858 | this.activate.emit({ value: item, entries: this.activeEntries });
|
10859 | };
|
10860 | PolarChartComponent.prototype.onDeactivate = function (item) {
|
10861 | var idx = this.activeEntries.findIndex(function (d) {
|
10862 | return d.name === item.name && d.value === item.value;
|
10863 | });
|
10864 | this.activeEntries.splice(idx, 1);
|
10865 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
10866 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
10867 | };
|
10868 | PolarChartComponent.prototype.deactivateAll = function () {
|
10869 | var e_5, _a;
|
10870 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
10871 | try {
|
10872 | for (var _b = __values(this.activeEntries), _c = _b.next(); !_c.done; _c = _b.next()) {
|
10873 | var entry = _c.value;
|
10874 | this.deactivate.emit({ value: entry, entries: [] });
|
10875 | }
|
10876 | }
|
10877 | catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
10878 | finally {
|
10879 | try {
|
10880 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
10881 | }
|
10882 | finally { if (e_5) throw e_5.error; }
|
10883 | }
|
10884 | this.activeEntries = [];
|
10885 | };
|
10886 | PolarChartComponent.prototype.trackBy = function (index, item) {
|
10887 | return "" + item.name;
|
10888 | };
|
10889 | return PolarChartComponent;
|
10890 | }(BaseChartComponent));
|
10891 | PolarChartComponent.decorators = [
|
10892 | { type: core.Component, args: [{
|
10893 | selector: 'ngx-charts-polar-chart',
|
10894 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event)\"\n (legendLabelDeactivate)=\"onDeactivate($event)\"\n >\n <svg:g class=\"polar-chart chart\" [attr.transform]=\"transform\">\n <svg:g [attr.transform]=\"transformPlot\">\n <svg:circle class=\"polar-chart-background\" cx=\"0\" cy=\"0\" [attr.r]=\"this.outerRadius\" />\n <svg:g *ngIf=\"showGridLines\">\n <svg:circle\n *ngFor=\"let r of radiusTicks\"\n class=\"gridline-path radial-gridline-path\"\n cx=\"0\"\n cy=\"0\"\n [attr.r]=\"r\"\n />\n </svg:g>\n <svg:g *ngIf=\"xAxis\">\n <svg:g\n ngx-charts-pie-label\n *ngFor=\"let tick of thetaTicks\"\n [data]=\"tick\"\n [radius]=\"outerRadius\"\n [label]=\"tick.label\"\n [max]=\"outerRadius\"\n [value]=\"showGridLines ? 1 : outerRadius\"\n [explodeSlices]=\"true\"\n [animations]=\"animations\"\n [labelTrim]=\"labelTrim\"\n [labelTrimSize]=\"labelTrimSize\"\n ></svg:g>\n </svg:g>\n </svg:g>\n <svg:g\n ngx-charts-y-axis\n [attr.transform]=\"transformYAxis\"\n *ngIf=\"yAxis\"\n [yScale]=\"yAxisScale\"\n [dims]=\"yAxisDims\"\n [showGridLines]=\"showGridLines\"\n [showLabel]=\"showYAxisLabel\"\n [labelText]=\"yAxisLabel\"\n [trimTicks]=\"trimYAxisTicks\"\n [maxTickLength]=\"maxYAxisTickLength\"\n [tickFormatting]=\"yAxisTickFormatting\"\n (dimensionsChanged)=\"updateYAxisWidth($event)\"\n ></svg:g>\n <svg:g\n ngx-charts-axis-label\n *ngIf=\"xAxis && showXAxisLabel\"\n [label]=\"xAxisLabel\"\n [offset]=\"labelOffset\"\n [orient]=\"orientation.Bottom\"\n [height]=\"dims.height\"\n [width]=\"dims.width\"\n ></svg:g>\n <svg:g [attr.transform]=\"transformPlot\">\n <svg:g *ngFor=\"let series of results; trackBy: trackBy\" [@animationState]=\"'active'\">\n <svg:g\n ngx-charts-polar-series\n [gradient]=\"gradient\"\n [xScale]=\"xScale\"\n [yScale]=\"yScale\"\n [colors]=\"colors\"\n [data]=\"series\"\n [activeEntries]=\"activeEntries\"\n [scaleType]=\"scaleType\"\n [curve]=\"curve\"\n [rangeFillOpacity]=\"rangeFillOpacity\"\n [animations]=\"animations\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n (select)=\"onClick($event)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n />\n </svg:g>\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
10895 | encapsulation: core.ViewEncapsulation.None,
|
10896 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
10897 | animations: [
|
10898 | animations.trigger('animationState', [
|
10899 | animations.transition(':leave', [
|
10900 | animations.style({
|
10901 | opacity: 1
|
10902 | }),
|
10903 | animations.animate(500, animations.style({
|
10904 | opacity: 0
|
10905 | }))
|
10906 | ])
|
10907 | ])
|
10908 | ],
|
10909 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n", ".pie-label{font-size:11px}.pie-label.animation{-webkit-animation:.75s ease-in fadeIn;animation:.75s ease-in fadeIn}@-webkit-keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.pie-label-line{stroke-dasharray:100%}.pie-label-line.animation{-webkit-animation:3s linear drawOut;animation:3s linear drawOut;transition:d .75s}@-webkit-keyframes drawOut{0%{stroke-dashoffset:100%}to{stroke-dashoffset:0}}@keyframes drawOut{0%{stroke-dashoffset:100%}to{stroke-dashoffset:0}}\n", ".polar-chart .polar-chart-background{fill:none}.polar-chart .radial-gridline-path{stroke-dasharray:10 10;fill:none}.polar-chart .pie-label-line{stroke:#2f3646}.polar-charts-series .polar-series-area{pointer-events:none}.polar-series-path{pointer-events:none}\n"]
|
10910 | },] }
|
10911 | ];
|
10912 | PolarChartComponent.propDecorators = {
|
10913 | legend: [{ type: core.Input }],
|
10914 | legendTitle: [{ type: core.Input }],
|
10915 | legendPosition: [{ type: core.Input }],
|
10916 | xAxis: [{ type: core.Input }],
|
10917 | yAxis: [{ type: core.Input }],
|
10918 | showXAxisLabel: [{ type: core.Input }],
|
10919 | showYAxisLabel: [{ type: core.Input }],
|
10920 | xAxisLabel: [{ type: core.Input }],
|
10921 | yAxisLabel: [{ type: core.Input }],
|
10922 | autoScale: [{ type: core.Input }],
|
10923 | showGridLines: [{ type: core.Input }],
|
10924 | curve: [{ type: core.Input }],
|
10925 | activeEntries: [{ type: core.Input }],
|
10926 | schemeType: [{ type: core.Input }],
|
10927 | rangeFillOpacity: [{ type: core.Input }],
|
10928 | trimYAxisTicks: [{ type: core.Input }],
|
10929 | maxYAxisTickLength: [{ type: core.Input }],
|
10930 | xAxisTickFormatting: [{ type: core.Input }],
|
10931 | yAxisTickFormatting: [{ type: core.Input }],
|
10932 | roundDomains: [{ type: core.Input }],
|
10933 | tooltipDisabled: [{ type: core.Input }],
|
10934 | showSeriesOnHover: [{ type: core.Input }],
|
10935 | gradient: [{ type: core.Input }],
|
10936 | yAxisMinScale: [{ type: core.Input }],
|
10937 | labelTrim: [{ type: core.Input }],
|
10938 | labelTrimSize: [{ type: core.Input }],
|
10939 | activate: [{ type: core.Output }],
|
10940 | deactivate: [{ type: core.Output }],
|
10941 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
10942 | };
|
10943 |
|
10944 | var PolarSeriesComponent = (function () {
|
10945 | function PolarSeriesComponent() {
|
10946 | this.tooltipDisabled = false;
|
10947 | this.gradient = false;
|
10948 | this.animations = true;
|
10949 | this.select = new core.EventEmitter();
|
10950 | this.activate = new core.EventEmitter();
|
10951 | this.deactivate = new core.EventEmitter();
|
10952 | this.circleRadius = 3;
|
10953 | this.barOrientation = exports.BarOrientation;
|
10954 | this.placementTypes = exports.PlacementTypes;
|
10955 | this.styleTypes = exports.StyleTypes;
|
10956 | }
|
10957 | PolarSeriesComponent.prototype.ngOnChanges = function (changes) {
|
10958 | this.update();
|
10959 | };
|
10960 | PolarSeriesComponent.prototype.update = function () {
|
10961 | var _this = this;
|
10962 | this.updateGradients();
|
10963 | var line = this.getLineGenerator();
|
10964 | var data = this.sortData(this.data.series);
|
10965 | var seriesName = this.data.name;
|
10966 | var linearScaleType = this.colors.scaleType === exports.ScaleType.Linear;
|
10967 | var min = this.yScale.domain()[0];
|
10968 | this.seriesColor = this.colors.getColor(linearScaleType ? min : seriesName);
|
10969 | this.path = line(data) || '';
|
10970 | this.circles = data.map(function (d) {
|
10971 | var a = _this.getAngle(d);
|
10972 | var r = _this.getRadius(d);
|
10973 | var value = d.value;
|
10974 | var color = _this.colors.getColor(linearScaleType ? Math.abs(value) : seriesName);
|
10975 | var cData = Object.assign({}, d, {
|
10976 | series: seriesName,
|
10977 | value: value,
|
10978 | name: d.name
|
10979 | });
|
10980 | return {
|
10981 | data: cData,
|
10982 | cx: r * Math.sin(a),
|
10983 | cy: -r * Math.cos(a),
|
10984 | value: value,
|
10985 | color: color,
|
10986 | label: d.name
|
10987 | };
|
10988 | });
|
10989 | this.active = this.isActive(this.data);
|
10990 | this.inactive = this.isInactive(this.data);
|
10991 | this.tooltipText = this.tooltipText || (function (c) { return _this.defaultTooltipText(c); });
|
10992 | };
|
10993 | PolarSeriesComponent.prototype.getAngle = function (d) {
|
10994 | var label = d.name;
|
10995 | if (this.scaleType === exports.ScaleType.Time) {
|
10996 | return this.xScale(label);
|
10997 | }
|
10998 | else if (this.scaleType === exports.ScaleType.Linear) {
|
10999 | return this.xScale(Number(label));
|
11000 | }
|
11001 | return this.xScale(label);
|
11002 | };
|
11003 | PolarSeriesComponent.prototype.getRadius = function (d) {
|
11004 | return this.yScale(d.value);
|
11005 | };
|
11006 | PolarSeriesComponent.prototype.getLineGenerator = function () {
|
11007 | var _this = this;
|
11008 | return d3Shape.lineRadial()
|
11009 | .angle(function (d) { return _this.getAngle(d); })
|
11010 | .radius(function (d) { return _this.getRadius(d); })
|
11011 | .curve(this.curve);
|
11012 | };
|
11013 | PolarSeriesComponent.prototype.sortData = function (data) {
|
11014 | if (this.scaleType === exports.ScaleType.Linear) {
|
11015 | return sortLinear(data, 'name');
|
11016 | }
|
11017 | else if (this.scaleType === exports.ScaleType.Time) {
|
11018 | return sortByTime(data, 'name');
|
11019 | }
|
11020 | return sortByDomain(data, 'name', 'asc', this.xScale.domain());
|
11021 | };
|
11022 | PolarSeriesComponent.prototype.isActive = function (entry) {
|
11023 | if (!this.activeEntries)
|
11024 | return false;
|
11025 | var item = this.activeEntries.find(function (d) {
|
11026 | return entry.name === d.name;
|
11027 | });
|
11028 | return item !== undefined;
|
11029 | };
|
11030 | PolarSeriesComponent.prototype.isInactive = function (entry) {
|
11031 | if (!this.activeEntries || this.activeEntries.length === 0)
|
11032 | return false;
|
11033 | var item = this.activeEntries.find(function (d) {
|
11034 | return entry.name === d.name;
|
11035 | });
|
11036 | return item === undefined;
|
11037 | };
|
11038 | PolarSeriesComponent.prototype.defaultTooltipText = function (_a) {
|
11039 | var label = _a.label, value = _a.value;
|
11040 | return "\n <span class=\"tooltip-label\">" + escapeLabel(this.data.name) + " \u2022 " + escapeLabel(label) + "</span>\n <span class=\"tooltip-val\">" + value.toLocaleString() + "</span>\n ";
|
11041 | };
|
11042 | PolarSeriesComponent.prototype.updateGradients = function () {
|
11043 | this.hasGradient = this.gradient || this.colors.scaleType === exports.ScaleType.Linear;
|
11044 | if (!this.hasGradient) {
|
11045 | return;
|
11046 | }
|
11047 | this.gradientId = 'grad' + id().toString();
|
11048 | this.gradientUrl = "url(#" + this.gradientId + ")";
|
11049 | if (this.colors.scaleType === exports.ScaleType.Linear) {
|
11050 | var values = this.data.series.map(function (d) { return d.value; });
|
11051 | var max = Math.max.apply(Math, __spreadArray([], __read(values)));
|
11052 | var min = Math.min.apply(Math, __spreadArray([], __read(values)));
|
11053 | this.gradientStops = this.colors.getLinearGradientStops(max, min);
|
11054 | }
|
11055 | else {
|
11056 | this.gradientStops = undefined;
|
11057 | }
|
11058 | };
|
11059 | return PolarSeriesComponent;
|
11060 | }());
|
11061 | PolarSeriesComponent.decorators = [
|
11062 | { type: core.Component, args: [{
|
11063 | selector: 'g[ngx-charts-polar-series]',
|
11064 | template: "\n <svg:g class=\"polar-charts-series\">\n <defs>\n <svg:g\n ngx-charts-svg-radial-gradient\n *ngIf=\"hasGradient\"\n [color]=\"seriesColor\"\n [name]=\"gradientId\"\n [startOpacity]=\"0.25\"\n [endOpacity]=\"1\"\n [stops]=\"gradientStops\"\n />\n </defs>\n <svg:g\n ngx-charts-line\n class=\"polar-series-path\"\n [path]=\"path\"\n [stroke]=\"hasGradient ? gradientUrl : seriesColor\"\n [class.active]=\"active\"\n [class.inactive]=\"inactive\"\n [attr.fill-opacity]=\"rangeFillOpacity\"\n [fill]=\"hasGradient ? gradientUrl : seriesColor\"\n [animations]=\"animations\"\n />\n <svg:g\n ngx-charts-circle\n *ngFor=\"let circle of circles\"\n class=\"circle\"\n [cx]=\"circle.cx\"\n [cy]=\"circle.cy\"\n [r]=\"circleRadius\"\n [fill]=\"circle.color\"\n [style.opacity]=\"inactive ? 0.2 : 1\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"placementTypes.Top\"\n [tooltipType]=\"styleTypes.tooltip\"\n [tooltipTitle]=\"tooltipTemplate ? undefined : tooltipText(circle)\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"circle.data\"\n (select)=\"select.emit(circle.data)\"\n (activate)=\"activate.emit({ name: circle.data.series })\"\n (deactivate)=\"deactivate.emit({ name: circle.data.series })\"\n ></svg:g>\n </svg:g>\n ",
|
11065 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
11066 | },] }
|
11067 | ];
|
11068 | PolarSeriesComponent.propDecorators = {
|
11069 | name: [{ type: core.Input }],
|
11070 | data: [{ type: core.Input }],
|
11071 | xScale: [{ type: core.Input }],
|
11072 | yScale: [{ type: core.Input }],
|
11073 | colors: [{ type: core.Input }],
|
11074 | scaleType: [{ type: core.Input }],
|
11075 | curve: [{ type: core.Input }],
|
11076 | activeEntries: [{ type: core.Input }],
|
11077 | rangeFillOpacity: [{ type: core.Input }],
|
11078 | tooltipDisabled: [{ type: core.Input }],
|
11079 | tooltipText: [{ type: core.Input }],
|
11080 | gradient: [{ type: core.Input }],
|
11081 | tooltipTemplate: [{ type: core.Input }],
|
11082 | animations: [{ type: core.Input }],
|
11083 | select: [{ type: core.Output }],
|
11084 | activate: [{ type: core.Output }],
|
11085 | deactivate: [{ type: core.Output }]
|
11086 | };
|
11087 |
|
11088 | var AdvancedPieChartComponent = (function (_super) {
|
11089 | __extends(AdvancedPieChartComponent, _super);
|
11090 | function AdvancedPieChartComponent() {
|
11091 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
11092 | _this.activeEntries = [];
|
11093 | _this.tooltipDisabled = false;
|
11094 | _this.label = 'Total';
|
11095 | _this.activate = new core.EventEmitter();
|
11096 | _this.deactivate = new core.EventEmitter();
|
11097 | _this.margin = [20, 20, 20, 20];
|
11098 | return _this;
|
11099 | }
|
11100 | AdvancedPieChartComponent.prototype.update = function () {
|
11101 | _super.prototype.update.call(this);
|
11102 | this.dims = calculateViewDimensions({
|
11103 | width: (this.width * 4) / 12.0,
|
11104 | height: this.height,
|
11105 | margins: this.margin
|
11106 | });
|
11107 | this.formatDates();
|
11108 | this.domain = this.getDomain();
|
11109 | this.setColors();
|
11110 | var xOffset = this.dims.width / 2;
|
11111 | var yOffset = this.margin[0] + this.dims.height / 2;
|
11112 | this.legendWidth = this.width - this.dims.width - this.margin[1];
|
11113 | this.outerRadius = Math.min(this.dims.width, this.dims.height) / 2.5;
|
11114 | this.innerRadius = this.outerRadius * 0.75;
|
11115 | this.transform = "translate(" + xOffset + " , " + yOffset + ")";
|
11116 | };
|
11117 | AdvancedPieChartComponent.prototype.getDomain = function () {
|
11118 | return this.results.map(function (d) { return d.label; });
|
11119 | };
|
11120 | AdvancedPieChartComponent.prototype.onClick = function (data) {
|
11121 | this.select.emit(data);
|
11122 | };
|
11123 | AdvancedPieChartComponent.prototype.setColors = function () {
|
11124 | this.colors = new ColorHelper(this.scheme, exports.ScaleType.Ordinal, this.domain, this.customColors);
|
11125 | };
|
11126 | AdvancedPieChartComponent.prototype.onActivate = function (item, fromLegend) {
|
11127 | if (fromLegend === void 0) { fromLegend = false; }
|
11128 | item = this.results.find(function (d) {
|
11129 | if (fromLegend) {
|
11130 | return d.label === item.name;
|
11131 | }
|
11132 | else {
|
11133 | return d.name === item.name;
|
11134 | }
|
11135 | });
|
11136 | var idx = this.activeEntries.findIndex(function (d) {
|
11137 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
11138 | });
|
11139 | if (idx > -1) {
|
11140 | return;
|
11141 | }
|
11142 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
11143 | this.activate.emit({ value: item, entries: this.activeEntries });
|
11144 | };
|
11145 | AdvancedPieChartComponent.prototype.onDeactivate = function (item, fromLegend) {
|
11146 | if (fromLegend === void 0) { fromLegend = false; }
|
11147 | item = this.results.find(function (d) {
|
11148 | if (fromLegend) {
|
11149 | return d.label === item.name;
|
11150 | }
|
11151 | else {
|
11152 | return d.name === item.name;
|
11153 | }
|
11154 | });
|
11155 | var idx = this.activeEntries.findIndex(function (d) {
|
11156 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
11157 | });
|
11158 | this.activeEntries.splice(idx, 1);
|
11159 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
11160 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
11161 | };
|
11162 | return AdvancedPieChartComponent;
|
11163 | }(BaseChartComponent));
|
11164 | AdvancedPieChartComponent.decorators = [
|
11165 | { type: core.Component, args: [{
|
11166 | selector: 'ngx-charts-advanced-pie-chart',
|
11167 | template: "\n <div [style.width.px]=\"width\" [style.height.px]=\"height\">\n <div class=\"advanced-pie chart\" [style.width.px]=\"dims.width\" [style.height.px]=\"dims.height\">\n <ngx-charts-chart [view]=\"[width, height]\" [showLegend]=\"false\" [animations]=\"animations\">\n <svg:g [attr.transform]=\"transform\" class=\"pie chart\">\n <svg:g\n ngx-charts-pie-series\n [colors]=\"colors\"\n [series]=\"results\"\n [innerRadius]=\"innerRadius\"\n [activeEntries]=\"activeEntries\"\n [outerRadius]=\"outerRadius\"\n [gradient]=\"gradient\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipText]=\"tooltipText\"\n (select)=\"onClick($event)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n [animations]=\"animations\"\n ></svg:g>\n </svg:g>\n </ngx-charts-chart>\n </div>\n <div class=\"advanced-pie-legend-wrapper\" [style.width.px]=\"width - dims.width\" [style.height.px]=\"height\">\n <ngx-charts-advanced-legend\n [data]=\"results\"\n [colors]=\"colors\"\n [width]=\"width - dims.width - margin[1]\"\n [label]=\"label\"\n [animations]=\"animations\"\n [valueFormatting]=\"valueFormatting\"\n [labelFormatting]=\"nameFormatting\"\n [percentageFormatting]=\"percentageFormatting\"\n (select)=\"onClick($event)\"\n (activate)=\"onActivate($event, true)\"\n (deactivate)=\"onDeactivate($event, true)\"\n >\n </ngx-charts-advanced-legend>\n </div>\n </div>\n ",
|
11168 | encapsulation: core.ViewEncapsulation.None,
|
11169 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
11170 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n", ".advanced-pie{display:inline-block;float:left}.advanced-pie-legend-wrapper{display:inline-block}\n"]
|
11171 | },] }
|
11172 | ];
|
11173 | AdvancedPieChartComponent.propDecorators = {
|
11174 | gradient: [{ type: core.Input }],
|
11175 | activeEntries: [{ type: core.Input }],
|
11176 | tooltipDisabled: [{ type: core.Input }],
|
11177 | tooltipText: [{ type: core.Input }],
|
11178 | label: [{ type: core.Input }],
|
11179 | activate: [{ type: core.Output }],
|
11180 | deactivate: [{ type: core.Output }],
|
11181 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }],
|
11182 | valueFormatting: [{ type: core.Input }],
|
11183 | nameFormatting: [{ type: core.Input }],
|
11184 | percentageFormatting: [{ type: core.Input }]
|
11185 | };
|
11186 |
|
11187 | var PieLabelComponent = (function () {
|
11188 | function PieLabelComponent(platformId) {
|
11189 | this.platformId = platformId;
|
11190 | this.animations = true;
|
11191 | this.labelTrim = true;
|
11192 | this.labelTrimSize = 10;
|
11193 | this.trimLabel = trimLabel;
|
11194 | }
|
11195 | PieLabelComponent.prototype.ngOnChanges = function (changes) {
|
11196 | this.setTransforms();
|
11197 | this.update();
|
11198 | };
|
11199 | PieLabelComponent.prototype.setTransforms = function () {
|
11200 | if (common.isPlatformServer(this.platformId)) {
|
11201 | this.styleTransform = "translate3d(" + this.textX + "px," + this.textY + "px, 0)";
|
11202 | this.attrTransform = "translate(" + this.textX + "," + this.textY + ")";
|
11203 | this.textTransition = !this.animations ? null : 'transform 0.75s';
|
11204 | }
|
11205 | else {
|
11206 | var isIE = /(edge|msie|trident)/i.test(navigator.userAgent);
|
11207 | this.styleTransform = isIE ? null : "translate3d(" + this.textX + "px," + this.textY + "px, 0)";
|
11208 | this.attrTransform = !isIE ? null : "translate(" + this.textX + "," + this.textY + ")";
|
11209 | this.textTransition = isIE || !this.animations ? null : 'transform 0.75s';
|
11210 | }
|
11211 | };
|
11212 | PieLabelComponent.prototype.update = function () {
|
11213 | var startRadius = this.radius;
|
11214 | if (this.explodeSlices) {
|
11215 | startRadius = (this.radius * this.value) / this.max;
|
11216 | }
|
11217 | var innerArc = d3Shape.arc().innerRadius(startRadius).outerRadius(startRadius);
|
11218 |
|
11219 | var innerPos = innerArc.centroid(this.data);
|
11220 | var scale = this.data.pos[1] / innerPos[1];
|
11221 | if (this.data.pos[1] === 0 || innerPos[1] === 0) {
|
11222 | scale = 1;
|
11223 | }
|
11224 | var outerPos = [scale * innerPos[0], scale * innerPos[1]];
|
11225 | this.line = "M" + innerPos + "L" + outerPos + "L" + this.data.pos;
|
11226 | };
|
11227 | Object.defineProperty(PieLabelComponent.prototype, "textX", {
|
11228 | get: function () {
|
11229 | return this.data.pos[0];
|
11230 | },
|
11231 | enumerable: false,
|
11232 | configurable: true
|
11233 | });
|
11234 | Object.defineProperty(PieLabelComponent.prototype, "textY", {
|
11235 | get: function () {
|
11236 | return this.data.pos[1];
|
11237 | },
|
11238 | enumerable: false,
|
11239 | configurable: true
|
11240 | });
|
11241 | PieLabelComponent.prototype.textAnchor = function () {
|
11242 | return this.midAngle(this.data) < Math.PI ? exports.TextAnchor.Start : exports.TextAnchor.End;
|
11243 | };
|
11244 | PieLabelComponent.prototype.midAngle = function (d) {
|
11245 | return d.startAngle + (d.endAngle - d.startAngle) / 2;
|
11246 | };
|
11247 | return PieLabelComponent;
|
11248 | }());
|
11249 | PieLabelComponent.decorators = [
|
11250 | { type: core.Component, args: [{
|
11251 | selector: 'g[ngx-charts-pie-label]',
|
11252 | template: "\n <title>{{ label }}</title>\n <svg:g [attr.transform]=\"attrTransform\" [style.transform]=\"styleTransform\" [style.transition]=\"textTransition\">\n <svg:text\n class=\"pie-label\"\n [class.animation]=\"animations\"\n dy=\".35em\"\n [style.textAnchor]=\"textAnchor()\"\n [style.shapeRendering]=\"'crispEdges'\"\n >\n {{ labelTrim ? trimLabel(label, labelTrimSize) : label }}\n </svg:text>\n </svg:g>\n <svg:path\n [attr.d]=\"line\"\n [attr.stroke]=\"color\"\n fill=\"none\"\n class=\"pie-label-line line\"\n [class.animation]=\"animations\"\n ></svg:path>\n ",
|
11253 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
11254 | },] }
|
11255 | ];
|
11256 | PieLabelComponent.ctorParameters = function () { return [
|
11257 | { type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
|
11258 | ]; };
|
11259 | PieLabelComponent.propDecorators = {
|
11260 | data: [{ type: core.Input }],
|
11261 | radius: [{ type: core.Input }],
|
11262 | label: [{ type: core.Input }],
|
11263 | color: [{ type: core.Input }],
|
11264 | max: [{ type: core.Input }],
|
11265 | value: [{ type: core.Input }],
|
11266 | explodeSlices: [{ type: core.Input }],
|
11267 | animations: [{ type: core.Input }],
|
11268 | labelTrim: [{ type: core.Input }],
|
11269 | labelTrimSize: [{ type: core.Input }]
|
11270 | };
|
11271 |
|
11272 | var PieArcComponent = (function () {
|
11273 | function PieArcComponent(element) {
|
11274 | this.startAngle = 0;
|
11275 | this.endAngle = Math.PI * 2;
|
11276 | this.cornerRadius = 0;
|
11277 | this.explodeSlices = false;
|
11278 | this.gradient = false;
|
11279 | this.animate = true;
|
11280 | this.pointerEvents = true;
|
11281 | this.isActive = false;
|
11282 | this.select = new core.EventEmitter();
|
11283 | this.activate = new core.EventEmitter();
|
11284 | this.deactivate = new core.EventEmitter();
|
11285 | this.dblclick = new core.EventEmitter();
|
11286 | this.barOrientation = exports.BarOrientation;
|
11287 | this.initialized = false;
|
11288 | this.element = element.nativeElement;
|
11289 | }
|
11290 | PieArcComponent.prototype.ngOnChanges = function (changes) {
|
11291 | this.update();
|
11292 | };
|
11293 | PieArcComponent.prototype.getGradient = function () {
|
11294 | return this.gradient ? this.gradientFill : this.fill;
|
11295 | };
|
11296 | PieArcComponent.prototype.getPointerEvents = function () {
|
11297 | return this.pointerEvents ? 'auto' : 'none';
|
11298 | };
|
11299 | PieArcComponent.prototype.update = function () {
|
11300 | var calc = this.calculateArc();
|
11301 | this.startOpacity = 0.5;
|
11302 | this.radialGradientId = 'linearGrad' + id().toString();
|
11303 | this.gradientFill = "url(#" + this.radialGradientId + ")";
|
11304 | if (this.animate) {
|
11305 | if (this.initialized) {
|
11306 | this.updateAnimation();
|
11307 | }
|
11308 | else {
|
11309 | this.loadAnimation();
|
11310 | this.initialized = true;
|
11311 | }
|
11312 | }
|
11313 | else {
|
11314 | this.path = calc.startAngle(this.startAngle).endAngle(this.endAngle)();
|
11315 | }
|
11316 | };
|
11317 | PieArcComponent.prototype.calculateArc = function () {
|
11318 | var outerRadius = this.outerRadius;
|
11319 | if (this.explodeSlices && this.innerRadius === 0) {
|
11320 | outerRadius = (this.outerRadius * this.value) / this.max;
|
11321 | }
|
11322 | return d3Shape.arc().innerRadius(this.innerRadius).outerRadius(outerRadius).cornerRadius(this.cornerRadius);
|
11323 | };
|
11324 | PieArcComponent.prototype.loadAnimation = function () {
|
11325 | var node = d3Selection.select(this.element)
|
11326 | .selectAll('.arc')
|
11327 | .data([{ startAngle: this.startAngle, endAngle: this.endAngle }]);
|
11328 | var calc = this.calculateArc();
|
11329 | node
|
11330 | .transition()
|
11331 | .attrTween('d', function (d) {
|
11332 | this._current = this._current || d;
|
11333 | var copyOfD = Object.assign({}, d);
|
11334 | copyOfD.endAngle = copyOfD.startAngle;
|
11335 | var interpolater = d3Interpolate.interpolate(copyOfD, copyOfD);
|
11336 | this._current = interpolater(0);
|
11337 | return function (t) {
|
11338 | return calc(interpolater(t));
|
11339 | };
|
11340 | })
|
11341 | .transition()
|
11342 | .duration(750)
|
11343 | .attrTween('d', function (d) {
|
11344 | this._current = this._current || d;
|
11345 | var interpolater = d3Interpolate.interpolate(this._current, d);
|
11346 | this._current = interpolater(0);
|
11347 | return function (t) {
|
11348 | return calc(interpolater(t));
|
11349 | };
|
11350 | });
|
11351 | };
|
11352 | PieArcComponent.prototype.updateAnimation = function () {
|
11353 | var node = d3Selection.select(this.element)
|
11354 | .selectAll('.arc')
|
11355 | .data([{ startAngle: this.startAngle, endAngle: this.endAngle }]);
|
11356 | var calc = this.calculateArc();
|
11357 | node
|
11358 | .transition()
|
11359 | .duration(750)
|
11360 | .attrTween('d', function (d) {
|
11361 | this._current = this._current || d;
|
11362 | var interpolater = d3Interpolate.interpolate(this._current, d);
|
11363 | this._current = interpolater(0);
|
11364 | return function (t) {
|
11365 | return calc(interpolater(t));
|
11366 | };
|
11367 | });
|
11368 | };
|
11369 | PieArcComponent.prototype.onClick = function () {
|
11370 | var _this = this;
|
11371 | clearTimeout(this._timeout);
|
11372 | this._timeout = setTimeout(function () { return _this.select.emit(_this.data); }, 200);
|
11373 | };
|
11374 | PieArcComponent.prototype.onDblClick = function (event) {
|
11375 | event.preventDefault();
|
11376 | event.stopPropagation();
|
11377 | clearTimeout(this._timeout);
|
11378 | this.dblclick.emit({
|
11379 | data: this.data,
|
11380 | nativeEvent: event
|
11381 | });
|
11382 | };
|
11383 | return PieArcComponent;
|
11384 | }());
|
11385 | PieArcComponent.decorators = [
|
11386 | { type: core.Component, args: [{
|
11387 | selector: 'g[ngx-charts-pie-arc]',
|
11388 | template: "\n <svg:g class=\"arc-group\">\n <svg:defs *ngIf=\"gradient\">\n <svg:g ngx-charts-svg-radial-gradient [color]=\"fill\" [name]=\"radialGradientId\" [startOpacity]=\"startOpacity\" />\n </svg:defs>\n <svg:path\n [attr.d]=\"path\"\n class=\"arc\"\n [class.active]=\"isActive\"\n [attr.fill]=\"getGradient()\"\n (click)=\"onClick()\"\n (dblclick)=\"onDblClick($event)\"\n (mouseenter)=\"activate.emit(data)\"\n (mouseleave)=\"deactivate.emit(data)\"\n [style.pointer-events]=\"getPointerEvents()\"\n />\n </svg:g>\n ",
|
11389 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
11390 | },] }
|
11391 | ];
|
11392 | PieArcComponent.ctorParameters = function () { return [
|
11393 | { type: core.ElementRef }
|
11394 | ]; };
|
11395 | PieArcComponent.propDecorators = {
|
11396 | fill: [{ type: core.Input }],
|
11397 | startAngle: [{ type: core.Input }],
|
11398 | endAngle: [{ type: core.Input }],
|
11399 | innerRadius: [{ type: core.Input }],
|
11400 | outerRadius: [{ type: core.Input }],
|
11401 | cornerRadius: [{ type: core.Input }],
|
11402 | value: [{ type: core.Input }],
|
11403 | max: [{ type: core.Input }],
|
11404 | data: [{ type: core.Input }],
|
11405 | explodeSlices: [{ type: core.Input }],
|
11406 | gradient: [{ type: core.Input }],
|
11407 | animate: [{ type: core.Input }],
|
11408 | pointerEvents: [{ type: core.Input }],
|
11409 | isActive: [{ type: core.Input }],
|
11410 | select: [{ type: core.Output }],
|
11411 | activate: [{ type: core.Output }],
|
11412 | deactivate: [{ type: core.Output }],
|
11413 | dblclick: [{ type: core.Output }]
|
11414 | };
|
11415 |
|
11416 | var PieChartComponent = (function (_super) {
|
11417 | __extends(PieChartComponent, _super);
|
11418 | function PieChartComponent() {
|
11419 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
11420 | _this.labels = false;
|
11421 | _this.legend = false;
|
11422 | _this.legendTitle = 'Legend';
|
11423 | _this.legendPosition = exports.LegendPosition.Right;
|
11424 | _this.explodeSlices = false;
|
11425 | _this.doughnut = false;
|
11426 | _this.arcWidth = 0.25;
|
11427 | _this.activeEntries = [];
|
11428 | _this.tooltipDisabled = false;
|
11429 | _this.trimLabels = true;
|
11430 | _this.maxLabelLength = 10;
|
11431 | _this.dblclick = new core.EventEmitter();
|
11432 | _this.select = new core.EventEmitter();
|
11433 | _this.activate = new core.EventEmitter();
|
11434 | _this.deactivate = new core.EventEmitter();
|
11435 | return _this;
|
11436 | }
|
11437 | PieChartComponent.prototype.update = function () {
|
11438 | var _this = this;
|
11439 | _super.prototype.update.call(this);
|
11440 | if (this.labels && this.hasNoOptionalMarginsSet()) {
|
11441 | this.margins = [30, 80, 30, 80];
|
11442 | }
|
11443 | else if (!this.labels && this.hasNoOptionalMarginsSet()) {
|
11444 |
|
11445 | this.margins = [20, 20, 20, 20];
|
11446 | }
|
11447 | this.dims = calculateViewDimensions({
|
11448 | width: this.width,
|
11449 | height: this.height,
|
11450 | margins: this.margins,
|
11451 | showLegend: this.legend,
|
11452 | legendPosition: this.legendPosition
|
11453 | });
|
11454 | this.formatDates();
|
11455 | var xOffset = this.margins[3] + this.dims.width / 2;
|
11456 | var yOffset = this.margins[0] + this.dims.height / 2;
|
11457 | this.translation = "translate(" + xOffset + ", " + yOffset + ")";
|
11458 | this.outerRadius = Math.min(this.dims.width, this.dims.height);
|
11459 | if (this.labels) {
|
11460 |
|
11461 | this.outerRadius /= 3;
|
11462 | }
|
11463 | else {
|
11464 | this.outerRadius /= 2;
|
11465 | }
|
11466 | this.innerRadius = 0;
|
11467 | if (this.doughnut) {
|
11468 | this.innerRadius = this.outerRadius * (1 - this.arcWidth);
|
11469 | }
|
11470 | this.domain = this.getDomain();
|
11471 |
|
11472 | this.data = this.results.sort(function (a, b) {
|
11473 | return _this.domain.indexOf(a.name) - _this.domain.indexOf(b.name);
|
11474 | });
|
11475 | this.setColors();
|
11476 | this.legendOptions = this.getLegendOptions();
|
11477 | };
|
11478 | PieChartComponent.prototype.getDomain = function () {
|
11479 | return this.results.map(function (d) { return d.label; });
|
11480 | };
|
11481 | PieChartComponent.prototype.onClick = function (data) {
|
11482 | this.select.emit(data);
|
11483 | };
|
11484 | PieChartComponent.prototype.setColors = function () {
|
11485 | this.colors = new ColorHelper(this.scheme, exports.ScaleType.Ordinal, this.domain, this.customColors);
|
11486 | };
|
11487 | PieChartComponent.prototype.getLegendOptions = function () {
|
11488 | return {
|
11489 | scaleType: exports.ScaleType.Ordinal,
|
11490 | domain: this.domain,
|
11491 | colors: this.colors,
|
11492 | title: this.legendTitle,
|
11493 | position: this.legendPosition
|
11494 | };
|
11495 | };
|
11496 | PieChartComponent.prototype.onActivate = function (item, fromLegend) {
|
11497 | if (fromLegend === void 0) { fromLegend = false; }
|
11498 | item = this.results.find(function (d) {
|
11499 | if (fromLegend) {
|
11500 | return d.label === item.name;
|
11501 | }
|
11502 | else {
|
11503 | return d.name === item.name;
|
11504 | }
|
11505 | });
|
11506 | var idx = this.activeEntries.findIndex(function (d) {
|
11507 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
11508 | });
|
11509 | if (idx > -1) {
|
11510 | return;
|
11511 | }
|
11512 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
11513 | this.activate.emit({ value: item, entries: this.activeEntries });
|
11514 | };
|
11515 | PieChartComponent.prototype.onDeactivate = function (item, fromLegend) {
|
11516 | if (fromLegend === void 0) { fromLegend = false; }
|
11517 | item = this.results.find(function (d) {
|
11518 | if (fromLegend) {
|
11519 | return d.label === item.name;
|
11520 | }
|
11521 | else {
|
11522 | return d.name === item.name;
|
11523 | }
|
11524 | });
|
11525 | var idx = this.activeEntries.findIndex(function (d) {
|
11526 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
11527 | });
|
11528 | this.activeEntries.splice(idx, 1);
|
11529 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
11530 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
11531 | };
|
11532 | PieChartComponent.prototype.hasNoOptionalMarginsSet = function () {
|
11533 | return !this.margins || this.margins.length <= 0;
|
11534 | };
|
11535 | return PieChartComponent;
|
11536 | }(BaseChartComponent));
|
11537 | PieChartComponent.decorators = [
|
11538 | { type: core.Component, args: [{
|
11539 | selector: 'ngx-charts-pie-chart',
|
11540 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelActivate)=\"onActivate($event, true)\"\n (legendLabelDeactivate)=\"onDeactivate($event, true)\"\n (legendLabelClick)=\"onClick($event)\"\n >\n <svg:g [attr.transform]=\"translation\" class=\"pie-chart chart\">\n <svg:g\n ngx-charts-pie-series\n [colors]=\"colors\"\n [series]=\"data\"\n [showLabels]=\"labels\"\n [labelFormatting]=\"labelFormatting\"\n [trimLabels]=\"trimLabels\"\n [maxLabelLength]=\"maxLabelLength\"\n [activeEntries]=\"activeEntries\"\n [innerRadius]=\"innerRadius\"\n [outerRadius]=\"outerRadius\"\n [explodeSlices]=\"explodeSlices\"\n [gradient]=\"gradient\"\n [animations]=\"animations\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipText]=\"tooltipText\"\n (dblclick)=\"dblclick.emit($event)\"\n (select)=\"onClick($event)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n />\n </svg:g>\n </ngx-charts-chart>\n ",
|
11541 | encapsulation: core.ViewEncapsulation.None,
|
11542 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
11543 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n", ".pie-label{font-size:11px}.pie-label.animation{-webkit-animation:.75s ease-in fadeIn;animation:.75s ease-in fadeIn}@-webkit-keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.pie-label-line{stroke-dasharray:100%}.pie-label-line.animation{-webkit-animation:3s linear drawOut;animation:3s linear drawOut;transition:d .75s}@-webkit-keyframes drawOut{0%{stroke-dashoffset:100%}to{stroke-dashoffset:0}}@keyframes drawOut{0%{stroke-dashoffset:100%}to{stroke-dashoffset:0}}\n"]
|
11544 | },] }
|
11545 | ];
|
11546 | PieChartComponent.propDecorators = {
|
11547 | labels: [{ type: core.Input }],
|
11548 | legend: [{ type: core.Input }],
|
11549 | legendTitle: [{ type: core.Input }],
|
11550 | legendPosition: [{ type: core.Input }],
|
11551 | explodeSlices: [{ type: core.Input }],
|
11552 | doughnut: [{ type: core.Input }],
|
11553 | arcWidth: [{ type: core.Input }],
|
11554 | gradient: [{ type: core.Input }],
|
11555 | activeEntries: [{ type: core.Input }],
|
11556 | tooltipDisabled: [{ type: core.Input }],
|
11557 | labelFormatting: [{ type: core.Input }],
|
11558 | trimLabels: [{ type: core.Input }],
|
11559 | maxLabelLength: [{ type: core.Input }],
|
11560 | tooltipText: [{ type: core.Input }],
|
11561 | dblclick: [{ type: core.Output }],
|
11562 | margins: [{ type: core.Input }],
|
11563 | select: [{ type: core.Output }],
|
11564 | activate: [{ type: core.Output }],
|
11565 | deactivate: [{ type: core.Output }],
|
11566 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
11567 | };
|
11568 |
|
11569 | function gridSize(dims, len, minWidth) {
|
11570 | var rows = 1;
|
11571 | var cols = len;
|
11572 | var width = dims.width;
|
11573 | if (width > minWidth) {
|
11574 | while (width / cols < minWidth) {
|
11575 | rows += 1;
|
11576 | cols = Math.ceil(len / rows);
|
11577 | }
|
11578 | }
|
11579 | return [cols, rows];
|
11580 | }
|
11581 | function gridLayout(dims, data, minWidth, designatedTotal) {
|
11582 | var xScale = d3Scale.scaleBand();
|
11583 | var yScale = d3Scale.scaleBand();
|
11584 | var width = dims.width;
|
11585 | var height = dims.height;
|
11586 | var _a = __read(gridSize(dims, data.length, minWidth), 2), columns = _a[0], rows = _a[1];
|
11587 | var xDomain = [];
|
11588 | var yDomain = [];
|
11589 | for (var i = 0; i < rows; i++) {
|
11590 | yDomain.push(i);
|
11591 | }
|
11592 | for (var i = 0; i < columns; i++) {
|
11593 | xDomain.push(i);
|
11594 | }
|
11595 | xScale.domain(xDomain);
|
11596 | yScale.domain(yDomain);
|
11597 | xScale.rangeRound([0, width], 0.1);
|
11598 | yScale.rangeRound([0, height], 0.1);
|
11599 | var res = [];
|
11600 | var total = designatedTotal ? designatedTotal : getTotal(data);
|
11601 | var cardWidth = xScale.bandwidth();
|
11602 | var cardHeight = yScale.bandwidth();
|
11603 | for (var i = 0; i < data.length; i++) {
|
11604 | res[i] = {};
|
11605 | res[i].data = {
|
11606 | name: data[i] ? data[i].name : '',
|
11607 | value: data[i] ? data[i].value : undefined,
|
11608 | extra: data[i] ? data[i].extra : undefined,
|
11609 | label: data[i] ? data[i].label : ''
|
11610 | };
|
11611 | res[i].x = xScale(i % columns);
|
11612 | res[i].y = yScale(Math.floor(i / columns));
|
11613 | res[i].width = cardWidth;
|
11614 | res[i].height = cardHeight;
|
11615 | res[i].data.percent = total > 0 ? res[i].data.value / total : 0;
|
11616 | res[i].data.total = total;
|
11617 | }
|
11618 | return res;
|
11619 | }
|
11620 | function getTotal(results) {
|
11621 | return results.map(function (d) { return (d ? d.value : 0); }).reduce(function (sum, val) { return sum + val; }, 0);
|
11622 | }
|
11623 |
|
11624 | var PieGridComponent = (function (_super) {
|
11625 | __extends(PieGridComponent, _super);
|
11626 | function PieGridComponent() {
|
11627 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
11628 | _this.tooltipDisabled = false;
|
11629 | _this.label = 'Total';
|
11630 | _this.minWidth = 150;
|
11631 | _this.activeEntries = [];
|
11632 | _this.activate = new core.EventEmitter();
|
11633 | _this.deactivate = new core.EventEmitter();
|
11634 | _this.margin = [20, 20, 20, 20];
|
11635 | _this.placementTypes = exports.PlacementTypes;
|
11636 | _this.styleTypes = exports.StyleTypes;
|
11637 | return _this;
|
11638 | }
|
11639 | PieGridComponent.prototype.update = function () {
|
11640 | _super.prototype.update.call(this);
|
11641 | this.dims = calculateViewDimensions({
|
11642 | width: this.width,
|
11643 | height: this.height,
|
11644 | margins: this.margin
|
11645 | });
|
11646 | this.formatDates();
|
11647 | this.domain = this.getDomain();
|
11648 | this.data = gridLayout(this.dims, this.results, this.minWidth, this.designatedTotal);
|
11649 | this.transform = "translate(" + this.margin[3] + " , " + this.margin[0] + ")";
|
11650 | this.series = this.getSeries();
|
11651 | this.setColors();
|
11652 | this.tooltipText = this.tooltipText || this.defaultTooltipText;
|
11653 | };
|
11654 | PieGridComponent.prototype.defaultTooltipText = function (_a) {
|
11655 | var data = _a.data;
|
11656 | var label = trimLabel(formatLabel(data.name));
|
11657 | var val = data.value.toLocaleString();
|
11658 | return "\n <span class=\"tooltip-label\">" + label + "</span>\n <span class=\"tooltip-val\">" + val + "</span>\n ";
|
11659 | };
|
11660 | PieGridComponent.prototype.getDomain = function () {
|
11661 | return this.results.map(function (d) { return d.label; });
|
11662 | };
|
11663 | PieGridComponent.prototype.getSeries = function () {
|
11664 | var _this = this;
|
11665 | var total = this.designatedTotal ? this.designatedTotal : this.getTotal();
|
11666 | return this.data.map(function (d) {
|
11667 | var baselineLabelHeight = 20;
|
11668 | var padding = 10;
|
11669 | var name = d.data.name;
|
11670 | var label = formatLabel(name);
|
11671 | var value = d.data.value;
|
11672 | var radius = d3Array.min([d.width - padding, d.height - baselineLabelHeight]) / 2 - 5;
|
11673 | var innerRadius = radius * 0.9;
|
11674 | var count = 0;
|
11675 | var colors = function () {
|
11676 | count += 1;
|
11677 | if (count === 1) {
|
11678 | return 'rgba(100,100,100,0.3)';
|
11679 | }
|
11680 | else {
|
11681 | return _this.colorScale.getColor(label);
|
11682 | }
|
11683 | };
|
11684 | var xPos = d.x + (d.width - padding) / 2;
|
11685 | var yPos = d.y + (d.height - baselineLabelHeight) / 2;
|
11686 | return {
|
11687 | transform: "translate(" + xPos + ", " + yPos + ")",
|
11688 | colors: colors,
|
11689 | innerRadius: innerRadius,
|
11690 | outerRadius: radius,
|
11691 | name: name,
|
11692 | label: trimLabel(label),
|
11693 | total: value,
|
11694 | value: value,
|
11695 | percent: d3Format.format('.1%')(d.data.percent),
|
11696 | data: [
|
11697 | d,
|
11698 | {
|
11699 | data: {
|
11700 | other: true,
|
11701 | value: total - value,
|
11702 | name: d.data.name
|
11703 | }
|
11704 | }
|
11705 | ]
|
11706 | };
|
11707 | });
|
11708 | };
|
11709 | PieGridComponent.prototype.getTotal = function () {
|
11710 | return this.results.map(function (d) { return d.value; }).reduce(function (sum, d) { return sum + d; }, 0);
|
11711 | };
|
11712 | PieGridComponent.prototype.onClick = function (data) {
|
11713 | this.select.emit(data);
|
11714 | };
|
11715 | PieGridComponent.prototype.setColors = function () {
|
11716 | this.colorScale = new ColorHelper(this.scheme, exports.ScaleType.Ordinal, this.domain, this.customColors);
|
11717 | };
|
11718 | PieGridComponent.prototype.onActivate = function (item, fromLegend) {
|
11719 | if (fromLegend === void 0) { fromLegend = false; }
|
11720 | item = this.results.find(function (d) {
|
11721 | if (fromLegend) {
|
11722 | return d.label === item.name;
|
11723 | }
|
11724 | else {
|
11725 | return d.name === item.name;
|
11726 | }
|
11727 | });
|
11728 | var idx = this.activeEntries.findIndex(function (d) {
|
11729 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
11730 | });
|
11731 | if (idx > -1) {
|
11732 | return;
|
11733 | }
|
11734 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
11735 | this.activate.emit({ value: item, entries: this.activeEntries });
|
11736 | };
|
11737 | PieGridComponent.prototype.onDeactivate = function (item, fromLegend) {
|
11738 | if (fromLegend === void 0) { fromLegend = false; }
|
11739 | item = this.results.find(function (d) {
|
11740 | if (fromLegend) {
|
11741 | return d.label === item.name;
|
11742 | }
|
11743 | else {
|
11744 | return d.name === item.name;
|
11745 | }
|
11746 | });
|
11747 | var idx = this.activeEntries.findIndex(function (d) {
|
11748 | return d.name === item.name && d.value === item.value && d.series === item.series;
|
11749 | });
|
11750 | this.activeEntries.splice(idx, 1);
|
11751 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
11752 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
11753 | };
|
11754 | return PieGridComponent;
|
11755 | }(BaseChartComponent));
|
11756 | PieGridComponent.decorators = [
|
11757 | { type: core.Component, args: [{
|
11758 | selector: 'ngx-charts-pie-grid',
|
11759 | template: "\n <ngx-charts-chart [view]=\"[width, height]\" [showLegend]=\"false\" [animations]=\"animations\">\n <svg:g [attr.transform]=\"transform\" class=\"pie-grid chart\">\n <svg:g *ngFor=\"let series of series\" class=\"pie-grid-item\" [attr.transform]=\"series.transform\">\n <svg:g\n ngx-charts-pie-grid-series\n [colors]=\"series.colors\"\n [data]=\"series.data\"\n [innerRadius]=\"series.innerRadius\"\n [outerRadius]=\"series.outerRadius\"\n [animations]=\"animations\"\n (select)=\"onClick($event)\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"placementTypes.Top\"\n [tooltipType]=\"styleTypes.tooltip\"\n [tooltipTitle]=\"tooltipTemplate ? undefined : tooltipText({ data: series })\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"series.data[0].data\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n />\n <svg:text\n *ngIf=\"animations\"\n class=\"label percent-label\"\n dy=\"-0.5em\"\n x=\"0\"\n y=\"5\"\n ngx-charts-count-up\n [countTo]=\"series.percent\"\n [countSuffix]=\"'%'\"\n text-anchor=\"middle\"\n ></svg:text>\n <svg:text *ngIf=\"!animations\" class=\"label percent-label\" dy=\"-0.5em\" x=\"0\" y=\"5\" text-anchor=\"middle\">\n {{ series.percent.toLocaleString() }}\n </svg:text>\n <svg:text class=\"label\" dy=\"0.5em\" x=\"0\" y=\"5\" text-anchor=\"middle\">\n {{ series.label }}\n </svg:text>\n <svg:text\n *ngIf=\"animations\"\n class=\"label\"\n dy=\"1.23em\"\n x=\"0\"\n [attr.y]=\"series.outerRadius\"\n text-anchor=\"middle\"\n ngx-charts-count-up\n [countTo]=\"series.total\"\n [countPrefix]=\"label + ': '\"\n ></svg:text>\n <svg:text\n *ngIf=\"!animations\"\n class=\"label\"\n dy=\"1.23em\"\n x=\"0\"\n [attr.y]=\"series.outerRadius\"\n text-anchor=\"middle\"\n >\n {{ label }}: {{ series.total.toLocaleString() }}\n </svg:text>\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
11760 | encapsulation: core.ViewEncapsulation.None,
|
11761 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
11762 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n", ".pie-grid .arc1{opacity:.4}.pie-grid .percent-label{font-size:16px;font-weight:400}\n"]
|
11763 | },] }
|
11764 | ];
|
11765 | PieGridComponent.propDecorators = {
|
11766 | designatedTotal: [{ type: core.Input }],
|
11767 | tooltipDisabled: [{ type: core.Input }],
|
11768 | tooltipText: [{ type: core.Input }],
|
11769 | label: [{ type: core.Input }],
|
11770 | minWidth: [{ type: core.Input }],
|
11771 | activeEntries: [{ type: core.Input }],
|
11772 | activate: [{ type: core.Output }],
|
11773 | deactivate: [{ type: core.Output }],
|
11774 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
11775 | };
|
11776 |
|
11777 | var PieGridSeriesComponent = (function () {
|
11778 | function PieGridSeriesComponent(element) {
|
11779 | this.innerRadius = 70;
|
11780 | this.outerRadius = 80;
|
11781 | this.animations = true;
|
11782 | this.select = new core.EventEmitter();
|
11783 | this.activate = new core.EventEmitter();
|
11784 | this.deactivate = new core.EventEmitter();
|
11785 | this.element = element.nativeElement;
|
11786 | }
|
11787 | PieGridSeriesComponent.prototype.ngOnChanges = function (changes) {
|
11788 | this.update();
|
11789 | };
|
11790 | PieGridSeriesComponent.prototype.update = function () {
|
11791 | this.layout = d3Shape.pie()
|
11792 | .value(function (d) { return d.data.value; })
|
11793 | .sort(null);
|
11794 | this.arcs = this.getArcs();
|
11795 | };
|
11796 | PieGridSeriesComponent.prototype.getArcs = function () {
|
11797 | var _this = this;
|
11798 | return this.layout(this.data).map(function (arc, index) {
|
11799 | var label = arc.data.data.name;
|
11800 | var other = arc.data.data.other;
|
11801 | if (index === 0) {
|
11802 | arc.startAngle = 0;
|
11803 | }
|
11804 | var color = _this.colors(label);
|
11805 | return {
|
11806 | data: arc.data.data,
|
11807 | class: 'arc ' + 'arc' + index,
|
11808 | fill: color,
|
11809 | startAngle: other ? 0 : arc.startAngle,
|
11810 | endAngle: arc.endAngle,
|
11811 | animate: _this.animations && !other,
|
11812 | pointerEvents: !other
|
11813 | };
|
11814 | });
|
11815 | };
|
11816 | PieGridSeriesComponent.prototype.onClick = function (data) {
|
11817 | this.select.emit(this.data[0].data);
|
11818 | };
|
11819 | PieGridSeriesComponent.prototype.trackBy = function (index, item) {
|
11820 | return item.data.name;
|
11821 | };
|
11822 | PieGridSeriesComponent.prototype.label = function (arc) {
|
11823 | return arc.data.name;
|
11824 | };
|
11825 | PieGridSeriesComponent.prototype.color = function (arc) {
|
11826 | return this.colors(this.label(arc));
|
11827 | };
|
11828 | return PieGridSeriesComponent;
|
11829 | }());
|
11830 | PieGridSeriesComponent.decorators = [
|
11831 | { type: core.Component, args: [{
|
11832 | selector: 'g[ngx-charts-pie-grid-series]',
|
11833 | template: "\n <svg:g class=\"pie-grid-arcs\">\n <svg:g\n ngx-charts-pie-arc\n *ngFor=\"let arc of arcs; trackBy: trackBy\"\n [attr.class]=\"arc.class\"\n [startAngle]=\"arc.startAngle\"\n [endAngle]=\"arc.endAngle\"\n [innerRadius]=\"innerRadius\"\n [outerRadius]=\"outerRadius\"\n [fill]=\"color(arc)\"\n [value]=\"arc.data.value\"\n [data]=\"arc.data\"\n [gradient]=\"false\"\n [pointerEvents]=\"arc.pointerEvents\"\n [animate]=\"arc.animate\"\n (select)=\"onClick($event)\"\n (activate)=\"activate.emit($event)\"\n (deactivate)=\"deactivate.emit($event)\"\n ></svg:g>\n </svg:g>\n ",
|
11834 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
11835 | },] }
|
11836 | ];
|
11837 | PieGridSeriesComponent.ctorParameters = function () { return [
|
11838 | { type: core.ElementRef }
|
11839 | ]; };
|
11840 | PieGridSeriesComponent.propDecorators = {
|
11841 | colors: [{ type: core.Input }],
|
11842 | data: [{ type: core.Input }],
|
11843 | innerRadius: [{ type: core.Input }],
|
11844 | outerRadius: [{ type: core.Input }],
|
11845 | animations: [{ type: core.Input }],
|
11846 | select: [{ type: core.Output }],
|
11847 | activate: [{ type: core.Output }],
|
11848 | deactivate: [{ type: core.Output }]
|
11849 | };
|
11850 |
|
11851 | var PieSeriesComponent = (function () {
|
11852 | function PieSeriesComponent() {
|
11853 | this.series = [];
|
11854 | this.innerRadius = 60;
|
11855 | this.outerRadius = 80;
|
11856 | this.trimLabels = true;
|
11857 | this.maxLabelLength = 10;
|
11858 | this.tooltipDisabled = false;
|
11859 | this.animations = true;
|
11860 | this.select = new core.EventEmitter();
|
11861 | this.activate = new core.EventEmitter();
|
11862 | this.deactivate = new core.EventEmitter();
|
11863 | this.dblclick = new core.EventEmitter();
|
11864 | this.placementTypes = exports.PlacementTypes;
|
11865 | this.styleTypes = exports.StyleTypes;
|
11866 | }
|
11867 | PieSeriesComponent.prototype.ngOnChanges = function (changes) {
|
11868 | this.update();
|
11869 | };
|
11870 | PieSeriesComponent.prototype.update = function () {
|
11871 | var pieGenerator = d3Shape.pie()
|
11872 | .value(function (d) { return d.value; })
|
11873 | .sort(null);
|
11874 | var arcData = pieGenerator(this.series);
|
11875 | this.max = d3Array.max(arcData, function (d) {
|
11876 | return d.value;
|
11877 | });
|
11878 | this.data = this.calculateLabelPositions(arcData);
|
11879 | this.tooltipText = this.tooltipText || this.defaultTooltipText;
|
11880 | };
|
11881 | PieSeriesComponent.prototype.midAngle = function (d) {
|
11882 | return d.startAngle + (d.endAngle - d.startAngle) / 2;
|
11883 | };
|
11884 | PieSeriesComponent.prototype.outerArc = function () {
|
11885 | var factor = 1.5;
|
11886 | return d3Shape.arc()
|
11887 | .innerRadius(this.outerRadius * factor)
|
11888 | .outerRadius(this.outerRadius * factor);
|
11889 | };
|
11890 | PieSeriesComponent.prototype.calculateLabelPositions = function (pieData) {
|
11891 | var _this = this;
|
11892 | var factor = 1.5;
|
11893 | var minDistance = 10;
|
11894 | var labelPositions = pieData;
|
11895 | labelPositions.forEach(function (d) {
|
11896 | d.pos = _this.outerArc().centroid(d);
|
11897 | d.pos[0] = factor * _this.outerRadius * (_this.midAngle(d) < Math.PI ? 1 : -1);
|
11898 | });
|
11899 | for (var i = 0; i < labelPositions.length - 1; i++) {
|
11900 | var a = labelPositions[i];
|
11901 | if (!this.labelVisible(a)) {
|
11902 | continue;
|
11903 | }
|
11904 | for (var j = i + 1; j < labelPositions.length; j++) {
|
11905 | var b = labelPositions[j];
|
11906 | if (!this.labelVisible(b)) {
|
11907 | continue;
|
11908 | }
|
11909 |
|
11910 | if (b.pos[0] * a.pos[0] > 0) {
|
11911 |
|
11912 | var o = minDistance - Math.abs(b.pos[1] - a.pos[1]);
|
11913 | if (o > 0) {
|
11914 |
|
11915 | b.pos[1] += Math.sign(b.pos[0]) * o;
|
11916 | }
|
11917 | }
|
11918 | }
|
11919 | }
|
11920 | return labelPositions;
|
11921 | };
|
11922 | PieSeriesComponent.prototype.labelVisible = function (myArc) {
|
11923 | return this.showLabels && myArc.endAngle - myArc.startAngle > Math.PI / 30;
|
11924 | };
|
11925 | PieSeriesComponent.prototype.getTooltipTitle = function (a) {
|
11926 | return this.tooltipTemplate ? undefined : this.tooltipText(a);
|
11927 | };
|
11928 | PieSeriesComponent.prototype.labelText = function (myArc) {
|
11929 | if (this.labelFormatting) {
|
11930 | return this.labelFormatting(myArc.data.name);
|
11931 | }
|
11932 | return this.label(myArc);
|
11933 | };
|
11934 | PieSeriesComponent.prototype.label = function (myArc) {
|
11935 | return formatLabel(myArc.data.name);
|
11936 | };
|
11937 | PieSeriesComponent.prototype.defaultTooltipText = function (myArc) {
|
11938 | var label = this.label(myArc);
|
11939 | var val = formatLabel(myArc.data.value);
|
11940 | return "\n <span class=\"tooltip-label\">" + escapeLabel(label) + "</span>\n <span class=\"tooltip-val\">" + val + "</span>\n ";
|
11941 | };
|
11942 | PieSeriesComponent.prototype.color = function (myArc) {
|
11943 | return this.colors.getColor(this.label(myArc));
|
11944 | };
|
11945 | PieSeriesComponent.prototype.trackBy = function (index, item) {
|
11946 | return item.data.name;
|
11947 | };
|
11948 | PieSeriesComponent.prototype.onClick = function (data) {
|
11949 | this.select.emit(data);
|
11950 | };
|
11951 | PieSeriesComponent.prototype.isActive = function (entry) {
|
11952 | if (!this.activeEntries)
|
11953 | return false;
|
11954 | var item = this.activeEntries.find(function (d) {
|
11955 | return entry.name === d.name && entry.series === d.series;
|
11956 | });
|
11957 | return item !== undefined;
|
11958 | };
|
11959 | return PieSeriesComponent;
|
11960 | }());
|
11961 | PieSeriesComponent.decorators = [
|
11962 | { type: core.Component, args: [{
|
11963 | selector: 'g[ngx-charts-pie-series]',
|
11964 | template: "\n <svg:g *ngFor=\"let arc of data; trackBy: trackBy\">\n <svg:g\n ngx-charts-pie-label\n *ngIf=\"labelVisible(arc)\"\n [data]=\"arc\"\n [radius]=\"outerRadius\"\n [color]=\"color(arc)\"\n [label]=\"labelText(arc)\"\n [labelTrim]=\"trimLabels\"\n [labelTrimSize]=\"maxLabelLength\"\n [max]=\"max\"\n [value]=\"arc.value\"\n [explodeSlices]=\"explodeSlices\"\n [animations]=\"animations\"\n ></svg:g>\n <svg:g\n ngx-charts-pie-arc\n [startAngle]=\"arc.startAngle\"\n [endAngle]=\"arc.endAngle\"\n [innerRadius]=\"innerRadius\"\n [outerRadius]=\"outerRadius\"\n [fill]=\"color(arc)\"\n [value]=\"arc.data.value\"\n [gradient]=\"gradient\"\n [data]=\"arc.data\"\n [max]=\"max\"\n [explodeSlices]=\"explodeSlices\"\n [isActive]=\"isActive(arc.data)\"\n [animate]=\"animations\"\n (select)=\"onClick($event)\"\n (activate)=\"activate.emit($event)\"\n (deactivate)=\"deactivate.emit($event)\"\n (dblclick)=\"dblclick.emit($event)\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"placementTypes.Top\"\n [tooltipType]=\"styleTypes.tooltip\"\n [tooltipTitle]=\"getTooltipTitle(arc)\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"arc.data\"\n ></svg:g>\n </svg:g>\n ",
|
11965 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
11966 | },] }
|
11967 | ];
|
11968 | PieSeriesComponent.propDecorators = {
|
11969 | colors: [{ type: core.Input }],
|
11970 | series: [{ type: core.Input }],
|
11971 | dims: [{ type: core.Input }],
|
11972 | innerRadius: [{ type: core.Input }],
|
11973 | outerRadius: [{ type: core.Input }],
|
11974 | explodeSlices: [{ type: core.Input }],
|
11975 | showLabels: [{ type: core.Input }],
|
11976 | gradient: [{ type: core.Input }],
|
11977 | activeEntries: [{ type: core.Input }],
|
11978 | labelFormatting: [{ type: core.Input }],
|
11979 | trimLabels: [{ type: core.Input }],
|
11980 | maxLabelLength: [{ type: core.Input }],
|
11981 | tooltipText: [{ type: core.Input }],
|
11982 | tooltipDisabled: [{ type: core.Input }],
|
11983 | tooltipTemplate: [{ type: core.Input }],
|
11984 | animations: [{ type: core.Input }],
|
11985 | select: [{ type: core.Output }],
|
11986 | activate: [{ type: core.Output }],
|
11987 | deactivate: [{ type: core.Output }],
|
11988 | dblclick: [{ type: core.Output }]
|
11989 | };
|
11990 |
|
11991 | var PieChartModule = (function () {
|
11992 | function PieChartModule() {
|
11993 | }
|
11994 | return PieChartModule;
|
11995 | }());
|
11996 | PieChartModule.decorators = [
|
11997 | { type: core.NgModule, args: [{
|
11998 | imports: [ChartCommonModule],
|
11999 | declarations: [
|
12000 | AdvancedPieChartComponent,
|
12001 | PieLabelComponent,
|
12002 | PieArcComponent,
|
12003 | PieChartComponent,
|
12004 | PieGridComponent,
|
12005 | PieGridSeriesComponent,
|
12006 | PieSeriesComponent
|
12007 | ],
|
12008 | exports: [
|
12009 | AdvancedPieChartComponent,
|
12010 | PieLabelComponent,
|
12011 | PieArcComponent,
|
12012 | PieChartComponent,
|
12013 | PieGridComponent,
|
12014 | PieGridSeriesComponent,
|
12015 | PieSeriesComponent
|
12016 | ]
|
12017 | },] }
|
12018 | ];
|
12019 |
|
12020 | var PolarChartModule = (function () {
|
12021 | function PolarChartModule() {
|
12022 | }
|
12023 | return PolarChartModule;
|
12024 | }());
|
12025 | PolarChartModule.decorators = [
|
12026 | { type: core.NgModule, args: [{
|
12027 | imports: [ChartCommonModule, PieChartModule, LineChartModule],
|
12028 | declarations: [PolarChartComponent, PolarSeriesComponent],
|
12029 | exports: [PolarChartComponent, PolarSeriesComponent]
|
12030 | },] }
|
12031 | ];
|
12032 |
|
12033 | function calculateTextWidth(fontFamilyKey, text, defaultWidth) {
|
12034 | if (defaultWidth === void 0) { defaultWidth = 8; }
|
12035 | return text.split('').reduce(function (acc, curr) {
|
12036 | var width = fontFamilyKey[curr] || defaultWidth;
|
12037 | return acc + width;
|
12038 | }, 0);
|
12039 | }
|
12040 |
|
12041 | var VERDANA_FONT_WIDTHS_16_PX = {
|
12042 | '0': 10,
|
12043 | '1': 10,
|
12044 | '2': 10,
|
12045 | '3': 10,
|
12046 | '4': 10,
|
12047 | '5': 10,
|
12048 | '6': 10,
|
12049 | '7': 10,
|
12050 | '8': 10,
|
12051 | '9': 10,
|
12052 | A: 11,
|
12053 | B: 11,
|
12054 | C: 11,
|
12055 | D: 12,
|
12056 | E: 10,
|
12057 | F: 9,
|
12058 | G: 12,
|
12059 | H: 12,
|
12060 | I: 7,
|
12061 | J: 7,
|
12062 | K: 11,
|
12063 | L: 9,
|
12064 | M: 13,
|
12065 | N: 12,
|
12066 | O: 13,
|
12067 | P: 10,
|
12068 | Q: 13,
|
12069 | R: 11,
|
12070 | S: 11,
|
12071 | T: 10,
|
12072 | U: 12,
|
12073 | V: 11,
|
12074 | W: 16,
|
12075 | X: 11,
|
12076 | Y: 10,
|
12077 | Z: 11,
|
12078 | a: 10,
|
12079 | b: 10,
|
12080 | c: 8,
|
12081 | d: 10,
|
12082 | e: 10,
|
12083 | f: 6,
|
12084 | g: 10,
|
12085 | h: 10,
|
12086 | i: 4,
|
12087 | j: 6,
|
12088 | k: 9,
|
12089 | l: 4,
|
12090 | m: 16,
|
12091 | n: 10,
|
12092 | o: 10,
|
12093 | p: 10,
|
12094 | q: 10,
|
12095 | r: 7,
|
12096 | s: 8,
|
12097 | t: 6,
|
12098 | u: 10,
|
12099 | v: 9,
|
12100 | w: 13,
|
12101 | x: 9,
|
12102 | y: 9,
|
12103 | z: 8,
|
12104 | '!': 6,
|
12105 | '@': 16,
|
12106 | '#': 13,
|
12107 | $: 10,
|
12108 | '%': 17,
|
12109 | '^': 13,
|
12110 | '&': 12,
|
12111 | '*': 10,
|
12112 | '(': 7,
|
12113 | ')': 7,
|
12114 | _: 10,
|
12115 | '-': 7,
|
12116 | '+': 13,
|
12117 | '=': 13,
|
12118 | ',': 6,
|
12119 | '.': 6,
|
12120 | '/': 7,
|
12121 | "'": 4,
|
12122 | ':': 7,
|
12123 | '|': 7,
|
12124 | '?': 9,
|
12125 | ';': 7,
|
12126 | '<': 13,
|
12127 | '>': 13
|
12128 | };
|
12129 |
|
12130 | var CardComponent = (function () {
|
12131 | function CardComponent(element, cd, zone, platformId) {
|
12132 | this.cd = cd;
|
12133 | this.zone = zone;
|
12134 | this.platformId = platformId;
|
12135 | this.animations = true;
|
12136 | this.select = new core.EventEmitter();
|
12137 | this.value = '';
|
12138 | this.textFontSize = 12;
|
12139 | this.textTransform = '';
|
12140 | this.initialized = false;
|
12141 | this.bandHeight = 10;
|
12142 | this.textPadding = [10, 20, 5, 20];
|
12143 | this.labelFontSize = 15;
|
12144 | this.element = element.nativeElement;
|
12145 | }
|
12146 | CardComponent.prototype.ngOnChanges = function (changes) {
|
12147 | this.update();
|
12148 | };
|
12149 | CardComponent.prototype.ngOnInit = function () {
|
12150 | if (common.isPlatformServer(this.platformId)) {
|
12151 | this.scaleTextSSR();
|
12152 | }
|
12153 | };
|
12154 | CardComponent.prototype.ngOnDestroy = function () {
|
12155 | if (common.isPlatformBrowser(this.platformId)) {
|
12156 | cancelAnimationFrame(this.animationReq);
|
12157 | }
|
12158 | };
|
12159 | CardComponent.prototype.update = function () {
|
12160 | var _this = this;
|
12161 | this.zone.run(function () {
|
12162 | var hasValue = _this.data && typeof _this.data.value !== 'undefined';
|
12163 | var valueFormatting = _this.valueFormatting || (function (card) { return card.value.toLocaleString(); });
|
12164 | var labelFormatting = _this.labelFormatting || (function (card) { return escapeLabel(trimLabel(card.label, 55)); });
|
12165 | _this.transform = "translate(" + _this.x + " , " + _this.y + ")";
|
12166 | _this.textWidth = Math.max(0, _this.width) - _this.textPadding[1] - _this.textPadding[3];
|
12167 | _this.cardWidth = Math.max(0, _this.width);
|
12168 | _this.cardHeight = Math.max(0, _this.height);
|
12169 | _this.label = _this.label ? _this.label : _this.data.name;
|
12170 | var cardData = {
|
12171 | label: _this.label,
|
12172 | data: _this.data,
|
12173 | value: _this.data.value
|
12174 | };
|
12175 | _this.formattedLabel = labelFormatting(cardData);
|
12176 | _this.transformBand = "translate(0 , " + (_this.cardHeight - _this.bandHeight) + ")";
|
12177 | var value = hasValue ? valueFormatting(cardData) : '';
|
12178 | _this.value = _this.paddedValue(value);
|
12179 | _this.setPadding();
|
12180 | _this.bandPath = roundedRect(0, 0, _this.cardWidth, _this.bandHeight, 3, [false, false, true, true]);
|
12181 | setTimeout(function () {
|
12182 | if (common.isPlatformBrowser(_this.platformId)) {
|
12183 | _this.scaleText();
|
12184 | }
|
12185 | _this.value = value;
|
12186 | if (hasValue && !_this.initialized) {
|
12187 | setTimeout(function () { return _this.startCount(); }, 20);
|
12188 | }
|
12189 | }, 8);
|
12190 | });
|
12191 | };
|
12192 | CardComponent.prototype.paddedValue = function (value) {
|
12193 | if (this.medianSize && this.medianSize > value.length) {
|
12194 | value += '\u2007'.repeat(this.medianSize - value.length);
|
12195 | }
|
12196 | return value;
|
12197 | };
|
12198 | CardComponent.prototype.startCount = function () {
|
12199 | var _this = this;
|
12200 | if (!this.initialized && this.animations) {
|
12201 | cancelAnimationFrame(this.animationReq);
|
12202 | var val_1 = this.data.value;
|
12203 | var decs = decimalChecker(val_1);
|
12204 | var valueFormatting_1 = this.valueFormatting || (function (card) { return card.value.toLocaleString(); });
|
12205 | var callback = function (_a) {
|
12206 | var value = _a.value, finished = _a.finished;
|
12207 | _this.zone.run(function () {
|
12208 | value = finished ? val_1 : value;
|
12209 | _this.value = valueFormatting_1({ label: _this.label, data: _this.data, value: value });
|
12210 | if (!finished) {
|
12211 | _this.value = _this.paddedValue(_this.value);
|
12212 | }
|
12213 | _this.cd.markForCheck();
|
12214 | });
|
12215 | };
|
12216 | this.animationReq = count(0, val_1, decs, 1, callback);
|
12217 | this.initialized = true;
|
12218 | }
|
12219 | };
|
12220 | CardComponent.prototype.scaleText = function () {
|
12221 | var _this = this;
|
12222 | this.zone.run(function () {
|
12223 | var _a = _this.textEl.nativeElement.getBoundingClientRect(), width = _a.width, height = _a.height;
|
12224 | if (width === 0 || height === 0) {
|
12225 | return;
|
12226 | }
|
12227 | var textPadding = (_this.textPadding[1] = _this.textPadding[3] = _this.cardWidth / 8);
|
12228 | var availableWidth = _this.cardWidth - 2 * textPadding;
|
12229 | var availableHeight = _this.cardHeight / 3;
|
12230 | var resizeScale = Math.min(availableWidth / width, availableHeight / height);
|
12231 | _this.textFontSize = Math.floor(_this.textFontSize * resizeScale);
|
12232 | _this.labelFontSize = Math.min(_this.textFontSize, 15);
|
12233 | _this.setPadding();
|
12234 | _this.cd.markForCheck();
|
12235 | });
|
12236 | };
|
12237 | CardComponent.prototype.scaleTextSSR = function () {
|
12238 | var width = calculateTextWidth(VERDANA_FONT_WIDTHS_16_PX, this.value, 10);
|
12239 | var height = 18;
|
12240 | var textPadding = (this.textPadding[1] = this.textPadding[3] = this.cardWidth / 8);
|
12241 | var availableWidth = this.cardWidth - 2 * textPadding;
|
12242 | var availableHeight = this.cardHeight / 3;
|
12243 | var resizeScale = Math.min(availableWidth / width, availableHeight / height);
|
12244 | this.textFontSize = Math.floor(this.textFontSize * resizeScale);
|
12245 | this.labelFontSize = Math.min(this.textFontSize, 15);
|
12246 | this.setPadding();
|
12247 | };
|
12248 | CardComponent.prototype.setPadding = function () {
|
12249 | this.textPadding[1] = this.textPadding[3] = this.cardWidth / 8;
|
12250 | var padding = this.cardHeight / 2;
|
12251 | this.textPadding[0] = padding - this.textFontSize - this.labelFontSize / 2;
|
12252 | this.textPadding[2] = padding - this.labelFontSize;
|
12253 | };
|
12254 | CardComponent.prototype.onClick = function () {
|
12255 | this.select.emit(this.data);
|
12256 | };
|
12257 | return CardComponent;
|
12258 | }());
|
12259 | CardComponent.decorators = [
|
12260 | { type: core.Component, args: [{
|
12261 | selector: 'g[ngx-charts-card]',
|
12262 | template: "\n <svg:g [attr.transform]=\"transform\" class=\"cell\" (click)=\"onClick()\">\n <svg:rect class=\"card\" [style.fill]=\"color\" [attr.width]=\"cardWidth\" [attr.height]=\"cardHeight\" rx=\"3\" ry=\"3\" />\n <svg:path\n *ngIf=\"bandColor && bandColor !== color\"\n class=\"card-band\"\n [attr.fill]=\"bandColor\"\n [attr.transform]=\"transformBand\"\n stroke=\"none\"\n [attr.d]=\"bandPath\"\n />\n <title>{{ label }}</title>\n <svg:foreignObject\n class=\"trimmed-label\"\n x=\"5\"\n [attr.x]=\"textPadding[3]\"\n [attr.y]=\"cardHeight - textPadding[2]\"\n [attr.width]=\"textWidth\"\n [attr.height]=\"labelFontSize + textPadding[2]\"\n alignment-baseline=\"hanging\"\n >\n <xhtml:p\n [style.color]=\"textColor\"\n [style.fontSize.px]=\"labelFontSize\"\n [style.lineHeight.px]=\"labelFontSize\"\n [innerHTML]=\"formattedLabel\"\n >\n </xhtml:p>\n </svg:foreignObject>\n <svg:text\n #textEl\n class=\"value-text\"\n [attr.x]=\"textPadding[3]\"\n [attr.y]=\"textPadding[0]\"\n [style.fill]=\"textColor\"\n text-anchor=\"start\"\n alignment-baseline=\"hanging\"\n [style.font-size.pt]=\"textFontSize\"\n >\n {{ value }}\n </svg:text>\n </svg:g>\n ",
|
12263 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
12264 | },] }
|
12265 | ];
|
12266 | CardComponent.ctorParameters = function () { return [
|
12267 | { type: core.ElementRef },
|
12268 | { type: core.ChangeDetectorRef },
|
12269 | { type: core.NgZone },
|
12270 | { type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
|
12271 | ]; };
|
12272 | CardComponent.propDecorators = {
|
12273 | color: [{ type: core.Input }],
|
12274 | bandColor: [{ type: core.Input }],
|
12275 | textColor: [{ type: core.Input }],
|
12276 | x: [{ type: core.Input }],
|
12277 | y: [{ type: core.Input }],
|
12278 | width: [{ type: core.Input }],
|
12279 | height: [{ type: core.Input }],
|
12280 | label: [{ type: core.Input }],
|
12281 | data: [{ type: core.Input }],
|
12282 | medianSize: [{ type: core.Input }],
|
12283 | valueFormatting: [{ type: core.Input }],
|
12284 | labelFormatting: [{ type: core.Input }],
|
12285 | animations: [{ type: core.Input }],
|
12286 | select: [{ type: core.Output }],
|
12287 | textEl: [{ type: core.ViewChild, args: ['textEl', { static: false },] }]
|
12288 | };
|
12289 |
|
12290 | |
12291 |
|
12292 |
|
12293 |
|
12294 |
|
12295 | function hexToRgb(value) {
|
12296 |
|
12297 | return d3_color__namespace.rgb(value);
|
12298 | }
|
12299 | |
12300 |
|
12301 |
|
12302 |
|
12303 |
|
12304 |
|
12305 | function invertColor(value) {
|
12306 | var color = d3_color__namespace.rgb(value);
|
12307 | var r = color.r, g = color.g, b = color.b, opacity = color.opacity;
|
12308 | if (opacity === 0) {
|
12309 | return color.toString();
|
12310 | }
|
12311 | var yiq = (r * 299 + g * 587 + b * 114) / 1000;
|
12312 | var depth = yiq >= 128 ? -0.8 : 0.8;
|
12313 | return shadeRGBColor(color, depth);
|
12314 | }
|
12315 | |
12316 |
|
12317 |
|
12318 |
|
12319 |
|
12320 |
|
12321 |
|
12322 | function shadeRGBColor(_a, percent) {
|
12323 | var r = _a.r, g = _a.g, b = _a.b;
|
12324 | var t = percent < 0 ? 0 : 255;
|
12325 | var p = percent < 0 ? percent * -1 : percent;
|
12326 | r = Math.round((t - r) * p) + r;
|
12327 | g = Math.round((t - g) * p) + g;
|
12328 | b = Math.round((t - b) * p) + b;
|
12329 | return "rgb(" + r + ", " + g + ", " + b + ")";
|
12330 | }
|
12331 |
|
12332 | var CardSeriesComponent = (function () {
|
12333 | function CardSeriesComponent() {
|
12334 | this.innerPadding = 15;
|
12335 | this.emptyColor = 'rgba(0, 0, 0, 0)';
|
12336 | this.animations = true;
|
12337 | this.select = new core.EventEmitter();
|
12338 | }
|
12339 | CardSeriesComponent.prototype.ngOnChanges = function (changes) {
|
12340 | this.update();
|
12341 | };
|
12342 | CardSeriesComponent.prototype.update = function () {
|
12343 | if (this.data.length > 2) {
|
12344 | var valueFormatting_1 = this.valueFormatting || (function (card) { return card.value.toLocaleString(); });
|
12345 | var sortedLengths = this.data
|
12346 | .map(function (d) {
|
12347 | var hasValue = d && d.data && typeof d.data.value !== 'undefined' && d.data.value !== null;
|
12348 | return hasValue
|
12349 | ? valueFormatting_1({
|
12350 | data: d.data,
|
12351 | label: d ? d.data.name : '',
|
12352 | value: d && d.data ? d.data.value : ''
|
12353 | }).length
|
12354 | : 0;
|
12355 | })
|
12356 | .sort(function (a, b) { return b - a; });
|
12357 | var idx = Math.ceil(this.data.length / 2);
|
12358 | this.medianSize = sortedLengths[idx];
|
12359 | }
|
12360 | var cards = this.getCards();
|
12361 | this.cards = cards.filter(function (d) { return d.data.value !== null; });
|
12362 | this.emptySlots = cards.filter(function (d) { return d.data.value === null; });
|
12363 | };
|
12364 | CardSeriesComponent.prototype.getCards = function () {
|
12365 | var _this = this;
|
12366 | var yPadding = typeof this.innerPadding === 'number' ? this.innerPadding : this.innerPadding[0] + this.innerPadding[2];
|
12367 | var xPadding = typeof this.innerPadding === 'number' ? this.innerPadding : this.innerPadding[1] + this.innerPadding[3];
|
12368 | return this.data.map(function (d, index) {
|
12369 | var label = d.data.name;
|
12370 | if (label && label.constructor.name === 'Date') {
|
12371 | label = label.toLocaleDateString();
|
12372 | }
|
12373 | else {
|
12374 | label = label ? label.toLocaleString() : label;
|
12375 | }
|
12376 | var value = d.data.value;
|
12377 | var valueColor = label ? _this.colors.getColor(label) : _this.emptyColor;
|
12378 | var color = _this.cardColor || valueColor || '#000';
|
12379 | return {
|
12380 | x: d.x,
|
12381 | y: d.y,
|
12382 | width: d.width - xPadding,
|
12383 | height: d.height - yPadding,
|
12384 | color: color,
|
12385 | bandColor: _this.bandColor || valueColor,
|
12386 | textColor: _this.textColor || invertColor(color),
|
12387 | label: label,
|
12388 | data: d.data,
|
12389 | tooltipText: label + ": " + value
|
12390 | };
|
12391 | });
|
12392 | };
|
12393 | CardSeriesComponent.prototype.trackBy = function (index, card) {
|
12394 | return card.label;
|
12395 | };
|
12396 | CardSeriesComponent.prototype.onClick = function (data) {
|
12397 | this.select.emit(data);
|
12398 | };
|
12399 | return CardSeriesComponent;
|
12400 | }());
|
12401 | CardSeriesComponent.decorators = [
|
12402 | { type: core.Component, args: [{
|
12403 | selector: 'g[ngx-charts-card-series]',
|
12404 | template: "\n <svg:rect\n *ngFor=\"let c of emptySlots; trackBy: trackBy\"\n class=\"card-empty\"\n [attr.x]=\"c.x\"\n [attr.y]=\"c.y\"\n [style.fill]=\"emptyColor\"\n [attr.width]=\"c.width\"\n [attr.height]=\"c.height\"\n rx=\"3\"\n ry=\"3\"\n />\n <svg:g\n ngx-charts-card\n *ngFor=\"let c of cards; trackBy: trackBy\"\n [x]=\"c.x\"\n [y]=\"c.y\"\n [width]=\"c.width\"\n [height]=\"c.height\"\n [color]=\"c.color\"\n [bandColor]=\"c.bandColor\"\n [textColor]=\"c.textColor\"\n [data]=\"c.data\"\n [label]=\"c.label\"\n [medianSize]=\"medianSize\"\n [valueFormatting]=\"valueFormatting\"\n [labelFormatting]=\"labelFormatting\"\n [animations]=\"animations\"\n (select)=\"onClick($event)\"\n />\n ",
|
12405 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
12406 | },] }
|
12407 | ];
|
12408 | CardSeriesComponent.propDecorators = {
|
12409 | data: [{ type: core.Input }],
|
12410 | dims: [{ type: core.Input }],
|
12411 | colors: [{ type: core.Input }],
|
12412 | innerPadding: [{ type: core.Input }],
|
12413 | cardColor: [{ type: core.Input }],
|
12414 | bandColor: [{ type: core.Input }],
|
12415 | emptyColor: [{ type: core.Input }],
|
12416 | textColor: [{ type: core.Input }],
|
12417 | valueFormatting: [{ type: core.Input }],
|
12418 | labelFormatting: [{ type: core.Input }],
|
12419 | animations: [{ type: core.Input }],
|
12420 | select: [{ type: core.Output }]
|
12421 | };
|
12422 |
|
12423 | var NumberCardComponent = (function (_super) {
|
12424 | __extends(NumberCardComponent, _super);
|
12425 | function NumberCardComponent() {
|
12426 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
12427 | _this.emptyColor = 'rgba(0, 0, 0, 0)';
|
12428 | _this.innerPadding = 15;
|
12429 | _this.margin = [10, 10, 10, 10];
|
12430 | return _this;
|
12431 | }
|
12432 | Object.defineProperty(NumberCardComponent.prototype, "clickable", {
|
12433 | get: function () {
|
12434 | return !!this.select.observers.length;
|
12435 | },
|
12436 | enumerable: false,
|
12437 | configurable: true
|
12438 | });
|
12439 | NumberCardComponent.prototype.update = function () {
|
12440 | _super.prototype.update.call(this);
|
12441 | this.dims = calculateViewDimensions({
|
12442 | width: this.width,
|
12443 | height: this.height,
|
12444 | margins: this.margin
|
12445 | });
|
12446 | this.formatDates();
|
12447 | this.domain = this.getDomain();
|
12448 | this.setColors();
|
12449 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
12450 | var size = gridSize(this.dims, this.results.length, 150);
|
12451 | var N = size[0] * size[1];
|
12452 | var data = this.results.slice();
|
12453 | while (data.length < N) {
|
12454 | data.push({ value: null });
|
12455 | }
|
12456 | this.data = gridLayout(this.dims, data, 150, this.designatedTotal);
|
12457 | };
|
12458 | NumberCardComponent.prototype.getDomain = function () {
|
12459 | return this.results.map(function (d) { return d.label; });
|
12460 | };
|
12461 | NumberCardComponent.prototype.onClick = function (data) {
|
12462 | this.select.emit(data);
|
12463 | };
|
12464 | NumberCardComponent.prototype.setColors = function () {
|
12465 | this.colors = new ColorHelper(this.scheme, exports.ScaleType.Ordinal, this.domain, this.customColors);
|
12466 | };
|
12467 | return NumberCardComponent;
|
12468 | }(BaseChartComponent));
|
12469 | NumberCardComponent.decorators = [
|
12470 | { type: core.Component, args: [{
|
12471 | selector: 'ngx-charts-number-card',
|
12472 | template: "\n <ngx-charts-chart [view]=\"[width, height]\" [showLegend]=\"false\" [animations]=\"animations\">\n <svg:g [attr.transform]=\"transform\" class=\"number-card chart\" [class.clickable]=\"clickable\">\n <svg:g\n ngx-charts-card-series\n [colors]=\"colors\"\n [cardColor]=\"cardColor\"\n [bandColor]=\"bandColor\"\n [textColor]=\"textColor\"\n [emptyColor]=\"emptyColor\"\n [data]=\"data\"\n [dims]=\"dims\"\n [innerPadding]=\"innerPadding\"\n [valueFormatting]=\"valueFormatting\"\n [labelFormatting]=\"labelFormatting\"\n [animations]=\"animations\"\n (select)=\"onClick($event)\"\n />\n </svg:g>\n </ngx-charts-chart>\n ",
|
12473 | encapsulation: core.ViewEncapsulation.None,
|
12474 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
12475 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n", "ngx-charts-number-card .cell .trimmed-label{font-size:12px;pointer-events:none;overflow:hidden;text-align:left;line-height:1em}ngx-charts-number-card .cell .trimmed-label p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width:100%;padding:0;margin:0}ngx-charts-number-card .cell .value-text{pointer-events:none}ngx-charts-number-card .number-card.clickable .cell .card,ngx-charts-number-card .number-card.clickable .cell .card-band{cursor:pointer}\n"]
|
12476 | },] }
|
12477 | ];
|
12478 | NumberCardComponent.propDecorators = {
|
12479 | cardColor: [{ type: core.Input }],
|
12480 | bandColor: [{ type: core.Input }],
|
12481 | emptyColor: [{ type: core.Input }],
|
12482 | innerPadding: [{ type: core.Input }],
|
12483 | textColor: [{ type: core.Input }],
|
12484 | valueFormatting: [{ type: core.Input }],
|
12485 | labelFormatting: [{ type: core.Input }],
|
12486 | designatedTotal: [{ type: core.Input }]
|
12487 | };
|
12488 |
|
12489 | var NumberCardModule = (function () {
|
12490 | function NumberCardModule() {
|
12491 | }
|
12492 | return NumberCardModule;
|
12493 | }());
|
12494 | NumberCardModule.decorators = [
|
12495 | { type: core.NgModule, args: [{
|
12496 | imports: [ChartCommonModule],
|
12497 | declarations: [CardComponent, CardSeriesComponent, NumberCardComponent],
|
12498 | exports: [CardComponent, CardSeriesComponent, NumberCardComponent]
|
12499 | },] }
|
12500 | ];
|
12501 |
|
12502 | var TreeMapCellComponent = (function () {
|
12503 | function TreeMapCellComponent(element) {
|
12504 | this.gradient = false;
|
12505 | this.animations = true;
|
12506 | this.select = new core.EventEmitter();
|
12507 | this.initialized = false;
|
12508 | this.orientation = exports.BarOrientation;
|
12509 | this.element = element.nativeElement;
|
12510 | }
|
12511 | TreeMapCellComponent.prototype.ngOnChanges = function () {
|
12512 | this.update();
|
12513 | this.valueFormatting = this.valueFormatting || (function (value) { return value.toLocaleString(); });
|
12514 | var labelFormatting = this.labelFormatting || (function (cell) { return escapeLabel(trimLabel(cell.label, 55)); });
|
12515 | var cellData = {
|
12516 | data: this.data,
|
12517 | label: this.label,
|
12518 | value: this.value
|
12519 | };
|
12520 | this.formattedValue = this.valueFormatting(cellData.value);
|
12521 | this.formattedLabel = labelFormatting(cellData);
|
12522 | this.gradientId = 'grad' + id().toString();
|
12523 | this.gradientUrl = "url(#" + this.gradientId + ")";
|
12524 | this.gradientStops = this.getGradientStops();
|
12525 | };
|
12526 | TreeMapCellComponent.prototype.update = function () {
|
12527 | if (this.initialized) {
|
12528 | this.animateToCurrentForm();
|
12529 | }
|
12530 | else {
|
12531 | if (this.animations) {
|
12532 | this.loadAnimation();
|
12533 | }
|
12534 | this.initialized = true;
|
12535 | }
|
12536 | };
|
12537 | TreeMapCellComponent.prototype.loadAnimation = function () {
|
12538 | var node = d3Selection.select(this.element).select('.cell');
|
12539 | node.attr('opacity', 0).attr('x', this.x).attr('y', this.y);
|
12540 | this.animateToCurrentForm();
|
12541 | };
|
12542 | TreeMapCellComponent.prototype.getTextColor = function () {
|
12543 | return invertColor(this.fill);
|
12544 | };
|
12545 | TreeMapCellComponent.prototype.animateToCurrentForm = function () {
|
12546 | var node = d3Selection.select(this.element).select('.cell');
|
12547 | if (this.animations) {
|
12548 | node
|
12549 | .transition()
|
12550 | .duration(750)
|
12551 | .attr('opacity', 1)
|
12552 | .attr('x', this.x)
|
12553 | .attr('y', this.y)
|
12554 | .attr('width', this.width)
|
12555 | .attr('height', this.height);
|
12556 | }
|
12557 | else {
|
12558 | node.attr('opacity', 1).attr('x', this.x).attr('y', this.y).attr('width', this.width).attr('height', this.height);
|
12559 | }
|
12560 | };
|
12561 | TreeMapCellComponent.prototype.onClick = function () {
|
12562 | this.select.emit(this.data);
|
12563 | };
|
12564 | TreeMapCellComponent.prototype.getGradientStops = function () {
|
12565 | return [
|
12566 | {
|
12567 | offset: 0,
|
12568 | color: this.fill,
|
12569 | opacity: 0.3
|
12570 | },
|
12571 | {
|
12572 | offset: 100,
|
12573 | color: this.fill,
|
12574 | opacity: 1
|
12575 | }
|
12576 | ];
|
12577 | };
|
12578 | return TreeMapCellComponent;
|
12579 | }());
|
12580 | TreeMapCellComponent.decorators = [
|
12581 | { type: core.Component, args: [{
|
12582 | selector: 'g[ngx-charts-tree-map-cell]',
|
12583 | template: "\n <svg:g>\n <defs *ngIf=\"gradient\">\n <svg:g\n ngx-charts-svg-linear-gradient\n [orientation]=\"orientation.Vertical\"\n [name]=\"gradientId\"\n [stops]=\"gradientStops\"\n />\n </defs>\n <svg:rect\n [attr.fill]=\"gradient ? gradientUrl : fill\"\n [attr.width]=\"width\"\n [attr.height]=\"height\"\n [attr.x]=\"x\"\n [attr.y]=\"y\"\n class=\"cell\"\n (click)=\"onClick()\"\n />\n <svg:foreignObject\n *ngIf=\"width >= 70 && height >= 35\"\n [attr.x]=\"x\"\n [attr.y]=\"y\"\n [attr.width]=\"width\"\n [attr.height]=\"height\"\n class=\"treemap-label\"\n [style.pointer-events]=\"'none'\"\n >\n <xhtml:p [style.color]=\"getTextColor()\" [style.height]=\"height + 'px'\" [style.width]=\"width + 'px'\">\n <xhtml:span class=\"treemap-label\" [innerHTML]=\"formattedLabel\"> </xhtml:span>\n <xhtml:br />\n <xhtml:span\n *ngIf=\"animations\"\n class=\"treemap-val\"\n ngx-charts-count-up\n [countTo]=\"value\"\n [valueFormatting]=\"valueFormatting\"\n >\n </xhtml:span>\n <xhtml:span *ngIf=\"!animations\" class=\"treemap-val\">\n {{ formattedValue }}\n </xhtml:span>\n </xhtml:p>\n </svg:foreignObject>\n </svg:g>\n ",
|
12584 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
12585 | },] }
|
12586 | ];
|
12587 | TreeMapCellComponent.ctorParameters = function () { return [
|
12588 | { type: core.ElementRef }
|
12589 | ]; };
|
12590 | TreeMapCellComponent.propDecorators = {
|
12591 | data: [{ type: core.Input }],
|
12592 | fill: [{ type: core.Input }],
|
12593 | x: [{ type: core.Input }],
|
12594 | y: [{ type: core.Input }],
|
12595 | width: [{ type: core.Input }],
|
12596 | height: [{ type: core.Input }],
|
12597 | label: [{ type: core.Input }],
|
12598 | value: [{ type: core.Input }],
|
12599 | valueFormatting: [{ type: core.Input }],
|
12600 | labelFormatting: [{ type: core.Input }],
|
12601 | gradient: [{ type: core.Input }],
|
12602 | animations: [{ type: core.Input }],
|
12603 | select: [{ type: core.Output }]
|
12604 | };
|
12605 |
|
12606 | var TreeMapCellSeriesComponent = (function () {
|
12607 | function TreeMapCellSeriesComponent() {
|
12608 | this.gradient = false;
|
12609 | this.tooltipDisabled = false;
|
12610 | this.animations = true;
|
12611 | this.select = new core.EventEmitter();
|
12612 | this.styleTypes = exports.StyleTypes;
|
12613 | this.placementTypes = exports.PlacementTypes;
|
12614 | }
|
12615 | TreeMapCellSeriesComponent.prototype.ngOnChanges = function (changes) {
|
12616 | this.cells = this.getCells();
|
12617 | };
|
12618 | TreeMapCellSeriesComponent.prototype.getCells = function () {
|
12619 | var _this = this;
|
12620 | return this.data.children
|
12621 | .filter(function (d) {
|
12622 | return d.depth === 1;
|
12623 | })
|
12624 | .map(function (d, index) {
|
12625 | var label = d.id;
|
12626 | return {
|
12627 | data: d.data,
|
12628 | x: d.x0,
|
12629 | y: d.y0,
|
12630 | width: d.x1 - d.x0,
|
12631 | height: d.y1 - d.y0,
|
12632 | fill: _this.colors.getColor(label),
|
12633 | label: label,
|
12634 | value: d.value
|
12635 | };
|
12636 | });
|
12637 | };
|
12638 | TreeMapCellSeriesComponent.prototype.getTooltipText = function (_a) {
|
12639 | var label = _a.label, value = _a.value;
|
12640 | return "\n <span class=\"tooltip-label\">" + escapeLabel(label) + "</span>\n <span class=\"tooltip-val\">" + value.toLocaleString() + "</span>\n ";
|
12641 | };
|
12642 | TreeMapCellSeriesComponent.prototype.onClick = function (data) {
|
12643 | this.select.emit(data);
|
12644 | };
|
12645 | TreeMapCellSeriesComponent.prototype.trackBy = function (index, item) {
|
12646 | return item.label;
|
12647 | };
|
12648 | return TreeMapCellSeriesComponent;
|
12649 | }());
|
12650 | TreeMapCellSeriesComponent.decorators = [
|
12651 | { type: core.Component, args: [{
|
12652 | selector: 'g[ngx-charts-tree-map-cell-series]',
|
12653 | template: "\n <svg:g\n ngx-charts-tree-map-cell\n *ngFor=\"let c of cells; trackBy: trackBy\"\n [data]=\"c.data\"\n [x]=\"c.x\"\n [y]=\"c.y\"\n [width]=\"c.width\"\n [height]=\"c.height\"\n [fill]=\"c.fill\"\n [label]=\"c.label\"\n [value]=\"c.value\"\n [valueFormatting]=\"valueFormatting\"\n [labelFormatting]=\"labelFormatting\"\n [gradient]=\"gradient\"\n [animations]=\"animations\"\n (select)=\"onClick($event)\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"placementTypes.Top\"\n [tooltipType]=\"styleTypes.tooltip\"\n [tooltipTitle]=\"tooltipTemplate ? undefined : getTooltipText(c)\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"c.data\"\n ></svg:g>\n ",
|
12654 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
12655 | },] }
|
12656 | ];
|
12657 | TreeMapCellSeriesComponent.propDecorators = {
|
12658 | data: [{ type: core.Input }],
|
12659 | dims: [{ type: core.Input }],
|
12660 | colors: [{ type: core.Input }],
|
12661 | valueFormatting: [{ type: core.Input }],
|
12662 | labelFormatting: [{ type: core.Input }],
|
12663 | gradient: [{ type: core.Input }],
|
12664 | tooltipDisabled: [{ type: core.Input }],
|
12665 | tooltipTemplate: [{ type: core.Input }],
|
12666 | animations: [{ type: core.Input }],
|
12667 | select: [{ type: core.Output }]
|
12668 | };
|
12669 |
|
12670 | var TreeMapComponent = (function (_super) {
|
12671 | __extends(TreeMapComponent, _super);
|
12672 | function TreeMapComponent() {
|
12673 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
12674 | _this.tooltipDisabled = false;
|
12675 | _this.gradient = false;
|
12676 | _this.select = new core.EventEmitter();
|
12677 | _this.margin = [10, 10, 10, 10];
|
12678 | return _this;
|
12679 | }
|
12680 | TreeMapComponent.prototype.update = function () {
|
12681 | _super.prototype.update.call(this);
|
12682 | this.dims = calculateViewDimensions({
|
12683 | width: this.width,
|
12684 | height: this.height,
|
12685 | margins: this.margin
|
12686 | });
|
12687 | this.domain = this.getDomain();
|
12688 | this.treemap = d3Hierarchy.treemap().size([this.dims.width, this.dims.height]);
|
12689 | var rootNode = {
|
12690 | name: 'root',
|
12691 | value: 0,
|
12692 | isRoot: true
|
12693 | };
|
12694 | var root = d3Hierarchy.stratify()
|
12695 | .id(function (d) {
|
12696 | var label = d.name;
|
12697 | if (label.constructor.name === 'Date') {
|
12698 | label = label.toLocaleDateString();
|
12699 | }
|
12700 | else {
|
12701 | label = label.toLocaleString();
|
12702 | }
|
12703 | return label;
|
12704 | })
|
12705 | .parentId(function (d) { return (d.isRoot ? null : 'root'); })(__spreadArray([rootNode], __read(this.results)))
|
12706 | .sum(function (d) { return d.value; });
|
12707 | this.data = this.treemap(root);
|
12708 | this.setColors();
|
12709 | this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
|
12710 | };
|
12711 | TreeMapComponent.prototype.getDomain = function () {
|
12712 | return this.results.map(function (d) { return d.name; });
|
12713 | };
|
12714 | TreeMapComponent.prototype.onClick = function (data) {
|
12715 | this.select.emit(data);
|
12716 | };
|
12717 | TreeMapComponent.prototype.setColors = function () {
|
12718 | this.colors = new ColorHelper(this.scheme, exports.ScaleType.Ordinal, this.domain, this.customColors);
|
12719 | };
|
12720 | return TreeMapComponent;
|
12721 | }(BaseChartComponent));
|
12722 | TreeMapComponent.decorators = [
|
12723 | { type: core.Component, args: [{
|
12724 | selector: 'ngx-charts-tree-map',
|
12725 | template: "\n <ngx-charts-chart [view]=\"[width, height]\" [showLegend]=\"false\" [animations]=\"animations\">\n <svg:g [attr.transform]=\"transform\" class=\"tree-map chart\">\n <svg:g\n ngx-charts-tree-map-cell-series\n [colors]=\"colors\"\n [data]=\"data\"\n [dims]=\"dims\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [valueFormatting]=\"valueFormatting\"\n [labelFormatting]=\"labelFormatting\"\n [gradient]=\"gradient\"\n [animations]=\"animations\"\n (select)=\"onClick($event)\"\n />\n </svg:g>\n </ngx-charts-chart>\n ",
|
12726 | encapsulation: core.ViewEncapsulation.None,
|
12727 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
12728 | styles: [".tree-map .treemap-val{font-size:1.3em;padding-top:5px;display:inline-block}.tree-map .treemap-label p{display:table-cell;text-align:center;line-height:1.2em;vertical-align:middle}\n"]
|
12729 | },] }
|
12730 | ];
|
12731 | TreeMapComponent.propDecorators = {
|
12732 | results: [{ type: core.Input }],
|
12733 | tooltipDisabled: [{ type: core.Input }],
|
12734 | valueFormatting: [{ type: core.Input }],
|
12735 | labelFormatting: [{ type: core.Input }],
|
12736 | gradient: [{ type: core.Input }],
|
12737 | select: [{ type: core.Output }],
|
12738 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }]
|
12739 | };
|
12740 |
|
12741 | var TreeMapModule = (function () {
|
12742 | function TreeMapModule() {
|
12743 | }
|
12744 | return TreeMapModule;
|
12745 | }());
|
12746 | TreeMapModule.decorators = [
|
12747 | { type: core.NgModule, args: [{
|
12748 | imports: [ChartCommonModule],
|
12749 | declarations: [TreeMapCellComponent, TreeMapCellSeriesComponent, TreeMapComponent],
|
12750 | exports: [TreeMapCellComponent, TreeMapCellSeriesComponent, TreeMapComponent]
|
12751 | },] }
|
12752 | ];
|
12753 |
|
12754 | var ElementType;
|
12755 | (function (ElementType) {
|
12756 | ElementType["Value"] = "value";
|
12757 | ElementType["Units"] = "units";
|
12758 | })(ElementType || (ElementType = {}));
|
12759 | var LinearGaugeComponent = (function (_super) {
|
12760 | __extends(LinearGaugeComponent, _super);
|
12761 | function LinearGaugeComponent() {
|
12762 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
12763 | _this.min = 0;
|
12764 | _this.max = 100;
|
12765 | _this.value = 0;
|
12766 | _this.margin = [10, 20, 10, 20];
|
12767 | _this.valueResizeScale = 1;
|
12768 | _this.unitsResizeScale = 1;
|
12769 | _this.valueTextTransform = '';
|
12770 | _this.valueTranslate = '';
|
12771 | _this.unitsTextTransform = '';
|
12772 | _this.unitsTranslate = '';
|
12773 | _this.barOrientation = exports.BarOrientation;
|
12774 | return _this;
|
12775 | }
|
12776 | LinearGaugeComponent.prototype.ngAfterViewInit = function () {
|
12777 | var _this = this;
|
12778 | _super.prototype.ngAfterViewInit.call(this);
|
12779 | setTimeout(function () {
|
12780 | _this.scaleText(ElementType.Value);
|
12781 | _this.scaleText(ElementType.Units);
|
12782 | });
|
12783 | };
|
12784 | LinearGaugeComponent.prototype.update = function () {
|
12785 | var _this = this;
|
12786 | _super.prototype.update.call(this);
|
12787 | this.hasPreviousValue = this.previousValue !== undefined;
|
12788 | this.max = Math.max(this.max, this.value);
|
12789 | this.min = Math.min(this.min, this.value);
|
12790 | if (this.hasPreviousValue) {
|
12791 | this.max = Math.max(this.max, this.previousValue);
|
12792 | this.min = Math.min(this.min, this.previousValue);
|
12793 | }
|
12794 | this.dims = calculateViewDimensions({
|
12795 | width: this.width,
|
12796 | height: this.height,
|
12797 | margins: this.margin
|
12798 | });
|
12799 | this.valueDomain = this.getValueDomain();
|
12800 | this.valueScale = this.getValueScale();
|
12801 | this.displayValue = this.getDisplayValue();
|
12802 | this.setColors();
|
12803 | var xOffset = this.margin[3] + this.dims.width / 2;
|
12804 | var yOffset = this.margin[0] + this.dims.height / 2;
|
12805 | this.transform = "translate(" + xOffset + ", " + yOffset + ")";
|
12806 | this.transformLine = "translate(" + (this.margin[3] + this.valueScale(this.previousValue)) + ", " + yOffset + ")";
|
12807 | this.valueTranslate = "translate(0, -15)";
|
12808 | this.unitsTranslate = "translate(0, 15)";
|
12809 | if (common.isPlatformServer(this.platformId)) {
|
12810 | this.scaleTextSSR('value');
|
12811 | this.scaleTextSSR('units');
|
12812 | }
|
12813 | else {
|
12814 | setTimeout(function () { return _this.scaleText(ElementType.Value); }, 50);
|
12815 | setTimeout(function () { return _this.scaleText(ElementType.Units); }, 50);
|
12816 | }
|
12817 | };
|
12818 | LinearGaugeComponent.prototype.getValueDomain = function () {
|
12819 | return [this.min, this.max];
|
12820 | };
|
12821 | LinearGaugeComponent.prototype.getValueScale = function () {
|
12822 | return d3Scale.scaleLinear().range([0, this.dims.width]).domain(this.valueDomain);
|
12823 | };
|
12824 | LinearGaugeComponent.prototype.getDisplayValue = function () {
|
12825 | if (this.valueFormatting) {
|
12826 | return this.valueFormatting(this.value);
|
12827 | }
|
12828 | return this.value.toLocaleString();
|
12829 | };
|
12830 | LinearGaugeComponent.prototype.scaleText = function (element, repeat) {
|
12831 | var _this = this;
|
12832 | if (repeat === void 0) { repeat = true; }
|
12833 | var el;
|
12834 | var resizeScale;
|
12835 | if (element === ElementType.Value) {
|
12836 | el = this.valueTextEl;
|
12837 | resizeScale = this.valueResizeScale;
|
12838 | }
|
12839 | else {
|
12840 | el = this.unitsTextEl;
|
12841 | resizeScale = this.unitsResizeScale;
|
12842 | }
|
12843 | var _a = el.nativeElement.getBoundingClientRect(), width = _a.width, height = _a.height;
|
12844 | if (width === 0 || height === 0)
|
12845 | return;
|
12846 | var oldScale = resizeScale;
|
12847 | var availableWidth = this.dims.width;
|
12848 | var availableHeight = Math.max(this.dims.height / 2 - 15, 0);
|
12849 | var resizeScaleWidth = Math.floor((availableWidth / (width / resizeScale)) * 100) / 100;
|
12850 | var resizeScaleHeight = Math.floor((availableHeight / (height / resizeScale)) * 100) / 100;
|
12851 | resizeScale = Math.min(resizeScaleHeight, resizeScaleWidth);
|
12852 | if (resizeScale !== oldScale) {
|
12853 | if (element === ElementType.Value) {
|
12854 | this.valueResizeScale = resizeScale;
|
12855 | this.valueTextTransform = "scale(" + resizeScale + ", " + resizeScale + ")";
|
12856 | }
|
12857 | else {
|
12858 | this.unitsResizeScale = resizeScale;
|
12859 | this.unitsTextTransform = "scale(" + resizeScale + ", " + resizeScale + ")";
|
12860 | }
|
12861 | this.cd.markForCheck();
|
12862 | if (repeat && common.isPlatformBrowser(this.platformId)) {
|
12863 | setTimeout(function () {
|
12864 | _this.scaleText(element, false);
|
12865 | }, 50);
|
12866 | }
|
12867 | }
|
12868 | };
|
12869 | LinearGaugeComponent.prototype.scaleTextSSR = function (element) {
|
12870 | var resizeScale = 1;
|
12871 | var value = element === 'value' ? this.displayValue : this.units;
|
12872 | var width = calculateTextWidth(VERDANA_FONT_WIDTHS_16_PX, value, 10);
|
12873 | var height = 25;
|
12874 | var availableWidth = this.dims.width;
|
12875 | var availableHeight = Math.max(this.dims.height / 2 - 15, 0);
|
12876 | var resizeScaleWidth = Math.floor((availableWidth / (width / resizeScale)) * 100) / 100;
|
12877 | var resizeScaleHeight = Math.floor((availableHeight / (height / resizeScale)) * 100) / 100;
|
12878 | resizeScale = Math.min(resizeScaleHeight, resizeScaleWidth);
|
12879 | if (element === 'value') {
|
12880 | this.valueResizeScale = resizeScale;
|
12881 | this.valueTextTransform = "scale(" + resizeScale + ", " + resizeScale + ")";
|
12882 | }
|
12883 | else {
|
12884 | this.unitsResizeScale = resizeScale;
|
12885 | this.unitsTextTransform = "scale(" + resizeScale + ", " + resizeScale + ")";
|
12886 | }
|
12887 | this.cd.markForCheck();
|
12888 | };
|
12889 | LinearGaugeComponent.prototype.onClick = function () {
|
12890 | this.select.emit({
|
12891 | name: 'Value',
|
12892 | value: this.value
|
12893 | });
|
12894 | };
|
12895 | LinearGaugeComponent.prototype.setColors = function () {
|
12896 | this.colors = new ColorHelper(this.scheme, exports.ScaleType.Ordinal, [this.value], this.customColors);
|
12897 | };
|
12898 | return LinearGaugeComponent;
|
12899 | }(BaseChartComponent));
|
12900 | LinearGaugeComponent.decorators = [
|
12901 | { type: core.Component, args: [{
|
12902 | selector: 'ngx-charts-linear-gauge',
|
12903 | template: "\n <ngx-charts-chart [view]=\"[width, height]\" [showLegend]=\"false\" [animations]=\"animations\" (click)=\"onClick()\">\n <svg:g class=\"linear-gauge chart\">\n <svg:g\n ngx-charts-bar\n class=\"background-bar\"\n [width]=\"dims.width\"\n [height]=\"3\"\n [x]=\"margin[3]\"\n [y]=\"dims.height / 2 + margin[0] - 2\"\n [data]=\"{}\"\n [orientation]=\"barOrientation.Horizontal\"\n [roundEdges]=\"true\"\n [animations]=\"animations\"\n ></svg:g>\n <svg:g\n ngx-charts-bar\n [width]=\"valueScale(value)\"\n [height]=\"3\"\n [x]=\"margin[3]\"\n [y]=\"dims.height / 2 + margin[0] - 2\"\n [fill]=\"colors.getColor(units)\"\n [data]=\"{}\"\n [orientation]=\"barOrientation.Horizontal\"\n [roundEdges]=\"true\"\n [animations]=\"animations\"\n ></svg:g>\n\n <svg:line\n *ngIf=\"hasPreviousValue\"\n [attr.transform]=\"transformLine\"\n x1=\"0\"\n y1=\"5\"\n x2=\"0\"\n y2=\"15\"\n [attr.stroke]=\"colors.getColor(units)\"\n />\n\n <svg:line\n *ngIf=\"hasPreviousValue\"\n [attr.transform]=\"transformLine\"\n x1=\"0\"\n y1=\"-5\"\n x2=\"0\"\n y2=\"-15\"\n [attr.stroke]=\"colors.getColor(units)\"\n />\n\n <svg:g [attr.transform]=\"transform\">\n <svg:g [attr.transform]=\"valueTranslate\">\n <svg:text\n #valueTextEl\n class=\"value\"\n [style.textAnchor]=\"'middle'\"\n [attr.transform]=\"valueTextTransform\"\n alignment-baseline=\"after-edge\"\n >\n {{ displayValue }}\n </svg:text>\n </svg:g>\n\n <svg:g [attr.transform]=\"unitsTranslate\">\n <svg:text\n #unitsTextEl\n class=\"units\"\n [style.textAnchor]=\"'middle'\"\n [attr.transform]=\"unitsTextTransform\"\n alignment-baseline=\"before-edge\"\n >\n {{ units }}\n </svg:text>\n </svg:g>\n </svg:g>\n </svg:g>\n </ngx-charts-chart>\n ",
|
12904 | encapsulation: core.ViewEncapsulation.None,
|
12905 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
12906 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n", ".linear-gauge{cursor:pointer}.linear-gauge .background-bar path{fill:#0000000d}.linear-gauge .units{fill:#666}\n"]
|
12907 | },] }
|
12908 | ];
|
12909 | LinearGaugeComponent.propDecorators = {
|
12910 | min: [{ type: core.Input }],
|
12911 | max: [{ type: core.Input }],
|
12912 | value: [{ type: core.Input }],
|
12913 | units: [{ type: core.Input }],
|
12914 | previousValue: [{ type: core.Input }],
|
12915 | valueFormatting: [{ type: core.Input }],
|
12916 | valueTextEl: [{ type: core.ViewChild, args: ['valueTextEl',] }],
|
12917 | unitsTextEl: [{ type: core.ViewChild, args: ['unitsTextEl',] }]
|
12918 | };
|
12919 |
|
12920 | var GaugeComponent = (function (_super) {
|
12921 | __extends(GaugeComponent, _super);
|
12922 | function GaugeComponent() {
|
12923 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
12924 | _this.legend = false;
|
12925 | _this.legendTitle = 'Legend';
|
12926 | _this.legendPosition = exports.LegendPosition.Right;
|
12927 | _this.min = 0;
|
12928 | _this.max = 100;
|
12929 | _this.bigSegments = 10;
|
12930 | _this.smallSegments = 5;
|
12931 | _this.showAxis = true;
|
12932 | _this.startAngle = -120;
|
12933 | _this.angleSpan = 240;
|
12934 | _this.activeEntries = [];
|
12935 | _this.tooltipDisabled = false;
|
12936 | _this.showText = true;
|
12937 | _this.activate = new core.EventEmitter();
|
12938 | _this.deactivate = new core.EventEmitter();
|
12939 | _this.resizeScale = 1;
|
12940 | _this.rotation = '';
|
12941 | _this.textTransform = 'scale(1, 1)';
|
12942 | _this.cornerRadius = 10;
|
12943 | return _this;
|
12944 | }
|
12945 | GaugeComponent.prototype.ngAfterViewInit = function () {
|
12946 | var _this = this;
|
12947 | _super.prototype.ngAfterViewInit.call(this);
|
12948 | setTimeout(function () { return _this.scaleText(); });
|
12949 | };
|
12950 | GaugeComponent.prototype.update = function () {
|
12951 | var _this = this;
|
12952 | _super.prototype.update.call(this);
|
12953 | if (!this.showAxis) {
|
12954 | if (!this.margin) {
|
12955 | this.margin = [10, 20, 10, 20];
|
12956 | }
|
12957 | }
|
12958 | else {
|
12959 | if (!this.margin) {
|
12960 | this.margin = [60, 100, 60, 100];
|
12961 | }
|
12962 | }
|
12963 |
|
12964 | if (this.startAngle < 0) {
|
12965 | this.startAngle = (this.startAngle % 360) + 360;
|
12966 | }
|
12967 | this.angleSpan = Math.min(this.angleSpan, 360);
|
12968 | this.dims = calculateViewDimensions({
|
12969 | width: this.width,
|
12970 | height: this.height,
|
12971 | margins: this.margin,
|
12972 | showLegend: this.legend,
|
12973 | legendPosition: this.legendPosition
|
12974 | });
|
12975 | this.domain = this.getDomain();
|
12976 | this.valueDomain = this.getValueDomain();
|
12977 | this.valueScale = this.getValueScale();
|
12978 | this.displayValue = this.getDisplayValue();
|
12979 | this.outerRadius = Math.min(this.dims.width, this.dims.height) / 2;
|
12980 | this.arcs = this.getArcs();
|
12981 | this.setColors();
|
12982 | this.legendOptions = this.getLegendOptions();
|
12983 | var xOffset = this.margin[3] + this.dims.width / 2;
|
12984 | var yOffset = this.margin[0] + this.dims.height / 2;
|
12985 | this.transform = "translate(" + xOffset + ", " + yOffset + ")";
|
12986 | this.rotation = "rotate(" + this.startAngle + ")";
|
12987 | setTimeout(function () { return _this.scaleText(); }, 50);
|
12988 | };
|
12989 | GaugeComponent.prototype.getArcs = function () {
|
12990 | var e_1, _a;
|
12991 | var arcs = [];
|
12992 | var availableRadius = this.outerRadius * 0.7;
|
12993 | var radiusPerArc = Math.min(availableRadius / this.results.length, 10);
|
12994 | var arcWidth = radiusPerArc * 0.7;
|
12995 | this.textRadius = this.outerRadius - this.results.length * radiusPerArc;
|
12996 | this.cornerRadius = Math.floor(arcWidth / 2);
|
12997 | var i = 0;
|
12998 | try {
|
12999 | for (var _b = __values(this.results), _c = _b.next(); !_c.done; _c = _b.next()) {
|
13000 | var d = _c.value;
|
13001 | var outerRadius = this.outerRadius - i * radiusPerArc;
|
13002 | var innerRadius = outerRadius - arcWidth;
|
13003 | var backgroundArc = {
|
13004 | endAngle: (this.angleSpan * Math.PI) / 180,
|
13005 | innerRadius: innerRadius,
|
13006 | outerRadius: outerRadius,
|
13007 | data: {
|
13008 | value: this.max,
|
13009 | name: d.name
|
13010 | }
|
13011 | };
|
13012 | var valueArc = {
|
13013 | endAngle: (Math.min(this.valueScale(d.value), this.angleSpan) * Math.PI) / 180,
|
13014 | innerRadius: innerRadius,
|
13015 | outerRadius: outerRadius,
|
13016 | data: {
|
13017 | value: d.value,
|
13018 | name: d.name
|
13019 | }
|
13020 | };
|
13021 | var arc = {
|
13022 | backgroundArc: backgroundArc,
|
13023 | valueArc: valueArc
|
13024 | };
|
13025 | arcs.push(arc);
|
13026 | i++;
|
13027 | }
|
13028 | }
|
13029 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
13030 | finally {
|
13031 | try {
|
13032 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
13033 | }
|
13034 | finally { if (e_1) throw e_1.error; }
|
13035 | }
|
13036 | return arcs;
|
13037 | };
|
13038 | GaugeComponent.prototype.getDomain = function () {
|
13039 | return this.results.map(function (d) { return d.name; });
|
13040 | };
|
13041 | GaugeComponent.prototype.getValueDomain = function () {
|
13042 | var values = this.results.map(function (d) { return d.value; });
|
13043 | var dataMin = Math.min.apply(Math, __spreadArray([], __read(values)));
|
13044 | var dataMax = Math.max.apply(Math, __spreadArray([], __read(values)));
|
13045 | if (this.min !== undefined) {
|
13046 | this.min = Math.min(this.min, dataMin);
|
13047 | }
|
13048 | else {
|
13049 | this.min = dataMin;
|
13050 | }
|
13051 | if (this.max !== undefined) {
|
13052 | this.max = Math.max(this.max, dataMax);
|
13053 | }
|
13054 | else {
|
13055 | this.max = dataMax;
|
13056 | }
|
13057 | return [this.min, this.max];
|
13058 | };
|
13059 | GaugeComponent.prototype.getValueScale = function () {
|
13060 | return d3Scale.scaleLinear().range([0, this.angleSpan]).nice().domain(this.valueDomain);
|
13061 | };
|
13062 | GaugeComponent.prototype.getDisplayValue = function () {
|
13063 | var value = this.results.map(function (d) { return d.value; }).reduce(function (a, b) { return a + b; }, 0);
|
13064 | if (this.textValue && 0 !== this.textValue.length) {
|
13065 | return this.textValue.toLocaleString();
|
13066 | }
|
13067 | if (this.valueFormatting) {
|
13068 | return this.valueFormatting(value);
|
13069 | }
|
13070 | return value.toLocaleString();
|
13071 | };
|
13072 | GaugeComponent.prototype.scaleText = function (repeat) {
|
13073 | var _this = this;
|
13074 | if (repeat === void 0) { repeat = true; }
|
13075 | if (!this.showText) {
|
13076 | return;
|
13077 | }
|
13078 | var width = this.textEl.nativeElement.getBoundingClientRect().width;
|
13079 | var oldScale = this.resizeScale;
|
13080 | if (width === 0) {
|
13081 | this.resizeScale = 1;
|
13082 | }
|
13083 | else {
|
13084 | var availableSpace = this.textRadius;
|
13085 | this.resizeScale = Math.floor((availableSpace / (width / this.resizeScale)) * 100) / 100;
|
13086 | }
|
13087 | if (this.resizeScale !== oldScale) {
|
13088 | this.textTransform = "scale(" + this.resizeScale + ", " + this.resizeScale + ")";
|
13089 | this.cd.markForCheck();
|
13090 | if (repeat) {
|
13091 | setTimeout(function () { return _this.scaleText(false); }, 50);
|
13092 | }
|
13093 | }
|
13094 | };
|
13095 | GaugeComponent.prototype.onClick = function (data) {
|
13096 | this.select.emit(data);
|
13097 | };
|
13098 | GaugeComponent.prototype.getLegendOptions = function () {
|
13099 | return {
|
13100 | scaleType: exports.ScaleType.Ordinal,
|
13101 | colors: this.colors,
|
13102 | domain: this.domain,
|
13103 | title: this.legendTitle,
|
13104 | position: this.legendPosition
|
13105 | };
|
13106 | };
|
13107 | GaugeComponent.prototype.setColors = function () {
|
13108 | this.colors = new ColorHelper(this.scheme, exports.ScaleType.Ordinal, this.domain, this.customColors);
|
13109 | };
|
13110 | GaugeComponent.prototype.onActivate = function (item) {
|
13111 | var idx = this.activeEntries.findIndex(function (d) {
|
13112 | return d.name === item.name && d.value === item.value;
|
13113 | });
|
13114 | if (idx > -1) {
|
13115 | return;
|
13116 | }
|
13117 | this.activeEntries = __spreadArray([item], __read(this.activeEntries));
|
13118 | this.activate.emit({ value: item, entries: this.activeEntries });
|
13119 | };
|
13120 | GaugeComponent.prototype.onDeactivate = function (item) {
|
13121 | var idx = this.activeEntries.findIndex(function (d) {
|
13122 | return d.name === item.name && d.value === item.value;
|
13123 | });
|
13124 | this.activeEntries.splice(idx, 1);
|
13125 | this.activeEntries = __spreadArray([], __read(this.activeEntries));
|
13126 | this.deactivate.emit({ value: item, entries: this.activeEntries });
|
13127 | };
|
13128 | GaugeComponent.prototype.isActive = function (entry) {
|
13129 | if (!this.activeEntries)
|
13130 | return false;
|
13131 | var item = this.activeEntries.find(function (d) {
|
13132 | return entry.name === d.name && entry.series === d.series;
|
13133 | });
|
13134 | return item !== undefined;
|
13135 | };
|
13136 | GaugeComponent.prototype.trackBy = function (index, item) {
|
13137 | return item.valueArc.data.name;
|
13138 | };
|
13139 | return GaugeComponent;
|
13140 | }(BaseChartComponent));
|
13141 | GaugeComponent.decorators = [
|
13142 | { type: core.Component, args: [{
|
13143 | selector: 'ngx-charts-gauge',
|
13144 | template: "\n <ngx-charts-chart\n [view]=\"[width, height]\"\n [showLegend]=\"legend\"\n [legendOptions]=\"legendOptions\"\n [activeEntries]=\"activeEntries\"\n [animations]=\"animations\"\n (legendLabelClick)=\"onClick($event)\"\n (legendLabelActivate)=\"onActivate($event)\"\n (legendLabelDeactivate)=\"onDeactivate($event)\"\n >\n <svg:g [attr.transform]=\"transform\" class=\"gauge chart\">\n <svg:g *ngFor=\"let arc of arcs; trackBy: trackBy\" [attr.transform]=\"rotation\">\n <svg:g\n ngx-charts-gauge-arc\n [backgroundArc]=\"arc.backgroundArc\"\n [valueArc]=\"arc.valueArc\"\n [cornerRadius]=\"cornerRadius\"\n [colors]=\"colors\"\n [isActive]=\"isActive(arc.valueArc.data)\"\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [valueFormatting]=\"valueFormatting\"\n [animations]=\"animations\"\n (select)=\"onClick($event)\"\n (activate)=\"onActivate($event)\"\n (deactivate)=\"onDeactivate($event)\"\n ></svg:g>\n </svg:g>\n\n <svg:g\n ngx-charts-gauge-axis\n *ngIf=\"showAxis\"\n [bigSegments]=\"bigSegments\"\n [smallSegments]=\"smallSegments\"\n [min]=\"min\"\n [max]=\"max\"\n [radius]=\"outerRadius\"\n [angleSpan]=\"angleSpan\"\n [valueScale]=\"valueScale\"\n [startAngle]=\"startAngle\"\n [tickFormatting]=\"axisTickFormatting\"\n ></svg:g>\n\n <svg:text\n #textEl\n *ngIf=\"showText\"\n [style.textAnchor]=\"'middle'\"\n [attr.transform]=\"textTransform\"\n alignment-baseline=\"central\"\n >\n <tspan x=\"0\" dy=\"0\">{{ displayValue }}</tspan>\n <tspan x=\"0\" dy=\"1.2em\">{{ units }}</tspan>\n </svg:text>\n </svg:g>\n </ngx-charts-chart>\n ",
|
13145 | encapsulation: core.ViewEncapsulation.None,
|
13146 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
13147 | styles: [".ngx-charts{float:left;overflow:visible}.ngx-charts .circle,.ngx-charts .cell,.ngx-charts .bar,.ngx-charts .arc{cursor:pointer}.ngx-charts .bar.active,.ngx-charts .bar:hover,.ngx-charts .cell.active,.ngx-charts .cell:hover,.ngx-charts .arc.active,.ngx-charts .arc:hover,.ngx-charts .card.active,.ngx-charts .card:hover{opacity:.8;transition:opacity .1s ease-in-out}.ngx-charts .bar:focus,.ngx-charts .cell:focus,.ngx-charts .arc:focus,.ngx-charts .card:focus{outline:none}.ngx-charts .bar.hidden,.ngx-charts .cell.hidden,.ngx-charts .arc.hidden,.ngx-charts .card.hidden{display:none}.ngx-charts g:focus{outline:none}.ngx-charts .line-series.inactive,.ngx-charts .line-series-range.inactive,.ngx-charts .polar-series-path.inactive,.ngx-charts .polar-series-area.inactive,.ngx-charts .area-series.inactive{transition:opacity .1s ease-in-out;opacity:.2}.ngx-charts .line-highlight{display:none}.ngx-charts .line-highlight.active{display:block}.ngx-charts .area{opacity:.6}.ngx-charts .circle:hover{cursor:pointer}.ngx-charts .label{font-size:12px;font-weight:normal}.ngx-charts .tooltip-anchor{fill:#000}.ngx-charts .gridline-path{stroke:#ddd;stroke-width:1;fill:none}.ngx-charts .refline-path{stroke:#a8b2c7;stroke-width:1;stroke-dasharray:5;stroke-dashoffset:5}.ngx-charts .refline-label{font-size:9px}.ngx-charts .reference-area{fill-opacity:.05;fill:#000}.ngx-charts .gridline-path-dotted{stroke:#ddd;stroke-width:1;fill:none;stroke-dasharray:1,20;stroke-dashoffset:3}.ngx-charts .grid-panel rect{fill:none}.ngx-charts .grid-panel.odd rect{fill:#0000000d}\n", ".gauge .background-arc path{fill:#0000000d}.gauge .gauge-tick path{stroke:#666}.gauge .gauge-tick text{font-size:12px;fill:#666;font-weight:bold}.gauge .gauge-tick-large path{stroke-width:2px}.gauge .gauge-tick-small path{stroke-width:1px}\n"]
|
13148 | },] }
|
13149 | ];
|
13150 | GaugeComponent.propDecorators = {
|
13151 | legend: [{ type: core.Input }],
|
13152 | legendTitle: [{ type: core.Input }],
|
13153 | legendPosition: [{ type: core.Input }],
|
13154 | min: [{ type: core.Input }],
|
13155 | max: [{ type: core.Input }],
|
13156 | textValue: [{ type: core.Input }],
|
13157 | units: [{ type: core.Input }],
|
13158 | bigSegments: [{ type: core.Input }],
|
13159 | smallSegments: [{ type: core.Input }],
|
13160 | results: [{ type: core.Input }],
|
13161 | showAxis: [{ type: core.Input }],
|
13162 | startAngle: [{ type: core.Input }],
|
13163 | angleSpan: [{ type: core.Input }],
|
13164 | activeEntries: [{ type: core.Input }],
|
13165 | axisTickFormatting: [{ type: core.Input }],
|
13166 | tooltipDisabled: [{ type: core.Input }],
|
13167 | valueFormatting: [{ type: core.Input }],
|
13168 | showText: [{ type: core.Input }],
|
13169 | margin: [{ type: core.Input }],
|
13170 | activate: [{ type: core.Output }],
|
13171 | deactivate: [{ type: core.Output }],
|
13172 | tooltipTemplate: [{ type: core.ContentChild, args: ['tooltipTemplate',] }],
|
13173 | textEl: [{ type: core.ViewChild, args: ['textEl',] }]
|
13174 | };
|
13175 |
|
13176 | var GaugeArcComponent = (function () {
|
13177 | function GaugeArcComponent() {
|
13178 | this.isActive = false;
|
13179 | this.tooltipDisabled = false;
|
13180 | this.animations = true;
|
13181 | this.select = new core.EventEmitter();
|
13182 | this.activate = new core.EventEmitter();
|
13183 | this.deactivate = new core.EventEmitter();
|
13184 | this.placementTypes = exports.PlacementTypes;
|
13185 | this.styleTypes = exports.StyleTypes;
|
13186 | }
|
13187 | GaugeArcComponent.prototype.tooltipText = function (arc) {
|
13188 | var label = formatLabel(arc.data.name);
|
13189 | var val;
|
13190 | if (this.valueFormatting) {
|
13191 | val = this.valueFormatting(arc.data.value);
|
13192 | }
|
13193 | else {
|
13194 | val = formatLabel(arc.data.value);
|
13195 | }
|
13196 | return "\n <span class=\"tooltip-label\">" + escapeLabel(label) + "</span>\n <span class=\"tooltip-val\">" + val + "</span>\n ";
|
13197 | };
|
13198 | return GaugeArcComponent;
|
13199 | }());
|
13200 | GaugeArcComponent.decorators = [
|
13201 | { type: core.Component, args: [{
|
13202 | selector: 'g[ngx-charts-gauge-arc]',
|
13203 | template: "\n <svg:g\n ngx-charts-pie-arc\n class=\"background-arc\"\n [startAngle]=\"0\"\n [endAngle]=\"backgroundArc.endAngle\"\n [innerRadius]=\"backgroundArc.innerRadius\"\n [outerRadius]=\"backgroundArc.outerRadius\"\n [cornerRadius]=\"cornerRadius\"\n [data]=\"backgroundArc.data\"\n [animate]=\"false\"\n [pointerEvents]=\"false\"\n ></svg:g>\n <svg:g\n ngx-charts-pie-arc\n [startAngle]=\"0\"\n [endAngle]=\"valueArc.endAngle\"\n [innerRadius]=\"valueArc.innerRadius\"\n [outerRadius]=\"valueArc.outerRadius\"\n [cornerRadius]=\"cornerRadius\"\n [fill]=\"colors.getColor(valueArc.data.name)\"\n [data]=\"valueArc.data\"\n [animate]=\"animations\"\n [isActive]=\"isActive\"\n (select)=\"select.emit($event)\"\n (activate)=\"activate.emit($event)\"\n (deactivate)=\"deactivate.emit($event)\"\n ngx-tooltip\n [tooltipDisabled]=\"tooltipDisabled\"\n [tooltipPlacement]=\"placementTypes.Top\"\n [tooltipType]=\"styleTypes.tooltip\"\n [tooltipTitle]=\"tooltipTemplate ? undefined : tooltipText(valueArc)\"\n [tooltipTemplate]=\"tooltipTemplate\"\n [tooltipContext]=\"valueArc.data\"\n ></svg:g>\n ",
|
13204 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
13205 | },] }
|
13206 | ];
|
13207 | GaugeArcComponent.propDecorators = {
|
13208 | backgroundArc: [{ type: core.Input }],
|
13209 | valueArc: [{ type: core.Input }],
|
13210 | cornerRadius: [{ type: core.Input }],
|
13211 | colors: [{ type: core.Input }],
|
13212 | isActive: [{ type: core.Input }],
|
13213 | tooltipDisabled: [{ type: core.Input }],
|
13214 | valueFormatting: [{ type: core.Input }],
|
13215 | tooltipTemplate: [{ type: core.Input }],
|
13216 | animations: [{ type: core.Input }],
|
13217 | select: [{ type: core.Output }],
|
13218 | activate: [{ type: core.Output }],
|
13219 | deactivate: [{ type: core.Output }]
|
13220 | };
|
13221 |
|
13222 | var GaugeAxisComponent = (function () {
|
13223 | function GaugeAxisComponent() {
|
13224 | this.rotate = '';
|
13225 | }
|
13226 | GaugeAxisComponent.prototype.ngOnChanges = function (changes) {
|
13227 | this.update();
|
13228 | };
|
13229 | GaugeAxisComponent.prototype.update = function () {
|
13230 | this.rotationAngle = -90 + this.startAngle;
|
13231 | this.rotate = "rotate(" + this.rotationAngle + ")";
|
13232 | this.ticks = this.getTicks();
|
13233 | };
|
13234 | GaugeAxisComponent.prototype.getTicks = function () {
|
13235 | var bigTickSegment = this.angleSpan / this.bigSegments;
|
13236 | var smallTickSegment = bigTickSegment / this.smallSegments;
|
13237 | var tickLength = 20;
|
13238 | var ticks = {
|
13239 | big: [],
|
13240 | small: []
|
13241 | };
|
13242 | var startDistance = this.radius + 10;
|
13243 | var textDist = startDistance + tickLength + 10;
|
13244 | for (var i = 0; i <= this.bigSegments; i++) {
|
13245 | var angleDeg = i * bigTickSegment;
|
13246 | var angle = (angleDeg * Math.PI) / 180;
|
13247 | var textAnchor = this.getTextAnchor(angleDeg);
|
13248 | var skip = false;
|
13249 | if (i === 0 && this.angleSpan === 360) {
|
13250 | skip = true;
|
13251 | }
|
13252 | if (!skip) {
|
13253 | var text = Number.parseFloat(this.valueScale.invert(angleDeg).toString()).toLocaleString();
|
13254 | if (this.tickFormatting) {
|
13255 | text = this.tickFormatting(text);
|
13256 | }
|
13257 | ticks.big.push({
|
13258 | line: this.getTickPath(startDistance, tickLength, angle),
|
13259 | textAnchor: textAnchor,
|
13260 | text: text,
|
13261 | textTransform: "\n translate(" + textDist * Math.cos(angle) + ", " + textDist * Math.sin(angle) + ") rotate(" + -this.rotationAngle + ")\n "
|
13262 | });
|
13263 | }
|
13264 | if (i === this.bigSegments) {
|
13265 | continue;
|
13266 | }
|
13267 | for (var j = 1; j <= this.smallSegments; j++) {
|
13268 | var smallAngleDeg = angleDeg + j * smallTickSegment;
|
13269 | var smallAngle = (smallAngleDeg * Math.PI) / 180;
|
13270 | ticks.small.push({
|
13271 | line: this.getTickPath(startDistance, tickLength / 2, smallAngle)
|
13272 | });
|
13273 | }
|
13274 | }
|
13275 | return ticks;
|
13276 | };
|
13277 | GaugeAxisComponent.prototype.getTextAnchor = function (angle) {
|
13278 |
|
13279 |
|
13280 |
|
13281 |
|
13282 | angle = (this.startAngle + angle) % 360;
|
13283 | var textAnchor = exports.TextAnchor.Middle;
|
13284 | if (angle > 45 && angle <= 135) {
|
13285 | textAnchor = exports.TextAnchor.Start;
|
13286 | }
|
13287 | else if (angle > 225 && angle <= 315) {
|
13288 | textAnchor = exports.TextAnchor.End;
|
13289 | }
|
13290 | return textAnchor;
|
13291 | };
|
13292 | GaugeAxisComponent.prototype.getTickPath = function (startDistance, tickLength, angle) {
|
13293 | var y1 = startDistance * Math.sin(angle);
|
13294 | var y2 = (startDistance + tickLength) * Math.sin(angle);
|
13295 | var x1 = startDistance * Math.cos(angle);
|
13296 | var x2 = (startDistance + tickLength) * Math.cos(angle);
|
13297 | var points = [
|
13298 | { x: x1, y: y1 },
|
13299 | { x: x2, y: y2 }
|
13300 | ];
|
13301 | var lineGenerator = d3Shape.line()
|
13302 | .x(function (d) { return d.x; })
|
13303 | .y(function (d) { return d.y; });
|
13304 | return lineGenerator(points);
|
13305 | };
|
13306 | return GaugeAxisComponent;
|
13307 | }());
|
13308 | GaugeAxisComponent.decorators = [
|
13309 | { type: core.Component, args: [{
|
13310 | selector: 'g[ngx-charts-gauge-axis]',
|
13311 | template: "\n <svg:g [attr.transform]=\"rotate\">\n <svg:g *ngFor=\"let tick of ticks.big\" class=\"gauge-tick gauge-tick-large\">\n <svg:path [attr.d]=\"tick.line\" />\n </svg:g>\n <svg:g *ngFor=\"let tick of ticks.big\" class=\"gauge-tick gauge-tick-large\">\n <svg:text\n [style.textAnchor]=\"tick.textAnchor\"\n [attr.transform]=\"tick.textTransform\"\n alignment-baseline=\"central\"\n >\n {{ tick.text }}\n </svg:text>\n </svg:g>\n <svg:g *ngFor=\"let tick of ticks.small\" class=\"gauge-tick gauge-tick-small\">\n <svg:path [attr.d]=\"tick.line\" />\n </svg:g>\n </svg:g>\n ",
|
13312 | changeDetection: core.ChangeDetectionStrategy.OnPush
|
13313 | },] }
|
13314 | ];
|
13315 | GaugeAxisComponent.propDecorators = {
|
13316 | bigSegments: [{ type: core.Input }],
|
13317 | smallSegments: [{ type: core.Input }],
|
13318 | min: [{ type: core.Input }],
|
13319 | max: [{ type: core.Input }],
|
13320 | angleSpan: [{ type: core.Input }],
|
13321 | startAngle: [{ type: core.Input }],
|
13322 | radius: [{ type: core.Input }],
|
13323 | valueScale: [{ type: core.Input }],
|
13324 | tickFormatting: [{ type: core.Input }]
|
13325 | };
|
13326 |
|
13327 | var GaugeModule = (function () {
|
13328 | function GaugeModule() {
|
13329 | }
|
13330 | return GaugeModule;
|
13331 | }());
|
13332 | GaugeModule.decorators = [
|
13333 | { type: core.NgModule, args: [{
|
13334 | imports: [ChartCommonModule, PieChartModule, BarChartModule],
|
13335 | declarations: [LinearGaugeComponent, GaugeComponent, GaugeArcComponent, GaugeAxisComponent],
|
13336 | exports: [LinearGaugeComponent, GaugeComponent, GaugeArcComponent, GaugeAxisComponent]
|
13337 | },] }
|
13338 | ];
|
13339 |
|
13340 |
|
13341 | function ngxChartsPolyfills() {
|
13342 |
|
13343 |
|
13344 | if (typeof SVGElement !== 'undefined' && typeof SVGElement.prototype.contains === 'undefined') {
|
13345 | SVGElement.prototype.contains = HTMLDivElement.prototype.contains;
|
13346 | }
|
13347 | }
|
13348 |
|
13349 | var NgxChartsModule = (function () {
|
13350 | function NgxChartsModule() {
|
13351 | ngxChartsPolyfills();
|
13352 | }
|
13353 | return NgxChartsModule;
|
13354 | }());
|
13355 | NgxChartsModule.decorators = [
|
13356 | { type: core.NgModule, args: [{
|
13357 | exports: [
|
13358 | ChartCommonModule,
|
13359 | AreaChartModule,
|
13360 | BarChartModule,
|
13361 | BoxChartModule,
|
13362 | BubbleChartModule,
|
13363 | HeatMapModule,
|
13364 | LineChartModule,
|
13365 | PolarChartModule,
|
13366 | NumberCardModule,
|
13367 | PieChartModule,
|
13368 | TreeMapModule,
|
13369 | GaugeModule
|
13370 | ]
|
13371 | },] }
|
13372 | ];
|
13373 | NgxChartsModule.ctorParameters = function () { return []; };
|
13374 |
|
13375 | function tickFormat(fieldType, groupByType) {
|
13376 | return function (label) {
|
13377 | if (label === 'No Value' || label === 'Other') {
|
13378 | return label;
|
13379 | }
|
13380 | if (fieldType === 'date' && groupByType === 'groupBy') {
|
13381 | var formatter = d3TimeFormat.timeFormat('MM/DD/YYYY');
|
13382 | return formatter(label);
|
13383 | }
|
13384 | return label.toString();
|
13385 | };
|
13386 | }
|
13387 |
|
13388 | |
13389 |
|
13390 |
|
13391 |
|
13392 | |
13393 |
|
13394 |
|
13395 |
|
13396 | exports.AdvancedLegendComponent = AdvancedLegendComponent;
|
13397 | exports.AdvancedPieChartComponent = AdvancedPieChartComponent;
|
13398 | exports.AreaChartComponent = AreaChartComponent;
|
13399 | exports.AreaChartModule = AreaChartModule;
|
13400 | exports.AreaChartNormalizedComponent = AreaChartNormalizedComponent;
|
13401 | exports.AreaChartStackedComponent = AreaChartStackedComponent;
|
13402 | exports.AreaComponent = AreaComponent;
|
13403 | exports.AreaSeriesComponent = AreaSeriesComponent;
|
13404 | exports.AxesModule = AxesModule;
|
13405 | exports.AxisLabelComponent = AxisLabelComponent;
|
13406 | exports.BarChartModule = BarChartModule;
|
13407 | exports.BarComponent = BarComponent;
|
13408 | exports.BarHorizontal2DComponent = BarHorizontal2DComponent;
|
13409 | exports.BarHorizontalComponent = BarHorizontalComponent;
|
13410 | exports.BarHorizontalNormalizedComponent = BarHorizontalNormalizedComponent;
|
13411 | exports.BarHorizontalStackedComponent = BarHorizontalStackedComponent;
|
13412 | exports.BarLabelComponent = BarLabelComponent;
|
13413 | exports.BarVertical2DComponent = BarVertical2DComponent;
|
13414 | exports.BarVerticalComponent = BarVerticalComponent;
|
13415 | exports.BarVerticalNormalizedComponent = BarVerticalNormalizedComponent;
|
13416 | exports.BarVerticalStackedComponent = BarVerticalStackedComponent;
|
13417 | exports.BaseChartComponent = BaseChartComponent;
|
13418 | exports.BoxChartComponent = BoxChartComponent;
|
13419 | exports.BoxChartModule = BoxChartModule;
|
13420 | exports.BoxComponent = BoxComponent;
|
13421 | exports.BoxSeriesComponent = BoxSeriesComponent;
|
13422 | exports.BubbleChartComponent = BubbleChartComponent;
|
13423 | exports.BubbleChartModule = BubbleChartModule;
|
13424 | exports.BubbleSeriesComponent = BubbleSeriesComponent;
|
13425 | exports.CardComponent = CardComponent;
|
13426 | exports.CardSeriesComponent = CardSeriesComponent;
|
13427 | exports.ChartCommonModule = ChartCommonModule;
|
13428 | exports.ChartComponent = ChartComponent;
|
13429 | exports.CircleComponent = CircleComponent;
|
13430 | exports.CircleSeriesComponent = CircleSeriesComponent;
|
13431 | exports.ColorHelper = ColorHelper;
|
13432 | exports.CountUpDirective = CountUpDirective;
|
13433 | exports.GaugeArcComponent = GaugeArcComponent;
|
13434 | exports.GaugeAxisComponent = GaugeAxisComponent;
|
13435 | exports.GaugeComponent = GaugeComponent;
|
13436 | exports.GaugeModule = GaugeModule;
|
13437 | exports.GridPanelComponent = GridPanelComponent;
|
13438 | exports.GridPanelSeriesComponent = GridPanelSeriesComponent;
|
13439 | exports.HeatCellSeriesComponent = HeatCellSeriesComponent;
|
13440 | exports.HeatMapCellComponent = HeatMapCellComponent;
|
13441 | exports.HeatMapComponent = HeatMapComponent;
|
13442 | exports.HeatMapModule = HeatMapModule;
|
13443 | exports.LegendComponent = LegendComponent;
|
13444 | exports.LegendEntryComponent = LegendEntryComponent;
|
13445 | exports.LineChartComponent = LineChartComponent;
|
13446 | exports.LineChartModule = LineChartModule;
|
13447 | exports.LineComponent = LineComponent;
|
13448 | exports.LineSeriesComponent = LineSeriesComponent;
|
13449 | exports.LinearGaugeComponent = LinearGaugeComponent;
|
13450 | exports.NgxChartsModule = NgxChartsModule;
|
13451 | exports.NumberCardComponent = NumberCardComponent;
|
13452 | exports.NumberCardModule = NumberCardModule;
|
13453 | exports.PieArcComponent = PieArcComponent;
|
13454 | exports.PieChartComponent = PieChartComponent;
|
13455 | exports.PieChartModule = PieChartModule;
|
13456 | exports.PieGridComponent = PieGridComponent;
|
13457 | exports.PieGridSeriesComponent = PieGridSeriesComponent;
|
13458 | exports.PieLabelComponent = PieLabelComponent;
|
13459 | exports.PieSeriesComponent = PieSeriesComponent;
|
13460 | exports.PolarChartComponent = PolarChartComponent;
|
13461 | exports.PolarChartModule = PolarChartModule;
|
13462 | exports.PolarSeriesComponent = PolarSeriesComponent;
|
13463 | exports.ScaleLegendComponent = ScaleLegendComponent;
|
13464 | exports.SeriesHorizontal = SeriesHorizontal;
|
13465 | exports.SeriesVerticalComponent = SeriesVerticalComponent;
|
13466 | exports.SvgLinearGradientComponent = SvgLinearGradientComponent;
|
13467 | exports.SvgRadialGradientComponent = SvgRadialGradientComponent;
|
13468 | exports.Timeline = Timeline;
|
13469 | exports.TooltipArea = TooltipArea;
|
13470 | exports.TooltipContentComponent = TooltipContentComponent;
|
13471 | exports.TooltipDirective = TooltipDirective;
|
13472 | exports.TooltipModule = TooltipModule;
|
13473 | exports.TooltipService = TooltipService;
|
13474 | exports.TreeMapCellComponent = TreeMapCellComponent;
|
13475 | exports.TreeMapCellSeriesComponent = TreeMapCellSeriesComponent;
|
13476 | exports.TreeMapComponent = TreeMapComponent;
|
13477 | exports.TreeMapModule = TreeMapModule;
|
13478 | exports.VisibilityObserver = VisibilityObserver;
|
13479 | exports.XAxisComponent = XAxisComponent;
|
13480 | exports.XAxisTicksComponent = XAxisTicksComponent;
|
13481 | exports.YAxisComponent = YAxisComponent;
|
13482 | exports.YAxisTicksComponent = YAxisTicksComponent;
|
13483 | exports.calculateViewDimensions = calculateViewDimensions;
|
13484 | exports.colorSets = colorSets;
|
13485 | exports.count = count;
|
13486 | exports.decimalChecker = decimalChecker;
|
13487 | exports.escapeLabel = escapeLabel;
|
13488 | exports.formatLabel = formatLabel;
|
13489 | exports.getDomain = getDomain;
|
13490 | exports.getScale = getScale;
|
13491 | exports.getScaleType = getScaleType;
|
13492 | exports.getUniqueXDomainValues = getUniqueXDomainValues;
|
13493 | exports.getXDomainArray = getXDomainArray;
|
13494 | exports.gridLayout = gridLayout;
|
13495 | exports.gridSize = gridSize;
|
13496 | exports.hexToRgb = hexToRgb;
|
13497 | exports.id = id;
|
13498 | exports.invertColor = invertColor;
|
13499 | exports.reduceTicks = reduceTicks;
|
13500 | exports.shadeRGBColor = shadeRGBColor;
|
13501 | exports.sortByDomain = sortByDomain;
|
13502 | exports.sortByTime = sortByTime;
|
13503 | exports.sortLinear = sortLinear;
|
13504 | exports.throttle = throttle;
|
13505 | exports.throttleable = throttleable;
|
13506 | exports.tickFormat = tickFormat;
|
13507 | exports.trimLabel = trimLabel;
|
13508 | exports.ɵa = InjectionRegisteryService;
|
13509 | exports.ɵb = InjectionService;
|
13510 |
|
13511 | Object.defineProperty(exports, '__esModule', { value: true });
|
13512 |
|
13513 | })));
|
13514 |
|