简体   繁体   English

如何更改谷歌图表地理地图中的默认颜色?

[英]How to change Default color in google charts geomap?

I want to change the default yellow color of chart region to user defined color.我想将图表区域的默认黄色更改为用户定义的颜色。 I can able to change only marker color.我只能更改标记颜色。 I used this code to generate chart data.我使用此代码生成图表数据。

         dataTable = new google.visualization.DataTable();
         dataTable.addRows(4);
         dataTable.addColumn('number', 'LATITUDE', 'Latitude');
         dataTable.addColumn('number', 'LONGITUDE', 'Longitude');
         dataTable.addColumn('number', 'Ticket', 'Value'); 
         dataTable.addColumn('string', 'HOVER', 'HoverText');

         dataTable.setValue(0,0,12.9715987);
         dataTable.setValue(0,1,77.5945627);
         dataTable.setValue(0,2,43);
         dataTable.setValue(0,3,"Banglore");

         dataTable.setValue(1,0,22.642664);
         dataTable.setValue(1,1,88.439122);
         dataTable.setValue(1,2,66);
         dataTable.setValue(1,3,"Kolkatta");

         dataTable.setValue(2,0,13.0826802);
         dataTable.setValue(2,1,80.2707184);
         dataTable.setValue(2,2,54);
         dataTable.setValue(2,3,"Chennai");

         dataTable.setValue(3,0,9.9252007);
         dataTable.setValue(3,1,78.1197754);
         dataTable.setValue(3,2,64);
         dataTable.setValue(3,3,"Madurai");

在此处输入图片说明

How to change the region, background and tooltip color?如何更改区域、背景和工具提示颜色? please help me请帮我

There is aaticket on github for this github上一张票

Basically the code below set's the options your need基本上下面的代码是您需要的选项

var options = {};
  options['region'] = 'US';
  options['resolution'] = 'provinces';
  options['colorAxis'] = { minValue : 0, maxValue : 1, colors : ['#FF0000','#0000FF']};
  options['backgroundColor'] = '#FFFFFF';
  options['datalessRegionColor'] = '#E5E5E5';
  options['width'] = 556;
  options['height'] = 347;
  options['legend'] = 'none';

  var geochart = new google.visualization.GeoChart(
      document.getElementById('visualization'));
  geochart.draw(geoData, options);

this is also covered in the official docs这也包含在官方文档中

backgroundColor背景颜色

The background color for the main area of the chart.图表主要区域的背景颜色。 Can be either a simple HTML color string, for example: 'red' or '#00cc00', or an object with the following properties.可以是简单的 HTML 颜色字符串,例如:'red' 或 '#00cc00',也可以是具有以下属性的对象。

Type: string or object Default: white类型:字符串或对象默认值:白色

backgroundColor.fill backgroundColor.fill

The chart fill color, as an HTML color string.图表填充颜色,作为 HTML 颜色字符串。

Type: string Default: white类型:字符串默认值:白色

backgroundColor.stroke backgroundColor.stroke

The color of the chart border, as an HTML color string.图表边框的颜色,作为 HTML 颜色字符串。

Type: string Default: '#666'类型:字符串默认值:'#666'

backgroundColor.strokeWidth backgroundColor.strokeWidth

The border width, in pixels.边框宽度,以像素为单位。

Type: number Default: 0类型:数字 默认值:0

Hey this worked for me嘿这对我有用

colors: ['#0077CC']

You can add this in Options Like :-您可以在选项中添加它,例如:-

var options = {
    region: 'IN',
    displayMode: 'markers',
    colorAxis: {colors: ['blue']}
  };

For more information you can visit Link有关更多信息,您可以访问链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM