2015-12-23 83 views
2

这里是我的图表对象。如何为系列添加highcharts-ng饼图自定义颜色?

$scope.chartConfig = { 
         options: { 
          chart: { 
           type: 'pie', 
           plotBackgroundColor: null, 
           plotBorderWidth: null, 
           plotShadow: false 

          }, 
          title: { 
           text: 'Status Counts in the Current Stage.' 
          }, 
          plotOptions: { 
           pie: { 
            dataLabels: { 
             enabled: false 
            }, 
            showInLegend: true 
           } 
          } 
         }, 
         series: [{  
          data: [ 
           ['foo', 10], 
           ['bar', 90], 
           ['baz', 100] 
          ] 
         }], 

         loading: true 
      }; 

在这里我需要为foo,bar,baz分隔用户定义的颜色。如何在highchart-ng中做到这一点。

回答

3

如果你想为每个用户自定义颜色,你可以修改你这样的代码:

$scope.chartConfig = { 
        options: { 
         chart: { 
          type: 'pie', 
          plotBackgroundColor: null, 
          plotBorderWidth: null, 
          plotShadow: false 

         }, 
         title: { 
          text: 'Status Counts in the Current Stage.' 
         }, 
         plotOptions: { 
          pie: { 
           dataLabels: { 
            enabled: false 
           }, 
           showInLegend: true 
          } 
         } 
        }, 
        series: [{  
         data: [{ 
           name: 'foo', 
           y: 56.33, 
           color: '#E94B3B' 
           }, { 
           name: 'bar', 
           y: 24.03, 
           color: '#8AD5E7', 
           sliced: true, 
           selected: true 
           }, { 
           name: 'baz', 
           color: '#F8C471', 
           y: 10.38 
          }] 
        }], 

        loading: true 
     }; 

的位置例如:

http://jsfiddle.net/69kmnxgj/2/

+0

佐丹奴我都试过,但我添加颜色到该阵列的方案,它不会更改图表中的颜色。 – user3045354

+0

你可以发布你的代码吗? – Giordano

+0

我刚刚将对象更改为此。数据:[ \t \t \t [ '富',10, '#E94B3B'], \t \t \t [ '酒吧',90, '#8AD5E7'], \t \t \t [ '巴兹',100,'# F8C471' ] \t \t \t] – user3045354

相关问题