Remove legend from rChart - r

I am using rCharts library in a Shiny application and want to remove the right side legend.
The tips I found did not work in this case...
for example: p1$chart(showLegend = FALSE)
My code is similar to this one:
library(rCharts)
mydata<-data.frame(weekday=c("friday","monday","thursday","tuesday","saturday","sunday","wednesday"),value=rnorm(7,10,2))
p1<-rPlot(value ~ weekday, color = 'weekday', data = mydata, type = 'bar')
p1$guides(
color = list(
numticks = length(unique(mydata$weekday))
),
x = list(title="",
ticks = c('sunday', 'monday', 'tuesday','wednesday','thursday','friday','saturday'),
labels ="",
levels = c('sunday', 'monday', 'tuesday','wednesday','thursday','friday','saturday')
),
y = list(title=""
)
)
p1$chart(showLegend = FALSE)
p1

I solved the problem using the following code line:
p1$set(legendPosition = "none")

Related

I am trying to figure out how to create custom tooltips that show up when hovering over an axis label in highcharter in R

This jsfiddle example shows what I am trying to do in highcharter in r:
http://jsfiddle.net/key2xanadu/zfsfz0c9/
Here is a very simple example that I am trying to get to work in R:
x <- c(0,1)
y <- c(29.9, 71.5)
data <- cbind(x,y)
data <- as.data.frame(data)
data %>%
hchart('line', hcaes(x = x, y = y)) %>%
hc_xAxis(
labels = list(
enabled = TRUE,
categories = c('one', 'two'),
formatter = JS("function(){
$('document').ready(function () {
$('#text_title').tooltip({placement: 'bottom', title:'HELLO TITLE!'});
$('#label_one').tooltip({placement: 'bottom', title:'HELLO ONE!'});
$('#label_two').tooltip({placement: 'bottom', title:'HELLO TWO!'});
});
}"
),
useHTML = TRUE
)
)
I am missing something though because it is not showing the xaxis labels or a tooltip that I want to show up when I hover. Any insight would be so much appreciated!

rCharts rnvd3 not rendering correctly in shinydashboard

I am trying to add a rChart and nvd3 plot a shiny dashboard.
However only the top part of the graph shows. and does not even fill the panel which is created.
my code ui code is
showOutput("myPlot")
I have also tried to alter it using the following
div(class='wrapper', tags$style(".Nvd3{ height: 700px;}"),
showOutput("myPlot"))
but all this seems to do is create a box the same colour as the shiny dashboard side bar.
My server code #
output$myPlot<- renderChart({
plotdataukv <- nPlot(verifiedUsers ~ date, group="group", data = myData, type = 'lineChart', dom = 'myPlot')
plotdataukv$xAxis(axisLabel = 'Time (Days)', tickFormat="#!function(d) {return d3.time.format('%d/%m/%Y')(new Date( d * 86400000 ));}!#", rotateLabels=-90 )
plotdataukv$yAxis(axisLabel = 'My Metric')
plotdataukv$chart(color = c('blue', 'red'))
return(plotdataukv)
})
Code:
output$myPlot<- renderChart({
plotdataukv <- nPlot(verifiedUsers ~ date, group="group", data = myData, type = 'lineChart', dom = 'myPlot')
plotdataukv$xAxis(axisLabel = 'Time (Days)', tickFormat="#!function(d) {return d3.time.format('%d/%m/%Y')(new Date( d * 86400000 ));}!#", rotateLabels=-90 )
plotdataukv$yAxis(axisLabel = 'My Metric')
plotdataukv$chart(color= c('blue', 'red'))
plotdataukv$set(dom = 'myPlot')
return(plotdataukv)
})
showOutput("myPlot", "nvd3")
I hope the above code is working properly..

Why aren't event.lines showing up when using chart.TimeSeries?

I am trying to plot various events over a times series data set using chart.TimeSeries in the PerformanceAnalytics library. I have tried to follow the example from but I think I am missing something.
ExampleChart MyChart
Neither my vertical event lines nor are my period areas are showing up on the chart. My code is almost identical to the example code. Any ideas?
risk.dates = c(
"2015-04-19"
)
risk.labels = c(
"Jon Oliver's Patent Episode "
)
cycle.dates <- c ("2015-1-01/2015-01-31",
"2015-03-01/2015-03-31",
"2015-05-01/2015-05-31",
"2015-07-01/2015-07-31"
)
chart.TimeSeries(df, colorset = "darkblue",
date.format.in = "%Y-%m-%d",
legend.loc = NULL,
period.areas = cycles.dates,
period.color = "lightblue",
event.lines = risk.dates,
event.labels = risk.labels,
event.color = "red", lwd = 2,
main = "Reddit Sentiment Index",
auto.grid = FALSE)
df <- data.frame(DateTime=
c("2/17/2015","2/18/2015","2/19/2015",
"2/20/2015","2/21/2015","2/22/2015",
"2/23/2015","2/24/2015","2/25/2015",
"2/26/2015","2/27/2015","2/28/2015",
"2/28/2015","2/27/2015"),
AvgSentimentScore=
c("NA","NA","NA","NA","NA","NA","NA","NA","NA",
"8.405975696","8.313470536","8.414560335",
"8.720865075","9.284902246"))

Set title in dPlot / R

I'm trying to set a title in my dPlot using rCharts:
library(rCharts)
a <- data.frame(dat=0,count=0)
t <- dPlot(
x = "dat",
y = "count",
data = a,
type = "line",
height = 400,
width = 700,
bounds = list(x=50,y=20,width=650,height=300)
)
t$templates$script = "http://timelyportfolio.github.io/rCharts_dimple/chartWithTitle.html"
t$set( title = "No Data found" )
t
Unfortunately, the suggested work around here doesn't work. Can someone help? Thanks.

rcharts dimple bubble chart in shiny

Using a variation of the below example dimple chart, how can I get this to auto scale with Shiny bootstrap without having to hard code height and width of the chart?
#get data used by dimple for all of its examples as a first test
data <- read.delim(
"http://pmsi-alignalytics.github.io/dimple/data/example_data.tsv"
)
#eliminate . to avoid confusion in javascript
colnames(data) <- gsub("[.]","",colnames(data))
#example 27 Bubble Matrix
d1 <- dPlot(
x = c( "Channel", "PriceTier"),
y = "Owner",
z = "Distribution",
groups = "PriceTier",
data = data,
type = "bubble",
aggregate = "dimple.aggregateMethod.max"
)
d1$xAxis( type = "addCategoryAxis" )
d1$yAxis( type = "addCategoryAxis" )
d1$zAxis( type = "addMeasureAxis", overrideMax = 200 )
d1$legend(
x = 200,
y = 10,
width = 500,
height = 20,
horizontalAlign = "right"
)
d1
Hi you have to put width="100%" in dplot(), like this :
d1 <- dPlot(
x = c( "Channel", "PriceTier"),
y = "Owner",
z = "Distribution",
groups = "PriceTier",
data = data,
type = "bubble",
aggregate = "dimple.aggregateMethod.max",
width="100%"
)

Resources