|
1 | 1 | /*
|
2 |
| - * heatmap.js v2.0.2 | JavaScript Heatmap Library |
| 2 | + * heatmap.js v2.0.5 | JavaScript Heatmap Library |
3 | 3 | *
|
4 | 4 | * Copyright 2008-2016 Patrick Wied <[email protected]> - All rights reserved.
|
5 | 5 | * Dual licensed under MIT and Beerware license
|
6 | 6 | *
|
7 |
| - * :: 2016-02-04 21:25 |
| 7 | + * :: 2016-09-05 01:16 |
8 | 8 | */
|
9 | 9 | ;(function (name, context, factory) {
|
10 | 10 |
|
@@ -38,7 +38,7 @@ var Store = (function StoreClosure() {
|
38 | 38 | this._coordinator = {};
|
39 | 39 | this._data = [];
|
40 | 40 | this._radi = [];
|
41 |
| - this._min = 0; |
| 41 | + this._min = 10; |
42 | 42 | this._max = 1;
|
43 | 43 | this._xField = config['xField'] || config.defaultXField;
|
44 | 44 | this._yField = config['yField'] || config.defaultYField;
|
@@ -74,15 +74,23 @@ var Store = (function StoreClosure() {
|
74 | 74 | } else {
|
75 | 75 | store[x][y] += value;
|
76 | 76 | }
|
| 77 | + var storedVal = store[x][y]; |
77 | 78 |
|
78 |
| - if (store[x][y] > max) { |
| 79 | + if (storedVal > max) { |
79 | 80 | if (!forceRender) {
|
80 |
| - this._max = store[x][y]; |
| 81 | + this._max = storedVal; |
81 | 82 | } else {
|
82 |
| - this.setDataMax(store[x][y]); |
| 83 | + this.setDataMax(storedVal); |
83 | 84 | }
|
84 | 85 | return false;
|
85 |
| - } else{ |
| 86 | + } else if (storedVal < min) { |
| 87 | + if (!forceRender) { |
| 88 | + this._min = storedVal; |
| 89 | + } else { |
| 90 | + this.setDataMin(storedVal); |
| 91 | + } |
| 92 | + return false; |
| 93 | + } else { |
86 | 94 | return {
|
87 | 95 | x: x,
|
88 | 96 | y: y,
|
@@ -133,6 +141,10 @@ var Store = (function StoreClosure() {
|
133 | 141 | // add to store
|
134 | 142 | var organisedEntry = this._organiseData(arguments[0], true);
|
135 | 143 | if (organisedEntry) {
|
| 144 | + // if it's the first datapoint initialize the extremas with it |
| 145 | + if (this._data.length === 0) { |
| 146 | + this._min = this._max = organisedEntry.value; |
| 147 | + } |
136 | 148 | this._coordinator.emit('renderpartial', {
|
137 | 149 | min: this._min,
|
138 | 150 | max: this._max,
|
|
0 commit comments