Files
youfang-app/fangija-zsyf/views/component/trends.js
T
2018-04-09 18:42:07 +08:00

241 lines
4.9 KiB
JavaScript

var rentPricesData = {rentPrices: []}
Vue.component('room-rent-component', {
template: `
`,
data: function(){
return rentPricesData;
},
methods: {
loadTrend:function(){
var myChart02 = echarts.init(document.getElementById('chart02'));
myChart02.setOption(option02,true);
}
},
mounted:function(){
this.loadTrend();
}
})
/* 小区租金走势 */
var option02 = {
tooltip: {
trigger: 'axis',
textStyle: {
fontFamily: 'arial,华文细黑',
fontSize: 12
},
formatter: '{a0}: {c0}元/月<br>{a1}: {c1}元/月<br>{a2}: {c2}元/月<br>{a3}: {c3}元/月<br>{a4}: {c4}元/月'
},
grid:{
x: 54,
y: 10,
x2: 16,
y2: 60,
borderWidth: 1
},
color: ['#F88C9F', '#FFBF5C', '#AAD672', '#78CDE6', '#AE94E9'],
legend: {
data: ['一室', '二室', '三室', '四室', '五室'],
y: 'bottom',
textStyle: {
fontFamily: '华文细黑',
fontWeight: 'bold'
},
itemWidth: 16,
itemHeight: 8
},
xAxis: {
type: 'category',
boundaryGap: false,
axisLine: {
lineStyle: {
color: '#ccc'
}
},
axisLabel: {
textStyle: {
fontFamily: 'arial',
color: '#666'
}
},
data: ['2017-02', '2017-03', '2017-04', '2017-05', '2017-06', '2017-07',
'2017-08', '2017-09', '2017-10', '2017-11', '2017-12', '2018-01'],
},
yAxis: {
type: 'value',
axisLine: {
lineStyle: {
color: '#ccc'
}
},
axisLabel: {
textStyle: {
fontFamily: 'arial',
color: '#666'
}
}
},
series: [
{
name: '一室',
type: 'line',
symbol: 'circle',
symbolSize: 6,
data: [2200, 2040, 2790, 2940, 2360, 2440, 2220, 2490, 2740, 2480, 2500, 2860]
},
{
name: '二室',
type: 'line',
symbol: 'circle',
symbolSize: 6,
data: [3200, 3040, 3790, 3940, 3360, 3440, 3220, 3490, 3740, 3480, 3500, 3860]
},
{
name: '三室',
type: 'line',
symbol: 'circle',
symbolSize: 6,
data: [4200, 4040, 4790, 4940, 4360, 4440, 4220, 4490, 4740, 4480, 4500, 4860]
},
{
name: '四室',
type: 'line',
symbol: 'circle',
symbolSize: 6,
data: [5200, 5040, 5790, 5940, 5360, 5440, 5220, 5490, 5740, 5480, 5500, 5860]
},
{
name: '五室',
type: 'line',
symbol: 'circle',
symbolSize: 6,
data: [6200, 6040, 6790, 6940, 6360, 6440, 6220, 6490, 6740, 6480, 6500, 6860]
}
]
};
function loadRentTrends(city, region, name){
var type = $("#trendDiv2 a.active").attr("t-v")
axios.get("/rest/trend/distRentTrends", {
params: {
city: city,
region:region,
name:name,
type:type
}
}).then(function (response) {
var re = response.data.data
var categories = new Array();
var series = new Array();
var m = re.times;
var pm = re.distMap
var rooms = re.rooms;
if(m && rooms.length>0){
for(var i=0;i<m.length;i++){
categories.push(m[i]);
}
for(var k in rooms){
var room = rooms[k]
var distM = pm[room];
var distObj = new Object();
var distDatas = new Array();
for(var i=0;i<m.length;i++){
if(distM[m[i]] == undefined){
distDatas.push(null);
} else {
distDatas.push(distM[m[i]]);
}
}
distObj.name = room+"室"
distObj.data = distDatas;
distObj.type = 'line';
distObj.symbolSize = 0;
series.push(distObj);
}
//showRentChart(categories, series);
showRentChart2(categories, series);
}else{
//没数据
$("#tabRentDiv").addClass("dn");
}
}).catch(function (error) {
alert(error)
console.log(error);
});
}
function showRentChart2(categories, series){
var option03 = {
tooltip: {
trigger: 'axis',
textStyle: {
fontFamily: 'arial,华文细黑',
fontSize: 12
}
},
grid:{
x: 54,
y: 10,
x2: 16,
y2: 60,
borderWidth: 1
},
color: ['#F88C9F', '#FFBF5C', '#AAD672', '#78CDE6', '#AE94E9'],
legend: {
y: 'bottom',
textStyle: {
fontFamily: '华文细黑',
fontWeight: 'bold'
},
itemWidth: 16,
itemHeight: 8
},
xAxis: {
type: 'category',
boundaryGap: false,
axisLine: {
lineStyle: {
color: '#ccc'
}
},
axisLabel: {
textStyle: {
fontFamily: 'arial',
color: '#666'
}
},
data: categories,
},
yAxis: {
type: 'value',
axisLine: {
lineStyle: {
color: '#ccc'
}
},
axisLabel: {
textStyle: {
fontFamily: 'arial',
color: '#666'
}
}
},
series:series
};
var myChart02 = echarts.init(document.getElementById('chart02'));
myChart02.setOption(option03,true);
}