From 62bd8ffda7894e2c4e3740661d7d546b9ed81f10 Mon Sep 17 00:00:00 2001 From: John Glover Date: Wed, 20 Feb 2013 11:43:42 +0000 Subject: [PATCH 1/3] [#324] Bug fix: fix tooltip content and placement in flot bar graph. --- src/view.flot.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/view.flot.js b/src/view.flot.js index ea87f40f..834cf63f 100644 --- a/src/view.flot.js +++ b/src/view.flot.js @@ -115,6 +115,11 @@ my.Flot = Backbone.View.extend({ var x = item.datapoint[0].toFixed(2), y = item.datapoint[1].toFixed(2); + if (this.state.attributes.graphType === 'bars') { + x = item.datapoint[1].toFixed(2), + y = item.datapoint[0].toFixed(2); + } + var content = _.template('<%= group %> = <%= x %>, <%= series %> = <%= y %>', { group: this.state.attributes.group, x: this._xaxisLabel(x), @@ -125,6 +130,9 @@ my.Flot = Backbone.View.extend({ // use a different tooltip location offset for bar charts var xLocation, yLocation; if (this.state.attributes.graphType === 'bars') { + xLocation = item.pageX + 15; + yLocation = item.pageY - 10; + } else if (this.state.attributes.graphType === 'columns') { xLocation = item.pageX + 15; yLocation = item.pageY; } else { From c8523d80f213d7362ed840517a504b4ebcff05f9 Mon Sep 17 00:00:00 2001 From: John Glover Date: Wed, 20 Feb 2013 12:11:28 +0000 Subject: [PATCH 2/3] [xs] Bug fix: dataset is already defined. --- demos/multiview/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/multiview/app.js b/demos/multiview/app.js index 89fe5aed..6ea80a4b 100755 --- a/demos/multiview/app.js +++ b/demos/multiview/app.js @@ -27,7 +27,7 @@ jQuery(function($) { ); dataset = new recline.Model.Dataset(datasetInfo); } else { - var dataset = new recline.Model.Dataset({ + dataset = new recline.Model.Dataset({ records: [ {id: 0, date: '2011-01-01', x: 1, y: 2, z: 3, country: 'DE', title: 'first', lat:52.56, lon:13.40}, {id: 1, date: '2011-02-02', x: 2, y: 4, z: 24, country: 'UK', title: 'second', lat:54.97, lon:-1.60}, From aaef39c724ac2eb825c7df6e02a827c45a957de5 Mon Sep 17 00:00:00 2001 From: John Glover Date: Wed, 20 Feb 2013 12:15:43 +0000 Subject: [PATCH 3/3] [#324] Show full labels on flot bar y-axis --- src/view.flot.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/view.flot.js b/src/view.flot.js index 834cf63f..70493ff7 100644 --- a/src/view.flot.js +++ b/src/view.flot.js @@ -191,7 +191,7 @@ my.Flot = Backbone.View.extend({ if (typeof label !== 'string') { label = label.toString(); } - if (label.length > 8) { + if (self.state.attributes.graphType !== 'bars' && label.length > 8) { label = label.slice(0, 5) + "..."; } @@ -211,11 +211,15 @@ my.Flot = Backbone.View.extend({ x = 1, i = 0; - while (x <= maxTicks) { - if ((numPoints / x) <= maxTicks) { - break; + // show all ticks in bar graphs + // for other graphs only show up to maxTicks ticks + if (self.state.attributes.graphType !== 'bars') { + while (x <= maxTicks) { + if ((numPoints / x) <= maxTicks) { + break; + } + x = x + 1; } - x = x + 1; } for (i = 0; i < numPoints; i = i + x) {