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

Unified Diff: tracing/tracing/ui/base/pie_chart.html

Issue 2124113002: Fix chart legends. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: finished refactoring DataSeries Map Created 4 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 | « tracing/tracing/ui/base/line_chart.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5edfd795219154d80cbdb9588e34564031201095..7bacd583670ff35b750c176cf659725a103b261e 100644
--- a/tracing/tracing/ui/base/pie_chart.html
+++ b/tracing/tracing/ui/base/pie_chart.html
@@ -4,10 +4,11 @@ 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">
<link rel="import" href="/tracing/ui/base/dom_helpers.html">
-<link rel="import" href="/tracing/ui/base/chart_base.html">
<link rel="stylesheet" href="/tracing/ui/base/pie_chart.css">
<script>
@@ -32,7 +33,6 @@ tr.exportTo('tr.ui.b', function() {
this.classList.add('pie-chart');
this.data_ = undefined;
- this.seriesKeys_ = undefined;
var chartAreaSel = d3.select(this.chartAreaElement);
var pieGroupSel = chartAreaSel.append('g')
@@ -64,18 +64,17 @@ 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_();
@@ -119,12 +118,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 +201,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)
« no previous file with comments | « tracing/tracing/ui/base/line_chart.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698