You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.2 KiB

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