<%
    def getChart
        chartData = {
            'chart': {
                'caption': 'Market Share of Web Servers',
                'plottooltext': '<b>$percentValue</b> of web servers run on $label servers',
                'showLegend': '0',
                'enableMultiSlicing': '0',
                'showPercentValues': '1',
                'legendPosition': 'bottom',
                'useDataPlotColorForLabels': '1',
                'theme': 'fusion',
            },
            'data': [{
                'label': 'Apache',
                'value': '32647479'
            }, {
                'label': 'Microsoft',
                'value': '22100932'
            }, {
                'label': 'Zeus',
                'value': '14376'
            }, {
                'label': 'Other',
                'value': '18674221'
            }]
        }

        # Chart rendering 
        chart = Fusioncharts::Chart.new({
                id: "first_chart",
                width: "700",
                height: "400",
                type: "pie2d",
                renderAt: "chartContainer",
                dataSource: chartData
            })

        chart.addEvent("dataplotClick", "plotClickHandler");
        return chart
    end
%>

    <style>
    input[type=radio], input[type=checkbox] {
		display:none;
	}

    input[type=radio] + label, input[type=checkbox] + label {
		display:inline-block;
		margin:-2px;
		padding: 4px 12px;
		margin-bottom: 0;
		font-size: 14px;
		line-height: 20px;
		color: #333;
		text-align: center;
		text-shadow: 0 1px 1px rgba(255,255,255,0.75);
		vertical-align: middle;
		cursor: pointer;
		background-color: #f5f5f5;
		background-image: -moz-linear-gradient(top,#fff,#e6e6e6);
		background-image: -webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));
		background-image: -webkit-linear-gradient(top,#fff,#e6e6e6);
		background-image: -o-linear-gradient(top,#fff,#e6e6e6);
		background-image: linear-gradient(to bottom,#fff,#e6e6e6);
		background-repeat: repeat-x;
		border: 1px solid #ccc;
		border-color: #e6e6e6 #e6e6e6 #bfbfbf;
		border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);
		border-bottom-color: #b3b3b3;
		filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0);
		filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
		-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);
		-moz-box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);
		box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);
	}

	 input[type=radio]:checked + label, input[type=checkbox]:checked + label{
		   background-image: none;
		outline: 0;
		-webkit-box-shadow: inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);
		-moz-box-shadow: inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);
		box-shadow: inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);
			background-color:#e0e0e0;
	}
    </style>


    <script>
        selectedItem = "none";
         plotClickHandler = function(event){
            clickedPlot = (event.data.categoryLabel).toLowerCase();
              if (selectedItem !== clickedPlot) {
                    selectedItem = clickedPlot;
              } else{
                    selectedItem = 'none';
              }
        };
        noneChecked = function(){
            FusionCharts("first_chart").slicePlotItem(0,false);
            FusionCharts("first_chart").slicePlotItem(1,false);
            FusionCharts("first_chart").slicePlotItem(2,false);
            FusionCharts("first_chart").slicePlotItem(3,false);
        }
        apacheChecked = function(){
            FusionCharts("first_chart").slicePlotItem(0,true);
        }
        microsoftChecked = function(){
            FusionCharts("first_chart").slicePlotItem(1,true);
        }
        zeusChecked = function(){
            FusionCharts("first_chart").slicePlotItem(2,true);
        }
        otherChecked = function(){
            FusionCharts("first_chart").slicePlotItem(3,true);
        }
    </script>

<h3>Use special chart type API</h3>
<div id="controllers" align="center" style="font-family:'Helvetica Neue', Arial; font-size: 14px;">
    <input type="radio" id="radio1" name="rdGrp-options" checked="checked" onclick="noneChecked()"/> 
    <label for="radio1">None</label>
    <input type="radio" id="radio2" name="rdGrp-options" onclick="apacheChecked()"/> 
    <label for="radio2">Apache</label>
    <input type="radio" id="radio3" name="rdGrp-options" onclick="microsoftChecked()"/> 
    <label for="radio3">Microsoft</label>
    <input type="radio" id="radio4" name="rdGrp-options" onclick="zeusChecked()"/> 
    <label for="radio4">Zeus</label>
    <input type="radio" id="radio5" name="rdGrp-options" onclick="otherChecked()"/> 
    <label for="radio5">Other</label>
</div>

<div id="chartContainer"></div>
<%= getChart.render() %>
<br/>
   <div>
        <p id ="dataLoaded">Click on data plot above</p>
    </div>
<br/>
<br/>
<a href="index">Go Back</a>
