// SCL-90(国网技术学院专用) (function () { 'use strict' // 获取url var js = 'scl904' 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] }] }] } // 处理主题 var body = document.getElementsByTagName('body')[0] if (body.getAttribute('data-echarts-theme-macarons')) { drawChart() } else { // 原生获取太难处理,还是用jquery算鸟 $.ajax('/Scripts/echarts/theme/macarons.js', { dataType: 'script', cache: true, complete: function () { body.setAttribute('data-echarts-theme-macarons', true) drawChart() } }) } // 绘制图表 function drawChart () { var dom1 = document.getElementById('chart-' + rnd1) var dom2 = document.getElementById('chart-' + rnd2) dom1.setAttribute('data-option', JSON.stringify(option1)) dom2.setAttribute('data-option', JSON.stringify(option2)) dom1.setAttribute('data-theme', 'macarons') dom2.setAttribute('data-theme', 'macarons') // console.log(JSON.stringify(option2,null,2)) echarts.init(dom1, 'macarons').setOption(option1) echarts.init(dom2, 'macarons').setOption(option2) } })()