<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SingleBarGraph.aspx.vb" Inherits="InovarPAA.SingleBarGraph" %>

<!DOCTYPE html>

<html style="width:100%; height:100%;">
<head>
    <style>
        #print {
            float: right;
            font-family: Verdana;
            color: #0B62A4;
            font-size: 10px;
            right: 10px;
            bottom: 0;
            position: fixed;
            cursor: pointer;
        }

        a {
            font-family: Verdana;
            float: right;
            font-size: 10px;
            position: fixed;
            right: 80px;
            bottom: 2px;
        }
    </style>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>​
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
        google.load("visualization", "1", { packages: ["corechart"] });
        google.setOnLoadCallback(drawChart);

        var size = TextSizePixels('<%= bigStr%>', 'Arial', '12px');

        if (size < 50) size = 50;

        function TextSizePixels(text, fontFamily, fontSize) {
            var mSpan = document.createElement("span");
            mSpan.innerText = text;
            mSpan.style.display = 'none';
            mSpan.style.fontFamily = fontFamily;
            mSpan.style.fontSize = fontSize;

            $('body')[0].appendChild(mSpan);

            var size = $(mSpan).width();

            $('body')[0].removeChild(mSpan);

            return size;
        }

        window.onresize = drawChart;

        function drawChart() {

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

            var options = {
                'title': '<%= Titutlo%>',
                hAxis: { title: '', minValue: 0 },
                chartArea: { left: size, height: '80%', width: '80%' },
                legend: { position: "none" },
                vAxis: { title: '', textStyle: { fontName: 'Arial', fontSize: 11 } }
            };

            var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
            chart.draw(data, options);

            document.getElementById('print').onclick = function () {
                //window.open(chart.getImageURI(), "_blank")
                downloadLink = document.createElement('a');
                downloadLink.href = chart.getImageURI();
                downloadLink.download = 'grafico.png';
                downloadLink.click();
            };
        }
    </script>
</head>

<body style="width:100%; height:100%;">
    <div id="chart_div" style="<%=style%>"></div>
    <button id="print">Exportar</button>
    <%=LinkApi%>
</body>
</html>