Chart.js雷达标签坐标 [英] Chart.js Radar Labels Coordenates

查看:336
本文介绍了Chart.js雷达标签坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法获得雷达图中标签的坐标?
我试图在标签区域中放置图片而不是文字。

is there any way to get the coordinates for the labels in the radar chart? I'm trying to put images instead of text in the labels area.

最好的问候。

推荐答案

您可以使用scale属性计算它。这是在动画完成后的那些点上绘制一个蓝色圆圈。

You can calculate it using the scale property. Here is something that draws a blue circle at those points after the animation completes.

onAnimationComplete: function () {
    for (var i = 0; i < this.scale.valuesCount; i++) {
        // get the poitn position
        var pointLabelPosition = this.scale.getPointPosition(i, this.scale.calculateCenterOffset(this.scale.max) + 5);

        // draw a circle at that point
        this.chart.ctx.beginPath();
        this.chart.ctx.arc(pointLabelPosition.x, pointLabelPosition.y, 5, 0, 2 * Math.PI, false);
        this.chart.ctx.fillStyle = '#77e';
        this.chart.ctx.fill();
        this.chart.ctx.stroke();
    }
}






小提琴 - http://jsfiddle.net/1jgmbyb7/

这篇关于Chart.js雷达标签坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆