cannot make smoothie work for me

284 views
Skip to first unread message

Ashot Aslanyan

unread,
Jun 24, 2012, 12:01:57 PM6/24/12
to Smoothie Charts
Hello everybody!

I need to draw a plot in real time, that represents server's CPU, RAM,
HDD usage, it's temperature changing dynamics etc. There is a web-
page, from where I get needed values in JSON.

Here is the example:

{"cpu":79,"ram":41,"hdd":47,"tmp":58,"asn":96,"net":100}

I need to have 6 lines in smoothie. My JS:

function get_server_data(server_id)
{
var result;

$.ajax({
url: server,
type: 'get',
dataType: 'json',
async: false,
success: function(data) {
result = data;
}
});

return result;
}

function initialize(server_id)
{
var lines = [];
var values = get_server_data(server_id);

for (var v in values)
{
var i = 0;
lines[i] = new TimeSeries();
lines[i].append(new Date().getTime(), values[v]);
}

setInterval(function(){
var values = get_server_data(server_id);
console.log(values);
for (var v in values)
{
var i = 0;
lines[i].append(new Date().getTime(), values[v]);
console.log(values[v]);
}
}, 10 * 1000);

var timeline = new SmoothieChart();

for (var i = 0; i < lines.length; i++)
timeline.addTimeSeries(lines[i], { strokeStyle: 'rgba(255, 0, 0,
1)', fillStyle: 'rgba(255, 0, 0, 0.1)', lineWidth: 3 });

timeline.streamTo($("div#" + server_id + ".server > canvas.plot")[0],
10 * 1000)
}

But as result I'm getting only one line, which draws I don't know
what.
Help me please!

Ashot Aslanyan

unread,
Jun 24, 2012, 12:29:52 PM6/24/12
to smoothi...@googlegroups.com
my bad. solved. needed to move "i" outside of the cycle =____=

however. question is still open:

i'm getting updates every 30 seconds in real. the numbers are always > 0. how can i make smoothie to work really good? i have set delay parameter in streamTo function but it still too fast for me.

cam

unread,
Jul 18, 2012, 3:00:06 PM7/18/12
to smoothi...@googlegroups.com
I think you want to up your millisPerPixel when you initialize your SmoothieChart to 5 seconds or something meaningful to your update rate.

new SmoothieChart({millisPerPixel:5000})
Reply all
Reply to author
Forward
0 new messages