chart_stanford_custom_elements.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <link rel="stylesheet" type="text/css" href="../css/c3.css">
  5. <style>
  6. .test-polygon1 {
  7. fill: white;
  8. }
  9. .test-polygon1 text {
  10. fill: black;
  11. }
  12. .test-polygon2 {
  13. fill: orange;
  14. }
  15. .test-polygon2 text {
  16. fill: black;
  17. }
  18. .test-polygon3 {
  19. fill: red;
  20. }
  21. .test-polygon3 text {
  22. fill: black;
  23. }
  24. .test-polygon4 {
  25. fill: gray;
  26. }
  27. .test-polygon4 text {
  28. fill: black;
  29. }
  30. .test-polygon5 {
  31. fill: orange;
  32. }
  33. .test-polygon5 text {
  34. fill: black;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <div id="chart"></div>
  40. <script src="https://d3js.org/d3.v5.min.js" charset="utf-8"></script>
  41. <script src="../js/c3.js"></script>
  42. <script>
  43. var chart = c3.generate({
  44. size: {
  45. height: 600,
  46. width: 600 * 1.12
  47. },
  48. data: {
  49. url: '/data/c3_stanford_data.json',
  50. mimeType: 'json',
  51. keys: {
  52. x: 'HPE',
  53. value: ['HPL', 'epochs']
  54. },
  55. type: 'stanford'
  56. },
  57. legend: {
  58. hide: true
  59. },
  60. point: {
  61. focus: {
  62. expand: {
  63. r: 5
  64. }
  65. },
  66. r: 2.5
  67. },
  68. axis: {
  69. x: {
  70. show: true,
  71. label: {
  72. text: 'HPE (m)',
  73. position: 'outer-center'
  74. },
  75. min: 0,
  76. max: 61,
  77. tick: {
  78. values: d3.range(0, 65, 10)
  79. },
  80. padding: {
  81. top: 0,
  82. bottom: 0,
  83. left: 0,
  84. right: 0
  85. },
  86. },
  87. y: {
  88. show: true,
  89. label: {
  90. text: 'HPL (m)',
  91. position: 'outer-middle'
  92. },
  93. min: 0,
  94. max: 60,
  95. tick: {
  96. values: d3.range(0, 65, 10)
  97. },
  98. padding: {
  99. top: 5,
  100. bottom: 0,
  101. left: 0,
  102. right: 0
  103. },
  104. }
  105. },
  106. stanford: {
  107. scaleMin: 1,
  108. scaleMax: 10000,
  109. scaleFormat: 'pow10',
  110. padding: {
  111. top: 15,
  112. right: 0,
  113. bottom: 0,
  114. left: 0
  115. },
  116. regions: [
  117. {
  118. points: [ // add points counter-clockwise
  119. {x: 0, y: 0},
  120. {x: 40, y: 40},
  121. {x: 0, y: 40},
  122. ],
  123. text: function (value, percentage) {
  124. return `Normal Operations: ${value} (${percentage}%)`;
  125. },
  126. opacity: 0.2, // 0 to 1
  127. class: "test-polygon1"
  128. },
  129. {
  130. points: [
  131. {x: 0, y: 0},
  132. {x: 40, y: 0},
  133. {x: 40, y: 40},
  134. ],
  135. text: function (value, percentage) {
  136. return `MI: ${value} (${percentage}%)`;
  137. },
  138. opacity: 0.2, // 0 to 1
  139. class: "test-polygon2"
  140. },
  141. {
  142. points: [
  143. {x: 40, y: 0},
  144. {x: 65, y: 0},
  145. {x: 65, y: 40},
  146. {x: 40, y: 40},
  147. ],
  148. text: function (value, percentage) {
  149. return `HMI: ${value} (${percentage}%)`;
  150. },
  151. opacity: 0.2, // 0 to 1
  152. class: "test-polygon3"
  153. },
  154. {
  155. points: [
  156. {x: 0, y: 40},
  157. {x: 40, y: 40},
  158. {x: 65, y: 65},
  159. {x: 0, y: 65},
  160. ],
  161. text: function (value, percentage) {
  162. return `Unavailable Epochs: ${value} (${percentage}%)`;
  163. },
  164. opacity: 0.2, // 0 to 1
  165. class: "test-polygon4"
  166. },
  167. {
  168. points: [
  169. {x: 40, y: 40},
  170. {x: 65, y: 40},
  171. {x: 65, y: 65}
  172. ],
  173. text: function (value, percentage) {
  174. return `MI:\n${value} (${percentage}%)`;
  175. },
  176. opacity: 0.2, // 0 to 1
  177. class: "test-polygon5"
  178. }
  179. ],
  180. lines: [ // value, text, position and class
  181. {value_x1: 0, value_y1: 0, value_x2: 65, value_y2: 65, class: "line"},
  182. {value_x1: 0, value_x2: 65, value_y1: 40, value_y2: 40, class: "line"},
  183. {value_x1: 40, value_x2: 40, value_y1: 0, value_y2: 40, class: "line"}
  184. ]
  185. }
  186. });
  187. </script>
  188. </body>
  189. </html>