What causes the "Unknown Renderer type" error in Google Charts?

Asked

Viewed 468 times

0

Hello, I’m making a program to generate graphics and started to appear this error in some, but the strange thing is, the graphics are generated from some selected checkbox, so when you select a certain amount of checkbox from right, another amount from wrong, someone would know to tell me what causes this to try to fix this mistake?

Generate the Graphics:

 for (int j = 0; j < @Model.pdisAno.Count; j++)
    {
        <script type="text/javascript">
            google.charts.load('current', { 'packages': ['bar'] });
            var teste = "teste" + @j
            google.charts.setOnLoadCallback(teste)

            function teste() {

                var data = new google.visualization.DataTable();
                data.addColumn('string', 'Ano');
                data.addColumn('number', 'Quantidade de Operadores');

                @for (int i = 0; i < @Model.AnosPdi[j].Count; i++)
            {
                @: data.addRow(['@Model.AnosPdi[j][i]',@Model.conAnos[j][i]]);
                                                            }

                var options = {
                    chart: {
                        title: '@Model.pdisAno[j]',
                        subtitle: 'Quantidade de Operarios por ano'
                    },
                    chartArea: { width: '100%', height: '50%' }
                };

                var chart = new google.charts.Bar(document.getElementById('columnchart_material' + '@j'));

                chart.draw(data, google.charts.Bar.convertOptions(options));
            }
        </script>
    }

This part to generate the Divs and show the Graphics:

 for (int i = 0; i < @Model.pdisAno.Count; i = i + 3)
{
    string nome1 = "columnchart_material" + i;
    string nome2 = "columnchart_material" + (i + 1);
    string nome3 = "columnchart_material" + (i + 2);
    <table style="width:100%">
        <tr>
            <td style="width:30%">
                <div id="@nome1" style="height:250px;"></div>
            </td>
            <td style="width:30%">
                <div id="@nome2" style="height:250px;"></div>
            </td>
            <td style="width:30%">
                <div id="@nome3" style="height:250px;"></div>
            </td>
        </tr>
    </table>
    <br />
}
  • Could put the code?

  • I put, apparently what’s causing the error is this part of the code, I need to generate these graphs dynamically, I tried to do so but it’s giving this error

  • Shows the line giving the error in the console?

  • No, the error is shown where you should show the chart

  • Thanks for your help ^^

1 answer

1

The line "google.charts.load('Current', { 'Packages': ['bar'] });" must be outside the loop.

The google.charts.load method can only be called once on the page.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.