score:17
there are two ways to get this working. the first way is to add h1$set(dom = "mychart")
in your server.r
. this is required so that both server.r
and ui.r
are communicating about the correct chart. the alternative is to use renderchart2
, which is in the dev
branch of rcharts
, that is a upgraded version of renderchart
and will eventually replace it. i am attaching the entire code for everyone's benefit.
require(rcharts)
require(shiny)
runapp(list(
ui = pagewithsidebar(
headerpanel("rcharts: highcharts"),
sidebarpanel(selectinput(
inputid = "x",
label = "choose x",
choices = c('sepallength', 'sepalwidth', 'petallength', 'petalwidth'),
selected = "sepallength"
)),
mainpanel(showoutput("mychart", "highcharts"))
),
server = function(input, output){
output$mychart <- renderchart2({
h1 <- highcharts$new()
h1$chart(type = "spline")
h1$series(data = c(1, 3, 2, 4, 5), dashstyle = "longdash")
h1$series(data = c(na, 4, 1, 3, 4), dashstyle = "shortdot")
h1$legend(symbolwidth = 80)
return(h1)
})
}
))
score:2
this is most likely due to the fact that rcharts
is javascript
based on there are strong incompatibilities between r
variable names and javascript
allowed variable names. specifically with regards to dots .
in names.
try running the following function on the data.frame
names and any character
columns:
nodot <- function(x)
gsub("\\.", "_", gsub("^\\.", "", x) )
ie:
names(df) <- nodot(names(df))
# and
char.cols <- sapply(df, function(x) any(is(x)=="character"))
df[, char.cols] <- sapply(df[, char.cols], nodot)
# note that this has not been tested
Source: stackoverflow.com
Related Query
- rCharts with Highcharts as shiny application
- rCharts and highcharts with shiny plot does not update correctly
- Highcharts - Global configuration with common code and unique data & Headings
- Highcharts 3D with rCharts
- rCharts shows limited functionality when used with Shiny 0.8.0.99
- passing formatting JavaScript code to HighCharts with JSON
- Highcharts series visibility with csv data source
- Pyramid chart in rCharts with Highcharts
- How to have multiple highcharts with different series data in vuejs without repeating code
- rCharts : Highcharts column with color based on value
- How to use Highcharts theme with rCharts
- Why code of Horizonal line(y-axis) on a single in Highcharts get applied to all other charts integrated with Webdatarocks
- Highcharts cloud issue with data source when duplicating chart
- Getting numbers on Y-axis to show up as percentages with code from a Highcharts code generator tool?
- Highcharts code with same set of code/data works in PHP but does not work in JSfiddle
- Reload chart data via JSON with Highcharts
- Highcharts - how to have a chart with dynamic height?
- Resize height with Highcharts
- Styling bar colors in Highcharts with a gradient issue
- How to use highcharts with angular 5?
- Loading Highcharts with require.js
- dealing with highcharts bar chart with really long category names
- Handling unix timestamp with highcharts
- Displaying hours and minutes on x-axis with Highcharts
- Highcharts - Keep Zero Centered on Y-Axis with Negative Values
- Resize data points with highcharts
- How to include highcharts with bower?
- Highcharts doesn't display series with lots of data points
- HighCharts - two Y-axis, one with max value
- how to import highcharts with webpack and babel
More Query from same tag
- HighCharts show/hide data points
- How to make - - legend in 'areaspline' type high charts?
- Is it better to update a Highcharts chart or destroy and recreate it?
- UseHTML=True in legend ignores itemWidth on click
- Sorting a group based on value
- Highcharts - multiple charts
- Highchart Line and Range
- HIghcharts: Hide particular Bar in Bar chart
- how can I make highstock flags stay put
- How to show difference in scatter chart with plots at same position in highchart
- Can I have a chart automatically size the height (rather than using 400px) using the Highcharts .NET Wrapper?
- Always show "0" value in Stacked Column Chart
- How do I manage the imports in Angular correctly?
- Highcharts border curve inside
- Highcharts - Make text inside pie chart responsive
- how to change highstock date to persian date
- Exporting several HighCharts graphs to Powerpoint slides
- How to modify Negative Axis Bar Graph in Highcharts?
- Align label and the marker on the same vertical line(Highcharts)
- Highchart fill area only between two series
- Having trouble just getting the Highchart to show
- Iterating through JSON structure matching criteria
- the picture from highcharts in the PDF made by html2canvas is blurry?
- Showing arrays in an array in tooltip in Highcharts
- Highcharts tooltip overlapped by absolute positioned element
- Highcharts adding new data points in VueJS / Vuex
- Synchronize two highcharts to drill down at once
- Issue with Spider HighChart as it is showing as a line chart sometimes
- Disabled points not hide. [Highcharts]
- Highcharts remove theme background before printing