220 lines
8.3 KiB
JavaScript
220 lines
8.3 KiB
JavaScript
var vms = Vue.component("amplify-nlhx", {
|
||
template: `
|
||
<div>
|
||
<div class="amplify-title-icon">
|
||
<img src="https://fileimg.makalu.cc/WEB_DBD5893450984E50AFF356EF44FF4139.png" @click="openAmplify">
|
||
</div>
|
||
<transition name="el-zoom-in-top">
|
||
<div class="amplify-fixed" v-show="show" style="display: none" @click="closeAmplifyAll">
|
||
<div class="amplify-max">
|
||
<div class="amplify-title">
|
||
<div>年龄画像</div>
|
||
<div class="amplify-close" @click="closeAmplify"><i class="el-icon-close"></i></div>
|
||
</div>
|
||
<div class="amplify-content">
|
||
<!--内容区域-->
|
||
<!--年龄画像-单位-->
|
||
<div class="amplify-time-study-title">
|
||
<div class="amplify-glr-login-rate">
|
||
<div>单位:%</div>
|
||
</div>
|
||
</div>
|
||
<!--折线图-->
|
||
<div class="amplify-time-study-title">
|
||
<div class="amplify-foldline" ref="chart"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</transition>
|
||
</div>
|
||
`,
|
||
props: {
|
||
|
||
},
|
||
data() {
|
||
return {
|
||
show:false,
|
||
ageStudyData: {},
|
||
}
|
||
},
|
||
mounted(){
|
||
|
||
},
|
||
methods: {
|
||
openAmplify(){
|
||
this.show = true
|
||
this.getAgeData()
|
||
},
|
||
closeAmplify(){
|
||
this.show = false
|
||
},
|
||
closeAmplifyAll(e){
|
||
if(e.target.className == 'amplify-fixed'){
|
||
this.show = false
|
||
}
|
||
},
|
||
getAgeData() {
|
||
axios.post("https://smz.makalu.cc/mkl/screenApi/getCqAgeData2?token=" + JSON.parse(localStorage.getItem("data")).smz_token + "&deptId=123&typtDeptId=" + JSON.parse(localStorage.getItem("data")).dept_id + "&typtProjectId=" + JSON.parse(localStorage.getItem("data")).id, {}).then(res => {
|
||
var ageStudyData = {};
|
||
ageStudyData.xAxis = ["18以下", "18-29", "30-39", "40-49", "50以上"];
|
||
ageStudyData.seriesName = "年龄分布占比";
|
||
if (res.data.code != "-1") {
|
||
var ageData = res.data.ageData;
|
||
var data = [ageData.shiqizb, ageData.shibazb, ageData.sanshizb, ageData.sishizb, ageData.wushiupzb];
|
||
ageStudyData.data = data;
|
||
}
|
||
this.ageStudyData = ageStudyData;
|
||
this.getChartData()
|
||
}).catch(err => {
|
||
})
|
||
},
|
||
// 折线图
|
||
getChartData(){
|
||
var chChartBar = echarts.init(this.$refs.chart);
|
||
this.echartBar(chChartBar,this.ageStudyData)
|
||
},
|
||
echartBar(chChart,data){
|
||
let newPromise = new Promise((resolve) => {
|
||
resolve()
|
||
})
|
||
//然后异步执行echarts的初始化函数
|
||
newPromise.then(() => {
|
||
this.option = {
|
||
grid: {
|
||
top:'10%',
|
||
left: "2%",
|
||
right: "0%",
|
||
bottom: "0%",
|
||
containLabel: true,
|
||
},
|
||
tooltip: {
|
||
trigger: "axis",
|
||
formatter: function (params) {
|
||
return (params[0].seriesName+"<br/>"
|
||
+params[0].name +":"+ params[0].data + "%")
|
||
},
|
||
},
|
||
xAxis: {
|
||
type: "category",
|
||
data: data.xAxis,
|
||
axisLine: {
|
||
//坐标轴轴线相关设置。数学上的x轴
|
||
show: true,
|
||
lineStyle: {
|
||
color: "#25597e",
|
||
type: "dashed",
|
||
},
|
||
},
|
||
axisTick: {
|
||
show: false
|
||
},
|
||
rich:{
|
||
fontSize:25
|
||
},
|
||
axisLabel: {
|
||
//坐标轴刻度标签的相关设置
|
||
textStyle: {
|
||
color: "#c5d9fc",
|
||
margin: 30,
|
||
fontSize:25
|
||
},
|
||
|
||
},
|
||
},
|
||
yAxis: {
|
||
type: "value",
|
||
axisLine: {
|
||
//坐标轴轴线相关设置。数学上的x轴
|
||
show: false,
|
||
lineStyle: {
|
||
color: "#c5d9fc",
|
||
type: "dashed",
|
||
},
|
||
},
|
||
axisTick: {
|
||
show: false
|
||
},
|
||
rich:{
|
||
fontSize:25
|
||
},
|
||
axisLabel: {
|
||
show: true,
|
||
//坐标轴刻度标签的相关设置
|
||
textStyle: {
|
||
color: "#c5d9fc",
|
||
margin: 30,
|
||
fontSize:25
|
||
},
|
||
},
|
||
splitLine: {
|
||
show: true,
|
||
lineStyle: {
|
||
color: "#25597e",
|
||
type: "dashed",
|
||
},
|
||
},
|
||
},
|
||
series: [
|
||
{
|
||
name: data.seriesName,
|
||
type: "pictorialBar",
|
||
barCategoryGap: "0%",
|
||
label: {
|
||
normal: {
|
||
show: true,
|
||
position: "top",
|
||
color:"#fff",
|
||
fontSize:25
|
||
},
|
||
},
|
||
|
||
//symbol: 'path://M0,10 L10,10 L5,0 L0,10 z',
|
||
symbol: "path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z",
|
||
|
||
|
||
itemStyle: {
|
||
normal: {
|
||
color: {
|
||
type: "linear",
|
||
x: 0,
|
||
y: 0,
|
||
x2: 0,
|
||
y2: 1,
|
||
colorStops: [
|
||
{
|
||
offset: 0,
|
||
color: "rgba(15,133,224,0.2)", // 0% 处的颜色
|
||
},
|
||
{
|
||
offset: 0.9,
|
||
color: "rgba(15,133,224,0.8)", // 100% 处的颜色
|
||
},
|
||
],
|
||
global: false, // 缺省为 false
|
||
},
|
||
},
|
||
emphasis: {
|
||
opacity: 1,
|
||
},
|
||
},
|
||
data: data.data,
|
||
z: 10,
|
||
},
|
||
],
|
||
};
|
||
chChart.setOption(this.option);
|
||
window.onresize = chChart.resize;
|
||
})
|
||
},
|
||
},
|
||
|
||
|
||
watch:{
|
||
|
||
},
|
||
|
||
})
|
||
|
||
|