提交 7484f2e4 编写于 作者: guangjun.yang's avatar guangjun.yang

图表样式处理

上级 fc6e6ea9
<!-- 柱状图-竖向 --> <!-- 柱状图-竖向 -->
<template> <template>
<div>
<div class="chart-column-vtc"> <div class="chart-column-vtc">
<div :id="id" :style="{width: chartWidth, height: chartHeight}"></div> <div :id="id" :style="{width: chartWidth, height: chartHeight}"></div>
</div> </div>
<CommonNoMore></CommonNoMore>
</div>
</template> </template>
<script> <script>
let vm = null; let vm = null;
import CommonNoMore from "@/components/common/common-no-more";
// let chartColumn = null; // let chartColumn = null;
export default { export default {
components: {
CommonNoMore
},
props: { props: {
id: { id: {
type: String, type: String,
...@@ -32,7 +39,7 @@ export default { ...@@ -32,7 +39,7 @@ export default {
data() { data() {
return { return {
chartWidth: "100%", chartWidth: "100%",
chartHeight: "350px" chartHeight: "200px"
}; };
}, },
watch: { watch: {
...@@ -56,37 +63,40 @@ export default { ...@@ -56,37 +63,40 @@ export default {
document.body.clientWidth || document.body.clientWidth ||
document.documentElement.clientWidth; document.documentElement.clientWidth;
this.chartWidth = clientWidth + "px"; this.chartWidth = clientWidth + "px";
// this.chartHeight = 54 * 3 + "px"; this.chartHeight = 53 * this.dataList.length + "px";
this.chartHeight = 43 * this.dataList.length + "px";
this.drawColumn(yAxisData, series0Data, series1Data); this.drawColumn(yAxisData, series0Data, series1Data);
} }
// this.drawColumn(yAxisData, series0Data, series1Data);
}, },
deep: false deep: true
} }
}, },
created() { created() {
if (process.client) {
// vm = this;
// this.drawColumn([], [], []);
}
}, },
mounted() { mounted() {
vm = this; vm = this;
}, },
methods: { methods: {
// 画 // 画
drawColumn(yAxisData, series0Data, series1Data) { drawColumn(yAxisData, series0Data, series1Data) {
let chartColumn = this.$echarts.init(document.getElementById(this.id)); let chartColumn = this.$echarts.init(document.getElementById(this.id));
// let chartColumn = this.$echarts.init(document.getElementById("myChart1"));
// 基于准备好的dom,初始化echarts实例 // 基于准备好的dom,初始化echarts实例
// 绘制图表 // 绘制图表
let options = { let options = {
color: vm.colors, color: vm.colors || [],
tooltip: { tooltip: {
trigger: "axis", trigger: "axis",
axisPointer: { axisPointer: {
// 坐标轴指示器,坐标轴触发有效 // 坐标轴指示器,坐标轴触发有效
type: "shadow" // 默认为直线,可选为:'line' | 'shadow' type: "shadow" // 默认为直线,可选为:'line' | 'shadow'
} },
formatter: "{b}<br/>{a0}: {c0}%<br/>{a1}: {c1}%"
}, },
legend: { legend: {
show: false, show: false,
...@@ -112,6 +122,7 @@ export default { ...@@ -112,6 +122,7 @@ export default {
xAxis: { xAxis: {
axisTick: false, axisTick: false,
type: "value", type: "value",
minInterval: 1,
axisLabel: { axisLabel: {
show: false, show: false,
formatter: "{value}", formatter: "{value}",
...@@ -187,6 +198,14 @@ export default { ...@@ -187,6 +198,14 @@ export default {
] ]
}; };
chartColumn.setOption(options); chartColumn.setOption(options);
let autoHeight = this.dataList.length * 53; // counst.length为柱状图的条数,即数据长度。35为我给每个柱状图的高度,50为柱状图x轴内容的高度(大概的)。
chartColumn.getDom().style.height = autoHeight + "px";
chartColumn.getDom().childNodes[0].style.height = autoHeight + "px";
chartColumn.getDom().childNodes[0].childNodes[0].setAttribute("height",autoHeight);
chartColumn.getDom().childNodes[0].childNodes[0].style.height = autoHeight + "px";
chartColumn.resize();
}, },
shortName: function (value, length = 5, append = '...') { shortName: function (value, length = 5, append = '...') {
if (value && value.length > length) { if (value && value.length > length) {
......
...@@ -108,6 +108,7 @@ export default { ...@@ -108,6 +108,7 @@ export default {
max: 100, max: 100,
axisTick: false, axisTick: false,
type: "value", type: "value",
minInterval: 1,
axisLabel: { axisLabel: {
formatter: "{value}%", formatter: "{value}%",
textStyle: { textStyle: {
......
...@@ -139,6 +139,9 @@ export default { ...@@ -139,6 +139,9 @@ export default {
color: "#676869" color: "#676869"
}, },
xAxis: { xAxis: {
// min: 0,
// max: 'dataMax',
minInterval: 1,
axisTick: false, axisTick: false,
type: "value", type: "value",
axisLabel: { axisLabel: {
...@@ -152,6 +155,15 @@ export default { ...@@ -152,6 +155,15 @@ export default {
color: "#efefef", color: "#efefef",
width: 1 width: 1
} }
},
//设置网格线颜色
splitLine: {
show: true,
lineStyle: {
color: ["#efefef"],
width: 1,
type: "solid"
}
} }
}, },
yAxis: { yAxis: {
...@@ -174,7 +186,16 @@ export default { ...@@ -174,7 +186,16 @@ export default {
color: "#efefef", color: "#efefef",
width: 1 width: 1
} }
} },
// //设置网格线颜色
// splitLine: {
// show: true,
// lineStyle: {
// color: ["#efefef"],
// width: 1,
// type: "solid"
// }
// }
}, },
series: vm.seriesData series: vm.seriesData
// series: [ // series: [
......
...@@ -64,6 +64,7 @@ export default { ...@@ -64,6 +64,7 @@ export default {
yAxis: { yAxis: {
axisTick: false, axisTick: false,
type: "value", type: "value",
minInterval: 1,
axisLabel: { axisLabel: {
formatter: "{value}", formatter: "{value}",
textStyle: { textStyle: {
......
...@@ -110,6 +110,7 @@ export default { ...@@ -110,6 +110,7 @@ export default {
yAxis: { yAxis: {
axisTick: false, axisTick: false,
type: "value", type: "value",
minInterval: 1,
axisLabel: { axisLabel: {
formatter: "{value}%", formatter: "{value}%",
textStyle: { textStyle: {
......
...@@ -66,6 +66,7 @@ export default { ...@@ -66,6 +66,7 @@ export default {
yAxis: { yAxis: {
axisTick: false, axisTick: false,
type: "value", type: "value",
minInterval: 1,
axisLabel: { axisLabel: {
formatter: "{value}", formatter: "{value}",
textStyle: { textStyle: {
......
...@@ -66,6 +66,7 @@ export default { ...@@ -66,6 +66,7 @@ export default {
yAxis: { yAxis: {
axisTick: false, axisTick: false,
type: "value", type: "value",
minInterval: 1,
axisLabel: { axisLabel: {
formatter: "{value}", formatter: "{value}",
textStyle: { textStyle: {
......
...@@ -62,22 +62,10 @@ export default { ...@@ -62,22 +62,10 @@ export default {
// 绘制图表 // 绘制图表
let options = { let options = {
color: echartColors, color: echartColors,
// title: {
// text: "总人数: 1,339,220人",
// // subtext: "纯属虚构",
// top: '20%',
// left: '60%',
// textStyle: {
// fontSize: 12,
// fontWeight: "bolder",
// color: "#000000"
// }
// },
tooltip: { tooltip: {
trigger: "item", trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)" formatter: "{a} <br/>{b} : {c} ({d}%)"
}, },
legend: { legend: {
type: "scroll", type: "scroll",
orient: "vertical", orient: "vertical",
...@@ -98,12 +86,13 @@ export default { ...@@ -98,12 +86,13 @@ export default {
}, },
series: [ series: [
{ {
name: "证书分布情况", name: "证书分布情况1",
type: "pie", type: "pie",
label: { label: {
position: "inner", position: "inner",
formatter: function(config) { formatter: function(config) {
return `${config.percent}%`; // alert(JSON.stringify(config))
return `${config}%`;
} }
}, },
radius: "65%", radius: "65%",
......
...@@ -28,7 +28,8 @@ export default { ...@@ -28,7 +28,8 @@ export default {
chartHeight: "1000px", chartHeight: "1000px",
handledData: {}, handledData: {},
legendData: [], legendData: [],
seriesData: {} seriesData: {},
count: 0
// 重置颜色,图标如果需要颜色,优先从用户提供的colors中依次提取,用户不提供,则根据默认的颜色进行选取 // 重置颜色,图标如果需要颜色,优先从用户提供的colors中依次提取,用户不提供,则根据默认的颜色进行选取
}; };
}, },
...@@ -63,6 +64,11 @@ export default { ...@@ -63,6 +64,11 @@ export default {
this.seriesData = pieData.map( item => { this.seriesData = pieData.map( item => {
return { name: item.name, value: item.value} return { name: item.name, value: item.value}
}) })
let count = 0
pieData.forEach( item => {
count += item.value;
})
this.count = count;
}, },
// 画饼图 // 画饼图
drawPie() { drawPie() {
...@@ -71,9 +77,21 @@ export default { ...@@ -71,9 +77,21 @@ export default {
// 绘制图表 // 绘制图表
let options = { let options = {
color: echartColors, color: echartColors,
title: {
text: "总人数: " + vm.count,
// subtext: "纯属虚构",
top: '10%',
left: '60%',
textStyle: {
fontSize: 12,
fontWeight: "bolder",
color: "#000000"
}
},
tooltip: { tooltip: {
trigger: "item", trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)" // formatter: "{a} <br/>{b} : {c} ({d}%)"
formatter: "{b}{c}"
}, },
legend: { legend: {
...@@ -83,7 +101,7 @@ export default { ...@@ -83,7 +101,7 @@ export default {
itemWidth: 9, itemWidth: 9,
itemHeight: 9, itemHeight: 9,
borderRadius: 9, borderRadius: 9,
top: '10%', top: '20%',
left: '60%', left: '60%',
bottom: 20, bottom: 20,
data: vm.legendData, // ["优秀证书", "及格证书", "未获证"], data: vm.legendData, // ["优秀证书", "及格证书", "未获证"],
...@@ -104,7 +122,8 @@ export default { ...@@ -104,7 +122,8 @@ export default {
label: { label: {
position: "inner", position: "inner",
formatter: function(config) { formatter: function(config) {
return `${config.percent}%`; // return `${config.percent}%`;
return `${config.percent.toFixed(1)}%`;
} }
}, },
radius: "65%", radius: "65%",
......
...@@ -35,18 +35,12 @@ export default { ...@@ -35,18 +35,12 @@ export default {
chartHeight: "1000px", chartHeight: "1000px",
handledData: {}, handledData: {},
legendData: [], legendData: [],
seriesData: {} seriesData: {},
count: 0
// 重置颜色,图标如果需要颜色,优先从用户提供的colors中依次提取,用户不提供,则根据默认的颜色进行选取 // 重置颜色,图标如果需要颜色,优先从用户提供的colors中依次提取,用户不提供,则根据默认的颜色进行选取
}; };
}, },
watch: { watch: {
// pieData: {
// handler(newValue, oldValue) {
// this.handlePieData(newValue);
// this.drawPie();
// },
// deep: true
// },
dataList: { dataList: {
handler(newValue, oldValue) { handler(newValue, oldValue) {
if (process.client) { if (process.client) {
...@@ -77,6 +71,11 @@ export default { ...@@ -77,6 +71,11 @@ export default {
this.seriesData = pieData.map(item => { this.seriesData = pieData.map(item => {
return { name: item.name, value: item.value }; return { name: item.name, value: item.value };
}); });
let count = 0
pieData.forEach( item => {
count += item.value;
})
this.count = count;
}, },
// 画饼图 // 画饼图
drawPie() { drawPie() {
...@@ -85,31 +84,32 @@ export default { ...@@ -85,31 +84,32 @@ export default {
// 绘制图表 // 绘制图表
let options = { let options = {
color: echartColors, color: echartColors,
// title: { title: {
// text: "总人数: 1,339,220人", text: "总人数: " + vm.count,
// // subtext: "纯属虚构", // subtext: "纯属虚构",
// top: '20%', top: '10%',
// left: '60%', left: '60%',
// textStyle: { textStyle: {
// fontSize: 12, fontSize: 12,
// fontWeight: "bolder", fontWeight: "bolder",
// color: "#000000" color: "#000000"
// } }
// }, },
tooltip: { tooltip: {
trigger: "item", trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)" // formatter: "{a} <br/>{b} : {c} ({d}%)"
formatter: "{b}{c}"
}, },
legend: { legend: {
// type: "scroll", type: "scroll",
type: "plain", // 普通图例 type: "plain", // 普通图例
orient: "vertical", orient: "vertical",
itemWidth: 9, itemWidth: 9,
itemHeight: 9, itemHeight: 9,
borderRadius: 20, borderRadius: 20,
// orient:'horizontal', // orient:'horizontal',
top: '10%', top: '20%',
left: "60%", left: "60%",
bottom: 20, bottom: 20,
data: vm.legendData, // ["优秀证书", "及格证书", "未获证"], data: vm.legendData, // ["优秀证书", "及格证书", "未获证"],
...@@ -159,7 +159,8 @@ export default { ...@@ -159,7 +159,8 @@ export default {
label: { label: {
position: "inner", position: "inner",
formatter: function(config) { formatter: function(config) {
return `${config.percent}%`; // return `${config.percent}%`;
return `${config.percent.toFixed(1)}%`;
} }
}, },
radius: "65%", radius: "65%",
......
...@@ -67,20 +67,10 @@ export default { ...@@ -67,20 +67,10 @@ export default {
// 绘制图表 // 绘制图表
options = { options = {
color: echartColors, color: echartColors,
// title: {
// text: "总人数: 1,339,220人",
// // subtext: "纯属虚构",
// top: '20%',
// left: '60%',
// textStyle: {
// fontSize: 12,
// fontWeight: "bolder",
// color: "#000000"
// }
// },
tooltip: { tooltip: {
trigger: "item", trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)" // formatter: "{a} <br/>{b} : {c} ({d}%)"
formatter: "{b}{c}"
}, },
legend: { legend: {
...@@ -109,7 +99,8 @@ export default { ...@@ -109,7 +99,8 @@ export default {
label: { label: {
position: "inner", position: "inner",
formatter: function(config) { formatter: function(config) {
return `${config.percent}%`; // alert(JSON.stringify(config))
return `${config.percent.toFixed(1)}%`;
} }
}, },
radius: "65%", radius: "65%",
......
...@@ -10,7 +10,7 @@ module.exports = { ...@@ -10,7 +10,7 @@ module.exports = {
{ name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui' }, { name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui' },
{ name: 'screen-orientation', content: 'portrait' }, { name: 'screen-orientation', content: 'portrait' },
{ name: 'apple-mobile-web-app-capable', content: 'yes' }, { name: 'apple-mobile-web-app-capable', content: 'yes' },
{ name: 'format-detection', content: 'telephone=yes' }, { name: 'format-detection', content: 'telephone=no' },
{ name: 'full-screen', content: 'yes' }, { name: 'full-screen', content: 'yes' },
{ name: 'x5-fullscreen', content: 'true' }, { name: 'x5-fullscreen', content: 'true' },
{ name: 'x5-fullscreen', content: 'true' }, { name: 'x5-fullscreen', content: 'true' },
......
...@@ -104,7 +104,6 @@ ...@@ -104,7 +104,6 @@
<PicaOrg v-show="isShowOrg" @confirm="orgConfirm" @cancel="orgCancel"></PicaOrg> <PicaOrg v-show="isShowOrg" @confirm="orgConfirm" @cancel="orgCancel"></PicaOrg>
<CommonLoading v-show="false"></CommonLoading> <CommonLoading v-show="false"></CommonLoading>
<PopTips :tipsContent="tipsContent" @clickTips="clickTips" v-show="isShowTips"></PopTips> <PopTips :tipsContent="tipsContent" @clickTips="clickTips" v-show="isShowTips"></PopTips>
<a href="tel:13817237261">打电话:13817237261</a>
</section> </section>
</template> </template>
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<TitleKLGPoint :title="title"></TitleKLGPoint> <TitleKLGPoint :title="title"></TitleKLGPoint>
<TipsInfo :content="tipsContent"></TipsInfo> <TipsInfo :content="tipsContent"></TipsInfo>
<ChartColumnHorizontalTCLong :dataList="knowledgeEffectList" class="mt-10"></ChartColumnHorizontalTCLong> <ChartColumnHorizontalTCLong :dataList="knowledgeEffectList" class="mt-10"></ChartColumnHorizontalTCLong>
<CommonNoMore></CommonNoMore>
</section> </section>
</template> </template>
<script> <script>
...@@ -13,7 +12,6 @@ import { getStudyEffect } from "@/service"; ...@@ -13,7 +12,6 @@ import { getStudyEffect } from "@/service";
import CommonHeader from "@/components/common/common-header"; import CommonHeader from "@/components/common/common-header";
import TitleKLGPoint from "@/components/bussiness/title-klg-point"; import TitleKLGPoint from "@/components/bussiness/title-klg-point";
import CommonNoMore from "@/components/common/common-no-more";
import TipsInfo from '@/components/bussiness/tips-info' import TipsInfo from '@/components/bussiness/tips-info'
import ChartColumnHorizontalTCLong from "@/components/bussiness/charts/chart-column-horizontal-tc-long"; import ChartColumnHorizontalTCLong from "@/components/bussiness/charts/chart-column-horizontal-tc-long";
...@@ -39,13 +37,12 @@ export default { ...@@ -39,13 +37,12 @@ export default {
} }
}, },
tipsContent: '报告数据来源仅包含摸底考和正式考的课程培训', tipsContent: '报告数据来源仅包含摸底考和正式考的课程培训',
knowledgeEffectList: [] knowledgeEffectList: [],
}; };
}, },
components: { components: {
CommonHeader, CommonHeader,
TitleKLGPoint, TitleKLGPoint,
CommonNoMore,
ChartColumnHorizontalTCLong, ChartColumnHorizontalTCLong,
TipsInfo TipsInfo
}, },
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册