| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /* *
- *
- * (c) 2014-2021 Highsoft AS
- *
- * Authors: Jon Arild Nygard / Oystein Moseng
- *
- * License: www.highcharts.com/license
- *
- * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
- *
- * */
- 'use strict';
- /* *
- *
- * Class
- *
- * */
- var TreemapAlgorithmGroup = /** @class */ (function () {
- /* *
- *
- * Constructor
- *
- * */
- function TreemapAlgorithmGroup(h, w, d, p) {
- this.height = h;
- this.width = w;
- this.plot = p;
- this.direction = d;
- this.startDirection = d;
- this.total = 0;
- this.nW = 0;
- this.lW = 0;
- this.nH = 0;
- this.lH = 0;
- this.elArr = [];
- this.lP = {
- total: 0,
- lH: 0,
- nH: 0,
- lW: 0,
- nW: 0,
- nR: 0,
- lR: 0,
- aspectRatio: function (w, h) {
- return Math.max((w / h), (h / w));
- }
- };
- }
- /* *
- *
- * Functions
- *
- * */
- /* eslint-disable valid-jsdoc */
- TreemapAlgorithmGroup.prototype.addElement = function (el) {
- this.lP.total = this.elArr[this.elArr.length - 1];
- this.total = this.total + el;
- if (this.direction === 0) {
- // Calculate last point old aspect ratio
- this.lW = this.nW;
- this.lP.lH = this.lP.total / this.lW;
- this.lP.lR = this.lP.aspectRatio(this.lW, this.lP.lH);
- // Calculate last point new aspect ratio
- this.nW = this.total / this.height;
- this.lP.nH = this.lP.total / this.nW;
- this.lP.nR = this.lP.aspectRatio(this.nW, this.lP.nH);
- }
- else {
- // Calculate last point old aspect ratio
- this.lH = this.nH;
- this.lP.lW = this.lP.total / this.lH;
- this.lP.lR = this.lP.aspectRatio(this.lP.lW, this.lH);
- // Calculate last point new aspect ratio
- this.nH = this.total / this.width;
- this.lP.nW = this.lP.total / this.nH;
- this.lP.nR = this.lP.aspectRatio(this.lP.nW, this.nH);
- }
- this.elArr.push(el);
- };
- TreemapAlgorithmGroup.prototype.reset = function () {
- this.nW = 0;
- this.lW = 0;
- this.elArr = [];
- this.total = 0;
- };
- return TreemapAlgorithmGroup;
- }());
- /* *
- *
- * Default Export
- *
- * */
- export default TreemapAlgorithmGroup;
|