histogram.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //var data = [4, 8, 15, 16, 23, 42];
  2. function defaults(){
  3. Chart.defaults.global.animation = false;
  4. }
  5. function f(data2) {
  6. defaults();
  7. // Get context with jQuery - using jQuery's .get() method.
  8. var ctx = $("#myChart").get(0).getContext("2d");
  9. ctx.width = $(window).width()*1.5;
  10. ctx.width = $(window).height *.5;
  11. // This will get the first returned node in the jQuery collection.
  12. var myNewChart = new Chart(ctx);
  13. var data = {
  14. labels: Array.apply(null, Array(data2.length)).map(function (_, i) {return i;}),
  15. datasets: [
  16. {
  17. label: "My First dataset",
  18. fillColor: "rgba(220,220,220,0.2)",
  19. strokeColor: "rgba(220,220,220,1)",
  20. pointColor: "rgba(220,220,220,1)",
  21. pointStrokeColor: "#fff",
  22. pointHighlightFill: "#fff",
  23. pointHighlightStroke: "rgba(220,220,220,1)",
  24. data: data2
  25. }
  26. ]
  27. };
  28. var myLineChart = new Chart(ctx).Line(data);
  29. }