Exporting Google Visualization charts to CSV/pdf

Discussion in 'Graphics & Multimedia' started by snrsarker, Aug 30, 2012.

  1. #1
    Hi,I cannot export google visualization charts to csv/pdf. Please help. I have already drawn the chart and all, but cannot export the charts. I am using client side coding using Java Script. Regards,Soumyajit
     
    snrsarker, Aug 30, 2012 IP
  2. phpking

    phpking Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    is it really possible?
     
    phpking, Aug 30, 2012 IP
  3. snrsarker

    snrsarker Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    As per Google, this capacity is not yet provided. However if there is any indirect way, then I would love to know that. Also if it is possible to export the contents of a div with a Google charts wrapper container, then how to do that? Please do not re-send me my questions. Please help me with solutions.
     
    snrsarker, Aug 30, 2012 IP
  4. Anna Stacy

    Anna Stacy Greenhorn

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    You can try this code to create chart, table and toolbar.

    google.load("visualization", "1", { packages: ["corechart"] });
    google.load('visualization', '1', { packages: ['table'] });
    //google.setOnLoadCallback(drawChart);


    function drawChart() {
    $.ajax({
    type: "GET",
    url: '@Url.Action("GunlukOkumalar", "Enerji")',
    data: "startDate=" + $('#start_date').val() + "&endDate=" + $('#end_date').val() + "&sayac_id=" + $("#sayaclar").val(), //belirli aralıklardaki veriyi cekmek için


    success: function (result) {
    if (result.success) {
    var evalledData = eval("(" + result.chartData + ")");
    var opts = { curveType: "function", width: '100%', height: 500, pointSize: 5 };
    new google.visualization.LineChart($("#chart_div").get(0)).draw(new google.visualization.DataTable(evalledData, 0.5), opts);
    $('#chart_div').show();


    var visualization;
    var data;
    var options = { 'showRowNumber': true };
    data = new google.visualization.DataTable(evalledData, 0.5);
    // Set paging configuration options
    // Note: these options are changed by the UI controls in the example.
    options['page'] = 'enable';
    options['pageSize'] = 10;
    options['pagingSymbols'] = { prev: 'prev', next: 'next' };
    options['pagingButtonsConfiguration'] = 'auto';


    // Create and draw the visualization.
    visualization = new google.visualization.Table(document.getElementById('table'));
    visualization.draw(data, options);


    var components = [
    { type: 'html', datasource: data },
    { type: 'csv', datasource: data }
    ];


    var container = document.getElementById('toolbar_div');
    google.visualization.drawToolbar(container, components);


    return false;
    }
    else {
    $('#chart_div').html('<span style="color:red;"><b>' + result.Error + '</b></span>');
    $('#chart_div').show();


    $('#table').html('<span style="color:red;"><b>' + result.Error + '</b></span>');
    $('#table').show();
    return false;
    }
    }
    });
    }


    Hope it works.
     
    Anna Stacy, Sep 4, 2012 IP
  5. snrsarker

    snrsarker Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi Anna, Thanks for your reply. I have already done what you have suggested. Actually I am aiming to export the chart that we can see on the page. After drawing the chart through the "chart.draw(data, options);" statement, I want to export the same chart. I had already composed the charts. All I want now is to export the chart to pdf/csv/excel. I can explore the data. I am sure of it. Even if I am using a container/wrapper for the chart component, I am unable to find a way to export the chart component. Please help. Regards, Soumyajit
     
    snrsarker, Sep 5, 2012 IP
  6. Navaneeth2013

    Navaneeth2013 Greenhorn

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #6
    Are you able to export the google chart into PDF Soumya, i'm having the same prob now. Please suggest
     
    Navaneeth2013, Apr 6, 2013 IP