block by ramnathv d640d4e29755667626f7

Radial Gradient Colors in Highcharts

Full Screen

index.html

<!doctype HTML>
<meta charset = 'utf-8'>
<html>
  <head>
    
    <script src='//code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
    <script src='//code.highcharts.com/highcharts.js' type='text/javascript'></script>
    <script src='//code.highcharts.com/highcharts-more.js"' type='text/javascript'></script>
    <script src='//code.highcharts.com/modules/exporting.js' type='text/javascript'></script>
    
    <style>
    .rChart {
      display: block;
      margin-left: auto; 
      margin-right: auto;
      width: 800px;
      height: 400px;
    }  
    </style>
    
  </head>
  <body >
    
    <div id = 'chart7babbbc148b' class = 'rChart highcharts'></div>    
    <script type='text/javascript'>
    (function($){
        $(function () {
            var chart = new Highcharts.Chart({
 "dom": "chart7babbbc148b",
"width":            800,
"height":            400,
"credits": {
 "href": null,
"text": null 
},
"exporting": {
 "enabled": false 
},
"title": {
 "text": null 
},
"yAxis": [
 {
 "title": {
 "text": "value" 
} 
} 
],
"series": [
 {
 "data": [
 [
 "a",
             1 
],
[
 "b",
             2 
],
[
 "c",
             3 
] 
],
"type": "pie",
"marker": {
 "radius":              3 
} 
} 
],
"legend": {
 "enabled": false 
},
"xAxis": [
 {
 "title": {
 "text": "key" 
},
"categories": [ "a", "b", "c" ] 
} 
],
"subtitle": {
 "text": null 
},
"plotOptions": {
 "pie": {
 "colors":  Highcharts.map(Highcharts.getOptions().colors, function(color) {
  return {
    radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
    stops: [
      [0, color],
      [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
      ]
}})  
} 
},
"id": "chart7babbbc148b",
"chart": {
 "renderTo": "chart7babbbc148b" 
} 
});
        });
    })(jQuery);
</script>
    
    <script></script>    
  </body>
</html>

code.R

library(rCharts)

# Reference: http://www.highcharts.com/demo/pie-gradient
colors = "#! Highcharts.map(Highcharts.getOptions().colors, function(color) {
  return {
    radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
    stops: [
      [0, color],
      [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
      ]
}}) !#"

x <- data.frame(key = c("a", "b", "c"), value = c(1, 2, 3))
h1 <- hPlot(x = "key", y = "value", data = x, type = "pie")
h1$plotOptions(pie = list(colors = colors))
h1