Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.ajax({
- type: 'POST',
- url: '[% c.uri_for("/weights_scatter/$stone.reference") %]?as_json=1',
- beforeSend:function(){
- },
- success:function(data){
- var sg = new RGraph.Scatter('scatter', data.stone.all.weights, data.stone.weights);
- sg.Set('chart.title', 'Pesos ' + data.stone.reference + ' Média: ' + data.stone.mean.toFixed(2) + ' Desv Pad: ' + data.stone.stddev.toFixed(2) + ' Num de Medidas: ' + data.stone.weights.size() );
- sg.Set('chart.background.barcolor1','rgba(255,255,255,1)');
- sg.Set('chart.background.barcolor2', 'rgba(255,255,255,1)');
- sg.Set('chart.grid.color', 'rgba(238,238,238,1)');
- sg.Set('chart.gutter.left', 80);
- sg.Set('chart.gutter.top', 40);
- sg.Set('chart.gutter.bottom', 80);
- sg.Set('chart.ylabels.count', 10);
- sg.Set('chart.line', true);
- sg.Set('chart.tickmarks', null);
- sg.Set('chart.key', ['Todas os Pesos','Pesos utilizados para média']);
- sg.Set('chart.scale.decimals', 2);
- sg.Set('chart.units.post', 'g');
- sg.Set('chart.noaxes', true);
- sg.Set('chart.ymax', data.stone.all.weights.max() + 0.1 );
- sg.Set('chart.ymin', data.stone.all.weights.min() - 0.1 );
- //sg.Set('chart.labels', ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
- sg.Set('chart.text.angle', 45);
- sg.Set('chart.labels', data.stone.all.xlabels);
- sg.Set('chart.xmax', data.stone.weights.size()-1); // Important!
- sg.Draw();
- var gutterLeft = sg.Get('chart.gutter.left');
- var gutterRight = sg.Get('chart.gutter.right');
- sg.context.beginPath();
- //sg.context.fillStyle = 'black';
- sg.context.moveTo( gutterLeft,data.stone.mean );
- sg.context.lineTo( sg.canvas.width-gutterRight,data.stone.mean );
- sg.context.stroke();
- },
- error:function(){
- $('#scatter').text('Erro!');
- }
- });
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement