admin管理员组

文章数量:1404050

Is there a way to make a Google Chart full screen on click?

I've been playing around with this for hours

JS -

 $('#chart_div').on('click', function(e) {
     $(this).css({
         width: "100%",
         height: "100%",
         margin: "0",
         border: "none"

     });
 });

CSS -

#chart_div {
    width: 100 px;
    height: 100 px;
    margin: 20 px;
    background - color: red;
    border: 1 px solid black;
}
body, html {
    height: 100 % ;
}

HTML - You are free to copy and use this sample in accordance with the terms of the Apache license (.0.html)

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    ".dtd">
<html xmlns="">

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>
        Google Visualization API Sample
    </title>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        google.load('visualization', '1', {
            packages: ['corechart']
        });
    </script>
    <script type="text/javascript">
        google.load("visualization", "1", {
            packages: ["corechart"]
        });
        google.setOnLoadCallback(drawChart);

        function drawChart() {
            var data = google.visualization.arrayToDataTable([
                ['Year', 'Sales', 'Expenses'],
                ['November', 1000, 400],
                ['December', 1170, 460],
                ['January', 660, 1120],
                ['February', 690, 1120],
                ['March', 780, 1120],
                ['April', 820, 1120],
                ['May', 660, 1120],
                ['June', 1030, 540]
            ]);

            var options = {
                title: '',
                backgroundColor: 'none',
                legend: {
                    position: 'none'
                },
                hAxis: {
                    title: 'Year',
                    titleTextStyle: {
                        color: 'grey'
                    }
                },
                chartArea: {
                    left: 40,
                    top: 10,
                    width: 900,
                    height: 350
                }
            };

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

        $('#chart_div').on('click', function(e) {
            $(this).css({
                width: "100%",
                height: "100%",
                margin: "0",
                border: "none"

            });
        });
    </script>
</head>

<body style="font-family: Arial;border: 0 none;">
    <div id="chart_div"></div>
</body>

</html>
​

/

Any help is much appreciated.

Is there a way to make a Google Chart full screen on click?

I've been playing around with this for hours

JS -

 $('#chart_div').on('click', function(e) {
     $(this).css({
         width: "100%",
         height: "100%",
         margin: "0",
         border: "none"

     });
 });

CSS -

#chart_div {
    width: 100 px;
    height: 100 px;
    margin: 20 px;
    background - color: red;
    border: 1 px solid black;
}
body, html {
    height: 100 % ;
}

HTML - You are free to copy and use this sample in accordance with the terms of the Apache license (http://www.apache/licenses/LICENSE-2.0.html)

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3/1999/xhtml">

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>
        Google Visualization API Sample
    </title>
    <script type="text/javascript" src="http://www.google./jsapi"></script>
    <script type="text/javascript">
        google.load('visualization', '1', {
            packages: ['corechart']
        });
    </script>
    <script type="text/javascript">
        google.load("visualization", "1", {
            packages: ["corechart"]
        });
        google.setOnLoadCallback(drawChart);

        function drawChart() {
            var data = google.visualization.arrayToDataTable([
                ['Year', 'Sales', 'Expenses'],
                ['November', 1000, 400],
                ['December', 1170, 460],
                ['January', 660, 1120],
                ['February', 690, 1120],
                ['March', 780, 1120],
                ['April', 820, 1120],
                ['May', 660, 1120],
                ['June', 1030, 540]
            ]);

            var options = {
                title: '',
                backgroundColor: 'none',
                legend: {
                    position: 'none'
                },
                hAxis: {
                    title: 'Year',
                    titleTextStyle: {
                        color: 'grey'
                    }
                },
                chartArea: {
                    left: 40,
                    top: 10,
                    width: 900,
                    height: 350
                }
            };

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

        $('#chart_div').on('click', function(e) {
            $(this).css({
                width: "100%",
                height: "100%",
                margin: "0",
                border: "none"

            });
        });
    </script>
</head>

<body style="font-family: Arial;border: 0 none;">
    <div id="chart_div"></div>
</body>

</html>
​

http://jsfiddle/FbKEL/5/

Any help is much appreciated.

Share Improve this question edited Feb 26, 2016 at 10:51 VishAl 3783 silver badges17 bronze badges asked Jan 7, 2013 at 19:17 this_guythis_guy 6042 gold badges13 silver badges25 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Can't you just call drawChart again?

$('#chart_div').on('click',function(e){
    $(this).css({
        width:"100%",
        height:"100%",
        margin:"0",
        border:"none"  
    });
    drawChart();
});

See here

本文标签: javascriptGoogle Chart Full Screen On ClickStack Overflow