私の会社のインターンプロジェクトの線図を作成したいと思います。 yAxisで私は命令を欲しい。 xAxisでは月が必要です(1月〜12月)。 xAxisには12個のラベルがあります。私の問題は、最初の12の注文だけがデータから選択されるということです。これをどうすれば解決できますか?同じ問題は1ヶ月です。私はここに説明するためのリンクを置く。 http://imgur.com/a/VJBvj そしてここでは私のコードです:Chart.jsデータ/ラベルスケール
<canvas id="orderChartCurrentMonth" width="400" height="400"></canvas>
<script>
<%= foo = ((Date.today).beginning_of_month) %>
var ctx = document.getElementById("orderChartCurrentMonth");
var orderChartCurrentMonth = new Chart(ctx, {
type: 'line',
data: {
labels: [
"<%=foo %>", "<%=foo + 1.week%>", "<%=foo + 2.week %>","<%=foo + 3.week%>", "<%=foo + 4.week%>"
], //x-Achse
datasets: [{
label: 'Graph Orders last week',
data: <%= (foo..foo.end_of_month).map { |date| Company.graph_order(date).to_f}.inspect %> //y-Achse
}]},
options:{
legend:{
display: false
},
scales: {
xAxes: [{
ticks: {
stepSize: 10
}}]}}})
</script>
挨拶