Search code examples
ruby-on-railsrubychartkick

How do i stop chartkick from showing the X-axis date (ruby on rails)


first time at stackoverflow.

it shows a date of every point in the graph under the x-axis. can someone help me removing it?

 <%= area_chart website.pings.limit(5).order(created_at: :desc).pluck(:created_at, (:ms)),
 width: "70x", height: "130px", messages: {empty: "No Ping made yet"}, curve: false, refresh: 10 %>

https://i.sstatic.net/e8zQS.jpg


Solution

  • Checkout this issue as wel. As it implies with your issue. How to hide axis using Chartkick.js

    And Chartkick also has options that you can chance if you follow the documentation: Chartkick website

    So when combining the answers you would have to add this to your code:

    <%= area_chart website.pings.limit(5).order(created_at: :desc).pluck(:created_at, (:ms)),
     width: "70x", height: "130px", messages: {empty: "No Ping made yet"}, 
    curve: false, refresh: 10, library: { scales: { xAxes: [{ display: false }] } } %>
    

    With library: { scales: { xAxes: [{ display: false }] } } you can add options, and the scales are the x and y scales where you can change the options of too.

    Checkout the full API here: Full Chartkick API