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

Editing transition animation types | e_scatter_3d #594

Open
MrMisc opened this issue Nov 25, 2023 · 6 comments
Open

Editing transition animation types | e_scatter_3d #594

MrMisc opened this issue Nov 25, 2023 · 6 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@MrMisc
Copy link

MrMisc commented Nov 25, 2023

I have a question regarding transition animations. I have been trying to look through the documentation for this and have been trying out the various options for e-charts documentation and echarts4r documentation, but I am struggling to make transition animations between frames for a 3D scatterplot convincing.

For example

library(echarts4r)
#Brownian motion
# Initialize empty lists for x, y, z coordinates
x_coords <- c()
y_coords <- c()
z_coords <- c()
type<-c()

# Define the spacing
spacing <- 50
max_val <- 400

# Generate the points
for (x in seq(0, max_val, spacing)) {
  for (y in seq(0, max_val, spacing)) {
    for (z in seq(0, max_val, spacing)) {
      x_coords <- c(x_coords, x)
      y_coords <- c(y_coords, y)
      z_coords <- c(z_coords, z)
      type<-c(type,rnorm(1,50,10))
    }
  }
}

len<-length(x_coords)
# Create a data frame with x, y, z coordinates
brown <- data.frame(x = x_coords, y = y_coords, z = z_coords,time = rep(1,length(x_coords)), type = type)
# brown<-data.frame(x = x,y=y,z=z,time = time)

for (i in 0:19){
  addto<-subset(brown,time == i+1)
  print(nrow(addto))
  toadd<-data.frame(x = addto$x+rnorm(len,0,20),y = addto$y+rnorm(len,0,20),z = addto$z+rnorm(len,0,20),time = rep(i+2,len), type = addto$type)
  brown<-rbind(brown,toadd)
}

my_scale <- function(x) scales::rescale(x, to = c(-10,80))

brown = subset(brown, time !=1)
brown|>group_by(time)|>e_charts(x,timeline = TRUE)|>
  e_scatter_3d(y,z, time, type)|>
  # e_visual_map(time,inRange = list(symbolSize = c(30,1)),scale = my_scale,dimension = 3)|>
  # e_visual_map(type,inRange = list(symbol = "diamond",colorLightness = c(0.6,0.9), colorHue = c(0,50),colorSaturation = c(120,200), dimension = 3))|>
  e_visual_map(type,inRange = list(colorLightness = c(0.5,0.8), colorHue = c(100,260),colorSaturation = c(120,200)),dimension = 4,bottom = 300, scale = my_scale, show=FALSE)|>
  e_tooltip()|>
  e_theme("vintage")|>
  # e_x_axis_3d(min = -50,max = 200,interval = 10)|>
  # e_y_axis_3d(min = 0,max = 200,interval = 10)|>
  # e_z_axis_3d(min = 0,max = 200,interval = 10)|>
  e_grid_3d(boxWidth = 100,boxHeight = 100,boxDepth = 100)|>
  e_timeline_opts(autoPlay = TRUE, show = FALSE)|>
  e_animation(duration = 0, delay = 0.0, duration.update = 0.01,easing.update = "quinticOut", delay.update = 0.0)|>
  e_legend(show = TRUE)

But the transition states between the states per frame look as though they are being redrawn from a static starting position, and not FROM the previous positions that the points were at. Is there any option or alternative way to make it happen that way? Thank you for reading!

Additionally, I would just like to point out that for some reason, e_x_axis_3d doesn't seem to work if timeline is activated. Is that intentional?

@rdatasculptor
Copy link
Contributor

rdatasculptor commented Nov 26, 2023

If you make animation time much longer you can see there is kind of transition between states. Although I must admit there seems to be something peculiar going on because it behaves less smoothly than expected.

The problem you mention about the axes not working when timeline is used, I tested it. To me it seems a clear bug. @munoztd0 do you agree?

@munoztd0
Copy link
Collaborator

@rdatasculptor , I agree

@MrMisc MrMisc closed this as completed Nov 28, 2023
@JohnCoene
Copy link
Owner

@MrMisc is this fixed?

@MrMisc
Copy link
Author

MrMisc commented Nov 28, 2023

@MrMisc is this fixed?

Sort of. I am personally seeing some other transition type issues, not just limited to 3d scatterplots, so I was contemplating opening this as a separate issue some other time.

As of right now, this problem can be alleviated by using a slower transition animation like 'sinusoidalIn'. I wouldn't necessarily consider this a full on fix however, since using slightly faster transitions brings about the issue again. For some reason, scatterplot transitions appear to not always follow the previous point's position and animate their path from the previous position to the current position.

@rdatasculptor
Copy link
Contributor

That's because of not being able to use the axis modification, if you could have set min and max it would be solved. (My best guess). So the issue is not solved I would say

@MrMisc
Copy link
Author

MrMisc commented Nov 28, 2023

That's because of not being able to use the axis modification, if you could have set min and max it would be solved. (My best guess). So the issue is not solved I would say

My apologies... I think closing was a mistake then..

@MrMisc MrMisc reopened this Nov 28, 2023
@munoztd0 munoztd0 added bug Something isn't working help wanted Extra attention is needed labels Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants