您好,提前感谢您的帮助、指导和鼓励。我是一名出色的编码员......主要是自学成才和半成功。
所以这里是挑战。我有一个浮点图,它有一个带有颜色样本、持久样本(它们不会关闭)、数据集切换和所有内容的定制图例。但是只有当我看到默认图例时才会出现样本。也就是说,我是否将图例设置为“显示:假”,样本也不会显示在我的自定义图例中。
有没有办法关闭/隐藏默认图例,但仍可以访问自定义图例可用的颜色托盘/色板?
这是代码块......它还有其他一些事情发生,其中一些我为了清楚起见而删掉了......
var options = {
yaxis: { min: 0 },
xaxis: { tickDecimals: 0 },
xaxes: [{
axisLabel: 'Frequency (Hz)',
}],
yaxes: [{
position: 'left',
axisLabel: 'Power (dB)',
}],
series: {
lines: {
lineWidth: 2,
show: true
},
points: {
show: false
}
},
legend: {
container: $("#labeler<?php echo $i ?>"),
show: true,
labelFormatter: function(label, series) {
}
},
grid:{
hoverable: true
}
};
var track = 0;
// hard-code color indices to prevent them from shifting as
// datasets are turned on/off
var i = 0;
$.each(datasets, function(key, val) {
val.color = i;
++i;
});
// insert checkboxes
var choiceContainer = $("#choices<?php echo $i ?>");
choiceContainer.append('<table><tr>');
$.each(datasets, function(key, val) {
track = track + 1;
if (track == 1){
choiceContainer.append('<td width=\"100\">Left Channel</td>');
} else if(track == <?php echo $tracks ?>){
choiceContainer.append('</tr><tr>');
choiceContainer.append('<td>Right Channel</td>');
}
choiceContainer.append('<td width=\"45\"><input type="checkbox" name="' + key +
'" checked="checked" id="id' + key + '">' +
'<div style=\"width:18px; white-space:nowrap; float:left\"><bar /></div><label for="id' + key + '">'
+ val.label + '</label></td>');
});
choiceContainer.append('</tr></table>');
choiceContainer.find("input").change(plotAccordingToChoices);
function plotAccordingToChoices() {
var data = [];
choiceContainer.find("input:checked").each(function () {
var key = $(this).attr("name");
if (key && datasets[key])
data.push(datasets[key]);
});
if (data.length > 0){
$.plot($("#placeholder<?php echo $i ?>"), data, options);
}
}
plotAccordingToChoices();
$('.legendColorBox > div').each(function(i){
$(this).clone().prependTo(choiceContainer.find("bar").eq(i));
});