I have a matrix filled with six data series, where I would like to label the first five with the same name 'process a' (also give them the same color), and the left one with 'process b'. So is there a way to do this in jqplot? Thanks for any suggestions.
Here is the code and demo:
$(document).ready(function(){
$.jqplot.config.enablePlugins = true;
s1 = [[10.0, 11.0, 11.0, 12.0, 12.0, 14.0], [10.0, 11.0, 12.0, 12.0, 12.0, 12.0], [10.0, 13.0, 14.0, 15.0, 15.0, 16.0], [10.0, 10.0, 11.0, 11.0, 11.0, 12.0], [10.0, 10.0, 11.0, 12.0, 12.0, 12.0]];
s2 = [10.0, 10.4, 10.816, 11.248640000000002, 11.698585600000003, 12.166529024000004];
s1.push(s2);
$.jqplot('chart1', s1, {
seriesDefaults: {
showMarker:false,
pointLabels: { show:false } ,
},
series:[
{label:'Process A'},{label:'Process B'}
],
legend: {
show: true,
location: 'nw',
placement: 'inside',
fontSize: '11px'
}
})
})
Yes there is a way. I think this is what you want. You already were on the right track. You just need to repeat setting of label and colour for each series accordingly, as in the code sample or below:
series:[
{label:'Process A', color: 'red'}, {label:'Process A', color: 'red'}, {label:'Process A', color: 'red'}, {label:'Process A', color: 'red'}, {label:'Process A', color: 'red'}, {label:'Process B',color:'blue'}
]
EDIT:
This is the answer where I show how to manipulate the legend.
Also please find this sample, extending the code of the other answer. The sample shows how to hide legend with index 1. Basically you grab swatches and labels and hide them using jQuery
's method hide()
:
var swatches = $('table.jqplot-table-legend tr td.jqplot-table-legend-swatch');
var labels = $('table.jqplot-table-legend tr td.jqplot-table-legend-label');
$(swatches[1]).hide();
$(labels[1]).hide();