Chromium Code Reviews| Index: Source/devtools/front_end/components/FlameChart.js |
| diff --git a/Source/devtools/front_end/components/FlameChart.js b/Source/devtools/front_end/components/FlameChart.js |
| index 1d2415f0752a3cca7bc881e2d0b9f49a729fd750..474b14cf7c23e3a478b521e0cb15b928de6c0709 100644 |
| --- a/Source/devtools/front_end/components/FlameChart.js |
| +++ b/Source/devtools/front_end/components/FlameChart.js |
| @@ -232,7 +232,6 @@ WebInspector.FlameChart.ColorGenerator = function(hueSpace, satSpace, lightnessS |
| this._satSpace = satSpace || 67; |
| this._lightnessSpace = lightnessSpace || 80; |
| this._colors = {}; |
| - this._currentColorIndex = 0; |
| } |
| WebInspector.FlameChart.ColorGenerator.prototype = { |
| @@ -253,18 +252,22 @@ WebInspector.FlameChart.ColorGenerator.prototype = { |
| { |
| var color = this._colors[id]; |
| if (!color) { |
| - color = this._createColor(this._currentColorIndex++); |
| + color = this._generateColorForID(id); |
| this._colors[id] = color; |
| } |
| return color; |
| }, |
| /** |
| - * @param {number} index |
| + * @param {string} id |
| * @return {string} |
| */ |
| - _createColor: function(index) |
| + _generateColorForID: function(id) |
| { |
| + var index = 0; |
| + var pow = 1; |
| + for (var i = 0; i < id.length; ++i) |
|
alph
2014/06/07 13:28:22
index = id.hashCode();
|
| + index += id.charCodeAt(i); |
| var h = this._indexToValueInSpace(index, this._hueSpace); |
| var s = this._indexToValueInSpace(index, this._satSpace); |
| var l = this._indexToValueInSpace(index, this._lightnessSpace); |
| @@ -281,7 +284,7 @@ WebInspector.FlameChart.ColorGenerator.prototype = { |
| if (typeof space === "number") |
| return space; |
| index %= space.count; |
| - return space.min + index / space.count * (space.max - space.min); |
| + return space.min + Math.floor(index / space.count * (space.max - space.min)); |
| } |
| } |