我在jqplot条形图中遇到了一个奇怪的问题。最后一个条形图中的条形图标签有时会显示,有时会消失。我添加了一个屏幕截图和我的脚本。!
这是我用过的脚本。
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesColors:<?php echo json_encode($barColor ); ?>,
<?php if(isset($_POST['additionalSubmit'])){ ?>
negativeSeriesColors: ["#792A86"],
<?php } else { ?>
negativeSeriesColors: <?php echo json_encode($barColornegative ); ?>,
<?php } ?>
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {
fillToZero: true,
barWidth: 30,
varyBarColor :true
},
pointLabels: {
show: true,
formatString :"€ %'s",
escapeHTML: false
}
},
canvasOverlay: {
show: true,
objects: [
{horizontalLine: {
name: 'zeroline',
y: 0,
lineWidth: 2,
xOffset: 0,
color: '#BBCCDD',
shadow: false
}}
]
},
axes: {
xaxis: {
autoscale:true,
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks,
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: {
fontSize: '8pt',
fontWeight: 'normal',
angle:-20,
},
borderColor: "#BBCCDD",
borderWidth:5
},
yaxis: {
autoscale:true,
tickOptions:{ prefix: '€' , formatString: "%'d",} ,
borderColor: "#BBCCDD",
borderWidth:5,
label: 'resultant in EURO',
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
}
},
legend: {
show: true,
placement: 'outside',
noColumns: 1
},
series: [
{
fill: true,
label: '<?php echo $_POST['scenario']; ?>'
}
],
highlighter: { show: false }
});
提前致谢。
答案 0 :(得分:1)
标签在点击边缘时不会显示。要避免这种检测,请为pointLabels设置edgeTolerance,如下所示:
pointLabels: {
show: true,
formatString :"€ %'s",
escapeHTML: false,
edgeTolerance: -100
}