Reputation: 7390
I am using Chartkick + Chart.js to plot 2 series of different scale ($/% or 0./$ etc.). Using this code it works but the secondary y-asix scale is 0 to 1. I would scale (min/max) to be automatically recognized based on data.
<%=line_chart url_for(action: :chart, metric_left: params[:metric_left], metric_right: params[:metric_right], days: 30, format: :json),
points: false, precision: 2, messages: {empty: "No data"}, library: {
scales: {
yAxes: [
{
id: params[:metric_left],
type: 'linear',
position: 'left',
gridLines: {display: false},
},
{
id: params[:metric_right],
type: 'linear',
position: 'right',
gridLines: {display: false},
}
]
}
}%>
Upvotes: 1
Views: 757
Reputation: 7390
I solved adding the yAxisID in the returned JSON
[{
"dataset": {
"yAxisID": "impressions" <-------
},
"name": "impressions",
"data": {
"2020-03-30": 30846,
"2020-03-31": 34019,
"2020-04-01": 40007,
"2020-04-02": 43751,
...
Upvotes: 1