// EMBU父母养育方式 (function () { 'use strict' // 获取url var js = 'embu' 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(',') json.splice(6, 0, '') // 配置 var option = { grid: { bottom: 110, left: 'left', containLabel: true, right: 10 }, title: { text: '《父母养育方式问卷(EMBU)》结果剖析图' }, tooltip: { formatter: '{b1}:{c1}', trigger: 'axis' }, toolbox: { feature: { dataView: {}, magicType: { type: ['bar'] }, restore: {}, saveAsImage: {} } }, legend: { top: 'bottom', data: ['高', '得分', '低'] }, xAxis: { axisLabel: { interval: 0, rotate: 315 }, data: ['父:情感温暖、理解', '父:惩罚、严厉', '父:过分干涉', '父:偏爱被试', '父:拒绝、否认', '父:过度保护', '-', '母:情感温暖、理解', '母:过干涉、过保护', '母:拒绝、否认', '母:惩罚、严厉', '母:偏爱被试'] }, yAxis: {}, series: [{ name: '高', type: 'line', smooth: true, silent: true, showSymbol: false, lineStyle: { width: 1, type: 'dashed' }, data: [69, 23, 28, 17, 13, 19, '-', 74, 49, 18, 17, 17] }, { name: '得分', type: 'line', smooth: true, label: { show: true }, data: json }, { name: '低', type: 'line', smooth: true, silent: true, showSymbol: false, lineStyle: { width: 1, type: 'dashed' }, data: [35, 15, 15, 8, 8, 10, '-', 37, 26, 10, 11, 7] }] } // 绘制图表 $.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) } }) })()