France elections

The following demo demonstrates how to colorize deffirent regions in different colors using OrdinalScale. First you describe classes with which values of attributes should be set for elements (regions or markers). Then you apply this classes to the regions or markers. The code in Ruby used to convert data could be found in this repository.

French presidential election, 2007

- Nicolas Sarkozy - Ségolène Royal

French presidential election, 2012

- François Hollande - Nicolas Sarkozy

Full code of an example:

$(function(){
  $.getJSON('/data/france-elections.json', function(data){
    new jvm.Map({
      map: 'fr_regions_merc',
      container: $('#map2007'),
      series: {
        regions: [{
          scale: {
            '1': '#4169E1',
            '2': '#FF69B4'
          },
          attribute: 'fill',
          values: data['year2007'].results
        }]
      }
    });

    new jvm.Map({
      map: 'fr_regions_merc',
      container: $('#map2012'),
      series: {
        regions: [{
          scale: {
            '1': '#FF69B4',
            '2': '#4169E1'
          },
          attribute: 'fill',
          values: data['year2012'].results
        }]
      }
    });
  });
});