Reputation: 390
I need to draw three series on a same canvas. The series are similar as:
rec1 = [0, 0, 150, 200, 0 ];
rec2 = [60, 120, 179, 240, 300];
rec3 = [50, 100, 150, 200, 250];
I use below source codes to draw the series.
$.jqplot("chart", [rec1, rec2, rec3], {
title: "",
axesDefaults: {
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: {
fontSize: '10pt'
}
},
seriesDefaults: {
rendererOptions: {
smooth: false
},
pointLabels: {
show: true,
ypadding: 10
},
showMarker: true,
lineWidth: 2
},
legend: {
show: true,
location: 'nw',
placement: "outside"
}
});
In rec1, the elements which has a zero value will always be zero. I want to hide these zero-value-elements in rec1. Is there any way to realize this? Set rec1 to be:
rec1 = [undefined, undefined, 150, 200, undefined]
will hide these undefined points, but causes point labels of 150 and 200 appearing at wrong positions, as shown by the picture. Thanks for any useful directions.
Upvotes: 1
Views: 87
Reputation: 8275
Instead of using "flat" array, you should use a 2-dimensional array in order to place your points :
rec1 = [[3, 150], [4, 200] ]; // we defined 2 points with their (x, y) coordinates
rec2 = [60, 120, 179, 240, 300];
rec3 = [50, 100, 150, 200, 250];
I have made a jsfiddle showing this (I have just move the point [3, 150]
at [3, 90]
from your example in order that you see the correct place of its label) : http://jsfiddle.net/5wgcqyet/1/
Upvotes: 1