更改Highmap的颜色

时间:2015-12-25 21:54:08

标签: css highcharts highmaps

我正在使用Highmaps,这是我使用的那个:

http://www.highcharts.com/maps/demo/data-class-ranges

在这张地图中,不同国家/地区的颜色从白色变为蓝色我希望将其更改为"红色变为蓝色"像这个css例子中的渐变:

 background: -webkit-linear-gradient(red, yellow, green, blue); /* For Safari 5.1 to 6.0 */
    background: -o-linear-gradient(red, yellow, green, blue); /* For Opera 11.1 to 12.0 */
    background: -moz-linear-gradient(red, yellow, green, blue); /* For Firefox 3.6 to 15 */
    background: linear-gradient(red, yellow, green, blue); /* Standard syntax (must be last) */

我该怎么做?

1 个答案:

答案 0 :(得分:2)

您可以在colorAxis对象中指定颜色。

colorAxis: {
  dataClasses: [{
    to: 3,
    color: "red"
  }, {
    from: 3,
    to: 10,
    color: "yellow"
  }, {
    from: 10,
    to: 30,
    color: "green"
  }, {
    from: 30,
    to: 100,
    color: "blue"
  }, {
    from: 100,
    to: 300,
    color: "pink"
  }, {
    from: 300,
    to: 1000,
    color: "purple"
  }, {
    from: 1000,
    color: "black"
  }]
},

#FF0000这样的十六进制值也适用。

工作示例:http://jsfiddle.net/8wcntpcz/

编辑: 文档:http://api.highcharts.com/highmaps#colorAxis.dataClasses