Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

don't draw pie chart if options.data[0] is undefined

  • Loading branch information...
commit 2a4efa85038fe54a743cb3ee8d03cf09fa72c7ad 1 parent 18ed335
@victorbstan authored
Showing with 9 additions and 7 deletions.
  1. +9 −7 flotr2.js
View
16 flotr2.js
@@ -4564,7 +4564,7 @@ var
_ = Flotr._;
Flotr.defaultPieLabelFormatter = function (total, value) {
- return (100 * value / total).toFixed(2)+'%';
+ value ? ((100 * value / total).toFixed(2)+'%') : null;
};
Flotr.addType('pie', {
@@ -4585,7 +4585,9 @@ Flotr.addType('pie', {
draw : function (options) {
- // TODO 3D charts what?
+ if (!options.data[0]) {
+ return;
+ }
var
data = options.data,
@@ -4601,10 +4603,10 @@ Flotr.addType('pie', {
fill = options.fill,
fillStyle = options.fillStyle,
radius = Math.min(canvas.width, canvas.height) * sizeRatio / 2,
- value = data[0][1],
+ value = data[0] ? data[0][1] : null,
html = [],
vScale = 1,//Math.cos(series.pie.viewAngle);
- measure = Math.PI * 2 * value / this.total,
+ measure = value ? (Math.PI * 2 * value / this.total) : null,
startAngle = this.startAngle || (2 * Math.PI * options.startAngle), // TODO: this initial startAngle is already in radians (fixing will be test-unstable)
endAngle = startAngle + measure,
bisection = startAngle + measure / 2,
@@ -4671,6 +4673,8 @@ Flotr.addType('pie', {
context.restore();
+ // console.log(this.slices);
+
// New start angle
this.startAngle = endAngle;
this.slices = this.slices || [];
@@ -4758,9 +4762,7 @@ Flotr.addType('pie', {
context.restore();
},
extendYRange : function (axis, data) {
- if(data[0] != undefined) {
- this.total = (this.total || 0) + data[0][1];
- }
+ (data[0] != undefined) ? (this.total = (this.total || 0) + data[0][1]) : null;
}
});
})();
Please sign in to comment.
Something went wrong with that request. Please try again.