Skip to content

Commit d91c50e

Browse files
committed
fixing get plotly_credentials
1 parent 3bec320 commit d91c50e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tools/analysis/visualize.r

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ input$x_facet<-"am"
1919

2020
make.ggplot(input)
2121

22-
23-
24-
2522
}
2623

2724
#main convoluted plotting fxn
@@ -725,7 +722,7 @@ list(
725722
#-----------------------------------
726723
#current plotly function is broken;
727724
#not to mention API does not return JSON as promised
728-
signup.plotly<-function (username = NULL, email = NULL, save =TRUE) {
725+
signup.plotly<-function (username = NULL, email = NULL, save =TRUE,...) {
729726
if (is.null(username)) {
730727
user<-strsplit(tempfile(),"\\\\")[[1]]
731728
username<-user[[length(user)]]
@@ -738,22 +735,23 @@ signup.plotly<-function (username = NULL, email = NULL, save =TRUE) {
738735
#wtf why is the response not JSON?
739736
tmp<-jsonlite::fromJSON(rawToChar(res$content))
740737
#get various info
741-
if(save==TRUE) save()
742-
return(list(api_key=tmp$api_key, username=tmp$un,password=tmp$tmp_pw))
738+
plotly_credentials<-list(api_key=tmp$api_key, username=tmp$un,password=tmp$tmp_pw)
739+
if(save==TRUE) save(plotly_credentials,file="plotly_credentials")
740+
return(plotly_credentials)
743741
}
744742

745743
#initialize plotly connection
746-
initialize_plotly<-function(plotly.instance="py"){
744+
initialize_plotly<-function(plotly.instance="py",...){
747745

748746
if(exists(plotly.instance)) return(warning("Plotly instance is already active./n"))
749747

750748
load.cred<-function(file="plotly_credentials"){load(file);return(plotly.credentials)}
751-
plotly.credentials<-tryCatch(load.cred(), error=function(e) {NULL})
752-
if(is.null(plotly.credentials)) {
753-
plotly.credentials<-signup.plotly()
754-
save("plotly.credentials", file="plotly_credentials")
749+
plotly_credentials<-tryCatch(load.cred(), error=function(e) {NULL})
750+
if(is.null(plotly_credentials)) {
751+
plotly_credentials<-signup.plotly(...)
752+
save(plotly_credentials, file="plotly_credentials")
755753
}
756-
return(plotly.credentials)
754+
return(plotly_credentials)
757755
}
758756

759757

0 commit comments

Comments
 (0)