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 9051661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:57:42+00:00 2026-06-16T12:57:42+00:00

I have my google line chart which looks something like this: 10| . |

  • 0

I have my google line chart which looks something like this:

10|                        .
  |            .....----''' ''--.
09| .-----'''''                  ''-
  |                                 '.
08|                                   \
  |                                    '.
07|                                      '.
  |________________________________________________________
   2012/12/27 12:01    2012/12/26 12:22    2012/12/25 11:33

And I want it to look like this (notice the X-Axis label):

10|                        .
  |            .....----''' ''-.
09| .-----'''''                 \
  |                              '.
08|                                \
  |                                 '.
07|                                   '.
  |_______________________________________________
   2012/12/27          2012/12/26       2012/12/25
   12:01               12:22            11:33

I tried adding <br>, \n, and \r but no luck.

I looked through the documentation and the closest thing I found was hAxis.maxTextLines but there is no minTextLines options so I couldn’t figure out how to force it. How can I do this?


UPDATE

It seems that this is possible when creating charts by linking to google. You just have to set the chxt variable with extra x values (however many more x axes you need): chxt=y,x,x. And then for each x axis, you set what the labels will be with the chxl variable. chxl=1:|2012/12/27|2012/12/26|2012/12/25|2:|12:01|12:22|11:33

For example:

http://chart.apis.google.com/chart?chxl=1:|2012/12/27|2012/12/26|2012/12/25|2:|12:01|12:22|11:33&chxr=0,7,10&chxt=y,x,x&chs=360×240&cht=bvg&chco=000000&chd=t1:9,10,7&cht=lc&chds=7,10

But the way I am creating my charts is through JavaScript. This way:

google.setOnLoadCallback(function(){
  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Date');
  data.addColumn('number', 'Count');

  //Populate data

  new google.visualization.LineChart(document.getElementById('chart')).
    draw(data, {curveType: 'function',
                chartArea: {left: 70, top: 50, width: '100%', height: '85%'},
                width: 950, height: 800,
                interpolateNulls: true,
                pointSize: 5,
                legend: {position: 'none'},
                vAxis: {title: 'Count', viewWindow: {min: 7, max: 10}},
                hAxis: {title: 'Date', viewWindow: {min: 0, max: 3}}
               });
});

So I need to figure out a way how to do this using this format/API. How can I do it this way?

  • 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-16T12:57:43+00:00Added an answer on June 16, 2026 at 12:57 pm

    Final Update

    Working Example: http://jsbin.com/eyokec/1/ (edit version)

    Well, as usual, some digging around yielded a few possible solutions. I was only successful at getting one to work but at least you know it’s possible at this point. This answer from Insert Links into Google Charts api data? provided the working solution above.

      // Note: You will probably need to tweak these deltas
      // for your labels to position nicely.
      var xDelta = 35;
      var yDelta = 13;
      var years = ['2012/12/27|12:01','2012/12/26|12:22','2012/12/25|11:33','2012/12/24|11:33'];
      $('text').each(function(i, el) {
          if (years.indexOf(el.textContent) != -1) {
              var g = el.parentNode;
              var x = el.getAttribute('x');
              var y = el.getAttribute('y');
              var width = el.getAttribute('width') || 70;
              var height = el.getAttribute('height') || 35;
      
              // A "ForeignObject" tag is how you can inject HTML into an SVG document.
             var fo = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
              fo.setAttribute('x', x - xDelta);
              fo.setAttribute('y', y - yDelta);
              fo.setAttribute('height', height);
              fo.setAttribute('width', width);
    
              var body = document.createElementNS("http://www.w3.org/1999/xhtml", "BODY");
              var p = document.createElement("P");
    
              p.setAttribute("style", "font-size:.8em; font-family:Arial;text-align:center;color:#555;");
              p.innerHTML = el.textContent.replace('|','<br />');
    
              body.appendChild(p);
              fo.appendChild(body);
      
              // Remove the original SVG text and replace it with the HTML.
              g.removeChild(el);
              g.appendChild(fo);
          }
      });
    

    The above code work but, understandably, is far from ideal. It’s just a proof of concept that you can hopefully use. I saw other similar questions about updating SVG files but I couldn’t get them to work. The above code might be able to update th SVG <text> nodes relying on <tspan> for multi-line support. I might try to get that to work at some point.

    Tests

    • Chrome 23.0.1271.97 m: PASS
    • Firefox 17.0.1: PASS (more height needed)
    • IE9: FAIL (not sure why)

    References

    • Manipulating SVG Documents Using ECMAScript (Javascript) and the DOM
    • http://raphaeljs.com/
    • jQuery SVG: http://keith-wood.name/svg.html

    Update 0

    Also, it appears that Google Image Charts API is now deprecated.

    Important: The Image Charts portion of Google Chart Tools has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy.

    So, although you can create the chart as an example of what you would like, it’s possible that functionality was not brought over to Google Chart Tools.

    That said, I did find this Chart Wizard that will help create the necessary JavaScript to embed your chart with the Visualization API.

    Google Chart Image Example


    Original

    Doesn’t appear possible. You could force it using hAxis.minTextSpacing. It works but that’s certainly not the purpose of that configuration option. You could also pull the labels out and handle them via HTML, but I know that’s not ideal either.

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

Sidebar

Related Questions

Hello I have a Google Visualisation Line chart like this... <script type=text/javascript src=https://www.google.com/jsapi></script> <script
For example we have this line chart at Google Code API there is a
I have a Google line chart, I set 'curveType': 'function' so the graph is
So I have a google line chart visualization with a data set that has
I see this link to use google chart api for putting multiple line charts
I have setup a simple Google Chart by following the example on this page:
I am trying to draw a Google Line Chart, where each line may have
Hello I want to have a % in my google chart data i have
I have the following line in my IsapiRewrite.ini file: RewriteRule ^/test-url.asp$ http://www.google.co.uk/ [R=301,L] But
I have google'd it, and tried some examples, but I always get stuck. This

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.