jquery - Formatting CSV values from a file in Javascript to populate Google Chart -
i have csv file values date value1 value2
. want populate google charts data. using jquery-csv.js , i'm reading values.
<script type="text/javascript" src="js/jquery.csv.js"></script> <script type="text/javascript"> // load visualization api , piechart package. google.load('visualization', '1.0', {'packages':['corechart']}); // set callback run when google visualization api loaded. google.setonloadcallback(drawchart); // callback creates , populates data table, // instantiates pie chart, passes in data , // draws it. function drawchart() { $.get("data.csv", function(csvstring) { // transform csv string 2-dimensional array var arraydata = $.csv.toarrays(csvstring, {onparsevalue: $.csv.hooks.casttoscalar}); //alert(arraydata); // new datatable object holds data var data = new google.visualization.arraytodatatable(arraydata); alert(data.getcolumnlabel(0)); //here alert 06/11/201522 usual google chart code follows }); } </script>
when alert data.getcolumnlabel(0) , values of first row combined. how split it? want each column data in separate variable. appreciated.
Comments
Post a Comment