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; } var bruteComplex = function(x){ return x * (x - 1) / 2; } $(function () { var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'line' }, title: { text: 'Brute Force Collision Check Counts' }, subtitle: { text: 'y = x(x - 1) / 2' }, xAxis: { title: { enabled: true, text: 'Entities' }, startOnTick: false, endOnTick: false, showLastLabel: true }, yAxis: { title: { text: 'Collision Checks' }, startOnTick: false }, tooltip: { formatter: function() { return 'Entities: ' + this.x +', Checks: '+ this.y; } }, legend: { enabled: false }, series: [{ name: '', data: asSeries( 0, 100, 1, bruteComplex ) }] }); }); });
<script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="margin: 0 auto"></div>