index.htm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. $('#container').highcharts({
  10. chart: {
  11. type: 'gauge',
  12. alignTicks: false,
  13. plotBackgroundColor: null,
  14. plotBackgroundImage: null,
  15. plotBorderWidth: 0,
  16. plotShadow: false
  17. },
  18. title: {
  19. text: 'Speedometer with dual axes'
  20. },
  21. pane: {
  22. startAngle: -150,
  23. endAngle: 150
  24. },
  25. yAxis: [{
  26. min: 0,
  27. max: 200,
  28. lineColor: '#339',
  29. tickColor: '#339',
  30. minorTickColor: '#339',
  31. offset: -25,
  32. lineWidth: 2,
  33. labels: {
  34. distance: -20,
  35. rotation: 'auto'
  36. },
  37. tickLength: 5,
  38. minorTickLength: 5,
  39. endOnTick: false
  40. }, {
  41. min: 0,
  42. max: 124,
  43. tickPosition: 'outside',
  44. lineColor: '#933',
  45. lineWidth: 2,
  46. minorTickPosition: 'outside',
  47. tickColor: '#933',
  48. minorTickColor: '#933',
  49. tickLength: 5,
  50. minorTickLength: 5,
  51. labels: {
  52. distance: 12,
  53. rotation: 'auto'
  54. },
  55. offset: -20,
  56. endOnTick: false
  57. }],
  58. series: [{
  59. name: 'Speed',
  60. data: [80],
  61. dataLabels: {
  62. formatter: function () {
  63. var kmh = this.y,
  64. mph = Math.round(kmh * 0.621);
  65. return '<span style="color:#339">'+ kmh + ' km/h</span><br/>' +
  66. '<span style="color:#933">' + mph + ' mph</span>';
  67. },
  68. backgroundColor: {
  69. linearGradient: {
  70. x1: 0,
  71. y1: 0,
  72. x2: 0,
  73. y2: 1
  74. },
  75. stops: [
  76. [0, '#DDD'],
  77. [1, '#FFF']
  78. ]
  79. }
  80. },
  81. tooltip: {
  82. valueSuffix: ' km/h'
  83. }
  84. }]
  85. },
  86. // Add some life
  87. function(chart) {
  88. setInterval(function() {
  89. var point = chart.series[0].points[0],
  90. newVal, inc = Math.round((Math.random() - 0.5) * 20);
  91. newVal = point.y + inc;
  92. if (newVal < 0 || newVal > 200) {
  93. newVal = point.y - inc;
  94. }
  95. point.update(newVal);
  96. }, 3000);
  97. });
  98. });
  99. </script>
  100. </head>
  101. <body>
  102. <script src="../../js/highcharts.js"></script>
  103. <script src="../../js/highcharts-more.js"></script>
  104. <script src="../../js/modules/exporting.js"></script>
  105. <div id="container" style="min-width: 310px; max-width: 400px; height: 300px; margin: 0 auto"></div>
  106. </body>
  107. </html>