Geochart: using the ISO 3266-2 region code, but displaying the real name

I use the Google geostationary visualization API to create a map of the country's regions. I provide ISO 3266-2 country code and get the correct results. However, showing the ISO 3266-2 codes as a shortcut on the diagram is a bad user interface. Therefore, I would like to provide a custom shortcut. Take this as an example:

  function drawVisualization() {
    var data = google.visualization.arrayToDataTable([
      ['Country', 'Popularity'],
      ['DE-BY', 200],
      ['DE-NW', 500]
    ]);

    var geochart = new google.visualization.GeoChart(
          document.getElementById('visualization'));
    geochart.draw(data, {width: 556, height: 347, region: 'DE', resolution: 'provinces'});
  }

[Try it on Code Playground]

I would like to provide "DE-BY", but as a label for "Bavaria". I need to use the ISO 3266-2 codes, although Google writes that

English text equivalent (for example, "US-NJ" or "New Jersey")

, "".

+5
2

, , - , , , , , .

, PatternFormat, , , , .

function drawVisualization() {

      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Country');
      data.addColumn('number', 'Value');
      data.addColumn('string', 'Display');

      data.addRows([
        ['Germany', 200, 'Germany'],
        ['United States', 300, 'USA'],
        ['Brazil', 400, 'Brasil'],
        ['Canada', 500, 'Canada'],
        ['France', 600, 'France'],
        ['RU', 700, 'Russia']
      ]);

      var geochart = new google.visualization.GeoChart(
          document.getElementById('visualization'));

      var formatter = new google.visualization.PatternFormat('{1}');  
      formatter.format(data, [0, 2]);

      var view = new google.visualization.DataView(data);
      view.setColumns([0, 1]);  

      geochart.draw(view, {width: 556, height: 347});
    }
+12

ISO 3166-2, , .

  • , , .

  • , ( ) , . , .

  • , , ( ).

  • , ( ).

  • (sub) - .

  • , - ASCII, ASCII Unicode.

, "-" , , "" . - №6 , ASCII. ISO 639-1 -3.

3166-2 - , , .

0

All Articles