Search code examples
ruby-on-railsgoogle-visualizationchart.jsbar-chartchartkick

Can't change labels' font color. Chartkick Ruby on rails


I am trying to display a bar chart with legends and labels in white, so i tried this code below on my view, but it didn't do nothing, and my continues displaying the default color.

      <%= bar_chart opfh, height: "150px", width: "450px", library: {chartArea: {top: 50,right: 50,bottom: 15,left: 130}, legend: { position: "left", labels: { fontSize: 16, backgroundColor: "none", fontColor: "#fff"} }, colors: ["#0526FF", "#FFFFFF"]} %>

Is there no way to solve this issue?

This is how my chart looks

This is how my chart looks

Edit: Thanks to @WhiteHat answer i cold resolve this! Actually i was trying to change vAxis colors instead


Solution

  • assuming you're creating a BarChart from Google Charts,
    see the configuration options...

    for the legend, need to use --> legend.textStyle -- (not legend.labels)
    and the following options do not exist...

    legend.textStyle.backgroundColor
    legend.textStyle.fontColor
    

    for font color, use --> color

    legend: { position: "left", textStyle: { fontSize: 16, color: "#fff"} }