index.htm 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
  7. <style type="text/css">
  8. ${demo.css}
  9. </style>
  10. <script type="text/javascript">
  11. $(function () {
  12. // Uncomment to style it like Apple Watch
  13. /*
  14. if (!Highcharts.theme) {
  15. Highcharts.setOptions({
  16. chart: {
  17. backgroundColor: 'black'
  18. },
  19. colors: ['#F62366', '#9DFF02', '#0CCDD6'],
  20. title: {
  21. style: {
  22. color: 'silver'
  23. }
  24. },
  25. tooltip: {
  26. style: {
  27. color: 'silver'
  28. }
  29. }
  30. });
  31. }
  32. // */
  33. Highcharts.chart('container', {
  34. chart: {
  35. type: 'solidgauge',
  36. marginTop: 50
  37. },
  38. title: {
  39. text: 'Activity',
  40. style: {
  41. fontSize: '24px'
  42. }
  43. },
  44. tooltip: {
  45. borderWidth: 0,
  46. backgroundColor: 'none',
  47. shadow: false,
  48. style: {
  49. fontSize: '16px'
  50. },
  51. pointFormat: '{series.name}<br><span style="font-size:2em; color: {point.color}; font-weight: bold">{point.y}%</span>',
  52. positioner: function (labelWidth, labelHeight) {
  53. return {
  54. x: 200 - labelWidth / 2,
  55. y: 180
  56. };
  57. }
  58. },
  59. pane: {
  60. startAngle: 0,
  61. endAngle: 360,
  62. background: [{ // Track for Move
  63. outerRadius: '112%',
  64. innerRadius: '88%',
  65. backgroundColor: Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0.3).get(),
  66. borderWidth: 0
  67. }, { // Track for Exercise
  68. outerRadius: '87%',
  69. innerRadius: '63%',
  70. backgroundColor: Highcharts.Color(Highcharts.getOptions().colors[1]).setOpacity(0.3).get(),
  71. borderWidth: 0
  72. }, { // Track for Stand
  73. outerRadius: '62%',
  74. innerRadius: '38%',
  75. backgroundColor: Highcharts.Color(Highcharts.getOptions().colors[2]).setOpacity(0.3).get(),
  76. borderWidth: 0
  77. }]
  78. },
  79. yAxis: {
  80. min: 0,
  81. max: 100,
  82. lineWidth: 0,
  83. tickPositions: []
  84. },
  85. plotOptions: {
  86. solidgauge: {
  87. borderWidth: '34px',
  88. dataLabels: {
  89. enabled: false
  90. },
  91. linecap: 'round',
  92. stickyTracking: false
  93. }
  94. },
  95. series: [{
  96. name: 'Move',
  97. borderColor: Highcharts.getOptions().colors[0],
  98. data: [{
  99. color: Highcharts.getOptions().colors[0],
  100. radius: '100%',
  101. innerRadius: '100%',
  102. y: 80
  103. }]
  104. }, {
  105. name: 'Exercise',
  106. borderColor: Highcharts.getOptions().colors[1],
  107. data: [{
  108. color: Highcharts.getOptions().colors[1],
  109. radius: '75%',
  110. innerRadius: '75%',
  111. y: 65
  112. }]
  113. }, {
  114. name: 'Stand',
  115. borderColor: Highcharts.getOptions().colors[2],
  116. data: [{
  117. color: Highcharts.getOptions().colors[2],
  118. radius: '50%',
  119. innerRadius: '50%',
  120. y: 50
  121. }]
  122. }]
  123. },
  124. /**
  125. * In the chart load callback, add icons on top of the circular shapes
  126. */
  127. function callback() {
  128. // Move icon
  129. this.renderer.path(['M', -8, 0, 'L', 8, 0, 'M', 0, -8, 'L', 8, 0, 0, 8])
  130. .attr({
  131. 'stroke': '#303030',
  132. 'stroke-linecap': 'round',
  133. 'stroke-linejoin': 'round',
  134. 'stroke-width': 2,
  135. 'zIndex': 10
  136. })
  137. .translate(190, 26)
  138. .add(this.series[2].group);
  139. // Exercise icon
  140. this.renderer.path(['M', -8, 0, 'L', 8, 0, 'M', 0, -8, 'L', 8, 0, 0, 8, 'M', 8, -8, 'L', 16, 0, 8, 8])
  141. .attr({
  142. 'stroke': '#303030',
  143. 'stroke-linecap': 'round',
  144. 'stroke-linejoin': 'round',
  145. 'stroke-width': 2,
  146. 'zIndex': 10
  147. })
  148. .translate(190, 61)
  149. .add(this.series[2].group);
  150. // Stand icon
  151. this.renderer.path(['M', 0, 8, 'L', 0, -8, 'M', -8, 0, 'L', 0, -8, 8, 0])
  152. .attr({
  153. 'stroke': '#303030',
  154. 'stroke-linecap': 'round',
  155. 'stroke-linejoin': 'round',
  156. 'stroke-width': 2,
  157. 'zIndex': 10
  158. })
  159. .translate(190, 96)
  160. .add(this.series[2].group);
  161. });
  162. });
  163. </script>
  164. </head>
  165. <body>
  166. <script src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
  167. <script src="http://cdn.hcharts.cn/highcharts/highcharts-more.js"></script>
  168. <script src="http://cdn.hcharts.cn/highcharts/modules/solid-gauge.js"></script>
  169. <div id="container" style="width: 400px; height: 400px; margin: 0 auto">
  170. </div>
  171. </body>
  172. </html>