masterPainterColorChoice.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. <script src="lib/jquery.min.js"></script>
  7. </head>
  8. <body>
  9. <style>
  10. html, body, #main {
  11. width: 100%;
  12. height: 100%;
  13. margin: 0;
  14. }
  15. </style>
  16. <div id="main"></div>
  17. <script>
  18. require([
  19. 'echarts',
  20. 'echarts/chart/scatter',
  21. 'echarts/component/title',
  22. 'echarts/component/grid',
  23. 'echarts/component/tooltip'
  24. ], function (echarts) {
  25. var chart = echarts.init(document.getElementById('main'));
  26. $.get('data/masterPainterColorChoice.json', function (json) {
  27. var data = json[0].x.map(function (x, idx) {
  28. return [+x, +json[0].y[idx]];
  29. });
  30. chart.setOption({
  31. title: {
  32. text: 'Master Painter Color Choices Throughout History',
  33. subtext: 'Data From Plot.ly',
  34. x: 'right'
  35. },
  36. tooltip: {
  37. trigger: 'axis',
  38. axisPointer: {
  39. type: 'cross'
  40. }
  41. },
  42. xAxis: {
  43. type: 'value',
  44. splitLine: {
  45. show: false
  46. },
  47. scale: true,
  48. splitNumber: 5,
  49. axisLabel: {
  50. formatter: function (val) {
  51. return val + 's';
  52. }
  53. }
  54. },
  55. yAxis: {
  56. type: 'value',
  57. min: 0,
  58. max: 360,
  59. splitNumber: 6,
  60. name: 'Hue',
  61. splitLine: {
  62. show: false
  63. }
  64. },
  65. series: [{
  66. name: 'scatter',
  67. type: 'scatter',
  68. symbolSize: function (val, param) {
  69. return json[0].marker.size[param.dataIndex] / json[0].marker.sizeref;
  70. },
  71. itemStyle: {
  72. normal: {
  73. color: function (param) {
  74. return json[0].marker.color[param.dataIndex];
  75. }
  76. }
  77. },
  78. data: data
  79. }]
  80. });
  81. });
  82. });
  83. </script>
  84. </body>
  85. </html>