Echarts学习记录——如何修改x轴和y轴的颜色

川长思鸟来 2022-05-13 05:46 387阅读 0赞

转载自:https://blog.csdn.net/flygoa/article/details/52922266

关键属性

axisLine:坐标轴线属性

示例代码

  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. <meta name="description" content="ECharts">
  8. <title>Echarts学习笔记</title>
  9. <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  10. </head>
  11. <script type="text/javascript">
  12. var width;
  13. var height;
  14. var myChart;
  15. $(function(){
  16. //自适应设置
  17. width = $(window).width();
  18. height = $(window).height();
  19. $("#mainBar").css("width",width-40);
  20. $("#mainBar").css("height",height-40);
  21. console.log(height);
  22. setEcharts();
  23. });
  24. $(window).resize(function() {
  25. width = $(window).width();
  26. height = $(window).height();
  27. $("#mainBar").css("width",width-40);
  28. $("#mainBar").css("height",height-40);
  29. });
  30. function setEcharts(){
  31. myChart = echarts.init(document.getElementById('mainBar'));
  32. //自适应
  33. window.onresize = myChart.resize;
  34. myChart.setOption({
  35. title : {
  36. text: '未来一周气温变化',
  37. subtext: '纯属虚构'
  38. },
  39. legend: {
  40. data:['蒸发量','降水量']
  41. },
  42. calculable : true,
  43. xAxis : [
  44. {
  45. type : 'category',
  46. data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
  47. //设置轴线的属性
  48. axisLine:{
  49. lineStyle:{
  50. color:'#FF0000',
  51. width:8,//这里是为了突出显示加上的
  52. }
  53. }
  54. }
  55. ],
  56. yAxis : [
  57. {
  58. type : 'value',
  59. //设置轴线的属性
  60. axisLine:{
  61. lineStyle:{
  62. color:'#00FF00',
  63. width:8,//这里是为了突出显示加上的
  64. }
  65. }
  66. }
  67. ],
  68. series : [
  69. {
  70. name:'蒸发量',
  71. type:'bar',
  72. data:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
  73. },
  74. {
  75. name:'降水量',
  76. type:'bar',
  77. data:[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
  78. }
  79. ]
  80. });
  81. }
  82. </script>
  83. <body>
  84. <div id="mainBar" style="border:1px solid #ccc;padding:10px;"></div>
  85. <!-- 标签式引入Eharts 如果你把引用echarts的script标签放置head内在IE8-的浏览器中会出现报错,解决的办法就是把标签移动到body内(后)。 -->
  86. <script type="text/javascript" src="http://apps.bdimg.com/libs/echarts/2.1.9/source/echarts-all.js"></script>
  87. <script>
  88. </script>
  89. </body>
  90. </html>

效果图

Jpxxksd.png

发表评论

表情:
评论列表 (有 0 条评论,387人围观)

还没有评论,来说两句吧...

相关阅读