Click here to Skip to main content
13,593,121 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I am working on populating a Flot-Plot. I have a JSON recordset which has the line data for the plot. I think I have managed to get the JSON records bound to the respective arrays which produce the data for the chart's lines. I think the data is assigned as a float but I still do not see the lines materialize in the chart.

Have two errors in the Development Console:

elem.css(...) is undefined at Line 32 in jQuery.js
Argument 4 of CanvasRenderingContext2D.createLinearGradient is not finite floating-point value at line 3090 in Jquery.js

The odd thing is that both of these errors where present when I had the Flot graph showing Sin, Cosine values.

Other then this errors I do not get any others.

What I have tried:

Plotting Function:

function plot() {
    	//	Data arrays for plot lines
    	var min = [],
			max = [],
			median = [],
			Average = [],
			Q1 = [],
			Q3 = [],
			LCL = [],
			LCL2 = [],
			UCL = [],
			UCL2 = [],
			Midpoint = [],
			LCL2A = [],
            UCL2A = [];
            
    	$.ajax({
   			type: 'GET',
   			url: 'http://192.168.1.103/Web%20Service/Service.asmx/GetFirstSample',
   			dataType: 'json',
   			contentType: 'application/json;charset=utf-8',
   			success: function(product) {
    			var products = JSON.parse(product.d);
    			var len = Object.keys(products.RunSet).length;    			
	    			for (var i = 0; i < len; i++) {
 	    					alert('Index: ' + i + '  Min: ' + products.RunSet[i].Minimum);
		    				min.push([i,products.RunSet[i].Minimum]);
				            max.push([i,products.RunSet[i].Maximum]);
							median.push([i,products.RunSet[i].Median]);
							Average.push([i,products.RunSet[i].Average]);
							Q1.push([i,products.RunSet[i].Q1]);
				            Q3.push([i,products.RunSet[i].Q3]);
							LCL.push([i,products.RunSet[i].LCL]);
							LCL2.push([i,products.RunSet[i].LCL2]);
				            UCL.push([i,products.RunSet[i].UCL]);
							UCL2.push([i,products.RunSet[i].UCL2]);
							Midpoint.push([i,products.RunSet[i].Midpoint]);
				            LCL2A.push([i,products.RunSet[i].LCL2A]);
							UCL2A.push([i,products.RunSet[i].UCL2A]);

					}
         	},
   			failure: function(error) {
   				 alert(error.d); 
   			}
   			});
        

        var options = {
            series: {
                lines: {
                    show: true
                },
                points: {
                    show: true
                }
            },
            grid: {
                hoverable: true //IMPORTANT! this is needed for tooltip to work
            },
            yaxis: {
                min: 0,
                max: 50
            },
            xaxis: {
                min: 0,
                max: 50
            },
            tooltip: true,
            tooltipOpts: {
                content: "'%s' of %x.1 is %y.4",
                shifts: {
                    x: -60,
                    y: 25
                }
            }
        };

        var plotObj = $.plot($("#flot-line-chart"), [{
                data: min,
                label: "Min"
            }, {
                data: max,
                label: "Max"
			}, {
                data: median,
                label: "Median"
            }, {
            	data: Average,
                label: "Average"
            }, {
            	data: Q1,
                label: "Q1"
            }, {
            	data: Q3,
                label: "Q3"
            }, {
            	data: LCL,
                label: "LCL"
            }, {
            	data: LCL2,
                label: "LCL2"
            }, {
            	data: UCL,
                label: "UCL"
            }, {
            	data: Midpoint,
                label: "Midpoint"
            }, {
            	data: LCL2A,
                label: "LCL2A"
            }, {
            	data: UCL2A,
                label: "UCL2A"
            }],
            options);
    }
   
					
           
});
Posted 14-Jun-18 11:46am
Updated 5 days ago
v3
Comments
‭011111100010‬ 5 days ago
   
Look in the browser's developer console for any errors.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I have resolved it, there wasn't anything I needed to change to the code. But rather to remove a breakpoint I had in code which was holding up the complete plot processes.

The chart plots now and I can move on with doing custom plotting using my listbox selection.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web03-2016 | 2.8.180618.1 | Last Updated 15 Jun 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100