ruby-on-railschartkick

How to setup logarithmic axis for line chart in rails chartkick?


Is there way to setup log axis using chartkick and default chart.js library?


Solution

  • Yes, you can pass the axis options using 'library' option like this:

    <%= line_chart data, {
        library: {
            legend: {
                position: 'bottom',
            },
            scales: {
                yAxes: [
                    {
                        id: 'y-axis',
                          type: 'logarithmic'
                    },]
            }
        }
    } %>
    

    For more options please consult with chart.js docs.