var vms = Vue.component("Company-amplify-ndczwcjd", {
template: `
`,
props: {
},
data() {
return {
show:false,
timeNum:0,
ActualNum:46,
text:'时间进度',
text1:'实际产值进度'
}
},
mounted(){
this.GetDateDiff("day")
},
methods: {
openAmplify(){
this.show = true
this.getChartData()
this.getChartData1()
},
closeAmplify(){
this.show = false
},
closeAmplifyAll(e){
if(e.target.className == 'amplify-fixed'){
this.show = false
}
},
GetDateDiff(diffType) {
//将计算间隔类性字符转换为小写
diffType = diffType.toLowerCase();
let sTime = new Date('2023-01-01'); //开始时间
let eTime = new Date(); //结束时间
if (sTime > eTime) {
alert("开始时间不能大于结束时间!!!");
return false;
}
//作为除数的数字
let divNum = 1;
switch (diffType) {
case "second":
divNum = 1000;
break;
case "minute":
divNum = 1000 * 60;
break;
case "hour":
divNum = 1000 * 3600;
break;
case "day":
divNum = 1000 * 3600 * 24;
break;
default:
break;
}
let ts = parseInt((eTime.getTime() - sTime.getTime()) / parseInt(divNum));
this.timeNum = ((ts / 365) * 100).toFixed(2)
},
//数据展示图1
getChartData(){
var chChartBar = echarts.init(this.$refs.chart1);
this.echartBar(chChartBar,this.timeNum,this.text)
},
echartBar(chChart,value,text){
let newPromise = new Promise((resolve) => {
resolve()
})
//然后异步执行echarts的初始化函数
newPromise.then(() => {
var placeHolderStyle = {
normal: {
label: {
show: false,
},
labelLine: {
show: false,
},
color: "rgba(0,0,0,0)",
borderWidth: 0,
},
emphasis: {
color: "rgba(0,0,0,0)",
borderWidth: 0,
},
};
var dataStyle = {
};
this.option ={
title: [
{
text: value+'%',
textAlign: "center",
left: "48%",
top: "50%",
textStyle: {
color: "#67abf2",
fontSize: 23,
},
},
{
text: text,
left: "48%",
top: "140%",
textAlign: "center",
textStyle: {
color: "#cdd7fa",
fontWeight: "normal",
fontSize: "16",
textAlign: "center",
},
},
],
series: [
{
type: "pie",
hoverAnimation: false,
radius: ["60%", "59%"],
center: ["50%", "40%"],
labelLine: {
normal: {
show: false,
},
},
label: {
normal: {
position: "center",
},
},
data: [
{
value: 100,
itemStyle: {
normal: {
color: "#255788",
},
},
},
],
},
{
type: "pie",
hoverAnimation: false,
radius: ["53%", "60%"],
center: ["50%", "40%"],
labelLine: {
normal: {
show: false,
},
},
label: {
normal: {
position: "center",
},
},
data: [
{
value: value,
itemStyle: {
normal: {
color: "#68a8f2",
},
},
normal: {
show: false,
},
},
{
value: 100-value,
itemStyle: placeHolderStyle,
},
],
},
],
};
chChart.setOption(this.option);
window.onresize = chChart.resize;
})
},
//数据展示图2
getChartData1(){
var chChartBar = echarts.init(this.$refs.chart2);
this.echartBar(chChartBar,this.ActualNum,this.text1)
},
echartBar(chChart,value,text){
let newPromise = new Promise((resolve) => {
resolve()
})
//然后异步执行echarts的初始化函数
newPromise.then(() => {
var placeHolderStyle = {
normal: {
label: {
show: false,
},
labelLine: {
show: false,
},
color: "rgba(0,0,0,0)",
borderWidth: 0,
},
emphasis: {
color: "rgba(0,0,0,0)",
borderWidth: 0,
},
};
var dataStyle = {
};
this.option ={
title: [
{
text: value+'%',
textAlign: "center",
left: "48%",
top: "36%",
textStyle: {
color: "#67abf2",
fontSize: 23,
},
},
{
text: text,
left: "48%",
top: "80%",
textAlign: "center",
textStyle: {
color: "#cdd7fa",
fontWeight: "normal",
fontSize: "16",
textAlign: "center",
},
},
],
series: [
{
type: "pie",
hoverAnimation: false,
radius: ["60%", "59%"],
center: ["50%", "40%"],
labelLine: {
normal: {
show: false,
},
},
label: {
normal: {
position: "center",
},
},
data: [
{
value: 100,
itemStyle: {
normal: {
color: "#255788",
},
},
},
],
},
{
type: "pie",
hoverAnimation: false,
radius: ["53%", "60%"],
center: ["50%", "40%"],
labelLine: {
normal: {
show: false,
},
},
label: {
normal: {
position: "center",
},
},
data: [
{
value: value,
itemStyle: {
normal: {
color: "#68a8f2",
},
},
normal: {
show: false,
},
},
{
value: 100-value,
itemStyle: placeHolderStyle,
},
],
},
],
};
chChart.setOption(this.option);
window.onresize = chChart.resize;
})
},
},
watch:{
},
})