gpt4 book ai didi

javascript - 是否可以使用 jqPlot 将图例写入单独的分区

转载 作者:行者123 更新时间:2023-11-28 09:07:25 25 4
gpt4 key购买 nike

我想将图例写入一个单独的div,这可以用jqPlot实现吗

legend: { 
show: true,
placement: 'outside',
fontSize: '11px',
location: 'n'
}

最佳答案

这是您可以使用的两个函数:

function graphLegendCreation(cnt){
var parentNode = _g("dmGraphLegend")//trying to get the div element with id dmGraphLegend
, newLegendItemNode = Util.ce("span") //creating an span element
, newLegendItemSelect = Util.cep("input", { //creating an input element
"type":"checkbox",
"name":"graphLegend",
"checked":true,
"value":cnt
})
, newLegendItemIconNode = Util.cep("canvas", {
"id":"series_icon_"+cnt,
"className":"series_icons"
});
newLegendItemIconNode.style.display = "inline-block";
newLegendItemIconNode.style.position = "relative";
if(parentNode) {
newLegendItemNode.innerHTML = graphPlot.series[cnt].label;
newLegendItemSelect = Util.ac(newLegendItemSelect,parentNode);
newLegendItemSelect.checked = true;

Util.addEvent(newLegendItemSelect,"click", function(e) {
graphPlot.series[this.value].show = newLegendItemSelect.checked;
graphPlot.redraw(false);
})
newLegendItemIconNode = Util.ac(newLegendItemIconNode,parentNode);
newLegendItemNode = Util.ac(newLegendItemNode,parentNode);
Util.ac(Util.ce("br"),parentNode);
}
}


function showlegend() {
var cntr = 0
,len = 0
,iconNodes
,legendItemIconNode
,seriesSequence = 0
,context
,bMarker;

iconNodes = Util.Style.g("series_icons");
len = iconNodes.length;
for(cntr = 0; cntr < len; cntr++) {
legendItemIconNode = iconNodes[cntr];
if ($.browser.msie) {
G_vmlCanvasManager.initElement(legendItemIconNode);
}
context = legendItemIconNode.getContext('2d');
bMarker = new nMarkerRenderer({
size:8,
color:graphPlot.series[cntr].color,
style:graphPlot.series[cntr].markerOptions.style
});
bMarker.draw(12,12,context, {});
}

}

CSS:.series_icons{宽度:20px;高度:20px;}

GraphLegendCreation 函数,每次在图例中创建条目时都必须调用该函数。ShowLegend 只是要创建图例图标。

“nMarkrenderer”已经是一个定义的函数。从 jsfiddle file 获取该函数

让我知道您需要更多帮助。它在 IE 上肯定有效。经过尝试和测试

关于javascript - 是否可以使用 jqPlot 将图例写入单独的分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16832218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com