Index: tracing/tracing/ui/base/pie_chart.html |
diff --git a/tracing/tracing/ui/base/pie_chart.html b/tracing/tracing/ui/base/pie_chart.html |
index b5afd0fc287e46f1d84e24ce986fa20a04ae3c17..cfa15680deb98d1f76d9b4148a4dc7aa0fbedee3 100644 |
--- a/tracing/tracing/ui/base/pie_chart.html |
+++ b/tracing/tracing/ui/base/pie_chart.html |
@@ -4,6 +4,7 @@ Copyright (c) 2014 The Chromium Authors. All rights reserved. |
Use of this source code is governed by a BSD-style license that can be |
found in the LICENSE file. |
--> |
+ |
<link rel="import" href="/tracing/base/range.html"> |
<link rel="import" href="/tracing/ui/base/chart_base.html"> |
<link rel="import" href="/tracing/ui/base/d3.html"> |
@@ -32,7 +33,6 @@ tr.exportTo('tr.ui.b', function() { |
Polymer.dom(this).classList.add('pie-chart'); |
this.data_ = undefined; |
- this.seriesKeys_ = undefined; |
var chartAreaSel = d3.select(this.chartAreaElement); |
var pieGroupSel = chartAreaSel.append('g') |
@@ -54,6 +54,9 @@ tr.exportTo('tr.ui.b', function() { |
return this.data_; |
}, |
+ get titleMarginPx() { |
+ return 40; |
+ }, |
/** |
* @param {Array} data Data for the chart, where each element in the array |
@@ -64,30 +67,22 @@ tr.exportTo('tr.ui.b', function() { |
// Figure out the label values in the data set. E.g. from |
// [{label: 'a', ...}, {label: 'b', ...}] |
// we would commpute ['a', 'y']. These become the series keys. |
- var seriesKeys = []; |
+ // Don't clear seriesByKey_; the caller might have put state in it using |
+ // customizeLegendTargets, customizeOptionalSeries, or |
+ // customizeEnabledSeries before setting data. |
var seenSeriesKeys = {}; |
data.forEach(function(d) { |
var k = d.label; |
if (seenSeriesKeys[k]) |
throw new Error('Label ' + k + ' has been used already'); |
- seriesKeys.push(k); |
+ this.getDataSeries(k); |
seenSeriesKeys[k] = true; |
}, this); |
- this.seriesKeys_ = seriesKeys; |
- } else { |
- this.seriesKeys_ = undefined; |
} |
this.data_ = data; |
this.updateContents_(); |
}, |
- get margin() { |
- var margin = {top: 0, right: 0, bottom: 0, left: 0}; |
- if (this.chartTitle_) |
- margin.top += 40; |
- return margin; |
- }, |
- |
getMinSize: function() { |
this.updateContents_(); |
@@ -119,12 +114,6 @@ tr.exportTo('tr.ui.b', function() { |
}; |
}, |
- |
- getLegendKeys_: function() { |
- // This class creates its own legend, instead of using ChartBase. |
- return undefined; |
- }, |
- |
updateScales_: function(width, height) { |
if (this.data_ === undefined) |
return; |
@@ -208,6 +197,14 @@ tr.exportTo('tr.ui.b', function() { |
}) |
.attr('dy', '.35em') |
.style('text-anchor', 'middle') |
+ .on('mouseenter', function(d, i) { |
+ var origData = this.data_[i]; |
+ this.pushTempHighlightedLegendKey(origData.label); |
+ }.bind(this)) |
+ .on('mouseleave', function(d, i) { |
+ var origData = this.data_[i]; |
+ this.popTempHighlightedLegendKey(origData.label); |
+ }.bind(this)) |
.text(function(d, i) { |
var origData = this.data_[i]; |
if (origData.valueText === undefined) |