代码之家  ›  专栏  ›  技术社区  ›  mamesaye

chartkick图表。js更改轴的颜色和轴标题的颜色

  •  1
  • mamesaye  · 技术社区  · 7 年前

    在我的rails应用程序中,我添加了一些图表,并希望更改黑色的颜色(见图)。
    enter image description here

    以下是我认为的代码:

    <%= line_chart $tweet_per_day, id: "line_chart $tweet_per_day", width: "400px", height: "300px", ytitle: "Tweets count", ytitleFontColor: ["pink", "#F76161"], colors: ["blue", "#76BDD1"], download: "top_hashtags", refresh: 60 %>  
    

    图表颜色正确,但轴标题为黑色,轴也是黑色。

    1 回复  |  直到 7 年前
        1
  •  1
  •   mamesaye    7 年前

    好吧,看起来 chartkick 具有 chart.js 有一些 limitations . 所以我切换到 google charts .
    我删除了图表。我的应用程序中的js代码。html。erb和应用。js并将其替换为 google chart code .
    更改折线图的步骤 this page 很有帮助。
    以下是我眼中的工作代码:

    <%= line_chart $tweet_day, id:"line_chart $tweet_day",xtitle: "Day of the Week", ytitle: "Tweets Count", colors: ["#C2F4FF"], download: "tweet_day", refresh: 60, 
      library: { 
        vAxis: { baselineColor: "#F76161",  gridlines: {Color: "" }, textStyle: { color: "#76BDD1"}, titleTextStyle: {color: "#F76161"} }, 
        hAxis: { baselineColor: "#F76161" , gridlines: {Color: "" }, textStyle: { color: "#76BDD1"} , titleTextStyle: {color: "#F76161"} } } %>   
    

    希望它能帮助别人。