|
@@ -1,7 +1,7 @@
|
|
<!--
|
|
<!--
|
|
* @Author: your name
|
|
* @Author: your name
|
|
* @Date: 2021-10-26 17:53:30
|
|
* @Date: 2021-10-26 17:53:30
|
|
- * @LastEditTime: 2021-10-27 11:05:22
|
|
|
|
|
|
+ * @LastEditTime: 2021-11-29 09:42:18
|
|
* @LastEditors: Please set LastEditors
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description: 成本分析扇形图
|
|
* @Description: 成本分析扇形图
|
|
* @FilePath: \hyyfScreen\src\views\Production\board\ChartCostPie.vue
|
|
* @FilePath: \hyyfScreen\src\views\Production\board\ChartCostPie.vue
|
|
@@ -15,90 +15,130 @@
|
|
export default {
|
|
export default {
|
|
props: {
|
|
props: {
|
|
data: {
|
|
data: {
|
|
- type: Array,
|
|
|
|
- default: () => []
|
|
|
|
- }
|
|
|
|
|
|
+ type: Object,
|
|
|
|
+ default: () => {},
|
|
|
|
+ },
|
|
|
|
+ title: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "",
|
|
|
|
+ },
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- myChart: null
|
|
|
|
- }
|
|
|
|
|
|
+ myChart: null,
|
|
|
|
+ };
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
init() {
|
|
init() {
|
|
|
|
+ let gtValue = parseFloat(this.data.gtValue);
|
|
|
|
+ let syValue = parseFloat(this.data.syValue);
|
|
|
|
+ let slValue = parseFloat(this.data.slValue);
|
|
|
|
+ let total = gtValue + syValue + slValue;
|
|
|
|
+ console.log("total", total);
|
|
let options = {
|
|
let options = {
|
|
|
|
+ title: {
|
|
|
|
+ text: this.title,
|
|
|
|
+ x: "center",
|
|
|
|
+ textAlign: "center",
|
|
|
|
+ textStyle: {
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ color: "#fff",
|
|
|
|
+ },
|
|
|
|
+ },
|
|
grid: {
|
|
grid: {
|
|
- x: 100
|
|
|
|
|
|
+ x: 100,
|
|
|
|
+ },
|
|
|
|
+ legend: {
|
|
|
|
+ top: "38%",
|
|
|
|
+ left: "75%",
|
|
|
|
+ orient: "vertical",
|
|
|
|
+ icon: "circle",
|
|
|
|
+ selectedMode: false, // 取消右侧项选中
|
|
|
|
+ itemGap: 20, // 各项间隔
|
|
|
|
+ textStyle: {
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ color: "#fff",
|
|
|
|
+ },
|
|
},
|
|
},
|
|
- // legend: {
|
|
|
|
- // top: '25%',
|
|
|
|
- // left: '75%',
|
|
|
|
- // orient: 'vertical',
|
|
|
|
- // icon: "circle",
|
|
|
|
- // selectedMode: false, // 取消右侧项选中
|
|
|
|
- // itemGap: 20, // 各项间隔
|
|
|
|
- // textStyle: {
|
|
|
|
- // fontSize: 15,
|
|
|
|
- // color: '#666'
|
|
|
|
- // },
|
|
|
|
- // },
|
|
|
|
series: [
|
|
series: [
|
|
{
|
|
{
|
|
// name: 'Access From',
|
|
// name: 'Access From',
|
|
- type: 'pie',
|
|
|
|
- radius: '70%', // 半径
|
|
|
|
- center: ['48%', '55%'],
|
|
|
|
|
|
+ type: "pie",
|
|
|
|
+ radius: "70%", // 半径
|
|
|
|
+ center: ["45%", "55%"],
|
|
avoidLabelOverlap: false,
|
|
avoidLabelOverlap: false,
|
|
labelLine: {
|
|
labelLine: {
|
|
- show: true
|
|
|
|
|
|
+ show: true,
|
|
},
|
|
},
|
|
itemStyle: {
|
|
itemStyle: {
|
|
normal: {
|
|
normal: {
|
|
- color: function (colors) { // 颜色设置
|
|
|
|
- var colorList = ['rgb(112,182,3)', 'rgb(232,56,92)', 'rgb(123,0,255)', 'rgb(0,215,233)', 'rgb(255,255,160)', 'rgb(0,0,255)']
|
|
|
|
- return colorList[colors.dataIndex]
|
|
|
|
|
|
+ color: function(colors) {
|
|
|
|
+ // 颜色设置
|
|
|
|
+ var colorList = [
|
|
|
|
+ "rgb(112,182,3)",
|
|
|
|
+ // "rgb(232,56,92)",
|
|
|
|
+ // "rgb(123,0,255)",
|
|
|
|
+ "rgb(0,215,233)",
|
|
|
|
+ "rgb(255,255,160)",
|
|
|
|
+ // "rgb(0,0,255)",
|
|
|
|
+ ];
|
|
|
|
+ return colorList[colors.dataIndex];
|
|
},
|
|
},
|
|
label: {
|
|
label: {
|
|
- formatter: '{b}: {c}%'
|
|
|
|
- }
|
|
|
|
|
|
+ // formatter: (params) => {
|
|
|
|
+ // let percent = ((params.value / total) * 100).toFixed(2);
|
|
|
|
+ // return `${params.name}: ${params.value.toFixed(
|
|
|
|
+ // 2
|
|
|
|
+ // )} ${percent}%`;
|
|
|
|
+ // },
|
|
|
|
+ formatter: "{b}: {c} {d}%",
|
|
|
|
+ },
|
|
},
|
|
},
|
|
label: {
|
|
label: {
|
|
- show: false
|
|
|
|
|
|
+ show: false,
|
|
},
|
|
},
|
|
emphasis: {
|
|
emphasis: {
|
|
label: {
|
|
label: {
|
|
show: true,
|
|
show: true,
|
|
- formatter: '{b}: {c}%',
|
|
|
|
|
|
+ formatter: "{b}: {c}%",
|
|
textStyle: {
|
|
textStyle: {
|
|
- fontSize: '15',
|
|
|
|
- }
|
|
|
|
|
|
+ fontSize: "15",
|
|
|
|
+ },
|
|
},
|
|
},
|
|
itemStyle: {
|
|
itemStyle: {
|
|
shadowBlur: 10,
|
|
shadowBlur: 10,
|
|
- shadowOffsetX: 0,
|
|
|
|
- shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
|
|
- }
|
|
|
|
|
|
+ shadowOffsetX: 5,
|
|
|
|
+ shadowColor: "rgba(0, 0, 0, 0.5)",
|
|
|
|
+ },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- data: this.data
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
|
|
+ data: [
|
|
|
|
+ { value: gtValue, name: "公摊成本" },
|
|
|
|
+ { value: syValue, name: "兽药成本" },
|
|
|
|
+ { value: slValue, name: "饲料成本" },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
};
|
|
};
|
|
|
|
|
|
- this.myChart.setOption(options)
|
|
|
|
- }
|
|
|
|
|
|
+ this.myChart.setOption(options, true);
|
|
|
|
+ },
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
- this.myChart = this.$echarts.init(document.getElementById('chartCostPie'));
|
|
|
|
- this.init()
|
|
|
|
|
|
+ this.myChart = this.$echarts.init(document.getElementById("chartCostPie"));
|
|
|
|
+ this.init();
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
data(value) {
|
|
data(value) {
|
|
- console.log('成本分析环形图数据', value)
|
|
|
|
- this.init()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+ console.log("成本分析环形图数据", value);
|
|
|
|
+ this.init();
|
|
|
|
+ },
|
|
|
|
+ title(value) {
|
|
|
|
+ console.log("成本分析环形图标题改了", value);
|
|
|
|
+ this.init;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
</script>
|
|
</script>
|
|
<style scoped>
|
|
<style scoped>
|
|
.cost-pie {
|
|
.cost-pie {
|