ankane / chartkick

Create beautiful JavaScript charts with one line of Ruby
https://chartkick.com
MIT License
6.33k stars 565 forks source link

Adding prefix/suffix for multi line chart #591

Closed leoplct closed 2 years ago

leoplct commented 2 years ago

I am using a line chart with 2 lines ($) on left-side and 1 line on right side (%) using the code below. How can I add a prefix ($ sign) for each label for the 2 lines and a % suffix for each label on right-side?

I don't see anything the in the library: https://www.chartjs.org/docs/latest/charts/line.html

 settings = {colors: ["#DD7704", "#2E8CB8", "#474747"], library: {scales: {
            yAxes: [
              {
                id: 'cost',
                type: 'linear',
                position: 'left',
                scaleLabel: {display: true, labelString: "spend,sales"},
              },
              {
                id: 'ratio',
                type: 'linear',
                position: 'right',
                scaleLabel: {display: true, labelString: "Ratio"},
                ticks: {
                    suggestedMin: 0,
                    suggestedMax: 100
                }

              }
            ]
          }
        } }.merge(CHART_SETTINGS)

        line_chart(url, **settings)
ankane commented 2 years ago

Hey @leoplct, please use Stack Overflow for help customizing charts.