*scale*.type | String |"radialLinear" | As defined in ["Radial Linear"](#scales-radial-linear-scale).
*elements*.line | Object | | Options for all line elements used on the chart, as defined in the global elements, duplicated here to show Radar chart specific defaults.
*elements.line*.lineTension | Number | 0 | Tension exhibited by lines when calculating splineCurve. Setting to 0 creates straight lines.
-offsetAngle | Number | 0 | The number of degrees to rotate the chart clockwise.
+startAngle | Number | 0 | The number of degrees to rotate the chart clockwise.
You can override these for your `Chart` instance by passing a second argument into the `Radar` method as an object with the keys you want to override.
getIndexAngle: function(index) {
var angleMultiplier = (Math.PI * 2) / this.getValueCount();
- var offsetAngle = this.chart.options && this.chart.options.offsetAngle ?
- this.chart.options.offsetAngle :
+ var startAngle = this.chart.options && this.chart.options.startAngle ?
+ this.chart.options.startAngle :
0;
- var offsetAngleRadians = offsetAngle * Math.PI * 2 / 360;
+ var startAngleRadians = startAngle * Math.PI * 2 / 360;
// Start from the top instead of right, so remove a quarter of the circle
- return index * angleMultiplier - (Math.PI / 2) + offsetAngleRadians;
+ return index * angleMultiplier - (Math.PI / 2) + startAngleRadians;
},
getDistanceFromCenterForValue: function(value) {
var me = this;
expect(chartInstance.scale.getDistanceFromCenterForValue(chartInstance.scale.min)).toBe(225);
expect(chartInstance.scale.getDistanceFromCenterForValue(chartInstance.scale.max)).toBe(0);
});
+
+ it('should correctly get angles for all points', function() {
+ chartInstance = window.acquireChart({
+ type: 'radar',
+ data: {
+ datasets: [{
+ data: [10, 5, 0, 25, 78]
+ }],
+ labels: ['label1', 'label2', 'label3', 'label4', 'label5']
+ },
+ options: {
+ scale: {
+ pointLabels: {
+ callback: function(value, index) {
+ return index.toString();
+ }
+ }
+ },
+ startAngle: 15
+ }
+ });
+
+ var radToNearestDegree = function(rad) {
+ return Math.round((360 * rad) / (2 * Math.PI));
+ }
+
+ var slice = 72; // (360 / 5)
+
+ for(var i = 0; i < 5; i++) {
+ expect(radToNearestDegree(chartInstance.scale.getIndexAngle(i))).toBe(15 + (slice * i) - 90);
+ }
+
+ chartInstance.options.startAngle = 0;
+ chartInstance.update();
+
+ for(var i = 0; i < 5; i++) {
+ expect(radToNearestDegree(chartInstance.scale.getIndexAngle(i))).toBe((slice * i) - 90);
+ }
+ });
});