Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         $.ajax({
  2.           type: 'POST',
  3.           url: '[% c.uri_for("/weights_scatter/$stone.reference") %]?as_json=1',
  4.           beforeSend:function(){
  5.           },
  6.           success:function(data){
  7.                 var sg = new RGraph.Scatter('scatter', data.stone.all.weights, data.stone.weights);
  8.                 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() );
  9.                 sg.Set('chart.background.barcolor1','rgba(255,255,255,1)');
  10.                 sg.Set('chart.background.barcolor2', 'rgba(255,255,255,1)');
  11.                 sg.Set('chart.grid.color', 'rgba(238,238,238,1)');
  12.                 sg.Set('chart.gutter.left', 80);
  13.                 sg.Set('chart.gutter.top', 40);
  14.                 sg.Set('chart.gutter.bottom', 80);
  15.                 sg.Set('chart.ylabels.count', 10);
  16.                 sg.Set('chart.line', true);
  17.                 sg.Set('chart.tickmarks', null);
  18.                 sg.Set('chart.key', ['Todas os Pesos','Pesos utilizados para média']);
  19.                 sg.Set('chart.scale.decimals', 2);
  20.                 sg.Set('chart.units.post', 'g');
  21.  
  22.                 sg.Set('chart.noaxes', true);
  23.                 sg.Set('chart.ymax', data.stone.all.weights.max() + 0.1 );
  24.                 sg.Set('chart.ymin', data.stone.all.weights.min() - 0.1 );
  25.                 //sg.Set('chart.labels', ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
  26.                 sg.Set('chart.text.angle', 45);
  27.                 sg.Set('chart.labels', data.stone.all.xlabels);
  28.                 sg.Set('chart.xmax', data.stone.weights.size()-1); // Important!
  29.  
  30.                 sg.Draw();
  31.  
  32.                 var gutterLeft = sg.Get('chart.gutter.left');
  33.                 var gutterRight = sg.Get('chart.gutter.right');
  34.  
  35.                 sg.context.beginPath();
  36.                 //sg.context.fillStyle = 'black';
  37.                 sg.context.moveTo( gutterLeft,data.stone.mean );
  38.                 sg.context.lineTo( sg.canvas.width-gutterRight,data.stone.mean );
  39.                 sg.context.stroke();
  40.           },
  41.           error:function(){
  42.                 $('#scatter').text('Erro!');
  43.           }
  44.         });
  45.     }
  46. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement