微信小程序cavas画折线图

drawCircle: function(e) {

var thisObj = this;

radCtx.save();

radCtx.setFontSize(14) //字体大小

radCtx.setFillStyle('#ff0000') //字体颜色

radCtx.setStrokeStyle("#6797F4")

radCtx.setLineWidth(3) //设置线宽

// radCtx.setShadow(100, -100, -10, 'blue')

lineCtx.save();

lineCtx.setFillStyle("#6797F4")

lineCtx.setLineWidth(1) //设置线宽

 

var att = this.data.dayMoneyList;

console.log(att)

for (var i = 0; i < att.length; i++) {

radCtx.beginPath();

lineCtx.beginPath();

var attObj = att[i];

var attObj1 = att[i - 1];

var space = mW / att.length * 0.5

//坐标

var x = mW / att.length * (i + 1) - space;

var y = thisObj.data.dayProgressHeight - attObj.height;

if (i == 0) {

var x1 = x;

var y1 = y;

} else {

var x1 = mW / (att.length) * (i) - space;

var y1 = thisObj.data.dayProgressHeight - attObj1.height;

}

if (y == 0) {

y = 10

}

if (y1 == 0) {

y1 = 10

}

if (e == i) {

if (e == 0) {

radCtx.moveTo(x1, y1) //起点 x轴起点,y轴起点

radCtx.lineTo(x, y) //终点

} else {

radCtx.moveTo(x1, y1) //起点 x轴起点,y轴起点

radCtx.lineTo(x - thisObj.data.circleRadius, y + thisObj.data.circleRadius / 2) //终点

}

 

} else if (e == (i - 1)) {

radCtx.moveTo(x1 + thisObj.data.circleRadius, y1 + thisObj.data.circleRadius / 2) //起点 x轴起点,y轴起点

radCtx.lineTo(x, y)

} else {

radCtx.moveTo(x1, y1) //起点 x轴起点,y轴起点

radCtx.lineTo(x, y) //终点

}

 

radCtx.closePath()

radCtx.stroke()

if (e == i) {

radCtx.beginPath();

radCtx.arc(x, y, thisObj.data.circleRadius, 0, 2 * Math.PI)

radCtx.closePath()

radCtx.stroke()

}

}

radCtx.restore();

radCtx.draw();

 

},

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值