This is a near exact replica of the morris.js getting started tutorial. All credit and attribution should be directed there. See the copyright and license at the end of this page.
The original tutorial says, "Add morris.js and its dependencies (jQuery & Raphael) to your page." Fortunately for us, rCharts handles this for us, and slidify can access this rCharts' brilliance through the ext_widgets: {rCharts: "libraries/morris"}
line in the header of this markdown. The config.yml in the morris directory performs the magic.
Instead of the <div>
and <script>
in the original tutorial, we will build this chart all with the R code below. You should notice a lot of similarity.
#if you have not installed slidify, slidifyLibraries, or rCharts
#require(devtools)
#install_github('slidify', 'ramnathv', ref = 'dev')
#install_github('rCharts', 'ramnathv')
#install_github('slidifyLibraries', 'ramnathv', ref = 'dev') # optional
require(rCharts)
#specify the data
data = data.frame(
c('2008', '2009', '2010', '2011', '2012'),
c(20,10,5,5,20),
stringsAsFactors = FALSE
)
colnames(data) <- c("year","value")
#build the plot
m1 <- mPlot(
x = "year",
y = "value",
data = data,
type = "Line"
)
m1$set( labels = "value" )
m1
Check out the rest of the documentation (which we will also eventually replicate using rCharts):
Also, check out Ryan Bates's excellent RailsCast #223 Graphs and Charts (note:requires subscription).
Simplified BSD License:
Copyright (c) 2013, Olly Smith
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.