Skip to content

Commit

Permalink
Merge pull request #1 from OklahomaChristian/pie-labels
Browse files Browse the repository at this point in the history
Pie labels
  • Loading branch information
zrgravity committed May 20, 2014
2 parents b4caee3 + 85c5fcd commit 8cde7de
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
8 changes: 5 additions & 3 deletions flotr2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,7 @@ Graph.prototype = {
textEnabled : this.textEnabled,
htmlText : this.options.HtmlText,
text : this._text, // TODO Is this necessary?
labelText : series.label,
element : this.el,
data : series.data,
color : series.color,
Expand Down Expand Up @@ -4765,8 +4766,8 @@ function isImage (i) {
var
_ = Flotr._;

Flotr.defaultPieLabelFormatter = function (total, value) {
return (100 * value / total).toFixed(2)+'%';
Flotr.defaultPieLabelFormatter = function (total, value, labelText) {
return labelText+(100 * value / total).toFixed(2)+'%';
};

Flotr.addType('pie', {
Expand Down Expand Up @@ -4809,7 +4810,8 @@ Flotr.addType('pie', {
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,
label = options.labelFormatter(this.total, value),
//label = options.labelFormatter(this.total, value),
label = options.labelFormatter(this.total, value, options.labelText),
//plotTickness = Math.sin(series.pie.viewAngle)*series.pie.spliceThickness / vScale;
explodeCoeff = explode + radius + 4,
distX = Math.cos(bisection) * explodeCoeff,
Expand Down
2 changes: 1 addition & 1 deletion flotr2.min.js

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions flotr2.nolibs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,7 @@ Graph.prototype = {
textEnabled : this.textEnabled,
htmlText : this.options.HtmlText,
text : this._text, // TODO Is this necessary?
labelText : series.label,
element : this.el,
data : series.data,
color : series.color,
Expand Down Expand Up @@ -3423,8 +3424,8 @@ function isImage (i) {
var
_ = Flotr._;

Flotr.defaultPieLabelFormatter = function (total, value) {
return (100 * value / total).toFixed(2)+'%';
Flotr.defaultPieLabelFormatter = function (total, value, labelText) {
return labelText+(100 * value / total).toFixed(2)+'%';
};

Flotr.addType('pie', {
Expand Down Expand Up @@ -3467,7 +3468,8 @@ Flotr.addType('pie', {
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,
label = options.labelFormatter(this.total, value),
//label = options.labelFormatter(this.total, value),
label = options.labelFormatter(this.total, value, options.labelText),
//plotTickness = Math.sin(series.pie.viewAngle)*series.pie.spliceThickness / vScale;
explodeCoeff = explode + radius + 4,
distX = Math.cos(bisection) * explodeCoeff,
Expand Down
1 change: 1 addition & 0 deletions js/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ Graph.prototype = {
textEnabled : this.textEnabled,
htmlText : this.options.HtmlText,
text : this._text, // TODO Is this necessary?
labelText : series.label,
element : this.el,
data : series.data,
color : series.color,
Expand Down
7 changes: 4 additions & 3 deletions js/types/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
var
_ = Flotr._;

Flotr.defaultPieLabelFormatter = function (total, value) {
return (100 * value / total).toFixed(2)+'%';
Flotr.defaultPieLabelFormatter = function (total, value, labelText) {
return labelText+(100 * value / total).toFixed(2)+'%';
};

Flotr.addType('pie', {
Expand Down Expand Up @@ -54,7 +54,8 @@ Flotr.addType('pie', {
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,
label = options.labelFormatter(this.total, value),
//label = options.labelFormatter(this.total, value),
label = options.labelFormatter(this.total, value, options.labelText),
//plotTickness = Math.sin(series.pie.viewAngle)*series.pie.spliceThickness / vScale;
explodeCoeff = explode + radius + 4,
distX = Math.cos(bisection) * explodeCoeff,
Expand Down

0 comments on commit 8cde7de

Please sign in to comment.