Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions flotr2.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@

return bean
});

// Underscore.js 1.1.7
// (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
Expand Down Expand Up @@ -1340,6 +1341,7 @@
};

})();

/**
* Flotr2 (c) 2012 Carl Sutherland
* MIT License
Expand All @@ -1355,6 +1357,9 @@ var
Flotr;

Flotr = {
el : "",
data : "",
options : "",
_: _,
bean: bean,
isIphone: /iphone/i.test(navigator.userAgent),
Expand Down Expand Up @@ -1402,6 +1407,9 @@ Flotr = {
* @return {Object} returns a new graph object and of course draws the graph.
*/
draw: function(el, data, options, GraphKlass){
Flotr.el = el;
Flotr.data = data;
Flotr.options = options;
GraphKlass = GraphKlass || Flotr.Graph;
return new GraphKlass(el, data, options);
},
Expand Down Expand Up @@ -1534,6 +1542,13 @@ Flotr = {
floorInBase: function(n, base) {
return base * Math.floor(n / base);
},
legendClick: function(index){
return "Flotr.toggleData(" + index + ");Flotr.draw(Flotr.el, Flotr.data, Flotr.options);";
},
toggleData: function(index){
Flotr.data[index].hide = !Flotr.data[index].hide;
return;
},
drawText: function(ctx, text, x, y, style) {
if (!ctx.fillText) {
ctx.drawText(text, x, y, style);
Expand Down Expand Up @@ -2090,7 +2105,6 @@ Flotr.DOM = {
var div = Flotr.DOM.create('div'), n;
div.innerHTML = html;
n = div.children[0];
div.innerHTML = '';
return n;
},
/**
Expand Down Expand Up @@ -4913,9 +4927,9 @@ Flotr.addType('pie', {
r = Math.sqrt(x * x + y * y),
theta = Math.atan(y / x),
circle = Math.PI * 2,
explode = slice.explode || options.explode,
start = slice.start % circle,
end = slice.end % circle,
explode = slice == null? false : slice.explode || options.explode,
start = slice == null? 0 : slice.start % circle,
end = slice == null? 0 : slice.end % circle,
epsilon = options.epsilon;

if (x < 0) {
Expand All @@ -4924,7 +4938,8 @@ Flotr.addType('pie', {
theta += circle;
}

if (r < slice.radius + explode && r > explode) {
var mySliceRadius = slice == null ? 0 : slice.radius;
if (r < mySliceRadius + explode && r > explode) {
if (
(theta > start && theta < end) || // Normal Slice
(start > end && (theta < end || theta > start)) || // First slice
Expand Down Expand Up @@ -6587,8 +6602,6 @@ Flotr.addPlugin('legend', {
opacity = legend.backgroundOpacity,
i, label, color;

if (itemCount) {

var lbw = legend.labelBoxWidth,
lbh = legend.labelBoxHeight,
lbm = legend.labelBoxMargin,
Expand Down Expand Up @@ -6651,7 +6664,7 @@ Flotr.addPlugin('legend', {
}
else {
for(i = 0; i < series.length; ++i){
if(!series[i].label || series[i].hide) continue;
if(!series[i].label) continue;

if(i % legend.noColumns === 0){
fragments.push(rowStarted ? '</tr><tr>' : '<tr>');
Expand All @@ -6663,11 +6676,16 @@ Flotr.addPlugin('legend', {
boxHeight = legend.labelBoxHeight;

label = legend.labelFormatter(s.label);
color = 'background-color:' + ((s.bars && s.bars.show && s.bars.fillColor && s.bars.fill) ? s.bars.fillColor : s.color) + ';';

if(series[i].hide){
color = 'background-color: #FFFFFF;';
}
else{
color = 'background-color:' + ((s.bars && s.bars.show && s.bars.fillColor && s.bars.fill) ? s.bars.fillColor : s.color) + ';';
}

fragments.push(
'<td class="flotr-legend-color-box">',
'<div style="border:1px solid ', legend.labelBoxBorderColor, ';padding:1px">',
'<div style="border:1px solid ', legend.labelBoxBorderColor, ';padding:1px" onclick="', Flotr.legendClick(i), '">',
'<div style="width:', (boxWidth-1), 'px;height:', (boxHeight-1), 'px;border:1px solid ', series[i].color, '">', // Border
'<div style="width:', boxWidth, 'px;height:', boxHeight, 'px;', color, '"></div>', // Background
'</div>',
Expand Down Expand Up @@ -6722,7 +6740,6 @@ Flotr.addPlugin('legend', {
}
}
}
}
}
});
})();
Expand Down
19 changes: 1 addition & 18 deletions flotr2.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion js/DOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Flotr.DOM = {
var div = Flotr.DOM.create('div'), n;
div.innerHTML = html;
n = div.children[0];
div.innerHTML = '';
return n;
},
/**
Expand Down
13 changes: 13 additions & 0 deletions js/Flotr.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ var
Flotr;

Flotr = {
el : "",
data : "",
options : "",
_: _,
bean: bean,
isIphone: /iphone/i.test(navigator.userAgent),
Expand Down Expand Up @@ -60,6 +63,9 @@ Flotr = {
* @return {Object} returns a new graph object and of course draws the graph.
*/
draw: function(el, data, options, GraphKlass){
Flotr.el = el;
Flotr.data = data;
Flotr.options = options;
GraphKlass = GraphKlass || Flotr.Graph;
return new GraphKlass(el, data, options);
},
Expand Down Expand Up @@ -192,6 +198,13 @@ Flotr = {
floorInBase: function(n, base) {
return base * Math.floor(n / base);
},
legendClick: function(index){
return "Flotr.toggleData(" + index + ");Flotr.draw(Flotr.el, Flotr.data, Flotr.options);";
},
toggleData: function(index){
Flotr.data[index].hide = !Flotr.data[index].hide;
return;
},
drawText: function(ctx, text, x, y, style) {
if (!ctx.fillText) {
ctx.drawText(text, x, y, style);
Expand Down
16 changes: 9 additions & 7 deletions js/plugins/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ Flotr.addPlugin('legend', {
opacity = legend.backgroundOpacity,
i, label, color;

if (itemCount) {

var lbw = legend.labelBoxWidth,
lbh = legend.labelBoxHeight,
lbm = legend.labelBoxMargin,
Expand Down Expand Up @@ -116,7 +114,7 @@ Flotr.addPlugin('legend', {
}
else {
for(i = 0; i < series.length; ++i){
if(!series[i].label || series[i].hide) continue;
if(!series[i].label) continue;

if(i % legend.noColumns === 0){
fragments.push(rowStarted ? '</tr><tr>' : '<tr>');
Expand All @@ -128,11 +126,16 @@ Flotr.addPlugin('legend', {
boxHeight = legend.labelBoxHeight;

label = legend.labelFormatter(s.label);
color = 'background-color:' + ((s.bars && s.bars.show && s.bars.fillColor && s.bars.fill) ? s.bars.fillColor : s.color) + ';';

if(series[i].hide){
color = 'background-color: #FFFFFF;';
}
else{
color = 'background-color:' + ((s.bars && s.bars.show && s.bars.fillColor && s.bars.fill) ? s.bars.fillColor : s.color) + ';';
}

fragments.push(
'<td class="flotr-legend-color-box">',
'<div style="border:1px solid ', legend.labelBoxBorderColor, ';padding:1px">',
'<div style="border:1px solid ', legend.labelBoxBorderColor, ';padding:1px" onclick="', Flotr.legendClick(i), '">',
'<div style="width:', (boxWidth-1), 'px;height:', (boxHeight-1), 'px;border:1px solid ', series[i].color, '">', // Border
'<div style="width:', boxWidth, 'px;height:', boxHeight, 'px;', color, '"></div>', // Background
'</div>',
Expand Down Expand Up @@ -187,7 +190,6 @@ Flotr.addPlugin('legend', {
}
}
}
}
}
});
})();
9 changes: 5 additions & 4 deletions js/types/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ Flotr.addType('pie', {
r = Math.sqrt(x * x + y * y),
theta = Math.atan(y / x),
circle = Math.PI * 2,
explode = slice.explode || options.explode,
start = slice.start % circle,
end = slice.end % circle,
explode = slice == null? false : slice.explode || options.explode,
start = slice == null? 0 : slice.start % circle,
end = slice == null? 0 : slice.end % circle,
epsilon = options.epsilon;

if (x < 0) {
Expand All @@ -162,7 +162,8 @@ Flotr.addType('pie', {
theta += circle;
}

if (r < slice.radius + explode && r > explode) {
var mySliceRadius = slice == null ? 0 : slice.radius;
if (r < mySliceRadius + explode && r > explode) {
if (
(theta > start && theta < end) || // Normal Slice
(start > end && (theta < end || theta > start)) || // First slice
Expand Down
1 change: 1 addition & 0 deletions make/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{ "src": "./lib/underscore.js", "jshint": false }
],
"flotr2": [
"./build/lib.js",
"./js/Flotr.js",
"./js/DefaultOptions.js",
"./js/Color.js",
Expand Down