Code Monkey home page Code Monkey logo

Comments (4)

motassimbakali avatar motassimbakali commented on May 22, 2024 1

Thank you very much! I will use that way and close this issue.

from echarts4r.

JohnCoene avatar JohnCoene commented on May 22, 2024

I cannot reproduce the issue.

Say we plot something clearer first.

df <- data.frame(
  x = 1:10,
  y = 1:10
)
df %>% 
  e_charts(x) %>% 
  e_line(y) %>% 
  e_tooltip(
    trigger = "axis"
  )

You shouldn't see any boundary gap. Now say we plot your example again, but with tighter boundaries to our graph.

min <- min(mtcars$wt)
max <- max(mtcars$wt)

mtcars %>% 
  e_charts(wt) %>% 
  e_area(qsec) %>% 
  e_x_axis(
    min = min,
    max = max
  ) %>% 
  e_tooltip(trigger = "axis")

The documentation for boundaryGap actually states that the parameter works differently for numerical and categorical data:

  • For numerical continuous data pass a vector
  • For categorical data pass TRUE or FALSE
mtcars %>% 
  e_charts(wt) %>% 
  e_area(qsec) %>% 
  e_x_axis(
    boundaryGap = c("50%", "50%") # add boundary gap
  ) %>% 
  e_tooltip(trigger = "axis")

If you have categorical:

df <- data.frame(
  x = LETTERS[1:4],
  y = runif(4, 1, 3)
)

df %>% 
  e_chart(x) %>% 
  e_bar(y) %>% 
  e_x_axis(
    boundaryGap = FALSE 
  )

So generally speaking you want to use boundaryGap depending on the data you have and the plot you are trying to create.

Let me know if this helps.

from echarts4r.

motassimbakali avatar motassimbakali commented on May 22, 2024

Thank you very much for your quick reply! All seems to work very well and I can use the tool_tip as well when using "axis".

However, if I change the e_tooltip to "item" instead of "axis", I do not get the tooltip for the maximum x-value. So for your first example:

df <- data.frame(
  x = 1:10,
  y = 1:10
)
df %>% 
  e_charts(x) %>% 
  e_line(y) %>% 
  e_tooltip(
    trigger = "item"
  )

This doesn't give me a tooltip at x = 10. Do you know what the reason is behind this?

from echarts4r.

JohnCoene avatar JohnCoene commented on May 22, 2024

Indeed.

Well this is when you could, for instance, use boundaryGap.

# initialise chart
df <- data.frame(
    x = 1:10,
    y = 1:10
)
df %>% 
    e_charts(x) %>% 
    e_line(y) %>% 
    e_tooltip(
        trigger = "item"
    ) %>% 
    e_tooltip(trigger = "item") -> p

Using boundaryGap - a vector for continuous data, as mentioned above.

p %>% e_x_axis(boundaryGap = c(0, .1))

Or min and max

p %>% e_x_axis(min = 0, max = 12)

And there are probably other ways I'm unaware of.

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.