02.选择ECharts图表.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. .box{
  10. width: 450px;
  11. height: 450px;
  12. background-color: pink;
  13. }
  14. </style>
  15. <script src="js/echarts.min.js"></script>
  16. </head>
  17. <body>
  18. <div class="box"></div>
  19. <script>
  20. var myChart = echarts.init(document.querySelector('.box'))
  21. option = {
  22. series: [
  23. {
  24. type: 'pie',
  25. data: [
  26. {
  27. value: 335,
  28. name: '直接访问'
  29. },
  30. {
  31. value: 234,
  32. name: '联盟广告'
  33. },
  34. {
  35. value: 1548,
  36. name: '搜索引擎'
  37. }
  38. ]
  39. }
  40. ]
  41. };
  42. myChart.setOption(option)
  43. </script>
  44. </body>
  45. </html>