Demo : ( 需自行架設 janus server )
https://wastu01.github.io/Chartjs-demo/
畫面成果展示:
Chartjs 常見問答:
https://www.chartjs3.com/docs/chart/chart-js-viewers-questions/
這些是 Chart.js 中常見的問題及解決方案的簡化翻譯。如果您需要更詳細的說明或示例,請隨時提問。
Ping Test
https://www.groupworld.net/pingtest.html
Janus WebRTC Server
https://github.com/meetecho/janus-gateway
固定 x 軸數量,第一筆應移除
remove : https://www.chartjs.org/docs/latest/developers/updates.html
每新增一筆時,移除最舊的一筆
原生功能:
function addData(chart, label, newData, maxDataPoints) {
if (chart.data.labels.length >= maxDataPoints) {
// 如果數據點數量達到最大值,移除最舊的數據點
chart.data.labels.shift(); // 移除第一個標籤
chart.data.datasets.forEach((dataset) => {
dataset.data.shift(); // 移除每個數據集的第一個數據點
});
}
// 添加新的數據點
chart.data.labels.push(label);
chart.data.datasets.forEach((dataset) => {
dataset.data.push(newData);
});
chart.update();
}
點擊開始按鈕,抓取 pingtest 一組數值(第 N 個封包,Ping RTT 數值),然後更新圖表,更新頻率?幾秒動態更新一次?
點擊結束後,停止動態更新圖表
再次點擊,重置圖表
https://www.chartjs.org/docs/latest/getting-started/
https://www.chartjs3.com/docs/chart/getting-started/
https://www.chartjs.org/docs/latest/samples/information.html
中文入門教學
https://how2j.cn/k/chartjs/chartjs-intro/2056.html
就這麼剛好有人使用 chartjs 模擬網路品質
https://codepen.io/mrwang01/pen/zYegEZX?editors=1010
官網 | Updating Charts
https://www.chartjs.org/docs/latest/developers/updates.html
Pop, Push |新增移除
調用函數語法中文解釋:
https://chenhailun.gitbooks.io/chartjs/content/di-liu-zhang-er-ci-kai-fa-xiang-guan.html
官網|資料結構:
https://www.chartjs.org/docs/latest/general/data-structures.html
資料格式 中文圖文解釋
https://pluscdev.com/tutorial-chartjs/
新版異動項目:|x,y軸 文字顏色設定
js 語法釐清:
$('#average_jitter').html(avg_jitter.toFixed(0));
語法:
JavaScript Number toFixed() Method
numObj.toFixed(); 整數後面要幾位小數,四捨五入
$(".btn1").click(function(){
$("p").html("Hello <b>world</b>!");
});
https://ithelp.ithome.com.tw/articles/10206424
bind():通過.bind()方法為元素綁定click、dblclick、 mousedown、mouseup…等事件。
https://developer.mozilla.org/zh-CN/docs/Web/API/Performance/now
計時用
https://blog.errorbaker.tw/posts/xiang/console-log/
console log 未來接『ping 數值』到圖表偵錯
https://kuro.tw/posts/2019/02/23/談談-JavaScript-的-setTimeout-與-setInterval/
setTimeout-與-setInterval
https://www.explainthis.io/zh-hant/swe/script-link-in-html
<script>
標籤應該放在 HTML 的什麼位置呢? ans : 放在 </body> 之前
JSON.parse() 轉成 JSON
https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/push
Chart.js 自學分享
https://alicialin2020.medium.com/chart-js-自學分享-243e11851a47
使用chart.js 畫系統監控圖表
https://ccsig.blogspot.com/2019/01/chartjs.html?sc=1694504913950
Web 視覺化(一):使用 Chart.js 輕鬆建立圖表
https://noob.tw/web-visualization-chartjs/
原生 Canvas :
https://ithelp.ithome.com.tw/articles/10198687
Anychart
https://docs.anychart.com/Working_with_Data/Data_Manipulation
echart
https://echarts.apache.org/zh/index.html
如何选择chart.js和Echarts——我为何放弃chart.js转战Echart?
https://juejin.cn/post/6970594322400378916
AJAX / google chart
https://ithelp.ithome.com.tw/questions/10214358?sc=rss.qu
chart.js 图表刷新_Chart.js的花式,响应式图表
https://blog.csdn.net/culi4814/article/details/108380380
https://stackoverflow.com/questions/31059399/how-to-push-datasets-dynamically-for-chart-js-bar-chart
2.3 版 隨機生成動態圖表範例
https://jsfiddle.net/iamarasekera/oek1wan2/
Dynamically update values of a chartjs chart
解答有 2.9 版本適用方案
https://stackoverflow.com/questions/17354163/dynamically-update-values-of-a-chartjs-chart