[#58,flot-graph][s]: switch to horizontal bar chart as normal bar chart tick labels are borked without rotation when lots of bars (rotation not yet in flot core [1]).
[1]: https://github.com/flot/flot/pull/15
This commit is contained in:
@@ -167,10 +167,11 @@ my.FlotGraph = Backbone.View.extend({
|
|||||||
// needs to be function as can depend on state
|
// needs to be function as can depend on state
|
||||||
getGraphOptions: function(typeId) {
|
getGraphOptions: function(typeId) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
// special tickformatter to show labels rather than numbers
|
||||||
var tickFormatter = function (val) {
|
var tickFormatter = function (val) {
|
||||||
if (self.model.currentDocuments.models[val]) {
|
if (self.model.currentDocuments.models[val]) {
|
||||||
var out = self.model.currentDocuments.models[val].get(self.chartConfig.group);
|
var out = self.model.currentDocuments.models[val].get(self.chartConfig.group);
|
||||||
// if the x-axis value was in fact a number we want that not the
|
// if the value was in fact a number we want that not the
|
||||||
if (typeof(out) == 'number') {
|
if (typeof(out) == 'number') {
|
||||||
return val;
|
return val;
|
||||||
} else {
|
} else {
|
||||||
@@ -209,14 +210,17 @@ my.FlotGraph = Backbone.View.extend({
|
|||||||
show: true,
|
show: true,
|
||||||
barWidth: 1,
|
barWidth: 1,
|
||||||
align: "center",
|
align: "center",
|
||||||
fill: true
|
fill: true,
|
||||||
|
horizontal: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
grid: { hoverable: true, clickable: true },
|
grid: { hoverable: true, clickable: true },
|
||||||
xaxis: {
|
yaxis: {
|
||||||
tickSize: 1,
|
tickSize: 1,
|
||||||
tickLength: 1,
|
tickLength: 1,
|
||||||
tickFormatter: tickFormatter
|
tickFormatter: tickFormatter,
|
||||||
|
min: -0.5,
|
||||||
|
max: self.model.currentDocuments.length - 0.5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,7 +287,12 @@ my.FlotGraph = Backbone.View.extend({
|
|||||||
if (typeof x === 'string') {
|
if (typeof x === 'string') {
|
||||||
x = index;
|
x = index;
|
||||||
}
|
}
|
||||||
|
// horizontal bar chart
|
||||||
|
if (self.chartConfig.graphType == 'bars') {
|
||||||
|
points.push([y, x]);
|
||||||
|
} else {
|
||||||
points.push([x, y]);
|
points.push([x, y]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
series.push({data: points, label: field});
|
series.push({data: points, label: field});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user