Input

Bars (1)

Number:

Bars (2)

Number: Color:

Bars (3)

Number: Color: Height:

Viz

$('button#show').click(function(){    
    var value = $('input#show').val()    
    console.log(value)
    $('.myviz').html(value)
})

$('button#setcolor').click(function(){    
    // TODO: set the background color of the viz window to the specified color
    var value = $('input#setcolor').val()   
    $('.myviz').css('background-color',value)
})

$('button#setheight').click(function(){    
    // TODO: set the background color of the viz window to the specified color
    var value = $('input#setheight').val()   
    $('.myviz').height(value)
})

// TODO: add an event handler for "Show Bars (1)" to display a specified number of
// vertical bars
$('button#bars1').click(function(){
	var number=$('input#bars1-number').val()     
    var svg = "<svg>"
    for(i=0; i < number; i++){
        svg+="<rect height='50' width='10' x='"+(i*20)+"'/>"
    }
    svg+="</svg>"
    $('.myviz').html(svg)    
})

$('button#bars2').click(function(){
	var number=$('input#bars2-number').val()
	var color=$('input#bars2-color').val()     
    var svg = "<svg>"
    for(i=0; i < number; i++){
        svg+="<rect height='50' width='10' x='"+(i*20)+"' style='fill: "+color+"'/>"
    }
    svg+="</svg>"
    $('.myviz').html(svg)    
})

$('button#bars3').click(function(){
	var number=$('input#bars3-number').val()
	var color=$('input#bars3-color').val()
	var height=$('input#bars3-height').val()     
    var svg = "<svg>"
    for(i=0; i < number; i++){
        svg+="<rect height='"+height+"' width='10' x='"+(i*20)+"' style='fill: "+color+"'/>"
    }
    svg+="</svg>"
    $('.myviz').html(svg)    
})