Solar eclipse path with local timeline (April 8th 2024)

library(dplyr)

gj <- jsonlite::read_json('https://helgasoft.github.io/echarty/test/eclipse.json')
getImage <- function(f) {   # avoid complains about CORS
  return(paste0("data:image/png;base64,", base64enc::base64encode(f)))  
}
ROOT_PATH <- 'https://echarts.apache.org/examples/data-gl/asset/'
globe <- list(
    baseTexture= getImage(paste0(ROOT_PATH, 'earth.jpg')), 
    environment= getImage(paste0(ROOT_PATH, 'starfield.jpg')),
    light= list(main= list(intensity= 0.2), ambient= list(intensity = 0.8)),
    viewControl= list(autoRotate= FALSE, alpha=30)
)
options <- lapply(gj$features[[1]]$geometry$coordinates, \(tt) {
    list(
    series= list(
        list(
            type='scatter3D', coordinateSystem='globe',
          symbol= 'path://M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z',
          symbolSize= c(22, 22),
          itemStyle= list(color= 'gold', opacity= 1),
            data= list(tt)
        )
    ))
})

library(echarty)
ec.init(load='3D', preset=FALSE,
    title= list(text= 'Solar eclipse Apr 8th in local time'),
    toolbox= list(list(right= '10%', feature= ec.util(cmd= 'fullscreen'))),
    globe= globe,
    series= list(
        list(
            type='scatter3D', coordinateSystem='globe',
            data= list(gj$features[[1]]$geometry$coordinates[[1]],
                          gj$features[[1]]$geometry$coordinates[[9]])
        ),
        list(type='lines3D', coordinateSystem='globe',
              polyline= T, blendMode='overlap',
            data= list(list(coords= gj$features[[1]]$geometry$coordinates)),
            lineStyle= list(color='blue', opacity=1, width=11)
        )
    ),
    timeline= list(axisType='time', orient= 'vertical', 
      symbol='diamond', playInterval= 1000, loop= TRUE, autoPlay= T, 
      right= 0, top= 20, bottom= 20,
      width= 55, checkpointStyle= list(borderWidth= 2),
      label= list(formatter= '{HH}-{mm}'),
      data= gj$features[[1]]$properties$coordTimes
    ),
    options= options
)