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

Unified Diff: tracing/tracing/ui/base/chart_base_2d.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/chart_base.html ('k') | tracing/tracing/ui/base/line_chart.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/ui/base/chart_base_2d.html
diff --git a/tracing/tracing/ui/base/chart_base_2d.html b/tracing/tracing/ui/base/chart_base_2d.html
index 84cd50191571943f0bdcc62f42d5bb1e7685562a..b67691d8901d24b8e7cedd722562ab5ec149fcae 100644
--- a/tracing/tracing/ui/base/chart_base_2d.html
+++ b/tracing/tracing/ui/base/chart_base_2d.html
@@ -38,9 +38,9 @@ tr.exportTo('tr.ui.b', function() {
this.isYLogScale_ = false;
this.yLogScaleMin_ = undefined;
this.dataRange_ = new tr.b.Range();
-
+ this.hideXAxis_ = false;
+ this.hideYAxis_ = false;
this.data_ = [];
- this.seriesKeys_ = [];
this.leftMargin_ = 50;
d3.select(this.chartAreaElement)
@@ -53,6 +53,24 @@ tr.exportTo('tr.ui.b', function() {
this.addEventListener('mousedown', this.onMouseDown_.bind(this));
},
+ get hideXAxis() {
+ return this.hideXAxis_;
+ },
+
+ set hideXAxis(h) {
+ this.hideXAxis_ = h;
+ this.updateContents_();
+ },
+
+ get hideYAxis() {
+ return this.hideYAxis_;
+ },
+
+ set hideYAxis(h) {
+ this.hideYAxis_ = h;
+ this.updateContents_();
+ },
+
get data() {
return this.data_;
},
@@ -109,23 +127,16 @@ tr.exportTo('tr.ui.b', function() {
return leftWidth * 0.5 + rightWidth * 0.5;
},
- getLegendKeys_: function() {
- if (this.seriesKeys_ &&
- this.seriesKeys_.length > 1)
- return this.seriesKeys_.slice();
- return [];
- },
-
updateSeriesKeys_: function() {
- // Accumulate the keys on each data point.
- var keySet = {};
+ // Don't clear seriesByKey_; the caller might have put state in it using
+ // customizeLegendTargets, customizeOptionalSeries, or
+ // customizeEnabledSeries before setting data.
this.data_.forEach(function(datum) {
Object.keys(datum).forEach(function(key) {
if (this.isDatumFieldSeries_(key))
- keySet[key] = true;
+ this.getDataSeries(key);
}, this);
}, this);
- this.seriesKeys_ = Object.keys(keySet);
},
isDatumFieldSeries_: function(fieldName) {
@@ -149,11 +160,12 @@ tr.exportTo('tr.ui.b', function() {
// Y.
var yRange = new tr.b.Range();
- var keySet = new Set(this.seriesKeys_);
- for (var i = 0; i < this.data_.length; i++)
- for (var key in this.data_[i])
- if (keySet.has(key))
+ for (var i = 0; i < this.data_.length; i++) {
+ for (var key in this.data_[i]) {
+ if (!isNaN(Math.max(this.data_[i][key])))
yRange.addValue(this.data_[i][key]);
+ }
+ }
this.yScale_.range([height, 0]);
this.yScale_.domain([yRange.min, yRange.max]);
@@ -166,6 +178,9 @@ tr.exportTo('tr.ui.b', function() {
updateXAxis_: function(xAxis) {
xAxis.selectAll('*').remove();
xAxis[0][0].style.opacity = 0;
+ if (this.hideXAxis)
+ return;
+
xAxis.attr('transform', 'translate(0,' + this.chartAreaSize.height + ')')
.call(d3.svg.axis()
.scale(this.xScale_)
@@ -218,6 +233,8 @@ tr.exportTo('tr.ui.b', function() {
updateYAxis_: function(yAxis) {
yAxis.selectAll('*').remove();
yAxis[0][0].style.opacity = 0;
+ if (this.hideYAxis)
+ return;
var axisModifier = d3.svg.axis()
.scale(this.yScale_)
@@ -296,9 +313,9 @@ tr.exportTo('tr.ui.b', function() {
*/
getDataBySeriesKey_: function() {
var dataBySeriesKey = {};
- this.seriesKeys_.forEach(function(seriesKey) {
- dataBySeriesKey[seriesKey] = [];
- });
+ for (var [key, series] of this.seriesByKey_) {
+ dataBySeriesKey[key] = [];
+ }
this.data_.forEach(function(multiSeriesDatum, index) {
var x = this.getXForDatum_(multiSeriesDatum, index);
« no previous file with comments | « tracing/tracing/ui/base/chart_base.html ('k') | tracing/tracing/ui/base/line_chart.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698