const agePie = function (data) {
const age = data;
const query = wx.createSelectorQuery("");
query.select("#agePie").fields({
node: true,
size: true
});
query.exec(function (res) {
const canvas = res[0].node;
// 定义颜色
const color = ['#8B0000','#4169E1','#D2691E','#228B22','#4B0082','#FF1493','#FFD700',]
const pie = canvas.getContext('2d');
const dpr = wx.getSystemInfoSync().pixelRatio;
canvas.width = res[0].width * dpr;
canvas.height = res[0].height * dpr;
// 中心点cp
const cp = {
x: canvas.width / 2,
y: canvas.height / 2+150
};
// 定义 π
const p = Math.PI;
// 年龄区间
var section = [];
// 人数总和
let all = 0;
age.forEach((item) => {
all +
扇形统计图————微信小程序
最新推荐文章于 2024-04-24 22:27:37 发布