box1.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. var dom = document.getElementById("box1");
  2. var myChart = echarts.init(dom);
  3. var app = {};
  4. option = null;
  5. var labelRight = {
  6. normal: {
  7. position: 'right'
  8. }
  9. };
  10. option = {
  11. tooltip : {
  12. trigger: 'axis',
  13. axisPointer : { // 坐标轴指示器,坐标轴触发有效
  14. type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  15. }
  16. },
  17. grid: {
  18. left:10,
  19. top: 20,
  20. bottom: 30
  21. },
  22. xAxis: {
  23. type : 'value',
  24. position: 'top',
  25. splitLine: {lineStyle:{type:'dashed'}},
  26. },
  27. textStyle:{//图例文字的样式
  28. color:'#fff',
  29. fontSize:12
  30. },
  31. yAxis: {
  32. type : 'category',
  33. axisLine: {show: false},
  34. axisLabel: {show: false},
  35. axisTick: {show: false},
  36. splitLine: {show: false},
  37. data : ['ten', 'nine', 'eight', 'seven', 'six', 'five', 'four', 'three', 'two', 'one']
  38. },
  39. series : [
  40. {
  41. name:'生活费',
  42. type:'bar',
  43. stack: '总量',
  44. label: {
  45. normal: {
  46. show: true,
  47. formatter: '{b}'
  48. }
  49. },
  50. data:[
  51. {value: -0.07, label: labelRight},
  52. {value: -0.09, label: labelRight},
  53. 0.2, 0.44,
  54. {value: -0.23, label: labelRight},
  55. 0.08,
  56. {value: -0.17, label: labelRight},
  57. 0.47,
  58. {value: -0.36, label: labelRight},
  59. 0.18
  60. ]
  61. }
  62. ]
  63. };
  64. ;
  65. if (option && typeof option === "object") {
  66. myChart.setOption(option, true);
  67. }