Carlos muchas gracias aplique lo q indicaste y salio perfecto
Gracias nuevamente

El jue., ago. 16, 2018 5:09 PM, carlos nicho <[email protected]>
escribió:

> Ah entonces necesitas recorrer el json y guardar tus valores en array y
> asi mostrarlo
> Para eso utiliza ajax para aca te paso el ejemplo:
>
> $.ajax({
> url: './json/myjson.json', //la ubicacion del json
> dataType: 'JSON', //aca va el tipo
> success: function(data) {
> $.each(data, function(i, item){ // con esto recorres el json y guardas
> todo lo que tengas
> var lotex = data[i].lote; // en tu caso seria data[i].sede, data[i].sema
> y asi el json se recorre como una matriz
> //claro que en lugar de var lotex usarias tu array ejemplo[i] =
> data[i].sede y asi sucesivamente
> }
>
> });
>
> esto pones en el <head>
> <script src="
> https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js";></script
> >
> <script src="https://code.jquery.com/jquery-1.12.4.js";></script>
> <script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js";></script>
> y donde declaras el <script type="text/javascript">
> la siguiente funcion
>
> function objetoAjax()
> {
> var xmlhttp = false;
> try {
> xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
> } catch (e) {
>
> try {
> xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
> } catch (E) {
> xmlhttp = false; }
> }
>
> if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
> xmlhttp = new XMLHttpRequest();
> }
> return xmlhttp;
> }
> Espero ayudarte sino busca en google como recorrer json con ajax ahi te
> saldra mas informacion si demoro en contestar.
>
>
> El domingo, 12 de agosto de 2018, 22:37:21 (UTC-5), schuiky escribió:
>>
>> Buenas noches, estoy tratando de mostrar un grafico de barras, con el
>> siguiente codigo
>>
>> <html>
>>   <head>
>>     <script type="text/javascript" src="
>> https://www.gstatic.com/charts/loader.js";></script>
>>     <script type="text/javascript" src="
>> https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
>> "></script>
>>     <script type="text/javascript">
>>     google.charts.load('current', {'packages':['corechart']});
>>     google.charts.setOnLoadCallback(drawChart);
>>     function drawChart() {
>>       var jsonData = $.ajax({
>>           url: "prueba.php",
>>           dataType: "json"
>>           }).responseText;
>> var data = new google.visualization.DataTable();
>> data.addColumn('string', 'sede');
>> data.addColumn('number', 'sema');
>> data.addColumn('number', 'tfre');
>> data.addColumn('number', 'tapli');
>> for (var i = 0; i < jsonData.length; i++) {
>>               var sede = jsonData[i].['sede'];
>>               var sema = jsonData[i].['sema'];
>>               var tfre = jsonData[i].['tfre'];
>>   var tapli = jsonData[i].['tapli'];
>>               data.addRow([sede, sema, tfre, tapli]); <!-- Codificamos
>> las tres variables en una fila-->
>>     };
>>       var chart = new
>> google.visualization.ColumnChart(document.getElementById('chart_div'));
>>       chart.draw(data, {width: 400, height: 240});
>>     }
>>     </script>
>>   </head>
>>   <body>
>>     <div id="chart_div"></div>
>>   </body>
>> </html>
>>
>> el archivo prueba.php genera este json
>>
>> [{"sede":"AREQUIPA","sema":"1","tfre":"0","tapli":"0"},{"sede":"CAJAMARCA","sema":"1","tfre":"0","tapli":"0"},{"sede":"CALLAO","sema":"1","tfre":"0","tapli":"0"},{"sede":"CHICLAYO","sema":"1","tfre":"0","tapli":"0"},{"sede":"CORONEL
>>  PORTILLO-PUCALLPA","sema":"1","tfre":"0","tapli":"0"}]
>>
>>
>> Alguien que me ayude con esto por favor
>>
>>
>> --
> 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/f51a5ceb-13be-4177-873c-2a08546658b6%40googlegroups.com
> <https://groups.google.com/d/msgid/google-visualization-api/f51a5ceb-13be-4177-873c-2a08546658b6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B2d6wGokMnS68jZu_CCETmPH7ZQx7Tvip2zfr1DGz84c8S98w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to