john.anderson
New Member
Hi everyone, I can't get my custom visual to work in power BI? I have followed the excellent step by step guide from https://stackoverflow.com/questions...plotly-library-in-r-script-visual-of-power-bi
and I was able to get the 'Iris' dataset into my power bi with all the full functionailty of ggplotly working so was stoked...
but when I customise my r.script file to my trial dataset, recreate the pbiviz custom file, import that file and my trial dataset into power bi, then when I drag
the fields into the custom visual template, no visual appears, only an error message, "Error in data.frame(closed, opened, weeks_ago): object 'closed' not found Execution halted"!! The weird thing is, if I just click on R in the visualisation pane, then tick the fields, closed, opened, weeks_ago, R automatically creates
the dataframe, dataset <- data.frame(closed, opened, weeks_ago) and when I add the remaining code below substituting trial with dataset and use the remaining code below (excluding the very last line), I get the visual appearing which is of course non interactive. In summary, why am I getting that error message when trying to create my visual with the ggplotly functionality from my trial dataset?? I will attach my excel trial dataset (use the trial tab) to see if someone can have a go from the link above and succeed. Note, I'm new to power bi and R and I consider this a new post because the topic is about incorporating ggplotly custom visuals into power bi. Look forward to your reply.
My r script is:
and I was able to get the 'Iris' dataset into my power bi with all the full functionailty of ggplotly working so was stoked...
but when I customise my r.script file to my trial dataset, recreate the pbiviz custom file, import that file and my trial dataset into power bi, then when I drag
the fields into the custom visual template, no visual appears, only an error message, "Error in data.frame(closed, opened, weeks_ago): object 'closed' not found Execution halted"!! The weird thing is, if I just click on R in the visualisation pane, then tick the fields, closed, opened, weeks_ago, R automatically creates
the dataframe, dataset <- data.frame(closed, opened, weeks_ago) and when I add the remaining code below substituting trial with dataset and use the remaining code below (excluding the very last line), I get the visual appearing which is of course non interactive. In summary, why am I getting that error message when trying to create my visual with the ggplotly functionality from my trial dataset?? I will attach my excel trial dataset (use the trial tab) to see if someone can have a go from the link above and succeed. Note, I'm new to power bi and R and I consider this a new post because the topic is about incorporating ggplotly custom visuals into power bi. Look forward to your reply.
My r script is:
Code:
source('./r_files/flatten_HTML.r')
############### Library Declarations ###############
libraryRequireInstall("ggplot2");
libraryRequireInstall("plotly")
libraryRequireInstall("reshape2")
###################Actual code#####################
trial <- data.frame(closed, opened, weeks_ago)
trial <- unique(trial)
names(trial) <- gsub(" ","_",names(trial))
m1 <- min(trial$weeks_ago)
m2 <- max(trial$weeks_ago)
###################################################
data.m <- melt(trial, id.vars='weeks_ago');
####################################################
q <- ggplot(data.m, aes(weeks_ago, value)) + geom_bar(aes(fill = variable),
width = 0.4, position = position_dodge(width=0.5), stat="identity") +
scale_x_reverse(breaks=seq(m1,m2,by=1)) + theme_classic()
############# Create and save widget ###############
p = ggplotly(g);
internalSaveWidget(p, 'out.html');
####################################################
Attachments
Last edited by a moderator: