Last active
August 29, 2015 14:08
-
-
Save ramnathv/d640d4e29755667626f7 to your computer and use it in GitHub Desktop.
Radial Gradient Colors in Highcharts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment