Skip to content

Instantly share code, notes, and snippets.

@reinholdsson
Created July 2, 2013 16:13
Show Gist options
  • Save reinholdsson/5910699 to your computer and use it in GitHub Desktop.
Save reinholdsson/5910699 to your computer and use it in GitHub Desktop.
Highcharts: Categorical xAxis
library(rCharts)
data <- data.frame(x = LETTERS, y = 1:26)
a <- rCharts:::Highcharts$new()
a$series(data = toJSONArray2(data, json = F, names = F))
a$chart(type = "column")
a$xAxis(type = "category")
a
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href="http://netdna.bootstrapcdn.com/bootswatch/2.3.1/cosmo/bootstrap.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" >
<link rel='stylesheet' href="http://twitter.github.io/bootstrap/assets/js/google-code-prettify/prettify.css">
<link rel='stylesheet' href="http://aozora.github.io/bootplus/assets/css/docs.css">
<script src='http://code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts-more.js' type='text/javascript'></script>
<style>
.rChart {
display: block
margin: auto auto;
width: 100%;
height: 400px;
}
/*
body {
margin-top: 60px;
}
*/
</style>
</head>
<body>
<div class='container'>
<div class='row'>
<div class='span8'>
<div class="bs-docs-example">
<div id='chart5a6f11935b84' class='rChart nvd3Plot highcharts'></div>
<br/>
<pre><code class='r'>library(rCharts)
data &lt;- data.frame(x = LETTERS, y = 1:26)
a &lt;- rCharts:::Highcharts$new()
a$series(data = toJSONArray2(data, json = F, names = F))
a$chart(type = &quot;column&quot;)
a$xAxis(type = &quot;category&quot;)
a
</code></pre>
</div>
</div>
</div>
</div>
<script type='text/javascript'>
(function($){
$(function () {
var chart = new Highcharts.Chart({
"dom": "chart5a6f11935b84",
"width": 800,
"height": 400,
"credits": {
"href": null,
"text": null
},
"title": {
"text": null
},
"yAxis": {
"title": {
"text": null
}
},
"series": [
{
"data": [
[
"A",
1
],
[
"B",
2
],
[
"C",
3
],
[
"D",
4
],
[
"E",
5
],
[
"F",
6
],
[
"G",
7
],
[
"H",
8
],
[
"I",
9
],
[
"J",
10
],
[
"K",
11
],
[
"L",
12
],
[
"M",
13
],
[
"N",
14
],
[
"O",
15
],
[
"P",
16
],
[
"Q",
17
],
[
"R",
18
],
[
"S",
19
],
[
"T",
20
],
[
"U",
21
],
[
"V",
22
],
[
"W",
23
],
[
"X",
24
],
[
"Y",
25
],
[
"Z",
26
]
]
}
],
"chart": {
"type": "column",
"renderTo": "chart5a6f11935b84"
},
"xAxis": {
"type": "category"
},
"id": "chart5a6f11935b84"
});
});
})(jQuery);
</script>
</body>
<!-- Google Prettify -->
<script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/188.0.0/prettify.js"></script>
<script
src='https://google-code-prettify.googlecode.com/svn-history/r232/trunk/src/lang-r.js'>
</script>
<script>
var pres = document.getElementsByTagName("pre");
for (var i=0; i < pres.length; ++i) {
pres[i].className = "prettyprint linenums";
}
prettyPrint();
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment