提交 368b0b32 编写于 作者: guangjun.yang's avatar guangjun.yang

解决图表为空的问题

上级 024503d8
...@@ -2,18 +2,21 @@ ...@@ -2,18 +2,21 @@
<template> <template>
<div> <div>
<div class="chart-column-vtc"> <div class="chart-column-vtc">
<div :id="id" :style="{width: chartWidth, height: chartHeight}"></div> <div v-show="isShow" :id="id" :style="{width: chartWidth, height: chartHeight}"></div>
<NoContent v-show="!isShow" :id="id" :style="{width: '100%', height: '220px'}"></NoContent>
</div> </div>
<CommonNoMore></CommonNoMore> <CommonNoMore v-show="isShow"></CommonNoMore>
</div> </div>
</template> </template>
<script> <script>
let vm = null; let vm = null;
import CommonNoMore from "@/components/common/common-no-more"; import CommonNoMore from "@/components/common/common-no-more";
import NoContent from "@/components/bussiness/no-content";
// let chartColumn = null; // let chartColumn = null;
export default { export default {
components: { components: {
CommonNoMore CommonNoMore,
NoContent
}, },
props: { props: {
id: { id: {
...@@ -39,12 +42,15 @@ export default { ...@@ -39,12 +42,15 @@ export default {
data() { data() {
return { return {
chartWidth: "100%", chartWidth: "100%",
chartHeight: "200px" chartHeight: "200px",
isShow: true
}; };
}, },
watch: { watch: {
dataList: { dataList: {
handler(newVal) { handler(newVal) {
if(newVal.length) {
this.isShow = true;
let yAxisData = [], let yAxisData = [],
series0Data = [], series0Data = [],
series1Data = []; series1Data = [];
...@@ -66,16 +72,16 @@ export default { ...@@ -66,16 +72,16 @@ export default {
this.chartHeight = 53 * this.dataList.length + "px"; this.chartHeight = 53 * this.dataList.length + "px";
this.drawColumn(yAxisData, series0Data, series1Data); this.drawColumn(yAxisData, series0Data, series1Data);
} }
} else {
this.isShow = false;
}
}, },
deep: true deep: true
} }
}, },
created() { created() {
if (process.client) {
// vm = this;
// this.drawColumn([], [], []);
}
}, },
mounted() { mounted() {
vm = this; vm = this;
......
...@@ -2,15 +2,20 @@ ...@@ -2,15 +2,20 @@
<template> <template>
<div> <div>
<div class="chart-column-htc"> <div class="chart-column-htc">
<div :id="id" :style="{width: chartWidth, height: chartHeight}"></div> <div v-show="isShow" :id="id" :style="{width: chartWidth, height: chartHeight}"></div>
<NoContent v-show="!isShow" :id="id" :style="{width: '100%', height: '220px'}"></NoContent>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { format } from "path"; import { format } from "path";
import NoContent from "@/components/bussiness/no-content";
let vm = null, let vm = null,
chartColumn = null; chartColumn = null;
export default { export default {
components: {
NoContent
},
props: { props: {
dataList: { dataList: {
type: Array, type: Array,
...@@ -28,19 +33,21 @@ export default { ...@@ -28,19 +33,21 @@ export default {
data() { data() {
return { return {
chartWidth: "300px", chartWidth: "300px",
chartHeight: "350px" chartHeight: "350px",
isShow: true,
}; };
}, },
watch: { watch: {
dataList: { dataList: {
handler(newVal) { handler(newVal) {
if(newVal.length) {
this.isShow = true;
let yAxisData = [], let yAxisData = [],
series0Data = [], series0Data = [],
series1Data = []; series1Data = [];
yAxisData = newVal.map(item => { yAxisData = newVal.map(item => {
return this.shortName(item.classifyName); return this.shortName(item.classifyName);
// return (item.classifyName || 0).toFixed(1) * 100 + '%'
}); });
series0Data = this.dataList.map(item => { series0Data = this.dataList.map(item => {
return ((item.beforeRate || 0) * 100).toFixed(1); return ((item.beforeRate || 0) * 100).toFixed(1);
...@@ -53,6 +60,9 @@ export default { ...@@ -53,6 +60,9 @@ export default {
series0Data.splice(0, 5), series0Data.splice(0, 5),
series1Data.splice(0, 5) series1Data.splice(0, 5)
); );
} else {
this.isShow = false;
}
}, },
deep: false deep: false
} }
......
<!-- 柱状图-横向 --> <!-- 柱状图-横向 -->
<template> <template>
<div class="chart-pie"> <div class="chart-pie">
<div :id="id" :style="{width: chartWidth, height: chartHeight}"></div> <div v-show="isShow" :id="id" :style="{width: chartWidth, height: chartHeight}"></div>
<NoContent v-show="!isShow" :id="id" :style="{width: '100%', height: '220px'}"></NoContent>
</div> </div>
</template> </template>
<script> <script>
import { format } from "path"; import { format } from "path";
import NoContent from "@/components/bussiness/no-content";
let vm = null; let vm = null;
let certNameConfig = { let certNameConfig = {
'-1': '未获证人数', '-1': '未获证人数',
...@@ -15,6 +17,9 @@ let certNameConfig = { ...@@ -15,6 +17,9 @@ let certNameConfig = {
'4': '获不及格人数', '4': '获不及格人数',
} }
export default { export default {
components: {
NoContent
},
props: { props: {
id: { id: {
type: String, type: String,
...@@ -42,6 +47,7 @@ export default { ...@@ -42,6 +47,7 @@ export default {
legendData: [], legendData: [],
yAxisData: [], yAxisData: [],
seriesData: [], seriesData: [],
isShow: true
}; };
}, },
mounted() { mounted() {
...@@ -50,6 +56,8 @@ export default { ...@@ -50,6 +56,8 @@ export default {
watch: { watch: {
echartsData: { echartsData: {
handler(newVal, oldValue) { handler(newVal, oldValue) {
if(newVal.length) {
this.isShow = true;
// console.log(newVal, oldValue); // console.log(newVal, oldValue);
vm.legendData = []; vm.legendData = [];
vm.yAxisData = []; vm.yAxisData = [];
...@@ -105,6 +113,9 @@ export default { ...@@ -105,6 +113,9 @@ export default {
} }
this.handlerSeriesData(newVal); this.handlerSeriesData(newVal);
vm.drawColumn(); vm.drawColumn();
} else {
this.isShow = false;
}
}, },
deep: true deep: true
} }
......
<!-- 柱状图-竖向 --> <!-- 柱状图-竖向 -->
<template> <template>
<section class="chart-pie"> <section class="chart-pie">
<div :id="id" :style="{width: chartWidth, height: chartHeight}"></div> <div v-show="isShow" :id="id" :style="{width: chartWidth, height: chartHeight}"></div>
<NoContent v-show="!isShow" :id="id" :style="{width: '100%', height: '220px'}"></NoContent>
</section> </section>
</template> </template>
<script> <script>
import { format } from "path"; import { format } from "path";
import NoContent from "@/components/bussiness/no-content";
let vm = null, chartColumn = null; let vm = null, chartColumn = null;
export default { export default {
components: {
NoContent
},
props: { props: {
id: { id: {
type: String, type: String,
...@@ -127,13 +132,15 @@ export default { ...@@ -127,13 +132,15 @@ export default {
barWidth: 20 //柱图宽度 barWidth: 20 //柱图宽度
} }
] ]
} },
isShow: true
}; };
}, },
watch: { watch: {
dataList: { dataList: {
handler(newVal) { handler(newVal) {
// debugger if(newVal.length) {
this.isShow = true;
this.xAxisData = newVal.map( item => { this.xAxisData = newVal.map( item => {
return item.times return item.times
}) })
...@@ -143,6 +150,9 @@ export default { ...@@ -143,6 +150,9 @@ export default {
this.options.xAxis.data = this.xAxisData; this.options.xAxis.data = this.xAxisData;
this.options.series[0].data = this.seriesData; this.options.series[0].data = this.seriesData;
chartColumn.setOption(this.options, true); chartColumn.setOption(this.options, true);
} else {
this.isShow = false;
}
}, },
deep: true deep: true
} }
......
...@@ -2,18 +2,21 @@ ...@@ -2,18 +2,21 @@
<template> <template>
<div> <div>
<div class="chart-column-vtc"> <div class="chart-column-vtc">
<div :id="id" :style="{width: chartWidth, height: chartHeight}"></div> <div v-show="isShow" :id="id" :style="{width: chartWidth, height: chartHeight}"></div>
<NoContent v-show="!isShow" :id="id" :style="{width: '100%', height: '220px'}"></NoContent>
</div> </div>
<TipsInfoChart content="报告数据来源仅包含摸底考和正式考的课程培训"></TipsInfoChart> <TipsInfoChart content="报告数据来源仅包含摸底考和正式考的课程培训"></TipsInfoChart>
</div> </div>
</template> </template>
<script> <script>
import { format } from "path"; import { format } from "path";
import NoContent from "@/components/bussiness/no-content";
import TipsInfoChart from "@/components/bussiness/tips-info-chart"; import TipsInfoChart from "@/components/bussiness/tips-info-chart";
let vm = null, chartColumn = null; let vm = null, chartColumn = null;
export default { export default {
components: { components: {
TipsInfoChart TipsInfoChart,
NoContent
}, },
props: { props: {
dataList: { dataList: {
...@@ -37,7 +40,8 @@ export default { ...@@ -37,7 +40,8 @@ export default {
data() { data() {
return { return {
chartWidth: "300px", chartWidth: "300px",
chartHeight: "320px" chartHeight: "320px",
isShow: true,
}; };
}, },
created() { created() {
...@@ -53,6 +57,8 @@ export default { ...@@ -53,6 +57,8 @@ export default {
watch: { watch: {
dataList: { dataList: {
handler(newVal) { handler(newVal) {
if(newVal.length) {
this.isShow = true;
let yAxisData = [], series0Data = [], series1Data = [] let yAxisData = [], series0Data = [], series1Data = []
yAxisData = newVal.map( item => { yAxisData = newVal.map( item => {
return this.shortName(item.classifyName) return this.shortName(item.classifyName)
...@@ -64,6 +70,9 @@ export default { ...@@ -64,6 +70,9 @@ export default {
return ((item.afterRate|| 0) * 100).toFixed(1); return ((item.afterRate|| 0) * 100).toFixed(1);
}) })
this.drawColumn(yAxisData.splice(0, 5), series0Data.splice(0, 5), series1Data.splice(0, 5)); this.drawColumn(yAxisData.splice(0, 5), series0Data.splice(0, 5), series1Data.splice(0, 5));
} else {
this.isShow = false;
}
}, },
deep: false deep: false
} }
......
<!-- 柱状图-竖向 --> <!-- 柱状图-竖向 -->
<template> <template>
<section class="chart-pie"> <section class="chart-pie">
<div :id="id" :style="{width: chartWidth, height: chartHeight}"></div> <div v-show="isShow" :id="id" :style="{width: chartWidth, height: chartHeight}"></div>
<NoContent v-show="!isShow" :id="id" :style="{width: '100%', height: '220px'}"></NoContent>
</section> </section>
</template> </template>
<script> <script>
import { format } from "path"; import { format } from "path";
import NoContent from "@/components/bussiness/no-content";
let vm = null, chartColumn = null; let vm = null, chartColumn = null;
export default { export default {
components: {
NoContent
},
props: { props: {
id: { id: {
type: String, type: String,
...@@ -121,12 +126,16 @@ export default { ...@@ -121,12 +126,16 @@ export default {
barWidth: 20 //柱图宽度 barWidth: 20 //柱图宽度
} }
] ]
} },
isShow: true
}; };
}, },
watch: { watch: {
dataList: { dataList: {
handler(newVal) { handler(newVal) {
console.log('chart-cvtimes', newVal)
if(newVal.length) {
this.isShow = true;
let cList = newVal.slice(0, 5); let cList = newVal.slice(0, 5);
this.xAxisData = cList.map( item => { this.xAxisData = cList.map( item => {
return item.timesStr return item.timesStr
...@@ -137,6 +146,10 @@ export default { ...@@ -137,6 +146,10 @@ export default {
this.options.xAxis.data = this.xAxisData; this.options.xAxis.data = this.xAxisData;
this.options.series[0].data = this.seriesData; this.options.series[0].data = this.seriesData;
chartColumn.setOption(this.options, true); chartColumn.setOption(this.options, true);
} else {
this.isShow = false;
}
}, },
deep: true deep: true
} }
......
<!-- 人员学历情况饼图 --> <!-- 人员学历情况饼图 -->
<template> <template>
<section class="chart-pie-edu"> <section class="chart-pie-edu">
<div :id="pieId" :style="{width: chartWidth, height: '220px'}"></div> <div v-show="isShow" :id="pieId" :style="{width: chartWidth, height: '220px'}"></div>
<NoContent v-show="!isShow" :id="pieId" :style="{width: '100%', height: '220px'}"></NoContent>
</section> </section>
</template> </template>
<script> <script>
import { format } from "path"; import { format } from "path";
import { echartColors } from '@/utils/index' import { echartColors } from '@/utils/index'
import NoContent from "@/components/bussiness/no-content";
let vm = null; let vm = null;
export default { export default {
name: "eduPie", name: "eduPie",
components: {
NoContent
},
props: { props: {
dataList: { dataList: {
type: Array, type: Array,
...@@ -29,23 +34,28 @@ export default { ...@@ -29,23 +34,28 @@ export default {
handledData: {}, handledData: {},
legendData: [], legendData: [],
seriesData: {}, seriesData: {},
count: 0 count: 0,
isShow: true
// 重置颜色,图标如果需要颜色,优先从用户提供的colors中依次提取,用户不提供,则根据默认的颜色进行选取 // 重置颜色,图标如果需要颜色,优先从用户提供的colors中依次提取,用户不提供,则根据默认的颜色进行选取
}; };
}, },
watch: { watch: {
dataList: { dataList: {
handler(newValue, oldValue) { handler(newValue, oldValue) {
if (process.client) { if (newValue.length) {
this.isShow = true;
let clientWidth = let clientWidth =
window.outerWidth || window.outerWidth ||
document.body.clientWidth || document.body.clientWidth ||
document.documentElement.clientWidth; document.documentElement.clientWidth;
this.chartWidth = Math.ceil(clientWidth * 0.90) + 'px'; this.chartWidth = Math.ceil(clientWidth * 0.90) + 'px';
console.log('this.chartWidth', this.chartWidth); console.log('this.chartWidth', this.chartWidth);
}
this.handlePieData(newValue); this.handlePieData(newValue);
this.drawPie(); this.drawPie();
} else {
this.isShow = false;
}
}, },
deep: true deep: true
} }
......
<!-- 人员职称情况饼图 --> <!-- 人员职称情况饼图 -->
<template> <template>
<section class="chart-pie"> <section class="chart-pie">
<div :id="pieId" :style="{width: chartWidth, height: '220px'}"></div> <div v-show="isShow" :id="pieId" :style="{width: chartWidth, height: '220px'}"></div>
<NoContent v-show="!isShow" :id="pieId" :style="{width: '100%', height: '220px'}"></NoContent>
</section> </section>
</template> </template>
<script> <script>
import { format } from "path"; import { format } from "path";
import { echartColors } from "@/utils/index"; import { echartColors } from "@/utils/index";
import NoContent from "@/components/bussiness/no-content";
let vm = null; let vm = null;
export default { export default {
name: "titlePie", name: "titlePie",
components: {
NoContent
},
props: { props: {
pieData: { pieData: {
type: Array, type: Array,
...@@ -26,7 +31,7 @@ export default { ...@@ -26,7 +31,7 @@ export default {
{ value: 310, name: "及格证书" }, { value: 310, name: "及格证书" },
{ value: 234, name: "未获证" } { value: 234, name: "未获证" }
] ]
} },
}, },
data() { data() {
return { return {
...@@ -36,14 +41,16 @@ export default { ...@@ -36,14 +41,16 @@ export default {
handledData: {}, handledData: {},
legendData: [], legendData: [],
seriesData: {}, seriesData: {},
count: 0 count: 0,
isShow: true,
// 重置颜色,图标如果需要颜色,优先从用户提供的colors中依次提取,用户不提供,则根据默认的颜色进行选取 // 重置颜色,图标如果需要颜色,优先从用户提供的colors中依次提取,用户不提供,则根据默认的颜色进行选取
}; };
}, },
watch: { watch: {
dataList: { dataList: {
handler(newValue, oldValue) { handler(newValue, oldValue) {
if (process.client) { if (newValue.length) {
this.isShow = true;
let clientWidth = let clientWidth =
window.outerWidth || window.outerWidth ||
document.body.clientWidth || document.body.clientWidth ||
...@@ -52,6 +59,8 @@ export default { ...@@ -52,6 +59,8 @@ export default {
console.log('this.chartWidth', this.chartWidth); console.log('this.chartWidth', this.chartWidth);
this.handlePieData(newValue); this.handlePieData(newValue);
this.drawPie(); this.drawPie();
} else {
this.isShow = false;
} }
}, },
deep: true deep: true
......
<!-- 饼图 --> <!-- 饼图 -->
<template> <template>
<section class="chart-pie"> <section class="chart-pie">
<div :id="id" :style="{width: '100%', height: '220px'}"></div> <div v-show="isShow" :id="id" :style="{width: '100%', height: '220px'}"></div>
<NoContent v-show="!isShow" :id="id" :style="{width: '100%', height: '220px'}"></NoContent>
</section> </section>
</template> </template>
<script> <script>
import { echartColors } from '@/utils/index' import { echartColors } from '@/utils/index'
import NoContent from "@/components/bussiness/no-content";
let vm = null; let vm = null;
let chartPie = null; let chartPie = null;
...@@ -18,6 +20,9 @@ let certNameConfig = { ...@@ -18,6 +20,9 @@ let certNameConfig = {
'4': '获不及格人数', '4': '获不及格人数',
} }
export default { export default {
components: {
NoContent
},
props: { props: {
id: { id: {
type: String, type: String,
...@@ -41,14 +46,16 @@ export default { ...@@ -41,14 +46,16 @@ export default {
chartHeight: "1000px", chartHeight: "1000px",
handledData: {}, handledData: {},
legendData: [], legendData: [],
seriesData: {} seriesData: {},
// 重置颜色,图标如果需要颜色,优先从用户提供的colors中依次提取,用户不提供,则根据默认的颜色进行选取 isShow: true
}; };
}, },
watch: { watch: {
pieData: { pieData: {
handler(newValue, oldValue) { handler(newValue, oldValue) {
// 处理数据 // 如果有数据,则处理数据并显示图表
if(newValue.length) {
this.isShow = true;
for(let i = 0; i < newValue.length; i ++) { for(let i = 0; i < newValue.length; i ++) {
if(this.certFlag == 1 && newValue[i].certId != -1) { if(this.certFlag == 1 && newValue[i].certId != -1) {
newValue[i].certName = '已获证人数' newValue[i].certName = '已获证人数'
...@@ -58,6 +65,10 @@ export default { ...@@ -58,6 +65,10 @@ export default {
} }
this.handlePieData(newValue); this.handlePieData(newValue);
this.drawPie(); this.drawPie();
} else {
this.isShow = false;
}
}, },
deep: true deep: true
} }
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<CommonCard :cardList="examCardList"></CommonCard> <CommonCard :cardList="examCardList"></CommonCard>
<CommonSplitLine></CommonSplitLine> <CommonSplitLine></CommonSplitLine>
<CommonTitle title="完成项目考试次数情况"></CommonTitle> <CommonTitle title="完成项目考试次数情况"></CommonTitle>
<ChartColumnVerticalTimes :dataList="generalExamData.examTimesList" id="chartCourseTimesId" :colors="colors"></ChartColumnVerticalTimes> <ChartColumnVerticalTimes :dataList="(generalExamData.examTimesList || []).slice(0, 5)" id="chartCourseTimesId" :colors="colors"></ChartColumnVerticalTimes>
<ShowAll v-show="generalExamData && generalExamData.examTimesList.length > 5" @action="gotoPage('/examtimes')" class="mt-10"></ShowAll> <ShowAll v-show="generalExamData && generalExamData.examTimesList.length > 5" @action="gotoPage('/examtimes')" class="mt-10"></ShowAll>
<CommonSplitLine></CommonSplitLine> <CommonSplitLine></CommonSplitLine>
<CommonTitle title="完成项目考试分数情况"></CommonTitle> <CommonTitle title="完成项目考试分数情况"></CommonTitle>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册