decimal-custom-hover.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <!doctype html>
  2. <head>
  3. <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
  4. <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js"></script>
  5. <script src="../morris.js"></script>
  6. <script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.min.js"></script>
  7. <script src="lib/example.js"></script>
  8. <link rel="stylesheet" href="lib/example.css">
  9. <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.min.css">
  10. <link rel="stylesheet" href="../morris.css">
  11. </head>
  12. <body>
  13. <h1>Decimal Data</h1>
  14. <div id="graph"></div>
  15. <pre id="code" class="prettyprint linenums">
  16. var decimal_data = [];
  17. for (var x = 0; x <= 360; x += 10) {
  18. decimal_data.push({
  19. x: x,
  20. y: 1.5 + 1.5 * Math.sin(Math.PI * x / 180).toFixed(4)
  21. });
  22. }
  23. window.m = Morris.Line({
  24. element: 'graph',
  25. data: decimal_data,
  26. xkey: 'x',
  27. ykeys: ['y'],
  28. labels: ['sin(x)'],
  29. parseTime: false,
  30. hoverCallback: function (index, options, default_content, row) {
  31. return default_content.replace("sin(x)", "1.5 + 1.5 sin(" + row.x + ")");
  32. },
  33. xLabelMargin: 10,
  34. integerYLabels: true
  35. });
  36. </pre>
  37. </body>