Chart.js/test/fixtures/element.point/rotation.js
Akihiko Kusanagi 1f2fa5c90c Adjust the size of rectRounded/rectRot point to fit pointRadius (#5858)
- Calculate the vertices of the shapes so that they are inscribed in the circle that has the radius of `pointRadius`
- Remove `translate()` and `rotate()` to fix the regression introduced by #5319
- Refactor `rectRounded` for better performance
2018-11-28 07:53:41 +01:00

57 lines
1.1 KiB
JavaScript

var gradient;
var datasets = ['circle', 'cross', 'crossRot', 'dash', 'line', 'rect', 'rectRounded', 'rectRot', 'star', 'triangle'].map(function(style, y) {
return {
pointStyle: style,
data: Array.apply(null, Array(17)).map(function(v, x) {
return {x: x, y: 10 - y};
})
};
});
var angles = Array.apply(null, Array(17)).map(function(v, i) {
return -180 + i * 22.5;
});
module.exports = {
config: {
type: 'bubble',
data: {
datasets: datasets
},
options: {
responsive: false,
legend: false,
title: false,
elements: {
point: {
rotation: angles,
radius: 10,
backgroundColor: function(context) {
if (!gradient) {
gradient = context.chart.ctx.createLinearGradient(0, 0, 512, 256);
gradient.addColorStop(0, '#ff0000');
gradient.addColorStop(1, '#0000ff');
}
return gradient;
},
borderColor: '#cccccc'
}
},
layout: {
padding: 20
},
scales: {
xAxes: [{display: false}],
yAxes: [{display: false}]
}
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};