// Conners儿童行为量表(父母问卷) (function () { 'use strict' // 获取url var js = 'conners1' 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(',') $.each(json, function (i, v) { if (v.indexOf('.') === 0) { json[i] = '0' + v } }) // 配置 var option = { grid: { left: 'left', containLabel: true, bottom: 0, right: 30 }, title: { text: '《Conners儿童行为量表(父母问卷)》结果剖析图' }, tooltip: { trigger: 'axis' }, toolbox: { feature: { dataView: {}, magicType: { type: ['bar'] }, restore: {}, saveAsImage: {} } }, xAxis: { data: ['品行问题', '学习问题', '心身障碍', '冲动—多动', '焦虑', '多动指数'] }, yAxis: { scale: true }, series: { name: '得分', type: 'line', smooth: false, markPoint: { data: [ { name: '最大值', type: 'max' }, { name: '最小值', type: 'min' } ] }, markLine: { data: [{ name: '平均值', type: 'average' }] }, data: json } } // 绘制图表 $.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) } }) })()