02.配置项的讲解和使用.html 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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>02.配置项的讲解和使用</title>
  8. <!-- 步骤1:引入echarts.js文件 -->
  9. <script src="lib/echarts.min.js"></script>
  10. </head>
  11. <body>
  12. <!-- 步骤2:准备一个呈现图表的盒子 -->
  13. <div style="width: 600px;height: 400px"></div>
  14. <script>
  15. //步骤3:初始化echar实例对象
  16. //参数:dom,决定图表最终呈现的位置
  17. var mCharts = echarts.init(document.querySelector('div'))
  18. //步骤4:准备配置项
  19. var option = {
  20. title:{
  21. text:'成绩',
  22. link:'https://www.baidu.com',
  23. textStyle:{
  24. color:'red'
  25. }
  26. },
  27. xAxis:{
  28. type:'category',//类目轴
  29. data:['小明','小红','小强']
  30. },
  31. yAxis:{
  32. type:'value'//数值轴
  33. },
  34. series:[
  35. {
  36. name:'语文',
  37. type:'bar',
  38. data:[70,90,80]
  39. }
  40. ]
  41. }
  42. //步骤5:将配置项设置给echarts实例对象
  43. mCharts.setOption(option)
  44. </script>
  45. </body>
  46. </html>