Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

JavaScript - Simple Example Istogramma

DZone's Guide to

JavaScript - Simple Example Istogramma

·
Free Resource
// Semplice esempio di istogramma fatto in javascript

// File istogramma.js

function istogramma()
{
	/*
	 *
	 * Prende in input una serie di numeri, sia positivi che negativi
	 * e crea un istogramma. 
	 */
	 	
	var n = window.prompt('Numero di valori da inserire:', '');
	
	n = parseInt(n); // rende il valore se valido Int altrimenti NaN
	
	if(isNaN(n) == true)
	{
		document.write('

Non hai selezionato nessun valore...

'); document.write('
'); } else { var num = new Array(); var max = 0; for(var i=0; i Istogramma for JavaScript

'); document.write('
'); document.write(' '); document.write(' '); document.write('
'); document.write(' '); for(var i=0; i<200; i++) { var aux = num[j]; if(num[j] == 0) document.write(' '); for(var j=0; j '); if(num[j] > 0 && i < 100) document.write(' '); else if(num[j] > 0 && i >= 100) { if((i-100) <= aux) document.write(' '); else document.write(' '); } if(num[j] < 0 && i < (100+aux)) document.write(' '); else if(num[j] < 0 && (i >= (100+aux) && i < 100)) document.write(' '); else if(num[j] < 0 && i >= 100) document.write(' '); } document.write(' '); } document.write('
       
'); document.write('
'); } }
// File istogramma.html Disegnare un Istogramma...
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}