// MMPI3(599题) (function () { 'use strict' // 获取url var js = 'mmpi3' var $script = $('script[src*="/lb/chart/' + js + '.js"]').last() var src = $script.attr('src') // 获取参数 var w = src.match(/[?&]w=([^&]+)/) var h = src.match(/[?&]h=([^&]+)/) var v = src.match(/[?&]v=([^&]+)/) // 处理参数 if (w === null || w.length < 1) { w = '100%' } else { w = w[1] + 'px' } if (h === null || h.length < 1) { h = 400 } else { h = h[1] } if (v === null || v.length < 1) { v = '' } else { v = v[1] } // 创建容器 var rnd = Math.random().toString().substring(2, 8) var div = '
' $script.after(div).remove() // 处理得分 var json = v.replace(/\|/g, ',').split(',') var json1 = json.slice(1, 4) // slice:返回一个新的数组,包含从 start 到 end (不包括该元素) var json2 = json.slice(4, 14) var json3 = json.slice(14) json2.splice(0, 0, '', '', '') json3.splice(0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '') // 配置 var option = { grid: { left: 'left', containLabel: true, right: 20 }, title: { text: '《明尼苏达多相个性调查表(MMPI3)》结果剖析图' }, toolbox: { feature: { dataView: {}, magicType: { type: ['bar'] }, restore: {}, saveAsImage: {} } }, legend: { top: 'bottom', data: ['效度量表', '临床量表', '附加量表'] }, xAxis: { data: ['L', 'F', 'K', 'Hs', 'D', 'Hy', 'Pd', 'Mf', 'Pa', 'Pt', 'Sc', 'Ma', 'Si', 'A', 'R', 'MAS', 'Es', 'Dy', 'Do', 'Re', 'Pr', 'St', 'Cn'] }, yAxis: { scale: true }, series: [{ name: '效度量表', type: 'line', smooth: false, label: { show: true }, markPoint: { data: [{ name: '最大值', type: 'max' }] }, data: json1 }, { name: '临床量表', type: 'line', smooth: false, label: { show: true }, markPoint: { data: [{ name: '最大值', type: 'max' }] }, data: json2 }, { name: '附加量表', type: 'line', smooth: false, label: { show: true }, markPoint: { data: [{ name: '最大值', type: 'max' }] }, data: json3 }] } // 绘制图表 $.ajax('/Scripts/echarts/theme/macarons.js', { dataType: 'script', cache: true, complete: function () { // console.log(JSON.stringify(option,null,2)); $('#chart-' + rnd).data({ option: option, theme: 'macarons' }) echarts.init(document.getElementById('chart-' + rnd), 'macarons').setOption(option) } }) })()