01.ECharts入门.html 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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: 400px;
  11. height: 400px;
  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. var option = {
  22. title: {
  23. text: 'ECharts 入门示例'
  24. },
  25. tooltip: {},
  26. legend: {
  27. data: ['销量']
  28. },
  29. xAxis: {
  30. data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
  31. },
  32. yAxis: {},
  33. series: [
  34. {
  35. name: '销量',
  36. type: 'bar',
  37. data: [5, 20, 36, 10, 10, 20]
  38. }
  39. ]
  40. };
  41. myChart.setOption(option)
  42. </script>
  43. </body>
  44. </html>