Commit 8a6b4fdb by 姜雷

修改图表

parent 520f6459
...@@ -11,7 +11,7 @@ function initChart(canvas, width, height, F2) { ...@@ -11,7 +11,7 @@ function initChart(canvas, width, height, F2) {
}); });
platforFeeChart.source(data, { platforFeeChart.source(data, {
days: { month: {
min: 1, min: 1,
max: 12, max: 12,
}, },
...@@ -26,7 +26,7 @@ function initChart(canvas, width, height, F2) { ...@@ -26,7 +26,7 @@ function initChart(canvas, width, height, F2) {
onShow(ev) { onShow(ev) {
const { items } = ev; const { items } = ev;
items[0].name = ''; items[0].name = '';
items[0].value = month + '-' + items[0].title; items[0].value = items[0].title + '月';
items[1].name = ''; items[1].name = '';
items[1].value = items[1].value + '元'; items[1].value = items[1].value + '元';
}, },
...@@ -62,18 +62,37 @@ function findMaxIndex(list, key) { ...@@ -62,18 +62,37 @@ function findMaxIndex(list, key) {
} }
Component({ Component({
lifetimes: {
attached() {
const query = wx.createSelectorQuery().in(this);
query
.select('#PlatformFeeChart')
.boundingClientRect(res => {
// res.top; // 这个组件内 #the-id 节点的上边界坐标
console.log(res);
this.setData({
x: res.left,
y: res.top,
});
})
.exec();
},
},
properties: { properties: {
dataList: { dataList: {
type: Array, type: Array,
value: [], value: [],
observer(newVal) { observer(newVal) {
platforFeeChart && platforFeeChart.changeData(newVal); platforFeeChart && platforFeeChart.changeData(newVal);
if (platforFeeChart) {
let index = findMaxIndex(newVal, 'totalMoney'); let index = findMaxIndex(newVal, 'totalMoney');
if (index !== -1) { if (index !== -1) {
let item = newVal[index]; let item = newVal[index];
const point = platforFeeChart.getPosition(item); const point = platforFeeChart.getPosition(item);
platforFeeChart.showTooltip(point); platforFeeChart.showTooltip(point);
} }
}
}, },
}, },
month: { month: {
...@@ -88,13 +107,16 @@ Component({ ...@@ -88,13 +107,16 @@ Component({
opts: { opts: {
onInit: initChart, onInit: initChart,
}, },
x: 0,
y: 0,
}, },
methods: { methods: {
clickHandle(e) { clickHandle(e) {
console.log(e); console.log(e.detail);
// let let x = e.detail.x - this.data.x;
const obj = platforFeeChart.getRecord(e.detail); let y = e.detail.y - this.data.y;
this.triggerEvent('selectedData', obj); const objArr = platforFeeChart.getSnapRecords({ x, y });
if (objArr.length) this.triggerEvent('selectedData', objArr[0]._origin);
}, },
}, },
}); });
...@@ -204,7 +204,7 @@ Component({ ...@@ -204,7 +204,7 @@ Component({
type: 2, type: 2,
}; };
operatorFetch({ operatorFetch({
url: '/operateBalance/rechage/order', url: '/operateBalance/rechage/order/forcodeimg',
method: 'POST', method: 'POST',
data: entity, data: entity,
}) })
......
...@@ -48,13 +48,27 @@ Page({ ...@@ -48,13 +48,27 @@ Page({
}) })
.then(res => { .then(res => {
const { areaCount, platformFees } = res; const { areaCount, platformFees } = res;
let datalist = new Array(12)
.fill({
totalMoney: 0,
})
.map((v, idx) => ({ ...v, month: idx + 1 }));
for (let index = 0; index < platformFees.length; index++) {
const element = platformFees[index];
let dataIndex = element.month - 1;
datalist[dataIndex] = {
...datalist[dataIndex],
...element,
};
}
this.setData!({ this.setData!({
areaCount, areaCount,
dataList: platformFees, dataList: datalist,
}); });
if (platformFees && platformFees.length) { if (datalist && datalist.length) {
let index = findMaxIndex(platformFees, 'totalMoney'); let index = findMaxIndex(datalist, 'totalMoney');
let item = platformFees[index]; let item = datalist[index];
this.setData!({ this.setData!({
selected: item, selected: item,
}); });
...@@ -77,8 +91,9 @@ Page({ ...@@ -77,8 +91,9 @@ Page({
}); });
}, },
selectedData(e) { selectedData(e) {
console.log(e)
const data = e.detail; const data = e.detail;
this.setData({ this.setData!({
selected: data, selected: data,
}); });
}, },
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<platform-fee-chart dataList="{{dataList}}" bind:selectedData="selectedData" /> <platform-fee-chart dataList="{{dataList}}" bind:selectedData="selectedData" />
</view> </view>
</view> </view>
<view class="platformFee-block" wx:if="{{selected.areaId}}"> <view class="platformFee-block" wx:if="{{selected.month}}">
<view class="platformFee-title"> <view class="platformFee-title">
<view class="platformFee-title-color user"></view> <view class="platformFee-title-color user"></view>
<view class="platformFee-title-text">各校区服务费({{selected.month}}月)</view> <view class="platformFee-title-text">各校区服务费({{selected.month}}月)</view>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</view> </view>
<view class="platformFee-areaList"> <view class="platformFee-areaList">
<view class="platformFee-areaItem" wx:for="{{selected.areaPlatformFees}}"> <view class="platformFee-areaItem" wx:for="{{selected.areaPlatformFees}}">
<view class="platformFee-areaItem-index">{{index}}</view> <view class="platformFee-areaItem-index">{{index + 1}}</view>
<view class="platformFee-areaItem-name">{{item.areaName}}</view> <view class="platformFee-areaItem-name">{{item.areaName}}</view>
<view class="platformFee-areaItem-price">{{item.totalMoney}}</view> <view class="platformFee-areaItem-price">{{item.totalMoney}}</view>
</view> </view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment