JSFiddle - React, Tailwind, and code Playground
by Castrolol
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
JavaScript
function p(n, arr){
arr = arr || [];
if( n == 1 ) return arr.concat([1]);
if( n % 2 == 0 ) return p(n/2,arr.concat([n/2]));
return p(n*3+1,arr.concat([n*3+1]));
}
var ns1 = (Math.round(Math.random() * 150));
var ns2 = (Math.round(Math.random() * 150));
var ns3 = (Math.round(Math.random() * 150));
var ns4 = (Math.round(Math.random() * 150));
var s1 = p(ns1);
var s2 = p(ns2);
var s3 = p(ns3);
var s4 = p(ns4);
console.log(s1);
console.log(s2);
console.log(s3);
console.log(s4);
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Besteirol Matematico :D',
x: -20 //center
},
subtitle: {
text: 'return isPair ? x/2 : x*3+1;',
x: -20
},
xAxis: {
title: {
text: 'passos'
}
},
yAxis: {
title: {
text: 'Valor'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y +'°C';
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: ns1,
data: s1
}, {
name: ns2,
data: s2
}, {
...