<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DonutGraphFornecedorGeral.aspx.vb" Inherits="i9.Dashboard.DonutGraphFornecedorGeral" %>

<!DOCTYPE html>

<html>
<head>
    <style>
        
        .piechartheader {
            text-align: center;
            margin-bottom: 0px!important;
            font-size: 10px;
            font-weight: bold;
            font-family: Verdana;
        }
        
        #print {
            float: right;
            font-family: Verdana;
            color: #0B62A4;
            font-size: 10px;
            right: 10px;
            bottom: 0;
            position: fixed;
            cursor: pointer;
        }
        
        #chart_div{
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0; 
            bottom: 0;
            left: 0; 
            right: 0;
            margin: auto;
        }
        
    </style>

    <!--Load the AJAX API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
        
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1.0', { 'packages': ['corechart'] });

        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(drawChart);

        // Callback that creates and populates a data table,
        // instantiates the pie chart, passes in the data and
        // draws it.
               
        function drawChart() {

            // Create the data table.
            var data = new google.visualization.DataTable();
            data.addColumn(<%= Column1%>);
            data.addColumn(<%= Column2%>);
            data.addRows(<%= TheData%>);

            var options = {
                pieSliceText: 'label',
                backgroundColor: { fill: 'transparent' },
                'title': '<%= Titutlo%>',
                <%= Cor%> ,
                titlePosition: 'none',
                legend: {position: 'right'},
                pieSliceText: 'none',
//                chartArea: {width: '100%', left: '55%'}
                chartArea: {left: '10%', top: '20%', height: '75%', width: '90%'}
//                chartArea: {left: '50%', top: '22%', width:'100%', height:'40%' }
            };

            // Instantiate and draw our chart, passing in some options.
            var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
            
            // Wait for the chart to finish drawing before calling the getImageURI() method.
            google.visualization.events.addListener(chart, 'ready', function () {
                var imagem=chart.getImageURI();
                
                var url = new URL(window.location.href);
                var param = url.searchParams.get("ID_Graf");
                                
                var urlref=document.location.href;
                
                var pos = urlref.lastIndexOf("/");
                var s="";
                if(pos >= 0)
                    s = urlref.substring(0, pos);

                pos = s.lastIndexOf("/Route");
				if (pos>0) {
					s = s.substring(0, pos);
				}

                var endereco=s+"/WebComponent/Graph/Imagem/SessionImage.aspx";
                                                
                var xhttp = new XMLHttpRequest();
                xhttp.open("POST", endereco, true);
                xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xhttp.send("ids="+param+"&imageurl="+imagem); 
            });
            
            
            chart.draw(data, options);
        }

       
    
        
    </script>
</head>

<body style="background-color:transparent; overflow:hidden;">
    <div id="chart_div"></div>
</body>
</html>
