I have found a small problem with a line chart and the container DIV.  

Originally the code would change the display style of the chart container 
DIV to ‘none’, so not to display, then get the data, plot the chart and 
change the style display back to ‘block’.

If the container div style is set to display ‘none’ when the chart is drawn 
it misses data on the legend and y axis labels.

I have fixed this by changing the style display to block before the chart 
has drawn.  

So just curious on why when the chart is drawn with whilst container 
display is set to ‘none’ why this might occur.

The following test code exhibits this problem:

<!DOCTYPE html>
<html>
<head>
    <title>Test chart</title>

    <script type="text/javascript" 
src="https://www.gstatic.com/charts/loader.js";></script>

    <script>
    google.charts.load('current', {'packages':['corechart']});

    function drawChart() {

        var d = [["X", "Y"], [0, 10], [1, 20], [2, 25]];
        var data = google.visualization.arrayToDataTable(d);

        var options = {
            title: 'Test chart',
            curveType: 'function',
            height: 600,
            width: 1100,
            legend: { position: 'bottom', textStyle: { color: '#202020', 
fontSize: 12} }
        };

        var chart = new 
google.visualization.LineChart(document.getElementById('chart'));

        chart.draw(data, options);
        
        document.getElementById('chart').style.display = 'block';
        
    }
    </script>
    <style>
    body {margin: 10px;}
    #chart {display: none;}
    </style>
</head>
<body onload='drawChart()' >
    <div id='chart'></div>
</body>
</html>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/2b29e73b-c218-472f-8cdb-4a6a9f1c3819%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to