// 心理症状自评量表(115) (function () { 'use strict' // 获取url var js = 'xlzc' 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 rnd1 = Math.random().toString().substring(2, 8) var rnd2 = Math.random().toString().substring(2, 8) var div = '
' $script.after(div).remove() // 处理得分,只取前10个 var json = v.replace(/\|/g, ',').split(',').slice(0, 10) // 折线图配置 var option1 = { grid: { left: 'left', containLabel: true, bottom: 0, right: 30 }, title: { text: '症状自评量表(SCL-90)剖析图' }, tooltip: { trigger: 'axis' }, toolbox: { feature: { dataView: {}, magicType: { type: ['bar'] }, restore: {}, saveAsImage: {} } }, xAxis: { axisLabel: { interval: 0 }, data: ['躯体化', '强迫症状', '人际敏感', '抑郁', '焦虑', '敌对', '恐怖', '偏执', '精神病性', '其他'] }, yAxis: { max: 5 }, series: { name: '均分', type: 'line', smooth: false, markPoint: { data: [{ name: '最大值', type: 'max', itemStyle: { color: '#b6a2de', opacity: 0.8 } }] }, markLine: { silent: true, data: [{ yAxis: 2.5, lineStyle: { color: '#b6a2de', opacity: 0.5 } }] }, data: json } } // 雷达图配置 var option2 = { toolbox: { feature: { dataView: {}, saveAsImage: {} } }, radar: { shape: 'circle', radius: '65%', indicator: [ { name: '躯体化', min: 1, max: 5 }, { name: '强迫症状', min: 1, max: 5 }, { name: '人际敏感', min: 1, max: 5 }, { name: '抑郁', min: 1, max: 5 }, { name: '焦虑', min: 1, max: 5 }, { name: '敌对', min: 1, max: 5 }, { name: '恐怖', min: 1, max: 5 }, { name: '偏执', min: 1, max: 5 }, { name: '精神病性', min: 1, max: 5 }, { name: '其他', min: 1, max: 5 } ] }, series: [{ type: 'radar', z: 3, areaStyle: {}, data: [{ value: json }] }, { type: 'radar', areaStyle: {}, symbolSize: 0, silent: true, data: [{ value: [2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5] }] }] } // 绘制图表 $.ajax('/Scripts/echarts/theme/macarons.js', { dataType: 'script', cache: true, complete: function () { // console.log(JSON.stringify(option2,null,2)); $('#chart-' + rnd1).data({ option: option1, theme: 'macarons' }) $('#chart-' + rnd2).data({ option: option2, theme: 'macarons' }) echarts.init(document.getElementById('chart-' + rnd1), 'macarons').setOption(option1) echarts.init(document.getElementById('chart-' + rnd2), 'macarons').setOption(option2) } }) })()