Highcharts is another way to represent the data manually. Highcharts
is a charting library which is written in pure JavaScript language. Basically
it provides an easy way of adding interactive charts to your website or web
application. Highcharts is a product that was created by the Norway-based
company, Highsoft.
Currently it supports many types of charts like line, spline,
area, areaspline, column, bar, pie, scatter, and so on.
Advantage:
·
You can create or modify themes to customize the charts
beautifully.
·
Lots of function like tooltips, titles, credits, legends, etc.
·
Provide various chart type with same
style scatters, bubble, line, time series, bar graphs, and Heatmaps etc.
·
Piping Style
·
Configure your charts in different ways using themes. There are
inbuilt themes provide by highcharter package like
economist, financial times, google, 538
among others.
·
Plugins: motion, drag points,
fontawesome, url-pattern, annotations.
Disadvantage:
- · Faceting is not possible in High charts
- · It uses standard evaluation plot(data$x, data$y) instead something like plot(data, ~x, ~y).
In this post we are going to plot interactive combo high
charts in R using rcharts package. In this tutorial we are also using shiny
package of R. This package is mostly used to create web application using R
language.
As you know in shiny package we have two files (ui.R and
server.R). Firstly we try to create a user interface file.
ui.R
library(shiny)
## Create Data
Tokyo
<- c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5,
23.3, 18.3, 13.9, 9.6)
NewYork <-
c(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0,
24.8, 24.1, 20.1, 14.1, 8.6, 2.5)
Berlin <- c(-0.9,
0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0)
London <- c(3.9,
4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8)
## Define UI for application that
draws a Combo Graph
shinyUI(fluidPage(
# Application title
titlePanel("Monthly
Average Temperature"),
# Show a plot
mainPanel(
showOutput("Graph",
"Highcharts")
)))
|
After created a ui.R
script, now come to server.R file.
server.R
library(shiny)
library(highcharter)
# Define server logic required to
draw a Combo graph
shinyServer(function(input, output) {
# High Chart code for Plotting the
Combo Graph
output$Graph
<- renderChart({
h1 <- Highcharts()
# Tokyo Line Graph
h1$series(data = Tokyo, type='spline', name='Tokyo')
# New York Line Graph
h1$series(data = NewYork, type='spline', name='New York')
# Berlin Line Graph
h1$series(data = Berlin, type='spline', name='Berlin')
# London column Graph
h1$series(data = London, type='column', name='London')
# Set Legend Layout
h1$legend(layout='vertical',align='right',verticaAlign='top',borderWidth=0)
# Add xAxis label in a graph
h1$xAxis(categories=c('Jan', 'Feb',
'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))
h1$set(dom='Graph')
h1
})
})
|
There are lots of things and options to do with high charts. You
can refer this link Highcharts
options to get more information about function in Highcharts.
When you save both file and click on RunApp button, you will get same output as you see in below image.
When you will go to any point then it will show to the
information regarding to that point. You can also visit http://www.highcharts.com/demo/ website to take demo for interactive high
charts.
Highcharts gives superb web design with high adaptability, and the highcharter package permits R clients to take full advantage of them. In case you're keen on discovering more about the usefulness of the package, I very prescribe perusing the highcharter package homepage page which contains an different variety of Highcharts, Highstock and Highmaps plots alongside test code to recreate them.
Highcharts gives superb web design with high adaptability, and the highcharter package permits R clients to take full advantage of them. In case you're keen on discovering more about the usefulness of the package, I very prescribe perusing the highcharter package homepage page which contains an different variety of Highcharts, Highstock and Highmaps plots alongside test code to recreate them.
No comments:
Post a Comment