index.htm 3.0 KB

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