Chart.js/samples/advanced/content-security-policy.js
David Winegar 1ad5f369af Allow switching platforms (#6964)
Allow switching platforms

Move the Chart.platform to Chart.platform.current instead, and add
ways to see available platforms and set the current platform. This
is necessary for adding tests that use the "basic" platform.
2020-01-26 15:33:20 -05:00

54 lines
1005 B
JavaScript

var utils = Samples.utils;
utils.srand(110);
// CSP: disable automatic style injection
Chart.platform.disableCSSInjection = true;
function generateData() {
var DATA_COUNT = 16;
var MIN_XY = -150;
var MAX_XY = 100;
var data = [];
var i;
for (i = 0; i < DATA_COUNT; ++i) {
data.push({
x: utils.rand(MIN_XY, MAX_XY),
y: utils.rand(MIN_XY, MAX_XY),
v: utils.rand(0, 1000)
});
}
return data;
}
window.addEventListener('load', function() {
new Chart('chart-0', {
type: 'bubble',
data: {
datasets: [{
backgroundColor: utils.color(0),
data: generateData()
}, {
backgroundColor: utils.color(1),
data: generateData()
}]
},
options: {
aspectRatio: 1,
legend: false,
tooltip: false,
elements: {
point: {
radius: function(context) {
var value = context.dataset.data[context.dataIndex];
var size = context.chart.width;
var base = Math.abs(value.v) / 1000;
return (size / 24) * base;
}
}
}
}
});
});