index.htm 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Highcharts Example</title>
  6. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  7. <script type="text/javascript">
  8. $(function () {
  9. // Register a parser for the American date format used by Google
  10. Highcharts.Data.prototype.dateFormats['m/d/Y'] = {
  11. regex: '^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2})$',
  12. parser: function (match) {
  13. return Date.UTC(+('20' + match[3]), match[1] - 1, +match[2]);
  14. }
  15. };
  16. // Get the CSV and create the chart
  17. $.get('/samples/highcharts/demo/line-ajax/analytics.csv', function (csv) {
  18. $('#container').highcharts({
  19. data: {
  20. csv: csv
  21. },
  22. title: {
  23. text: 'Daily visits at www.highcharts.com'
  24. },
  25. subtitle: {
  26. text: 'Source: Google Analytics'
  27. },
  28. xAxis: {
  29. type: 'datetime',
  30. tickInterval: 7 * 24 * 3600 * 1000, // one week
  31. tickWidth: 0,
  32. gridLineWidth: 1,
  33. labels: {
  34. align: 'left',
  35. x: 3,
  36. y: -3
  37. }
  38. },
  39. yAxis: [{ // left y axis
  40. title: {
  41. text: null
  42. },
  43. labels: {
  44. align: 'left',
  45. x: 3,
  46. y: 16,
  47. formatter: function() {
  48. return Highcharts.numberFormat(this.value, 0);
  49. }
  50. },
  51. showFirstLabel: false
  52. }, { // right y axis
  53. linkedTo: 0,
  54. gridLineWidth: 0,
  55. opposite: true,
  56. title: {
  57. text: null
  58. },
  59. labels: {
  60. align: 'right',
  61. x: -3,
  62. y: 16,
  63. formatter: function() {
  64. return Highcharts.numberFormat(this.value, 0);
  65. }
  66. },
  67. showFirstLabel: false
  68. }],
  69. legend: {
  70. align: 'left',
  71. verticalAlign: 'top',
  72. y: 20,
  73. floating: true,
  74. borderWidth: 0
  75. },
  76. tooltip: {
  77. shared: true,
  78. crosshairs: true
  79. },
  80. plotOptions: {
  81. series: {
  82. cursor: 'pointer',
  83. point: {
  84. events: {
  85. click: function() {
  86. hs.htmlExpand(null, {
  87. pageOrigin: {
  88. x: this.pageX,
  89. y: this.pageY
  90. },
  91. headingText: this.series.name,
  92. maincontentText: Highcharts.dateFormat('%A, %b %e, %Y', this.x) +':<br/> '+
  93. this.y +' visits',
  94. width: 200
  95. });
  96. }
  97. }
  98. },
  99. marker: {
  100. lineWidth: 1
  101. }
  102. }
  103. },
  104. series: [{
  105. name: 'All visits',
  106. lineWidth: 4,
  107. marker: {
  108. radius: 4
  109. }
  110. }, {
  111. name: 'New visitors'
  112. }]
  113. });
  114. });
  115. });
  116. </script>
  117. </head>
  118. <body>
  119. <script src="../../js/highcharts.js"></script>
  120. <script src="../../js/modules/data.js"></script>
  121. <script src="../../js/modules/exporting.js"></script>
  122. <!-- Additional files for the Highslide popup effect -->
  123. <script type="text/javascript" src="http://www.highcharts.com/highslide/highslide-full.min.js"></script>
  124. <script type="text/javascript" src="http://www.highcharts.com/highslide/highslide.config.js" charset="utf-8"></script>
  125. <link rel="stylesheet" type="text/css" href="http://www.highcharts.com/highslide/highslide.css" />
  126. <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
  127. </body>
  128. </html>