/** * 股本股东页交互:股东户数折线图初始化。 */ (function ($) { 'use strict'; // 旧锚点映射;tabs.js 初始化时读取。 window.QuoteTabAliases = $.extend({ 'holder-number': 'shareholder-numbers', 'circulating': 'circulating-shareholders', 'top-holders': 'top-shareholders', 'fund': 'fund-holdings', 'restricted': 'restricted-shares', 'manager': 'executive-holdings' }, window.QuoteTabAliases || {}); // 切回股东户数标签时,隐藏面板中的图表需要重新计算尺寸。 $(document).on('quote:tabactivated', function (event, detail) { if (detail && detail.id === 'shareholder-numbers' && window.gdhsChart) { window.setTimeout(function () { window.gdhsChart.resize(); }, 0); } }); function renderHolderNumbers() { var $data = $('#gdhsData'); if (!$data.length || typeof window.echarts === 'undefined' || !document.getElementById('gdhs')) { return; } var data = JSON.parse($data.text()); var dataMin = Math.min.apply(null, data.data); var dataMax = Math.max.apply(null, data.data); var chart = window.echarts.init(document.getElementById('gdhs')); window.gdhsChart = chart; chart.setOption({ title: { text: '股东户数趋势图', left: 20, top: 15, textStyle: { fontSize: 14, fontWeight: 'normal', color: '#333' } }, tooltip: { trigger: 'axis', backgroundColor: 'rgba(255,255,255,0.96)', borderColor: '#d7d6db', borderWidth: 1, textStyle: { fontSize: 12, color: '#333' }, formatter: function (params) { var index = params[0].dataIndex; var avgHold = (data.avgHold && data.avgHold[index]) || '--'; var ratio = data.ratio ? data.ratio[index] : null; if (ratio && ratio !== '-' && ratio !== '--') { ratio = ratio + '%'; } else { ratio = ratio || '--'; } return [ data.xAxisData[index], '股东户数:' + Number(data.data[index]).toLocaleString() + ' 户', '户均持股:' + avgHold + ' 股', '较上期变化:' + ratio ].join('
'); } }, grid: { left: 20, right: 20, top: 50, bottom: 20, containLabel: true }, xAxis: { type: 'category', data: data.xAxisData, axisLine: { lineStyle: { color: '#d8d8d8' } }, axisLabel: { fontSize: 11, color: '#666', interval: 0, formatter: function (value) { return value.length > 7 ? value.substring(2, 7) : value; } }, axisTick: { show: false } }, yAxis: { type: 'value', min: Math.floor(dataMin * 0.98), max: Math.ceil(dataMax * 1.02), axisLine: { show: false }, axisTick: { show: false }, splitLine: { lineStyle: { color: '#EDEDED', type: 'solid' } }, axisLabel: { fontSize: 11, color: '#666', formatter: function (value) { return (value / 10000).toFixed(1) + '万'; } } }, series: [{ name: '股东户数', type: 'line', data: data.data, smooth: false, lineStyle: { color: '#c27c00', width: 2 }, itemStyle: { color: '#c27c00' }, symbol: 'circle', symbolSize: 6 }] }); $(window).on('resize', function () { chart.resize(); }); } $(function () { renderHolderNumbers(); }); }(jQuery));