Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8614735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:11:29+00:00 2026-06-12T05:11:29+00:00

The new Google Chart API creates charts as SVGs (not PNGs as it used

  • 0

The new Google Chart API creates charts as SVGs (not PNGs as it used to). I’d like to be able to save the generated SVG. How can I do this?

If I use Chrome to inspect elements on the page, I can find the svg tag that holds the SVG. I’d like to be able to get the generated SVG using JavaScript. I’d prefer not to search the HTML source for the svg tag in JavaScript, and if there’s a way to get the SVG string directly from the chart object (maybe the ChartWrapper class?) that would be preferable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:11:30+00:00Added an answer on June 12, 2026 at 5:11 am

    Apparently, this is not supported by the Google Charts API (references 1, 2, and 3). I created the below hack to get the SVG string as a workaround. Below is the full JavaScript.

    function drawVisualization() {
        // Create and populate the data table.
        var data = google.visualization.arrayToDataTable([
            ['Task', 'Hours per Day'],
            ['Work', 11],
            ['Eat', 2],
            ['Commute', 2],
            ['Watch TV', 2],
            ['Sleep', 7]
            ]);
    
        // Create and draw the visualization.
        var chart = new google.visualization.PieChart(document.getElementById('visualization'));
        google.visualization.events.addListener(chart, 'ready', allReady); // ADD LISTENER
        chart.draw(data, {title:"So, how was your day?"});
    }
    
    function allReady() {
        var e = document.getElementById('visualization');
        // svg elements don't have inner/outerHTML properties, so use the parents
        alert(e.getElementsByTagName('svg')[0].outerHTML);
    }
    
    google.setOnLoadCallback(drawVisualization);
    

    Note that this doesn’t work in IE because the Google Charts API doesn’t use SVG in IE. I’m always open to better solutions.

    (thanks to untill for suggesting .outerHTML over .parentNode.innerHTML)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Google Chart (using the Google Visualization API , not Google Charts
I would like some help about an Android Application. I used the new Google
Iam quite new to Google chart API's and I am trying to integrate it
I am trying to use the Google Charts API to create a chart that
I am trying to set Google Chart using API generated from below link Google
I am trying to implement an Annotated Time Line Chart via Google Charts API.
I see this link to use google chart api for putting multiple line charts
I'm updating an older data visualization module which used the Google Image Chart API
I am using Google charts api to draw a table chart. I am making
I'm drawing a chart ( Google Charts API ) with this DataTable: chart_data =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.