Echarts纵坐标显示为整数小数

 1 chart.DoubleDeckBarChart = function (getIDParam, Legend, xAxisData, seriesName1, seriesName2, seriesData1, seriesData2, color1, color2) {
 2 
 3             require.config({paths: {echarts: '/lib/echarts'}});
 4 
 5             require(
 6                 [
 7                     'echarts',
 8                     'echarts/chart/bar'
 9                 ],
10                 function (ec) {
11                     var DoubleDeckBar = ec.init(getIDParam);
12                     var option = {
13                         tooltip: {
14                             trigger: 'axis',
15                             axisPointer: {            // 坐标轴指示器,坐标轴触发有效
16                                 type: 'line'        // 默认为直线,可选为:'line' | 'shadow'
17                             }
18                         },
19                         legend: {
20                             data: Legend
21                         },
22                         grid: {
23                             x: '40',
24                             x2: '20',
25                             y2: '50',
26                             y: '38'
27                         },
28                         xAxis: [
29                             {
30                                 type: 'category',
31                                 data: xAxisData,
32                                 axisLabel: {
33                                     rotate: 40
34                                 },
35                             }
36                         ],
37                         yAxis: [
38                             {
39                                 type: 'value',
40                                 axisLabel: {
41                                     formatter: function (v) {
42                                         return parseInt(v)//表示整数。其他数值类型以此类推
43                                     }
44                                 }
45                                   //或者
46                                   //axisLabel: {
47                                     //formatter: function (v) {
48                                        // return v.toFixed(2);   //0表示小数为0位,1表示1位小数,2表示2位小数
49                                     //}
50                                 //},
51                             }
52                         ],
53                         series: [
54                             {
55                                 name: seriesName2,
56                                 type: 'bar',
57                                 stack: '广告',
58                                 data: seriesData2,
59                                 itemStyle: {
60                                     normal: {
61                                         color: color2,
62                                     },
63 
64                                 },
65                             },
66                             {
67                                 name: seriesName1,
68                                 type: 'bar',
69                                 stack: '广告',
70                                 data: seriesData1,
71                                 itemStyle: {
72                                     normal: {
73                                         color: color1,
74                                     },
75 
76                                 },
77                             }
78 
79                         ]
80                     };
81 
82                     DoubleDeckBar.setOption(option, true);
83                 }
84             );
85         }
86                                     

 

posted @ 2017-11-17 09:23  小旺同学  阅读(6688)  评论(0编辑  收藏  举报