zoukankan      html  css  js  c++  java
  • HighCharts 后台加载数据的时候去掉默认的 series

    var chart;
    
    var options = {
        chart: {
            renderTo: 'container',
            type:'line'
        },
        title: {
            text: '历史趋势时序图',
            x: -20 //center
        },
        xAxis: {
            events : {afterSetExtremes : loadDate },
            categories: []
        },
        yAxis: {
        	title: { text: '测点峰值历史趋势' },
            min: 0,
            max: 100
        }
        //series: [{}]
    };
    
    $(document).ready(function(){
    	// 获取测点数据
    	loadSensor();
    	
    	var series = {
    		yAxis: 0,
    		name: "默认测点"
    	};//这里是关键
    		
    	chart = new Highcharts.Chart(options);
    	chart.addSeries(series);
        
        $("#btn_sure").click(function(){
    		loadDate();
    
    	});
        
        // 时间设置
        jQuery('#startDate, #endDate').datetimepicker({
            timeFormat: "hh:mm:ss",
            dateFormat: "yy-mm-dd"
        });
    });
    
    // 获取数据
        function loadDate() {
            
            var startDate = $.trim($("#startDate").val());
            var endDate = $.trim($("#endDate").val());
            var sensor = $.trim($("#sensor").val());
            chart.showLoading('正在加载数据...');
            
            $.ajax({
                url : 'jsonDiagno/jsondiagno_history.do?startDate='+startDate+'&endDate='+endDate+'&sensor='+encodeURI(encodeURI(sensor)),
                type : 'POST',
                dataType : 'json',
                contentType: "application/x-www-form-urlencoded; charset=utf-8", 
                success : function(data) {
                
                    var series = {
                        yAxis: 0,
                        name: sensor,
                        data: data.rows
                    };//加载数据的时候把之前的覆盖掉
                    
                    chart = new Highcharts.Chart(options);
                    chart.addSeries(series);
                
                }
            });
        }
    


    1. 初始化的时候

    2. 加载数据的时候

  • 相关阅读:
    软件工程第五次作业——例行报告
    “Hello world!”团队—团队选题展示(视频展示说明)
    “Hello world!”团队—文案+美工
    “Hello world!”团队—选题展示
    “Hello world!”贡献分分配规则
    “hello world!”团队第三次会议
    软件工程第四次作业——例行报告
    【AtCoder】ARC092 D
    Set和数组的互换
    优先队列的基本用法(java和c++)
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3268793.html
Copyright © 2011-2022 走看看