Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added fps option and use setTimeout intead of setInterval for increas…

…ed performance.
  • Loading branch information...
commit b7d5be2720471ec60ff8ef99c9f5ba4609e05215 1 parent 3e7168d
@mape mape authored committed
Showing with 5 additions and 3 deletions.
  1. +1 −1  examples/server-load.js
  2. +4 −2 smoothie.js
View
2  examples/server-load.js
@@ -27,7 +27,7 @@ function initHost(hostId) {
}, 1000);
// Build the timeline
- var timeline = new SmoothieChart({ millisPerPixel: 20, grid: { strokeStyle: '#555555', lineWidth: 1, millisPerLine: 1000, verticalSections: 4 }});
+ var timeline = new SmoothieChart({ fps: 30, millisPerPixel: 20, grid: { strokeStyle: '#555555', lineWidth: 1, millisPerLine: 1000, verticalSections: 4}});
for (var i = 0; i < cpuDataSets.length; i++) {
timeline.addTimeSeries(cpuDataSets[i], seriesOptions[i]);
}
View
6 smoothie.js
@@ -48,6 +48,7 @@ function SmoothieChart(options) {
options = options || {};
options.grid = options.grid || { fillStyle:'#000000', strokeStyle: '#777777', lineWidth: 1, millisPerLine: 1000, verticalSections: 2 };
options.millisPerPixel = options.millisPerPixel || 20;
+ options.fps = options.fps || 30;
options.labels = options.labels || { fillStyle:'#ffffff' }
this.options = options;
this.seriesSet = [];
@@ -59,9 +60,10 @@ SmoothieChart.prototype.addTimeSeries = function(timeSeries, options) {
SmoothieChart.prototype.streamTo = function(canvas, delay) {
var self = this;
- setInterval(function() {
+ (function render() {
self.render(canvas, new Date().getTime() - (delay || 0));
- });
+ setTimeout(render, 1000/self.options.fps);
+ })()
};
SmoothieChart.prototype.render = function(canvas, time) {
Please sign in to comment.
Something went wrong with that request. Please try again.