-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add to canvas with a loop #10
Labels
help wanted
Extra attention is needed
Comments
Hi, it's not working because the canvas id is the same. You need to change it while looping. Best. |
you need also the make sure that left and top are modified in each loop, otherwise you would have shapes that overlap. |
Great, I will do that. I tried to update the left and top, and I think I
tried to update the ID , but I guess that this didn’t work as it should.
I will try again and let you know if this solves it.
Many thanks for your response!
Hans
Op ma 18 jan. 2021 om 19:41 schreef Ihaddaden Mohamed El Fodil <
[email protected]>
… you need also the make sure that left and top are modified in each loop,
otherwise you would have shapes that overlap.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASQKDNFD6MIAZXMYVL3VZ2DS2R6GZANCNFSM4WHUMFEA>
.
|
Good luck :) |
Hi,
Probably I do something wrong, but when I create the most simple app I can
think of. And try to loop through a vector and print text on the canvas in
that loop it fails...
I just see the text I initially put on the canvas, and not the text that I
add later in the loop.
See below the code I use:
library(shiny)
library(fabricerin)
# create input data
visits <- c("Visit 1", "Visit 2", "Visit 3", "Visit 4", "Visit 5")
leftpos <- 200
n <- 1
ui <- fluidPage(
fabric_text(cid = "canvaId", # canvas id
cwidth = 800, # the width of the canvas
cheight = 700, # the height of the canvas
textId = "text_visith",
text = "Visit",
fontSize = 20,
left = 100, # the position of the shape from the left
relative to the canvas
top = 50
),
for (visit in visits) {
print(n)
print(leftpos)
id <- paste0("visitID",n)
print(id)
fabric_text_add(cid = "canvaId",
textId = id,
text = visit,
fontSize = 20,
left = leftpos, # the position of the shape from the
left relative to the canvas
top = 50)
n = n + 1
leftpos = leftpos + 100
}
)
server <- function(input, output){}
shinyApp(ui, server)
thanks,
Hans
Op ma 18 jan. 2021 om 22:05 schreef Ihaddaden Mohamed El Fodil <
[email protected]>:
… Good luck :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASQKDNAKFNGURIWAR4WP4MLS2SPARANCNFSM4WHUMFEA>
.
|
Interesting ... I don't know why it's not working, will check it out. |
I did some further exploration and it looks like this issue occurs because
of the missing comma between the different 'fabric_add' functions.
I just don't know how to solve this.
When I do several 'if statements' instead of the for loop it does work. But
having to specify if statements for every potential length of the vector is
not really a good idea of course.
Op di 19 jan. 2021 om 10:43 schreef Ihaddaden Mohamed El Fodil <
[email protected]>:
… Interesting ... I don't know why it's not working, will check it out.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASQKDNB332OCTFG62WBOZ6LS2VH2JANCNFSM4WHUMFEA>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
How can I add objects to the canvas in a loop?
Let say I have a logics: <- c(TRUE, FALSE, TRUE)
and I want to add a shape to the canvas if logic is TRUE.
When I try to do something like this in my UI then nothing is displayed:
for (logic in logics) {
if (logic== TRUE) {
fabric_shape(cid = "canvaId",
shapeId = "shape1",
shape = "Rect",
left = 130,
top = 200)
}
}
I am new at R programming, but I can't see why this doesn't work..
thanks,
Kind regards,
Hans
The text was updated successfully, but these errors were encountered: