Code Monkey home page Code Monkey logo

Comments (2)

JohnCoene avatar JohnCoene commented on May 23, 2024 1

I think I came up with a reasonable solution. Use the functions as you would before, however, extract the year from the dates to plot then group the data by

dates <- seq.Date(as.Date("2017-01-01"), as.Date("2018-12-31"), by = "day")
values <- rnorm(length(dates), 20, 6)

year <- data.frame(date = dates, values = values)

year %>% 
  dplyr::mutate(year = format(date, "%Y")) %>% 
  dplyr::group_by(year) %>% 
  e_charts(date) %>% 
  e_calendar(range = "2017",top="40") %>% 
  e_calendar(range = "2018",top="260") %>% 
  e_heatmap(values, coord.system = "calendar") %>% 
  e_visual_map(max = 30) %>% 
  e_title("Calendar", "Heatmap")%>%
  e_tooltip("item") 

If you lay the calendars before running e_heatmap then the function will apply the data to its corresponding calendar, however if you add the calendars (e_calendar) afterwards then you will have to specify the index of calendar index (as in the previous example).

dates <- seq.Date(as.Date("2017-01-01"), as.Date("2018-12-31"), by = "day")
values <- rnorm(length(dates), 20, 6)

year <- data.frame(date = dates, values = values)

year %>% 
  dplyr::mutate(year = format(date, "%Y")) %>% 
  dplyr::group_by(year) %>% 
  e_charts(date) %>% 
  e_heatmap(values, coord.system = "calendar", 
    calendar = c(0 ,1)  # pass calendar indices
  ) %>% 
  e_calendar(range = "2017",top="40") %>% 
  e_calendar(range = "2018",top="260") %>% 
  e_visual_map(max = 30) %>% 
  e_title("Calendar", "Heatmap")%>%
  e_tooltip("item") 

Let me know if that works for you.

from echarts4r.

JohnCoene avatar JohnCoene commented on May 23, 2024

The API for the heatmap/calendar is a bit clunky, I'll work on improving that. The solution to what you want to achieve is over at #31.

from echarts4r.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.