简体   繁体   English

图例对齐问题JQPlot

[英]Legend alignment issue JQPlot

Folks, 民间,

We are having some difficulty in aligning the legends of group bar chart. 我们在对齐组条形图的图例时遇到一些困难。

Basically we want to align legends horizontally in a single raw but legends are coming in different line 基本上,我们希望将图例在一个原始中水平对齐,但是图例的行数不同

also legends are overlapping with axis we tried marginTop,marginLeft but it is not taking any effect. 图例也与我们尝试过的marginTop,marginLeft轴重叠,但没有任何效果。

Code

<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="excanvas.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script>
<script type="text/javascript" src="plugins/jqplot.barRenderer.min.js"></script>
<script type="text/javascript" src="plugins/jqplot.pieRenderer.min.js"></script>
<script type="text/javascript" src="plugins/jqplot.categoryAxisRenderer.min.js"></script>
<script type="text/javascript" src="plugins/jqplot.pointLabels.min.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.jqplot.css" />

<div id="chart2" style="height:400px;width:300px; "></div>

<script>

$(document).ready(function(){
var s1 = [2, 6, 7, 10];
var s2 = [7, 5, 3, 2];
var s3 = [7, 5, 3, 3];
var ticks = ['a', 'b', 'c', 'd'];
plot2 = $.jqplot('chart2', [s1, s2, s3], {
seriesDefaults: {
renderer:$.jqplot.BarRenderer,
pointLabels: { show: true,stackValue:true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
legend: {
renderer: jQuery.jqplot.EnhancedLegendRenderer,
show: true, 
location: 's',
placement: 'outside',
rendererOptions: {
numberRows: '1',
numberColumns: '3'
}
}

});
});

You need to load the enhancedLegendRenderer in order to use it : 您需要加载EnhancedLegendRenderer才能使用它:

<script type="text/javascript" src="plugins/jqplot.enhancedLegendRenderer.min.js"></script>

Please see a working example here (using enhancedLegendRenderer as an external resources) 在此处查看一个工作示例(使用EnhancedLegendRenderer作为外部资源)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM