javascript - Square Line Chart / Step Chart jqplot -


i need plot 3 series of data, first line , other 2 dots. line should step chart (instead of line drawing point point, should draw line horizontal , value

i stuck how jqplot.

$(document).ready(function(){     var plot1 = $.jqplot ('chart1', [[3,7,9,1,4,6,8,2,5]]); }); 

the above code produce blue line on below graph, instead need green line.

enter image description here

unfortunately, not allowed make comments. therefore have write new answer.

the given answer suggests subtract small amount x value (0.001 in example) prevent triangle effect. not quite accurate , can seen workaround.

the triangle effect caused sorting performed jqplot. sorting required chart types, including line charts. if data sorted before feeding jqplot, sorting can disabled jqplot setting sortdata attribute false, see jqplot.sortdata

this prevent sorting issues , therefore no triangle effect occurs!

you may want hide point markers jqplot doesn't know difference between real points , our injected artificial points.

var data = [3, 7, 9, 1, 4, 6, 8, 2, 5]; var points = [[1, data[0]]]; (var = 1; < data.length; i++) {     points.push([i + 1, data[i - 1]]);     points.push([i + 1, data[i]]); }  var plot1 = $.jqplot('chart1', [points], {     sortdata: false,     seriesdefaults: {         showmarker: false     } }); 

try in fiddle

if want point markers right, option see changing rendering logic, e.g. writing step chart plugin.

for reference, see answers in following post: jqplot step chart not plotting in series order


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -