123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- var d = dialog({contentType:'load', skin:'bk-popup'});
- /* 查询健康指标图表
- * @param {Object} type 健康指标类型(1血糖,2血压,3体重,4腰围)
- * @param {Object} begin 记录开始时间
- * @param {Object} end 记录结束时间
- * @param {Object} gi_type 就餐时间段(0:无)
- */
- function queryChatByTypePromise(charType,begin, end, gi_type) {
- //拼请求内容
- var params = {};
- params.type = charType;
- params.begin = begin+" 00:00:00";
- params.end = end+" 23:59:59";
- params.gi_type = gi_type;
- d.show();
-
- return new Promise(function(resolve, reject) {
- //发送ajax请求
- sendPost("patient/health_index/chart", params, "json", "post", function() {
- queryChartFailed()
- }, function(res) {
- d.close();
- if (res.status == 200) {
- resolve(res)
- } else {
- //非200则为失败
- queryChartFailed(res);
- }
- });
- })
- }
- /**
- * 健康指标图表查询失败处理方法
- */
- function queryChartFailed(res) {
- d.close();
- if (res && res.msg) {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
- }
- }
- function buildData(value, max, min) {
- if (!!!value) {
- return;
- }
- if(value < min) {
- return {
- value: value,
- itemStyle: {
- normal: {
- color: '#47a8ef'
- }
- }
- }
- } else if(value > max) {
- return {
- value: value,
- itemStyle: {
- normal: {
- color: '#ff6a56'
- }
- }
- }
- } else {
- return {
- value: value,
- itemStyle: {
- normal: {
- color: '#323232'
- }
- }
- }
- }
- }
- function getChartOptions(type,yAxisName,xAxisData,seriesData) {
- var options = {
- tooltip: {
- trigger: 'axis'
- },
- grid:{x:40,y:20,x2:25,y2:20},
- toolbox:{show:false},
- calculable:false,
- xAxis:[{
- type:"category",
- boundaryGap:false,
- data:xAxisData,
- axisLabel:{margin:6}
- }],
- yAxis:[{name:yAxisName,type:"value"}],
- series:[{
- name: type == 1 ? '血糖' : type == 3 ? '体重' : '腰围',
- type:"line",
- symbol:"emptyCircle",
- itemStyle: {
- normal: {
- borderWidth: 8,
- color: '#0ad800',
- lineStyle: { // 系列级个性化折线样式,横向渐变描边
- borderWidth: 2,
- color: "#5dd1d2",
- width: 4
- },
- nodeStyle: {
- borderWidth: 2,
- color: '#93DB70',
- borderColor: '#93DB70'
- }
- },
- emphasis: {
- label: {
- show: true
- }
- }
- },
- data: seriesData
- }]
- }
- return options;
- }
- function getChartOptions1(type,yAxisName,xAxisData,seriesData) {
- var options = {
- tooltip: {
- trigger: 'axis'
- },
- grid: {
- x: 30,
- y: 20,
- x2: 25,
- y2: 20
- },
- legend: {
- show: false,
- data: ['收缩压','舒张压']
- },
- toolbox: {
- show: false
- },
- calculable: false,
- xAxis: [{
- type: 'category',
- boundaryGap: false,
- data: xAxisData,
- axisLabel: {
- margin: 6
- }
- }],
- yAxis: [{
- name : yAxisName,
- type: 'value'
- }],
- series:seriesData
- }
- return options;
- }
- // type 健康指标类型(1血糖,2血压,3体重,4腰围)
- function createChartPromise(el,type,yAxisName,xAxisData,seriesData) {
- return new Promise(function(resolve, reject) {
- // 路径配置
- require.config({
- paths: {
- echarts: 'http://echarts.baidu.com/build/dist'
- }
- });
- require(['echarts',
- 'echarts/chart/line'] // 使用柱状图就加载bar模块,按需加载]
- ,function(echarts) {
- var myChart = echarts.init(el);
- // 为echarts对象加载数据
- if (type == 1 || type == 3 || type == 4) {
- myChart.setOption(getChartOptions(type,yAxisName,xAxisData,seriesData));
- resolve(myChart);
- }
- if (type == 2) {
- myChart.setOption(getChartOptions1(type,yAxisName,xAxisData,seriesData));
- resolve(myChart);
- }
-
- });
- })
- }
|