masterPainterColorChoice.html 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. zlevel: 1
  42. },
  43. xAxis: {
  44. type: 'value',
  45. splitLine: {
  46. show: false
  47. },
  48. scale: true,
  49. splitNumber: 5,
  50. axisLabel: {
  51. formatter: function (val) {
  52. return val + 's';
  53. }
  54. }
  55. },
  56. yAxis: {
  57. type: 'value',
  58. min: 0,
  59. max: 360,
  60. splitNumber: 6,
  61. name: 'Hue',
  62. splitLine: {
  63. show: false
  64. }
  65. },
  66. series: [{
  67. name: 'scatter',
  68. type: 'scatter',
  69. symbolSize: function (val, param) {
  70. return json[0].marker.size[param.dataIndex] / json[0].marker.sizeref;
  71. },
  72. itemStyle: {
  73. normal: {
  74. color: function (param) {
  75. return json[0].marker.color[param.dataIndex];
  76. }
  77. }
  78. },
  79. data: data
  80. }]
  81. });
  82. });
  83. });
  84. </script>
  85. </body>
  86. </html>