查找有关如何做事的文档的最佳位置是API文档 http://www.jqplot.com/docs/files/jqplot-core-js.html。它包含有关每个组件和插件的文档以及每个组件和插件的可用选项。 [在此处和答案顶部重述,因为我刚刚添加了链接。]
点标签的文档位于插件 API 文档中:点标签 http://www.jqplot.com/docs/files/plugins/jqplot-pointLabels-js.html(插件/jqplot.pointLabels.js)。
您可以通过添加属性来删除零值标签hideZeros: true
。这意味着改变:
pointLabels: {
show: true,
},
to:
pointLabels: {
show: true,
hideZeros: true
},
有一个工作 JSFiddle http://jsfiddle.net/arzv5j6o/1/.
完整的 JavaScript:
var s3 = [11, 28, 22, 47, 11, 11];
var s1 = [0, 6, 3, 0, 0, 0];
var s2 = [1, 0, 3, 0, 0, 0];
var dataArray = [s3, s1, s2];
var ticks = ['John', 'Tumm', 'Wen', 'Ken', 'Dolly'];
var options = {
title: 'Title ',
stackSeries: true,
seriesColors: ["#eb4b3d", "#ffc800", "#009149"],
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: {
show: true,
hideZeros: true
},
rendererOptions: {
barWidth: 25,
varyBarColor: true,
},
},
axes: {
xaxis: {
// renderer: $.jqplot.CategoryAxisRenderer,
//
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks,
},
yaxis: {
//autoscale: true,
//label: 'Application Count',
min: 0,
tickInterval: 5,
max: 50
}
},
axesDefaults: {
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: {
angle: -30,
fontSize: '10pt'
}
}
};
var plot = $.jqplot('chartDivId', dataArray, options);
HTML:
<div id="chartDivId"/>