// 14PF人格问卷 (function () { 'use strict' // 获取url var js = '14pf' 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 option = { grid: { left: 'left', containLabel: true, bottom: 15, right: 25 }, title: { show: false }, tooltip: { trigger: 'axis' }, toolbox: { feature: { dataView: {}, magicType: { type: ['bar'] }, restore: {}, saveAsImage: {} } }, xAxis: { type: 'value', position: 'top', min: 1, max: 10, splitNumber: 10 }, yAxis: { type: 'category', inverse: true, data: ['乐群(A)', '聪慧(B)', '稳定(C)', '兴奋(D)', '恃强(E)', '轻松(F)', '有恒(G)', '敢为(H)', '敏感(I)', '充沛(J)', '世故(N)', '忧虑(O)', '自律(Q3)', '紧张(Q4)', '适应与焦虑', '内向与外向', '神经是否过敏'] }, series: { name: '标准分', type: 'line', step: 'middle', smooth: false, markLine: { silent: true, label: { show: true, position: 'start', formatter: '{b}' }, data: [{ name: '中线', xAxis: 5.5, lineStyle: { color: '#b6a2de', opacity: 0.7 } }] }, label: { show: true, position: 'right' }, data: json } } // 绘制图表 $.ajax('/Scripts/echarts/theme/macarons.js', { dataType: 'script', cache: true, complete: function () { $('#chart-' + rnd).data({ option: option, theme: 'macarons' }) echarts.init(document.getElementById('chart-' + rnd), 'macarons').setOption(option) } }) })()