word_statistics.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?PHP
  2. include "../pcdl/html_head.php";
  3. ?>
  4. <body>
  5. <style type="text/css">
  6. .highcharts-figure, .highcharts-data-table table {
  7. flex:1;
  8. min-width: 220px;
  9. max-width: 100%;
  10. margin: 1em auto;
  11. }
  12. .highcharts-data-table table {
  13. font-family: Verdana, sans-serif;
  14. border-collapse: collapse;
  15. border: 1px solid #EBEBEB;
  16. margin: 10px auto;
  17. text-align: center;
  18. width: 100%;
  19. max-width: 500px;
  20. }
  21. .highcharts-data-table caption {
  22. padding: 1em 0;
  23. font-size: 1.2em;
  24. color: #555;
  25. }
  26. .highcharts-data-table th {
  27. font-weight: 600;
  28. padding: 0.5em;
  29. }
  30. .highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
  31. padding: 0.5em;
  32. }
  33. .highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
  34. background: #f8f8f8;
  35. }
  36. .highcharts-data-table tr:hover {
  37. background: #f1f7ff;
  38. }
  39. </style>
  40. <script src="../public/js/highcharts/highcharts.js"></script>
  41. <script src="../public/js/highcharts/modules/sunburst.js"></script>
  42. <script src="../public/js/highcharts/modules/exporting.js"></script>
  43. <script src="../public/js/highcharts/modules/export-data.js"></script>
  44. <script src="../public/js/highcharts/modules/accessibility.js"></script>
  45. <?php
  46. require_once("../pcdl/head_bar.php");
  47. ?>
  48. <h2 style="text-align:center;"><?php echo $_GET["word"] ?></h2>
  49. <div style="display:flex;">
  50. <figure class="highcharts-figure">
  51. <div id="container"></div>
  52. </figure>
  53. <figure class="highcharts-figure">
  54. <div id="container_list" style="height:50em;"></div>
  55. </figure>
  56. </div>
  57. <script type="text/javascript">
  58. $.get("../search/word_statistics.php",
  59. {
  60. word : "<?php echo $_GET["word"] ?>"
  61. },
  62. function(data,status){
  63. let worddata = JSON.parse(data);
  64. // Splice in transparent for the center circle
  65. Highcharts.getOptions().colors.splice(0, 0, 'transparent');
  66. Highcharts.setOptions({
  67. colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4']
  68. });
  69. Highcharts.chart('container', {
  70. chart: {
  71. height: '100%'
  72. },
  73. title: {
  74. text: 'Distribution'
  75. },
  76. subtitle: {
  77. text: ''
  78. },
  79. series: [{
  80. type: "sunburst",
  81. data: worddata,
  82. allowDrillToNode: true,
  83. cursor: 'pointer',
  84. dataLabels: {
  85. format: '{point.name}',
  86. filter: {
  87. property: 'innerArcLength',
  88. operator: '>',
  89. value: 16
  90. },
  91. rotationMode: 'circular'
  92. },
  93. levels: [{
  94. level: 1,
  95. levelIsConstant: false,
  96. dataLabels: {
  97. filter: {
  98. property: 'outerArcLength',
  99. operator: '>',
  100. value: 64
  101. }
  102. }
  103. }, {
  104. level: 2,
  105. colorByPoint: true
  106. },
  107. {
  108. level: 3,
  109. colorVariation: {
  110. key: 'brightness',
  111. to: -0.5
  112. }
  113. }, {
  114. level: 4,
  115. colorVariation: {
  116. key: 'brightness',
  117. to: 0.5
  118. }
  119. }]
  120. }],
  121. tooltip: {
  122. headerFormat: "",
  123. pointFormat: '三藏译文 <b>{point.name}</b> 为 <b>{point.value}</b>'
  124. }
  125. });
  126. });
  127. $.get("../search/word_list.php",
  128. {
  129. word : "<?php echo $_GET["word"] ?>"
  130. },
  131. function(data,status){
  132. let worddata = JSON.parse(data);
  133. Highcharts.chart('container_list', {
  134. chart: {
  135. type: 'bar'
  136. },
  137. title: {
  138. text: 'Declension List'
  139. },
  140. xAxis: {
  141. categories: worddata.wordlist
  142. },
  143. yAxis: {
  144. min: 0,
  145. title: {
  146. text: 'Frequency'
  147. }
  148. },
  149. legend: {
  150. reversed: true
  151. },
  152. plotOptions: {
  153. series: {
  154. stacking: 'normal'
  155. }
  156. },
  157. series: worddata.data
  158. });
  159. });
  160. </script>
  161. <?php
  162. include "../pcdl/html_foot.php";
  163. ?>