使用jqPlot,是否可以将点标签限制为一个系列?见下面的截图!我想要显示的只是“实际”栏上方的值。 “平均”和“计划”不应该显示!
谢谢!
这是我的代码
<script type="text/javascript">
$(document).ready(function () {
$.jqplot.config.enablePlugins = true;
var trendline = [60000, 70000, 110000, 80000];
var planned = [70000, 90000, 120000, 100000,];
var actual = [80000, 80000, 150000, 120000];
var xAxis = ['Jan', 'Feb', 'Mar', 'Apr'];
$(function() {
$.jqplot('chartDiv', [planned, actual, trendline], BarChart());
});
function BarChart()
{
var optionsObj = {
title: '',
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: xAxis,
},
yaxis: {
tickOptions: { showMark: false, formatString: "%'d" },
},
},
legend: {
show: true,
},
grid: {
borderColor: "#dad5d1",
background: "#dad5d1",
drawGridlines: false,
shadow: false
},
series: [
{label:'Planned',renderer:$.jqplot.BarRenderer},
{label: 'Actual',renderer:$.jqplot.BarRenderer},
{label: 'Mean',
pointLabels: {
show: true,
},
renderer:$.jqplot.LineRenderer,
lineWidth:4,
markerOptions:{
color: "#d87d12",
size:12,
}}
],
seriesColors: [ "#ada195", "#4a4541", "#ff9619"],
seriesDefaults:{
shadow: false,
rendererOptions:{
barPadding: 0,
barMargin: 10,
barWidth: 25
}
},
};
return optionsObj;
}
});
</script>
答案 0 :(得分:1)
这实际上看起来像点标签插件中的错误。你可以通过禁用seriesDefault(show:false)中的值然后为你想要的系列打开它来解决它:
series: [
{label:'Planned',renderer:$.jqplot.BarRenderer},
{label: 'Actual',renderer:$.jqplot.BarRenderer},
{label: 'Mean',
pointLabels: {
show: true,
},
renderer:$.jqplot.LineRenderer,
lineWidth:4,
markerOptions:{
color: "#d87d12",
size:12,
}}
],
seriesDefaults:{
pointLabels:{show:false},
shadow: false,
rendererOptions:{
barPadding: 0,
barMargin: 10,
barWidth: 25
}
},