改变 HighCharts 的背景颜色?

14

我不太知道如何做这个。

我需要改变这个highcharts图表的背景颜色:

http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/polar-spider/

但似乎我无法这样做 - 没有明显的地方可以设置背景颜色?

我已经尝试在这个部分写了许多不同的值:

chart: {
        polar: true,
        type: 'line'
},

但它没有做任何事情(它偶尔会破坏这个脚本)。

我是否需要在包含的.js文件中的某个地方更改它?还是可以从加载的脚本级别完成?

JS真的很令人困惑。有人能帮帮我吗?


整个图表的背景,还是六边形内部的部分? - DBS
5个回答

36

请查看这里的Highcharts API:https://api.highcharts.com/highcharts/chart.backgroundColor,您会发现它是图表对象的一个属性,可以采用纯色:

{
  chart: {
     backgroundColor: '#FCFFC5',
     polar: true,
     type: 'line'
  }
}

或渐变:

{
  chart: {
    backgroundColor: {
       linearGradient: [0, 0, 500, 500],
       stops: [
         [0, 'rgb(255, 255, 255)'],
         [1, 'rgb(200, 200, 255)']
       ]
     },
     polar: true,
     type: 'line'
  }
}

2
我已经尝试了这两种方法制作饼图,但是无论如何,都会在SVG中出现,并覆盖设置:<rect x="0" y="0" width="655" height="328" strokeWidth="0" fill="#FFFFFF" class=" highcharts-background"></rect> - Jason Kleban

2

您可以使用backgroundColor标签来设置背景颜色:(http://jsfiddle.net/aeP4E/)

chart: {
      polar: true,
      type: 'line',
      backgroundColor:'blue' 
},

1
那是你想要的。`

`
chart: {
            polar: true,
            type: 'line',
            backgroundColor:'rgba(255, 255, 255, 0.1)'
        }

`


0

演示

你可以使用 data: [[0, 0, true], 来显示数值,你可以通过 'false' 隐藏数值,并且你可以设置渐变效果。

  colorAxis: {
        min: 0,
        stops: [
         [0, '#5DBA76'],
        [0.4, '#ffff00'],
        [0.8, '#F30000']
    ],
        minColor: '#ff0000',
        maxColor: '#ffff00'
    },

谢谢 :)


0

你可以通过使用“false”来隐藏值

data: [[0, 0, false], [0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [1, 0, 2], [1, 1, 4], [1, 2, 6], [1, 3, 8], [1, 4, 10], [2, 0, 3], [2, 1, 6], [2, 2, 9], [2, 3, 12], [2, 4, 15], [3, 0, 4], [3, 1, 8], [3, 2,12], [3, 3, 16], [3, 4, 20], [4, 0, 5], [4, 1, 10], [4, 2, 15], [4, 3, 20], [4, 4, 25]

http://jsfiddle.net/3527r4ty/1/


您能否详细阐述一下您的答案,并对您提供的解决方案进行更多描述? - abarisone

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接