This patch adds support for the colorAxis and datalessRegionColor options for the Google Charts GeoChart ('geo') chart type.

With this patch the colorAxis option can be used to set a custom range of colours for the map display. For example:

    $options = [
      'type' => 'geo',
      'title' => $this->t('Chart title'),
      'colorAxis' => ['#c7e4ff', '#a0cbf3', '#77b1e6', '#5098da', '#287ece', '#0064c1'],
      'datalessRegionColor' => '#dedede',
    ];
    $categories = ['United States','United Kingdom', 'Canada', 'India'];
    $seriesData[] = [
      'name' => 'Users',
      'data' => [3250, 2500, 1350, 400],
    ];

Results in this:
Screenshot showing rendered geoChart

Comments

megan_m created an issue. See original summary.

megan_m’s picture

Issue summary: View changes
megan_m’s picture

StatusFileSize
new2.82 KB

Small change to prevent this from breaking other charts that don't include the colorAxis option.

  • andileco committed 1ba23b1 on 8.x-3.x authored by megan_m
    Issue #3086825 by megan_m, andileco: Add support for GeoChart colorAxis...
andileco’s picture

Status: Active » Fixed

Thanks for the patch and the EXCELLENT issue write-up! I made two small changes that prevented a couple undefined index issues in the dblog when I tested with your code.

megan_m’s picture

Issue summary: View changes
andileco’s picture

Version: 8.x-3.x-dev » 8.x-4.x-dev
Status: Fixed » Needs work

Applying this to 4.x (should have done this before).

  • andileco committed f8174ae on 8.x-4.x authored by megan_m
    Issue #3086825 by megan_m, andileco: Add support for GeoChart colorAxis...
andileco’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.