Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1019)

Unified Diff: Source/devtools/front_end/ui/PieChart.js

Issue 429883004: DevTools: add pie chart to the paint profiler overview. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaselined Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/timeline/TimelineUIUtils.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ui/PieChart.js
diff --git a/Source/devtools/front_end/ui/PieChart.js b/Source/devtools/front_end/ui/PieChart.js
index 8c732d05ccb1804ede274e391efa83eba9b481f9..44e7d55606fb8e1f7b16ffda4a47a17f43030788 100644
--- a/Source/devtools/front_end/ui/PieChart.js
+++ b/Source/devtools/front_end/ui/PieChart.js
@@ -30,10 +30,10 @@
/**
* @constructor
- * @param {number=} totalValue
+ * @param {number} size
* @param {function(number):string=} formatter
*/
-WebInspector.PieChart = function(totalValue, formatter)
+WebInspector.PieChart = function(size, formatter)
{
var shadowSize = WebInspector.PieChart._ShadowSizePercent;
this.element = document.createElementWithClass("div", "pie-chart");
@@ -48,31 +48,37 @@ WebInspector.PieChart = function(totalValue, formatter)
var background = this._createSVGChild(this._group, "circle");
background.setAttribute("r", 1);
background.setAttribute("fill", "hsl(0,0%,92%)");
- if (totalValue) {
- var totalString = formatter ? formatter(totalValue) : totalValue;
- this._totalElement = this.element.createChild("div", "pie-chart-foreground");
- this._totalElement.textContent = totalString;
- this._totalValue = totalValue;
- }
+ this._totalElement = this.element.createChild("div", "pie-chart-foreground");
+ this._formatter = formatter;
+ this._slices = [];
this._lastAngle = -Math.PI/2;
- this.setSize(100);
+ this._setSize(size);
}
WebInspector.PieChart._ShadowSizePercent = 0.02;
WebInspector.PieChart.prototype = {
/**
- * @param {number} value
+ * @param {number} totalValue
*/
- setTotal: function(value)
+ setTotal: function(totalValue)
{
- this._totalValue = value;
+ for (var i = 0; i < this._slices.length; ++i)
+ this._slices[i].remove();
+ this._slices = [];
+ this._totalValue = totalValue;
+ var totalString;
+ if (totalValue)
+ totalString = this._formatter ? this._formatter(totalValue) : totalValue;
+ else
+ totalString = "";
+ this._totalElement.textContent = totalString;
},
/**
* @param {number} value
*/
- setSize: function(value)
+ _setSize: function(value)
{
this._group.setAttribute("transform", "scale(" + (value / 2) + ") translate(" + (1 + WebInspector.PieChart._ShadowSizePercent) + ",1)");
var size = value + "px";
@@ -101,6 +107,7 @@ WebInspector.PieChart.prototype = {
var largeArc = sliceAngle > Math.PI ? 1 : 0;
path.setAttribute("d", "M0,0 L" + x1 + "," + y1 + " A1,1,0," + largeArc + ",1," + x2 + "," + y2 + " Z");
path.setAttribute("fill", color);
+ this._slices.push(path);
},
/**
« no previous file with comments | « Source/devtools/front_end/timeline/TimelineUIUtils.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698