Skip to content
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

Open
hansvt opened this issue Jan 18, 2021 · 7 comments
Open

add to canvas with a loop #10

hansvt opened this issue Jan 18, 2021 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@hansvt
Copy link

hansvt commented Jan 18, 2021

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

@feddelegrand7
Copy link
Owner

Hi,

it's not working because the canvas id is the same. You need to change it while looping.

Best.

@feddelegrand7
Copy link
Owner

you need also the make sure that left and top are modified in each loop, otherwise you would have shapes that overlap.

@hansvt
Copy link
Author

hansvt commented Jan 18, 2021 via email

@feddelegrand7
Copy link
Owner

Good luck :)

@hansvt
Copy link
Author

hansvt commented Jan 19, 2021 via email

@feddelegrand7
Copy link
Owner

Interesting ... I don't know why it's not working, will check it out.

@feddelegrand7 feddelegrand7 reopened this Jan 19, 2021
@feddelegrand7 feddelegrand7 added the help wanted Extra attention is needed label Jan 19, 2021
@hansvt
Copy link
Author

hansvt commented Jan 20, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants