动态滚轴折线图,多条



效果如上  ,   废话不多说, 贴码::           jsp::::::<div id="container" style="height: 400px; min-width: 310px"></div>


js::    function   xueyachart(){
         var seriesOptions = [],
         seriesCounter = 0,
         names = ['舒张压','收缩压'];
        function createChart() {

             $('#container').highcharts('StockChart', {

                 rangeSelector: {
                     selected: 4
                 },
//                 rangeSelector: {
//                 buttonTheme: {
//                     display: 'none' // 不显示按钮
//                 },
//                
//                 selected: 1,
//                inputEnabled: false //不显示年份
//             },
                 yAxis: {
                     labels: {
                         formatter: function () {
//                                低血压:收缩压<90mmHg、舒张压<60mmHg
//                                正常血压:收缩压<120mmHg、舒张压<80mmHg    
//                                正常高值:收缩压120~139mmHg、舒张压80~89mmHg;
//                                1级高血压(轻度):收缩压140-159mmHg、舒张压90-99mmHg;
//                                2级高血压(中度):收缩压160-179mmHg、舒张压100-109mmHg
//                                3级高血压(重度):≥180 mmHg、 ≥110 mmHg
                             if(names[0]=='舒张压'){
                                 if(this.value < 90){
                                     return ''+ this.value + '低血压';
                                 }
                                 if(this.value <120){
                                     return ''+ this.value + '正常血压';
                                 }
                                 if(this.value >= 120&&this.value<=139){
                                     return ''+ this.value + '正常高值';
                                 }
                                 if(this.value >= 140&&this.value<=159){
                                     return ''+ this.value + '1级高血压(轻度)';
                                 }
                                 if(this.value >= 160&&this.value<=179){
                                     return ''+ this.value + '2级高血压(中度)';
                                 }
                                 if(this.value >= 180){
                                     return ''+ this.value + '3级高血压(重度)';
                                 }
                             }
                             else{
                                 if(this.value < 60){
                                     return ''+ this.value + '低血压';
                                 }
                                 if(this.value <80){
                                     return ''+ this.value + '正常血压';
                                 }
                                 if(this.value >= 80&&this.value<=89){
                                     return ''+ this.value + '正常高值';
                                 }
                                 if(this.value >= 90&&this.value<=99){
                                     return ''+ this.value + '1级高血压(轻度)';
                                 }
                                 if(this.value >= 100&&this.value<=109){
                                     return ''+ this.value + '2级高血压(中度)';
                                 }
                                 if(this.value >= 110){
                                     return ''+ this.value + '3级高血压(重度)';
                                 }
                             }

//                             return (this.value > 0 ? ' + ' : '') + this.value + '%';
                         }
                     },
                     plotLines: [{
                         value: 0,
                         width: 2,
                         color: 'silver'
                     }]
                 },

              

                 tooltip: {
                     pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> <br/>',
                     valueDecimals: 2
                 },
                 series: seriesOptions
             });
         }
        


        var arr = new Array(sousuoya,shuzhangya);
         $.each(names, function (i, name) {
             if(i==1)
                    seriesOptions[i] = {
                        color:'red',
                        name: name,
                        data: jQuery.parseJSON(arr[i])
                    
                    };
                 else
                     seriesOptions[i] = {
                            color:'green',
                            name: name,
                            data: jQuery.parseJSON(arr[i])
                        
                        };
            
                seriesCounter += 1;
                if (seriesCounter <= names.length) {
                
                    createChart();
                }
            });
    }    ::::



唯一要注意的便是 json格式     自己封装了一个方法来拼数据::  可借鉴


function commonUtil (data){
        var str=JSON.stringify(data);
                        while(str.indexOf('{')>=0){
                            str=str.replace('{','[')
                            
                            }
                            while(str.indexOf('}')>=0){
                                str=str.replace('}',']')
                                
                            }
                            while(str.indexOf('"')>=0){
                                str=str.replace('"','')
                                
                            }
                            return str.toString();
            
        }




  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值