2017-11-08 1 views
0

時間軸の言語を変更する方法がわかりません。私は月に 'MMM'を使用していますので、その月の短い説明がありますが、オランダ語には分かりません。私は間違って何をしていますか?ChartJS:月時間軸をオランダ語に翻訳する

5月の代わりにメイがあるはずです。

これは私が使用しているスクリップです:

moment.locale('nl'); 

var lvlC = document.getElementById("levelChart").getContext("2d"); 
var levelChart = new Chart(lvlC, { 
    type: "line", 
    data: { 
    datasets: [ 
     { 
     label: "Levels", 
     data: [ 
      { 
      x: '2017-01-01', 
      y: 10 
      }, 
      { 
      x: '2017-02-15', 
      y: 20 
      }, 
      { 
      x: '2017-06-01', 
      y: 30 
      }, 
      { 
      x: '2018-10-01', 
      y: 40 
      } 
     ], 
     backgroundColor: ["rgba(0, 197, 161, 0)"], 
     borderColor: ["rgba(0,197,161,1)"], 
     borderWidth: 1, 
     steppedLine: true 
     } 
    ] 
    }, 
    options: { 
    legend: { 
     display: false 
    }, 
    elements: { 
     point: { 
     radius: 0 
     } 
    }, 
    scales: { 
     xAxes: [ 
     { 
      type: "time", 
      distribution: 'series', 
      time: { 
      unit: "month", 
      displayFormats: { 
       month: "MMM" 
      }, 
      }, 
      scaleLabel: { 
      display: false, 
      labelString: "Date" 
      }, 
      gridLines: { 
      drawBorder: false 
      }, 
      ticks: { 
     autoSkip: true, 
     maxTicksLimit: 6 
    } 
     } 
     ], 
     yAxes: [ 
     { 
      ticks: { 
      display: false, 
      beginAtZero: true 
      }, 
      gridLines: { 
      drawBorder: false, 
      display: false 
      } 
     } 
     ] 
    } 
    } 
}); 

を私はすべての情報はここで見つけることができますので、codepenにこれに取り組んでいます: https://codepen.io/anon/pen/JObzZZ?editors=0010

答えて

0

あなたは

ticks: { 
    callback: function(value, index){    
     return moment.monthsShort(index % 12, "MMM"); 
    } 
} 
を使用することができます

ticksコールバックオプションとして使用します。

関連する問題