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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:09:45+00:00 2026-05-25T15:09:45+00:00

I’m looking to format my data in which I replace numbers with icons. As

  • 0

I’m looking to format my data in which I replace numbers with icons.

As far as I can tell Google do not currently have a formatter to do so:

http://code.google.com/apis/chart/interactive/docs/reference.html#formatters

There is a brief mention within the documents about custom formatters, but I cannot seem to find any documents on how to begin writting a custom formatters.

Can anyone point me in the right direction?

There is a similar question on StackOverflow: Write a custom formatter for Google Charts Api . However the question was resolved simply using the built-in formatters (which I don’t think I can use).

  • 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-05-25T15:09:45+00:00Added an answer on May 25, 2026 at 3:09 pm

    I don’t think you’ll be able to make the current formatters to do what you want, but you should be able to make your own formatter easily enough. I put together iconFormatter below for a sample – this could be adjusted to do whatever you need really.

    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <script type="text/javascript" src="http://www.google.com/jsapi"></script>
        <script type="text/javascript">
          google.load('visualization', '1', {packages: ['table']});
        </script>
        <script type="text/javascript">
          /**
          * Gviz icon formatter
          * @param {Object<Number, String>} Map of numbers to icon URIs
          */
          var iconFormatter = function(iconMap) {
            this.iconMap = iconMap;
          }
          /**
           * Formats a gviz DataTable column
           * @param {Object} dt DataTable to format
           * @param {Number} column index number
           */
          iconFormatter.prototype.format = function(dt, column) {
            for (var i=0;i<dt.getNumberOfRows();i++) {
              var formattedValue = this.iconMap[dt.getValue(i, column)];
              var htmlString = "<img src="+formattedValue+" />";
              dt.setFormattedValue(i, column, htmlString);
              // underlying value preserved
              console.log(dt.getValue(i, column)); 
            }
          }
        </script>
        <script>
          function drawVisualization() {
            // Create and populate the data table.
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Name');
            data.addColumn('number', 'Height');
            data.addRows(3);
            data.setCell(0, 0, 'Tong Ning mu');
            data.setCell(1, 0, 'Huang Ang fa');
            data.setCell(2, 0, 'Teng nu');
            data.setCell(0, 1, 174);
            data.setCell(1, 1, 523);
            data.setCell(2, 1, 86);
    
            var iconMap = {
              174: "http://farm1.static.flickr.com/76/buddyicons/63892905@N00.jpg?1149480603",
              523: "http://farm1.static.flickr.com/28/buddyicons/20741728@N00.jpg?1129271399",
              86: "http://farm3.static.flickr.com/2698/buddyicons/70986564@N00.jpg?1303489082"
              // other numbers
            }
    
            // Create and draw the visualization.
            visualization = new google.visualization.Table(document.getElementById('table'));
            // apply our formatter, just like normal
            var formatter = new iconFormatter(iconMap);
            formatter.format(data, 1);
            // allow html, just like any html formatter will require
            visualization.draw(data, {allowHtml: true});
          }
          google.setOnLoadCallback(drawVisualization);
        </script>
      </head>
      <body>
        <div id="table"></div>
      </body>
    </html>
    

    Hope that helps.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.