宁德股票行情今日股价 (宁德股票行情走势图)
访客
34
今日股价
-
当前价格:
-
涨跌幅:
-
涨跌额:
-
成交量:
-
换手率:
股价走势图
// 获取实时股价数据fetch('https://stock.finance.sina.com.cn/priceapi/json_v2.php?type=rt&symbol=sh688235').then(res => res.json()).then(data => {// 填充今日股价数据document.getElementById('current-price').innerText = data.current_price;document.getElementById('change-percent').innerText = `${data.rise_percent}%`;document.getElementById('change-amount').innerText = `${data.rise_rate}元`;document.getElementById('volume').innerText = `${data.volume}手`;document.getElementById('turnover-rate').innerText = `${data.turnover_rate}%`;});// 创建股价走势图const ctx = document.getElementById('stock-chart').getContext('2d');const chart = new Chart(ctx, {type: 'line',data: {labels: [],datasets: [{label: '宁德时代',data: [],borderColor: 'blue',fill: false}]},options: {scales: {y: {title: {text: '股价 (元)'}}}}});// 定时获取股价数据并更新走势图setInterval(() => {fetch('https://stock.finance.sina.com.cn/priceapi/json_v2.php?type=rt&symbol=sh688235').then(res => res.json()).then(data => {// 添加新数据点chart.data.labels.push('');chart.data.datasets[0].data.push(data.current_price);// 移除最旧的数据点if (chart.data.labels.length > 100) {chart.data.labels.shift();chart.data.datasets[0].data.shift();}// 更新图表chart.update();});}, 1000);
标签: 宁德股票行情今日股价
版权声明:除非特别标注,否则均为本站转摘于网络,转载时请以链接形式注明文章出处。