Merge pull request #324 from okfn/324-flot-bar-fixes
Bugs in flot bar graph
This commit is contained in:
@@ -27,7 +27,7 @@ jQuery(function($) {
|
|||||||
);
|
);
|
||||||
dataset = new recline.Model.Dataset(datasetInfo);
|
dataset = new recline.Model.Dataset(datasetInfo);
|
||||||
} else {
|
} else {
|
||||||
var dataset = new recline.Model.Dataset({
|
dataset = new recline.Model.Dataset({
|
||||||
records: [
|
records: [
|
||||||
{id: 0, date: '2011-01-01', x: 1, y: 2, z: 3, country: 'DE', title: 'first', lat:52.56, lon:13.40},
|
{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},
|
{id: 1, date: '2011-02-02', x: 2, y: 4, z: 24, country: 'UK', title: 'second', lat:54.97, lon:-1.60},
|
||||||
|
|||||||
@@ -115,6 +115,11 @@ my.Flot = Backbone.View.extend({
|
|||||||
var x = item.datapoint[0].toFixed(2),
|
var x = item.datapoint[0].toFixed(2),
|
||||||
y = item.datapoint[1].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 %>', {
|
var content = _.template('<%= group %> = <%= x %>, <%= series %> = <%= y %>', {
|
||||||
group: this.state.attributes.group,
|
group: this.state.attributes.group,
|
||||||
x: this._xaxisLabel(x),
|
x: this._xaxisLabel(x),
|
||||||
@@ -125,6 +130,9 @@ my.Flot = Backbone.View.extend({
|
|||||||
// use a different tooltip location offset for bar charts
|
// use a different tooltip location offset for bar charts
|
||||||
var xLocation, yLocation;
|
var xLocation, yLocation;
|
||||||
if (this.state.attributes.graphType === 'bars') {
|
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;
|
xLocation = item.pageX + 15;
|
||||||
yLocation = item.pageY;
|
yLocation = item.pageY;
|
||||||
} else {
|
} else {
|
||||||
@@ -183,7 +191,7 @@ my.Flot = Backbone.View.extend({
|
|||||||
if (typeof label !== 'string') {
|
if (typeof label !== 'string') {
|
||||||
label = label.toString();
|
label = label.toString();
|
||||||
}
|
}
|
||||||
if (label.length > 8) {
|
if (self.state.attributes.graphType !== 'bars' && label.length > 8) {
|
||||||
label = label.slice(0, 5) + "...";
|
label = label.slice(0, 5) + "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,11 +211,15 @@ my.Flot = Backbone.View.extend({
|
|||||||
x = 1,
|
x = 1,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
while (x <= maxTicks) {
|
// show all ticks in bar graphs
|
||||||
if ((numPoints / x) <= maxTicks) {
|
// for other graphs only show up to maxTicks ticks
|
||||||
break;
|
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) {
|
for (i = 0; i < numPoints; i = i + x) {
|
||||||
|
|||||||
Reference in New Issue
Block a user