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

  • Home
  • SEARCH
  • 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 8447039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:05:13+00:00 2026-06-10T10:05:13+00:00

Below is the code I’m using, based on a how to I found in

  • 0

Below is the code I’m using, based on a how to I found in Google’s documentation, but I’m not sure if it applies to the Geochart, if I’m doing it right, or if there is some other way to do it for a Geochart.

This code works fine if I don’t include the tooltip column. When I do, I get the error “Incompatible data table: Error: Table contains more columns than expected (Expecting 2 columns),” displayed where the Geochart should be.

This question addresses the same issue, but not specifically for a Geochart.

<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>

    google.load( 'visualization', '1', { 'packages': ['geochart'] } );
    google.setOnLoadCallback( drawRegionsMap );

    function drawRegionsMap()
    {

        var data = google.visualization.arrayToDataTable([
            [ 'State', 'Relevance', {type: 'string', role: 'tooltip'} ],
            [ 'Alabama', 3, 'tooltip test text' ],
            [ 'Arizona', 1, 'tooltip test text' ],
        ]);

        var options =
        {
            region:         'US',
            resolution:     'provinces',
        };

        var chart = new google.visualization.GeoChart( document.getElementById( 'chart_div' ) );
        chart.draw( data, options );

    };

</script>
  • 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-10T10:05:14+00:00Added an answer on June 10, 2026 at 10:05 am

    It seems like it is impossible to format the text the exact way I was attempting to with the GeoChart tool. Below is the solution I finally came up with and the rendered map:

    Rendered Map with Tooltip View

    enter image description here

    PHP & JavaScript Code

    <!-- generate geo map -->
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
    
        google.load( 'visualization', '1', { 'packages': ['geochart'] } );
        google.setOnLoadCallback( drawRegionsMap );
    
        function drawRegionsMap()
        {
    
            // create data table
            var data = google.visualization.arrayToDataTable([
                <?php echo $data_table; ?>
            ]);
    
            // create chart object
            var chart = new google.visualization.GeoChart(
                document.getElementById( 'chart_div' )
            );
    
            // defines the data for the tooltip
            var formatter = new google.visualization.PatternFormat('{0}');
            formatter.format( data, [0,1], 1 );
            var formatter = new google.visualization.PatternFormat('{2}');
            formatter.format( data, [0,1,2], 0 );
    
            // defines the data for the chart values
            var view = new google.visualization.DataView(data);
            view.setColumns([0, 1]);
    
            // set options for this chart
            var options =
            {
                width:          <?php echo $width; ?>,
                region:         'US',
                resolution:     'provinces',
                colorAxis: { colors: ['#abdfab', '#006600'] },
                legend: 'none'
            };
    
            // draw chart
            chart.draw( view, options );
    
        };
    
    </script>
    
    <div id="chart_div" style="width: <?php echo $width; ?>px; height: <?php echo $height; ?>px;"></div>
    

    Rendered HTML

    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
    
        google.load( 'visualization', '1', { 'packages': ['geochart'] } );
        google.setOnLoadCallback( drawRegionsMap );
    
        function drawRegionsMap()
        {
    
            // create data table
            var data = google.visualization.arrayToDataTable([
                [ 'State', 'in', 'String' ],
                [ 'Arizona', 2, 'Has Facility, Sells Direct' ],
                [ 'California', 4, 'Has Facility, Has Distributor, Sells Direct' ],
                [ 'Colorado', 1, 'Sells Direct' ],
                [ 'Florida', 1, 'Has Distributor' ],
                [ 'Georgia', 1, 'Has Distributor' ],
                [ 'Idaho', 1, 'Sells Direct' ],
                [ 'Illinois', 1, 'Has Distributor' ],
                [ 'Indiana', 1, 'Has Distributor' ],
                [ 'Iowa', 1, 'Has Distributor' ],
                [ 'Kansas', 1, 'Has Distributor' ],
                [ 'Kentucky', 1, 'Has Distributor' ],
                [ 'Louisiana', 1, 'Has Distributor' ],
                [ 'Maryland', 2, 'Has Distributor' ],
                [ 'Montana', 1, 'Sells Direct' ],
                [ 'Nevada', 2, 'Has Facility, Sells Direct' ],
                [ 'New Mexico', 2, 'Has Facility, Sells Direct' ],
                [ 'North Carolina', 1, 'Has Distributor' ],
                [ 'North Dakota', 1, 'Has Distributor' ],
                [ 'Oklahoma', 1, 'Sells Direct' ],
                [ 'Oregon', 1, 'Sells Direct' ],
                [ 'Pennsylvania', 1, 'Has Distributor' ],
                [ 'South Carolina', 1, 'Has Distributor' ],
                [ 'Tennessee', 1, 'Has Distributor' ],
                [ 'Texas', 1, 'Has Distributor' ],
                [ 'Utah', 2, 'Has Facility, Sells Direct' ],
                [ 'Washington', 1, 'Sells Direct' ],
                [ 'Wyoming', 1, 'Sells Direct' ],       ]);
    
            // create chart object
            var chart = new google.visualization.GeoChart(
                document.getElementById( 'chart_div' )
            );
    
            // defines the data for the tooltip
            var formatter = new google.visualization.PatternFormat('{0}');
            formatter.format( data, [0,1], 1 );
            var formatter = new google.visualization.PatternFormat('{2}');
            formatter.format( data, [0,1,2], 0 );
    
            // defines the data for the chart values
            var view = new google.visualization.DataView(data);
            view.setColumns([0, 1]);
    
            // set options for this chart
            var options =
            {
                width:          286,
                region:         'US',
                resolution:     'provinces',
                colorAxis: { colors: ['#abdfab', '#006600'] },
                legend: 'none'
            };
    
            // draw chart
            chart.draw( view, options );
    
        };
    
    </script>
    
    <div id="chart_div" style="width: 286px; height: 180px;"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The below code works in Firefox but not in Google Chrome: <!DOCTYPE html> <html>
Below code not work, but it's work fine for jsf1.2. Now the framework is
Below code is working properly now. But if I replace 'text.txt' with ' http://google.com
Below code gives this error message Specified method is not supported. But here is
The below code rocks in Chrome and FF but not working in IE I
Below code is not working in IE but working in Chrome... $(this).css(border,solid 1px green)
Below code works fine in Firefox, but not in IE8. It triggers mouse click
Below code i am using for MSSQL 2005,but when i try to run in
The below code compiles with .Net Framework 4.0 but not with Silverlight 4.0. I
In below code when I click 'Vote' a vote results screen is displayed but

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.