こんにちは。
JS初心者なのですが、Chart.js、chart.js streaming、moment.jsを使ったリアルタイムグラフの線グラフの描画が、下記の写真のように、グラフが上から下に流れていくのですが、それを逆に下から上に流したいのですが、どうすれば良いでしょうか。
下記が私が書いたコードです。
js
1var chartColors = { 2 red: 'rgb(255, 99, 132)', 3}; 4 5function randomScalingFactor() { 6 var min = 0; 7 var max = 100; 8 var a = Math.floor( Math.random() * (max + 1 - min) ) + min ; 9 return(a); 10} 11 12function onRefresh(chart) { 13 chart.config.data.datasets.forEach(function(dataset) { 14 dataset.data.push({ 15 x: randomScalingFactor(), 16 y: Date.now() 17 }); 18 }); 19} 20 21var color = Chart.helpers.color; 22var config = { 23 type: 'line', 24 data: { 25 datasets: [{ 26 label: 'グラフ', 27 backgroundColor: color(chartColors.red).alpha(0.5).rgbString(), 28 borderColor: chartColors.red, 29 fill:false 30 }] 31 }, 32 options: { 33 title: { 34 display: true, 35 text: '' 36 }, 37 scales: { 38 xAxes: [{ 39 type: 'linear', 40 display: true, 41 scaleLabel: { 42 display: true, 43 labelString: '' 44 } 45 }], 46 yAxes: [{ 47 type: 'realtime', 48 realtime: { 49 duration: 20000, 50 refresh: 1000, 51 delay: 2000, 52 onRefresh: onRefresh 53 }, 54 }] 55 } 56 } 57}; 58 59window.onload = function() { 60 var ctx = document.getElementById('myChart').getContext('2d'); 61 window.myChart = new Chart(ctx, config); 62};

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。