8000 Change line ending to LF · leetcode/flot-plugin-collection@0da7a71 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0da7a71

Browse files
committed
Change line ending to LF
1 parent 6330b8f commit 0da7a71

File tree

1 file changed

+83
-83
lines changed

1 file changed

+83
-83
lines changed

src/flot/jquery.flot.autoscale.js

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,83 @@
1-
/**
2-
* Flot plugin for adding additional auto scalling modes.
3-
*
4-
* @author Joel Oughton
5-
*/
6-
(function ($) {
7-
function init(plot) {
8-
9-
plot.autoScale = function () {
10-
var optsY = plot.getYAxes()[0].options;
11-
var optsX = plot.getXAxes()[0].options;
12-
var data = plot.getData();
13-
var maxX = 0, maxY = 0, minX = 0, minY = 0;
14-
15-
$.each(data, function (index, s) {
16-
var max = autoScale(plot, s, s.data, s.datapoints);
17-
maxX = Math.max(maxX, max['maxX']);
18-
maxY = Math.max(maxY, max['maxY']);
19-
minX = Math.max(minX, min['minX']);
20-
minY = Math.max(minY, min['minY']);
21-
});
22-
23-
optsX.min = minX;
24-
optsX.max = maxX;
25-
optsY.min = minY;
26-
optsY.max = maxY;
27-
28-
plot.setupGrid();
29-
plot.draw();
30-
31-
return {
32-
minY: optsY.min,
33-
maxY: optsY.max,
34-
minX: optsX.min,
35-
maxX: optsX.max,
36-
};
37-
}
38-
39-
function autoScale(plot, series, data, datapoints) {
40-
var options = plot.getOptions();
41-
42-
// limit to visible serie
43-
if (series.lines.show || series.points.show || series.bars.show) {
44-
var maxX = Number.NEGATIVE_INFINITY;
45-
var maxY = Number.NEGATIVE_INFINITY;
46-
var minX = Number.POSITIVE_INFINITY;
47-
var minY = Number.POSITIVE_INFINITY;
48-
49-
for (var i = 0; i < data.length; i++) {
50-
maxX = Math.max(maxX, data[i][0]);
51-
maxY = Math.max(maxY, data[i][1]);
52-
minX = Math.min(minX, data[i][0]);
53-
minY = Math.min(minY, data[i][1]);
54-
}
55-
56-
maxX += 2;
57-
maxY += maxY * options.yaxis.autoscaleMargin * 10;
58-
59-
minY -= 2;
60-
minY -= minY * options.yaxis.autoscaleMargin * 10;
61-
return {
62-
minX: minX,
63-
minY: minY,
64-
maxX: maxX,
65-
maxY: maxY
66-
};
67-
} else {
68-
return {
69-
minX: 0,
70-
minY: 0,
71-
maxX: 0,
72-
maxY: 0
73-
};
74-
}
75-
}
76-
}
77-
78-
$.plot.plugins.push({
79-
init: init,
80-
name: "autoscalemode",
81-
version: "0.6"
82-
});
83-
})(jQuery);
1+
/**
2+
* Flot plugin for adding additional auto scalling modes.
3+
*
4+
* @author Joel Oughton
5+
*/
6+
(function ($) {
7+
function init(plot) {
8+
9+
plot.autoScale = function () {
10+
var optsY = plot.getYAxes()[0].options;
11+
var optsX = plot.getXAxes()[0].options;
12+
var data = plot.getData();
13+
var maxX = 0, maxY = 0, minX = 0, minY = 0;
14+
15+
$.each(data, function (index, s) {
16+
var max = autoScale(plot, s, s.data, s.datapoints);
17+
maxX = Math.max(maxX, max['maxX']);
18+
maxY = Math.max(maxY, max['maxY']);
19+
minX = Math.max(minX, min['minX']);
20+
minY = Math.max(minY, min['minY']);
21+
});
22+
23+
optsX.min = minX;
24+
optsX.max = maxX;
25+
optsY.min = minY;
26+
optsY.max = maxY;
27+
28+
plot.setupGrid();
29+
plot.draw();
30+
31+
return {
32+
minY: optsY.min,
33+
maxY: optsY.max,
34+
minX: optsX.min,
35+
maxX: optsX.max,
36+
};
37+
}
38+
39+
function autoScale(plot, series, data, datapoints) {
40+
var options = plot.getOptions();
41+
42+
// limit to visible serie
43+
if (series.lines.show || series.points.show || series.bars.show) {
44+
var maxX = Number.NEGATIVE_INFINITY;
45+
var maxY = Number.NEGATIVE_INFINITY;
46+
var minX = Number.POSITIVE_INFINITY;
47+
var minY = Number.POSITIVE_INFINITY;
48+
49+
for (var i = 0; i < data.length; i++) {
50+
maxX = Math.max(maxX, data[i][0]);
51+
maxY = Math.max(maxY, data[i][1]);
52+
minX = Math.min(minX, data[i][0]);
53+
minY = Math.min(minY, data[i][1]);
54+
}
55+
56+
maxX += 2;
57+
maxY += maxY * options.yaxis.autoscaleMargin * 10;
58+
59+
minY -= 2;
60+
minY -= minY * options.yaxis.autoscaleMargin * 10;
61+
return {
62+
minX: minX,
63+
minY: minY,
64+
maxX: maxX,
65+
maxY: maxY
66+
};
67+
} else {
68+
return {
69+
minX: 0,
70+
minY: 0,
71+
maxX: 0,
72+
maxY: 0
73+
};
74+
}
75+
}
76+
}
77+
78+
$.plot.plugins.push({
79+
init: init,
80+
name: "autoscalemode",
81+
version: "0.6"
82+
});
83+
})(jQuery);

0 commit comments

Comments
 (0)
0