messagebus.js 1000 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. function logTransform(v) {
  2. return Math.log(v + 1);
  3. }
  4. function plotHist(where, hist) {
  5. var max = hist.map(function(x) {return x[1]}).reduce(function(x, y) {return Math.max(x, y)});
  6. var ticks = [];
  7. for (var t = 1; ; t *= 10) {
  8. if (t > max) {
  9. break;
  10. }
  11. ticks.push(t);
  12. }
  13. $.plot(where, [hist],
  14. {
  15. data: hist,
  16. series: {
  17. bars: {
  18. show: true,
  19. barWidth: 0.9
  20. }
  21. },
  22. xaxis: {
  23. mode: 'categories',
  24. tickLength: 0
  25. },
  26. yaxis: {
  27. ticks: ticks,
  28. transform: logTransform
  29. }
  30. }
  31. );
  32. }
  33. function plotQueueSize(where, data, ticks) {
  34. $.plot(where, [data],
  35. {
  36. xaxis: {
  37. ticks: ticks,
  38. },
  39. yaxis: {
  40. //transform: logTransform
  41. }
  42. }
  43. );
  44. }