import * as echarts from "../../ec-canvas/echarts";
function initChart(canvas, width, height) {
const chart = echarts.init(canvas, null, {
width: width,
height: height
});
canvas.setChart(chart);
var option = {
//
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b}: {c} ({d}%)"
},
//
legend: {
selectedMode: false, //
orient: "horizontal", // vertical
width: 100, //,
x: "50%", //
y: "center", //
data: ["", "", "", "", ""],
textStyle: { //
color: "-sharp333", //
fontSize: 12 //
},
itemWidth: 12,
itemHeight: 12
},
//
color: ["-sharp62d1de", "-sharp54d6b6", "-sharpa6db69", "-sharpffd454", "-sharpffa361", "-sharpd1d1d1"],
series: [
{
name: "", //
type: "pie", //
center: ["25%", "50%"], //
radius: ["50%", "70%"], //
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: "center"
},
emphasis: {
show: true,
textStyle: {
fontSize: "16",
fontWeight: "bold"
}
}
},
labelLine: {
normal: {
show: false
}
},
data: [
{value: 335, name: ""},
{value: 310, name: ""},
{value: 234, name: ""},
{value: 135, name: ""},
{value: 1548, name: ""}
]
/*
(function () {
var arr1 = [];
wx.request({
url: "https://www.baifubao.com/callback?cmd=1059&callback=phone&phone=13854322342",
method: "post",
dataType: "json",
success: res => {
console.log(2323);
arr1 = [
{ value: 335, name: "" },
{ value: 310, name: "" }
]
},
fail: function (a) {
console.log(a)
arr1 = [
{ value: 335, name: "" },
{ value: 310, name: "" }
]
}
})
console.log(arr1)
return arr1
})()
*/
}
]
};
chart.setOption(option);
return chart;
}
// pages/bill/history.js
Page({
/**
*
*/
data: {
datetabs: [],
ec: {
onInit: initChart
},
selectedIdx: 0
},
how can the function outside page {} get the data value in the function to modify?