chartkick chart.js 更改轴的颜色和轴标题的颜色
chartkick chart.js change colour of axis and colour of axis title
在我的 rails 应用程序中,我添加了一些图表并希望将颜色从黑色更改(见图)。
这是我认为的代码:
<%= 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 %>
图表颜色正确,但轴标题是黑色,轴也是黑色。
好吧,好像是chartkick with chart.js has some limitations. So I switch to google charts。
我删除了 application.html.erb 和 application.js 中的 chart.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"} } } %>
希望对大家有所帮助。
在我的 rails 应用程序中,我添加了一些图表并希望将颜色从黑色更改(见图)。
这是我认为的代码:
<%= 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 %>
图表颜色正确,但轴标题是黑色,轴也是黑色。
好吧,好像是chartkick with chart.js has some limitations. So I switch to google charts。
我删除了 application.html.erb 和 application.js 中的 chart.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"} } } %>
希望对大家有所帮助。