Standard Polar Scatter Zoom?
Standard Polar Scatter Zoom?
by brian428
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/boost.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 600px; margin: 0 auto"></div>
JavaScript
$(function () {
console.time('asyncRender1');
console.time('asyncRender2');
var forceBoost = true;
var boostThreshold = -1;
var turboThreshold = 0;
if( !forceBoost ) {
boostThreshold = 10000;
}
// Prepare the data
var data1 = [],
data2 = [],
n = 10,
i;
// Build original (cartesian) data
for (i = 0; i < n; i += 1) {
data1.push([
(Math.pow(Math.random(), 2) * 140) + (Math.pow(Math.random(), 2) * 30),
(Math.pow(Math.random(), 2) * 130) + (Math.pow(Math.random(), 2) * 20),
]);
data2.push([
(Math.pow(Math.random(), 2) * 150) + (Math.pow(Math.random(), 2) * 20),
(Math.pow(Math.random(), 2) * 80) + (Math.pow(Math.random(), 2) * 50),
]);
}
// Convert to radial?
var cartesian2Polar = function ( x, y ) {
let distance = Math.sqrt( x * x + y * y );
let radians = Math.atan2( y, x ); //This takes y first
let degrees = radians * ( 180 / Math.PI );
return { distance: distance, radians: radians, degrees: degrees };
};
var convertedData1 = [];
data1.forEach( function convert(value) {
let result = cartesian2Polar(value[0], value[1]);
convertedData1.push( [ result.distance, result.degrees ] );
});
var convertedData2 = [];
data2.forEach( function convert(value) {
let result = cartesian2Polar(value[0], value[1]);
convertedData2.push( [ result.distance, result.degrees ] );
});
data1 = convertedData1;
data2 = convertedData2;
$('#container').highcharts({
chart: {
//type: 'scatter',
polar: true
},
title: {
text: 'Height Versus Weight of 507 Individuals by Gender'
},
subtitle: {
text: 'Source: Heinz 2003'
},
xAxis: {
title: {
enabled:...