lishifeng
2020-09-15 ce10677f47a14879424e7f562f78442cc03cfda1
src/components/chart/BarChart.vue
@@ -39,6 +39,14 @@
        showLabel: {
            type: Boolean,
            default: true,
        },
        maxColor: {
            type: String,
            default: 'green',
        },
        minColor:  {
            type: String,
            default: 'red',
        }
    },
    methods:{
@@ -92,7 +100,7 @@
                            if(max == -Infinity) {
                                max = 1;
                            }
                            return Math.ceil(max*1.01);
                            return Number((max+max*0.2).toFixed(2));
                        }
                    }
                ],
@@ -126,6 +134,8 @@
            if(!opt || !opt.series) {
                return [];
            }
            let minColor = this.minColor;
            let maxColor = this.maxColor;
            // 设置配置项
            let series = opt.series.map(item=>{
                let max = this.getMax(item.data);
@@ -154,9 +164,9 @@
                        color: function(value) {
                            let val = value.value[1];
                            if(val == max) {
                                return 'green';
                                return maxColor;
                            }else if(val == min) {
                                return 'red';
                                return minColor;
                            }
                        }
                    };