var toHash = function(x, objectSize, oneDCellCount){ var i, xHash; var cellSize = Math.SQRT2 * objectSize ,inverseCellSize = 1/cellSize ,xyzHashMask = oneDCellCount - 1; if(x < 0){ i = (-x) * inverseCellSize; xHash = oneDCellCount - 1 - ( ~~i & xyzHashMask ); } else { i = x * inverseCellSize; xHash = ~~i & xyzHashMask; } return xHash; } var asSeries = function( start, end, step, func ){ var i, all = []; var funcArgs = Array.prototype.slice.call(arguments, 4); funcArgs.unshift('0'); for( i = start; i <= end; i += step ){ funcArgs[0] = i; all.push( [ i, func.apply(null, funcArgs) ] ); } return all; } $(function () { var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'scatter', marginRight: 130 }, title: { text: 'Hash Distribution', x: -20 //center }, subtitle: { text: 'In One Dimension', x: -20 }, xAxis: { title: { enabled: true, text: 'Position (Input)' }, startOnTick: false, endOnTick: false, showLastLabel: true }, yAxis: { title: { text: 'Hash Bucket' }, startOnTick: false }, tooltip: { formatter: function() { return 'Input: ' + this.x.toFixed(3) +', Hashed: '+ this.y; } }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', x: 0, y: 70, floating: true, backgroundColor: '#FFFFFF', borderWidth: 1 }, plotOptions: { scatter: { marker: { radius: 2, states: { hover: { enabled: true, lineColor: 'rgb(100,100,100)' } } }, states: { hover: { marker: { enabled: false } } } } }, series: [{ name: 'Size 10', data: asSeries( 0, 400, 1, toHash, 10, 16384 ) }, { name: 'Size 50', data: asSeries( 0, 400, 1, toHash, 50, 16384 ) }, { name: 'Size 100', data: asSeries( 0, 400, 1, toHash, 100, 16384 ) }] }); }); });
<script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="margin: 0 auto"></div>