jbkunst / highcharter Goto Github PK
View Code? Open in Web Editor NEWR wrapper for highcharts
Home Page: http://jkunst.com/highcharter/
License: Other
R wrapper for highcharts
Home Page: http://jkunst.com/highcharter/
License: Other
Hi,
I believe hc_add_series_ohlc is not correctly handling intraday xts.
Example:
ProdData <- xts(runif(100,0,1), seq(as.POSIXct("2016-01-04 08:00:00"), as.POSIXct("2016-01-15 08:01:00"), length = 100),tz="GMT");
names(ProdData)<-"Price"
highchart(highstock = TRUE) %>%
hc_add_series_ohlc(to.period(ProdData,period = 'secs',k = 10))
hc
I believe the issue is in hc_add_series_ohlc where your convert to date_to_timestamp and cutoff the time segment. I understand this could be worked around by coverting to JSON but just thought I'd point it out.
Cheers
Hi Joshua
I'm building my highchart from scratch (with hichart() method) to specify each serie the option and i don't find the way to add a zoom and a rangeselector
hc.pap <- highchart() %>%
hc_xAxis(categories = don.pap.sp$date) %>%
hc_add_series(name = names(don.pap.sp)[2], data = don.pap.sp[,2],marker=list(enabled = FALSE),color='#CCCCCC') %>%
hc_zoom ?
hc RangeSelector ?
Thanks
Fabien
hi,
I took the standard xts example :
library("quantmod")
usdjpy <- getSymbols("USD/JPY", src = "oanda", auto.assign = FALSE)
eurkpw <- getSymbols("EUR/KPW", src = "oanda", auto.assign = FALSE)
hc <- highchart(type = "stock") %>%
hc_add_series_xts(usdjpy, id = "usdjpy") %>%
hc_add_series_xts(eurkpw, id = "eurkpw")
Now I want to impose in the navigator below the chart a third xts series
eurusd <- getSymbols("EUR/USD", src = "oanda", auto.assign = FALSE)
How can I reproduce this example : http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/stock/navigator/series-data/ in highcharter ?
Thanks a lot for the wonderful package!
Thanks for all your work on this. I am new to testing out this widget and am impressed. I am trying to adjust the padding around a highchart when it is saved with saveWidget (see http://jsfiddle.net/gRYGn/4/). However, I don't seem to be able to adjust the padding and when I try to it triggers the appearance of the download menu in the upper right corner.
Example code below
mtcars %>%
group_by(cyl) %>%
summarise(ave_mpg = mean(mpg)) -> tmp
highchart(theme = hc_theme_chalk(),
hc_opts = list(marginRight = '200px')) %>% # triggers appearance of download menu and does not adjust margins
hc_title(text = "Example", style = list(color = "#F3F2F2")) %>%
hc_subtitle(text = paste("Example Date", Sys.Date()-1),
style = list(color = "#F3F2F2", fontWeight = "bold")) %>%
hc_xAxis(categories = tmp$cyl) %>%
hc_add_series(name = "mpg", type = "column", color = "#002878", showInLegend = FALSE,
dataLabels = list(align = "center", enabled = TRUE, format = "", color = "#F3F2F2"),
data = tmp$ave_mpg) %>%
hc_tooltip(crosshairs = TRUE, shared = TRUE, valueSuffix = "") %>%
hc_yAxis(title = "mpg", minorGridLineWidth = 0, gridLineWidth = 0, labels = list(format = ""), max = max(tmp$ave_mpg)
)
there is lot of retyping dataframe$var1, dataframe$var2 etc. It would be nice to use the dataframe once and then just refer to the vars for eg. in rbokeh
library(rbokeh)
p <- figure() %>%
ly_points(Sepal.Length, Sepal.Width, data = iris,
color = Species, glyph = Species,
hover = list(Sepal.Length, Sepal.Width))
p
This is a vey inmature idea. The goal is define function to implement in an easy way events without write javascript.
This will be usefull with shiny app, addin etc.
Hi,
Really nice package, appreciate the detailed introduction with the extended examples and incorporating piping
I had some questions:
Does the library support plotting xts directly (like dygrpahs). How would I pass an intraday POSIXct object directly?
Does the library have shiny integration?
Does the library incorporate the new boost module from highcharts?
http://www.highcharts.com/articles/2-news/175-highcharts-performance-boost
Awesome package.
Cheers,
Anthony
Hi, first of all, thanks for this great package. It's very powerful.
However, I encounter an issue related to the encoding in windows. I'm not familiar with htmlwidgets
and not be able to figure out what the problem is. So, I come here to file this issue and hopefully can get the help from you, thanks.
library(magrittr)
r <- data.frame(a = 1:3, b = c("a", "b", "c"))
highcharter::highchart() %>%
highcharter::hc_chart(type = "column") %>%
highcharter::hc_xAxis(categories = r$b) %>%
highcharter::hc_add_series(data = r$a, name = "ๆ็็ฑป")
Error in gsub("</", "\\u003c/", payload, fixed = TRUE) :
invalid multibyte string at '<bb>"<7d>]},"theme":null,"conf_opts":{"global":{"Date":null,"VMLRadialGradientURL":"http =//code.highcharts.com/list(version)/gfx/vml-radial-gradient.png","canvasToolsURL":"http =//code.highcharts.com/list(version)/modules/canvas-tools.js","getTimezoneOffset":null,"timezoneOffset":0,"useUTC":true},"lang":{"contextButtonTitle":"Chart context menu","decimalPoint":".","downloadJPEG":"Download JPEG image","downloadPDF":"Download PDF document","downloadPNG":"Download PNG image","downloadSVG":"Download SVG vector image","drillUpText":"Back to {series.name}","invalidDate":null,"loading":"Loading...","months":["January","February","March","April","May","June","July","August","September","October","November","December"],"noData":"No data to display","numericSymbols":["k","M","G","T","P","E"],"printChart":"Print chart","resetZoom":"Reset zoom","resetZoomTitle":"Reset zoom level 1:1","shortMonths":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct",
devtools::session_info()
> devtools::session_info()
Session info -------------------------------------------------------------------------------
setting value
version R version 3.2.2 (2015-08-14)
system i386, mingw32
ui RStudio (0.99.879)
language (EN)
collate Chinese (Simplified)_People's Republic of China.936
tz Asia/Taipei
date 2016-02-29
Packages -----------------------------------------------------------------------------------
package * version date source
assertthat 0.1 2013-12-06 CRAN (R 3.1.1)
chron 2.3-47 2015-06-24 CRAN (R 3.2.1)
data.table 1.9.7 2015-11-04 Github (Rdatatable/data.table@819ac6f)
DBI 0.3.1.9008 2015-07-17 Github (rstats-db/DBI@f5bd553)
devtools 1.10.0 2016-01-23 CRAN (R 3.2.3)
digest 0.6.9 2016-01-08 CRAN (R 3.2.3)
dplyr 0.4.3.9000 2016-01-06 Github (hadley/dplyr@4f2d7f8)
highcharter 0.2.0 2016-02-25 CRAN (R 3.2.3)
htmltools 0.3 2015-12-29 CRAN (R 3.2.3)
htmlwidgets 0.6 2016-02-29 Github (ramnathv/htmlwidgets@9557407)
jsonlite 0.9.19 2015-11-28 CRAN (R 3.2.3)
lattice 0.20-33 2015-07-14 CRAN (R 3.2.2)
magrittr * 1.5 2014-11-22 CRAN (R 3.1.2)
memoise 1.0.0 2016-01-29 CRAN (R 3.2.3)
purrr 0.2.1 2016-02-16 Github (hadley/purrr@da96161)
quantmod 0.4-5 2015-07-24 CRAN (R 3.2.1)
R6 2.1.2 2016-01-26 CRAN (R 3.2.3)
Rcpp 0.12.3 2016-01-10 CRAN (R 3.2.3)
rlist 0.4.5.1 2015-09-09 CRAN (R 3.2.3)
rstudioapi 0.5 2016-01-24 CRAN (R 3.2.3)
stringi 1.0-1 2015-10-22 CRAN (R 3.2.2)
stringr 1.0.0 2015-04-30 CRAN (R 3.2.0)
tidyr 0.4.1 2016-02-05 CRAN (R 3.2.3)
TTR 0.23-0 2015-07-10 CRAN (R 3.2.1)
viridisLite 0.1.1 2015-12-31 CRAN (R 3.2.3)
xts 0.9-7 2014-01-02 CRAN (R 3.1.1)
zoo 1.7-12 2015-03-16 CRAN (R 3.1.3)
sessionInfo()
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936
[2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_People's Republic of China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] magrittr_1.5
loaded via a namespace (and not attached):
[1] Rcpp_0.12.3 rstudioapi_0.5 devtools_1.10.0 viridisLite_0.1.1
[5] lattice_0.20-33 R6_2.1.2 stringr_1.0.0 TTR_0.23-0
[9] highcharter_0.2.0 dplyr_0.4.3.9000 tools_3.2.2 xts_0.9-7
[13] parallel_3.2.2 quantmod_0.4-5 grid_3.2.2 data.table_1.9.7
[17] DBI_0.3.1.9008 htmltools_0.3 assertthat_0.1 digest_0.6.9
[21] purrr_0.2.1 tidyr_0.4.1 htmlwidgets_0.6 rlist_0.4.5.1
[25] memoise_1.0.0 stringi_1.0-1 jsonlite_0.9.19 chron_2.3-47
[29] zoo_1.7-12
Is it possible to use highcharter with shiny apps? Is there something like 'showOutput()' and 'renderChart()' functions?
How can we show additional variables in tooltips?
Say I have a dataframe with x,y and z.
df <- data.frame(x=c(4,5,6,3),y=c(2,4,3,2),z=c("A","A","A","B"))
x and y are on x and y axis respectively. z is not used in anyway for plotting. Not even as grouping variable. How do I show z variable in the tooltip?
When plotting in e.g. the RStudio Viewer the height of the chart is not updated to reflect the height of the Viewer pane.
Use knitr::image_uri
so you can save (saveWidget
) as widget and don't lose the image if the link broke!
Or we can search for all image sources and change to data URI. This maybe needs discussion.
I cannot set multi-axis with hc_yAxis or hc_xAxis
Please tell me how to solve that.
Thanks very much.
Not sure if you have already looked into this, but one feature I would really appreciate is to be able to generate static chart images:
I think it would be really useful when creating different outputs (pdf or html) in rmarkdown. For example, when rendering a pdf document the package would automatically render a static image instead of an interactive javascript chart.
For an example, see: https://github.com/reinholdsson/test-highcharts-server-side-charts
What do you think about adding this feature to highcharter?
Keep up the good work! :)
In highchart.js, put a if
sentence to verify if already exist a link tag with the font name
Like the themes?
I would like to get back data point indexes (through a window box drawn by the user) into R, do some processing, and update accordingly the highcharter graph. (without redrawing it).
example: I selected "Employed", "Housewife" and "Retired" by drawing a window:
I now want to group these 3 levels into 1, and assign the new level the mean value of the old levels.
Would be glad to contribute to add this feature, if you think it's feasible
This include highcharts, exporting, and boost (no more, no less)
hcboost()? highcharterboost()?
As @MySchizoBuddy recommended (http://jkunst.com/r/presenting-highcharter/#comment-2461558016) it is a good idea write about this.
We can add a function to get the jsonobject to make easy to campare what are you writing in R versus the example to reproduce.
So, will be:
hc_add_theme(
hc_theme_x(colors = cols)
)
instead of:
hc_add_theme(
hc_theme_merge(
hc_theme_x(),
hc_theme(
colors = cols
)
)
)
I installed highcharter package.
all functions are OK! but there is not "hc_add_series_map".
Something like gglpot's theme_set
For future please add stock charting from the highstocks package. It works best for timeseries data. It is like google finance charts
http://www.highcharts.com/stock/demo/
I like some of these https://github.com/cttobin/ggthemr
Hi,
I really like this new package and I'm implementing a graph in Shiny where users can create their own time series with the "draggable point" option from the http://jkunst.com/highcharter/oldindex.html#draggable-points example. I would like to use the "new" datapoints in server.r and also show them in a table. If someone could help me how to return the data points, that would be great.Please find the code below.
Many thanks, Tim
server.r:
data(citytemp, package = "highcharter")
function(input, output) {
hcbase <- reactive({
# hcbase <- function() highchart()
hc <- highchart()
if (input$credits)
hc <- hc %>% hc_credits(enabled = TRUE, text = "Highcharter", href = "http://jkunst.com/highcharter/")
if (input$exporting)
hc <- hc %>% hc_exporting(enabled = TRUE)
if (input$theme != FALSE) {
theme <- switch(input$theme,
null = hc_theme_null(),
economist = hc_theme_economist(),
dotabuff = hc_theme_db(),
darkunica = hc_theme_darkunica(),
gridlight = hc_theme_gridlight(),
sandsignika = hc_theme_sandsignika(),
fivethirtyeight = hc_theme_538(),
chalk = hc_theme_chalk(),
handdrwran = hc_theme_handdrawn()
)
hc <- hc %>% hc_add_theme(theme)
}
hc
})
output$table <-renderDataTable({
#Output from graph
data.table(month=citytemp$month,berlin=citytemp$berlin
,berlin_dragged=citytemp$berlin)#Here I want to use the dragged data. something linke input$highchart$... should do the trick I guess...
})
output$highchart <- renderHighchart({
data(citytemp)
highchart() %>%
hc_chart(animation = FALSE) %>%
hc_title(text = "draggable points demo") %>%
hc_xAxis(categories = month.abb) %>%
hc_plotOptions(
series = list(
stickyTracking = FALSE
),
column = list(
stacking = "normal"
),
line = list(
cursor = "ns-resize"
)
) %>%
hc_add_series(
data = citytemp$berlin,
draggableY = TRUE
)
})
}
ui.r
library("shiny")
library("shinydashboard")
library("highcharter")
library("dplyr")
library("viridisLite")
library("markdown")
library("quantmod")
library("tidyr")
library("ggplot2")
library("treemap")
library("forecast")
library("DT")
rm(list = ls())
dashboardPage(
skin = "black",
dashboardHeader(title = "highcharter", disable = FALSE),
dashboardSidebar(
sidebarMenu(
menuItem("Examples", tabName = "examples", icon = icon("bar-chart"))
)
#,
#div(includeMarkdown("hcterinfo.md"), style = "padding:10px")
),
dashboardBody(
# tags$head(tags$script(src = "js/ga.js")),
# tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "css/custom_fixs.css")),
tabItems(
tabItem(tabName = "examples",
fluidRow(
box(width = 6, highchartOutput("highchart")),
box(width = 6, dataTableOutput("table"))
)
)
)
))
Plot R objects like time series, treemaps a la https://github.com/sinhrks/ggfortify via hchart(x)
.
Obviuosly this functions will use the functions from #7.
Due 405f04a it is necessary rewrite old functions and
deprecate them:
They use same arguments so:
hc_add_serie_scatter <- function(...){
.Deprecated("hc_add_series_scatter")
hc_add_series_scatter(...)
}
FYI
demo("shiny-ex")
triggers this error message:
Error in force(ui) : object 'ui' not found
for the package version on CRAN. (Version I tried downloading from GitHub worked OK).
Error in FUN(X[[i]], ...) :
'options' must be a fully named list, or have no names (NULL)
May be put which value have no name.
Hi everybody
Great package, simplify a lot of work.
Is there a way to add a highchart plugin : the draggable-points.js to higcharter ? Would be great if it's easy.
Thks for help
Fabien
Function to add data to plot from objects, vectors.
hc_add_serie_labels_values
.hc_add_serie_scatter
.hc_add_serie_ts2
.hc_add_serie_xts
. (or better: hc_add_serie.xts
and hc_add_serie.ts
Hi,
Trying to incorporate a symbol into a spline as per
http://www.highcharts.com/demo/spline-symbols
hc <- highchart()
hc <- hc_title(hc, text = "A nice chart")
hc <- hc_add_series(hc, data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2,list(y= 26.5, marker=list(symbol='square'))))
hc
Getting a ".. fully named list.." error, assuming its to do with the list(y= 26.5, segment.
Any ideas?
Sorry for all the notes but I think I found another small issue with hc_add_series_xts
This works as expected.
ProdData <- xts(runif(10000,0,1), seq(as.POSIXct("2016-01-04 08:00:00"), as.POSIXct("2016-01-06 08:11:00"), length = 10000),tz="GMT");
names(ProdData)<-"Price"
highchart() %>%
hc_add_series_xts(Cl(to.daily(ProdData)))
However, changed to intraday does not work
hc_add_series_xts(Cl(to.period(ProdData,period = 'secs',k = 1)))
I imagine this is the same bug as hc_add_series_ohlc
Hello,
First of all, thank you for your package. It is very useful and you made an incredible work.
I would like to know if you are thinking of integrating a brush point functionality. Similar to the one available for base and ggplot2 plots.
I know it is not available in the highchart.js library but it seems like it could be possible to implement it.
Thanks
Add support to more complex objects
I see that you've got a nice vignette file here on GitHub. However, when I download this package using devtools::install_github("jbkunst/highcharter", build_vignettes = TRUE)
your vignette isn't there when I run help(package="highcharter")
.
I've had a similar problem with my own packages at times. I was able to fix this by doing build(vignettes = TRUE)
locally before pushing a commit to GitHub. I was told that if you just use the RStudio build menu command, vignettes to not get built by default (that's to save time during local development)
@royfrancis ask about how have multiples chart in one output.
The code is based in @royfrancis demo app https://roymf.shinyapps.io/highchartrtest/ (using rCharts)
library("shiny")
library("highcharter")
ui <- fluidPage(
selectInput("nplots", "Choose", multiple = TRUE, width = "100%",
choices = c("cars", "mtcars", "iris",
"Puromycin", "ChickWeight")),
fluidRow(
column(12, htmlOutput("hcontainer")),
highchartOutput("hcontainer2", height = "0", width = "0")
# the previous output is hide. This is needed load highcharts/highcharter
# javascript in the app
)
)
server <- function(input, output) {
gethc <- function(dfname = "cars") {
# function to return the chart in a column div
df <- get(dfname)
hc <- highchart(height = 300) %>%
hc_title(text = dfname) %>%
hc_xAxis(title = list(text = names(df)[1])) %>%
hc_yAxis(title = list(text = names(df)[2])) %>%
hc_add_serie_scatter(df[,1], df[, 2]) %>%
hc_add_theme(
list(hc_theme_538(), hc_theme_economist(), hc_theme_darkunica())[sample(1:3, size = 1)][[1]]
)
column(width = 6, hc)
}
output$hcontainer <- renderUI({
# input <- list(nplots = c("cars", "mtcars"))
charts <- lapply(input$nplots, gethc)
do.call(tagList, charts)
})
}
shinyApp(ui = ui, server = server)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.