Jquery 如何使Jqplot条形图点标签垂直对齐。?
我正在做一个图表,在那里我不需要什么帮助。(我在谷歌上搜索了这么多,但没有成功,这就是为什么要问这个问题。-如果可能的话,我道歉。) 我的代码:Jquery 如何使Jqplot条形图点标签垂直对齐。?,jquery,jqplot,Jquery,Jqplot,我正在做一个图表,在那里我不需要什么帮助。(我在谷歌上搜索了这么多,但没有成功,这就是为什么要问这个问题。-如果可能的话,我道歉。) 我的代码: var plot2 = $.jqplot('distance_graph', data.distance, { // The "seriesDefaults" option is an options object that will // be applied to all series
var plot2 = $.jqplot('distance_graph', data.distance, {
// The "seriesDefaults" option is an options object that will
// be applied to all series in the chart.
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {fillToZero: false},
pointLabels: { show: true },
},
// Custom labels for the series are specified with the "label"
// option on the series option. Here a series option object
// is specified for each series.
// Show the legend and put it outside the grid, but inside the
// plot container, shrinking the grid to accomodate the legend.
// A value of "outside" would not shrink the grid and allow
// the legend to overflow the container.
legend: {
show: true,
placement: 'outsideGrid'
},
axes: {
// Use a category axis on the x axis and use our custom ticks.
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
label: 'Date',
ticks: ticks,
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: {
angle: -30
}
},
// Pad the y axis just a little so bars can get close to, but
// not touch, the grid boundaries. 1.2 is the default padding.
yaxis: {
label: 'Distance Travelled',
pad: 1.05,
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: {
labelPosition:'middle'
},
min:min_val,
max:max_val
}
}
});
plot2.legend.labels = data.device;
plot2.replot( { resetAxes: false } );
我如何也删除0值,因为我正在将此图表转换为多项目的图表。这是当前一个项目的图表。。因此,如何删除0个标签…基于以下示例:,您可以使用CSS中的.jqplot point label
类修改点标签的显示。因此,您可以使用CSStransform
属性旋转文本,如下所述:
若要删除0值的标签,需要提供一组将零更改为空字符串的标签。您可以按如下方式使用此自定义集:
pointLabels: {
show: true,
labels: customSetOfLabels
},
function removeZeros(x){
return x===0 ? '' : x;
}
var line1 = [14, 32, 41, 44, 0, 40];
var line1Labels = line1.map(removeZeros);
但是,jqPlot似乎会阻止来自JSFIDLE的请求,因此有时脚本不会加载。您可以在本地尝试,也可以在一个浏览器窗口中访问和JSFIDLE,以便从缓存加载脚本
我使用JavaScript数组函数创建自定义标签集,如下所示:
pointLabels: {
show: true,
labels: customSetOfLabels
},
function removeZeros(x){
return x===0 ? '' : x;
}
var line1 = [14, 32, 41, 44, 0, 40];
var line1Labels = line1.map(removeZeros);
请注意,
map()
可能不适用于所有浏览器,因此您可能希望使用for循环来迭代数组。谢谢您,DDK,我现在明白了。我会记住的。。谢谢,谢谢你的回答。这种垂直标签在Firefox中运行良好。我现在还没有测试过其他的。我使用了点标签:{show:true,hideZeros:true,fillToZero:false},谢谢您的回答。这种垂直标签在Firefox中运行良好。我现在还没有测试过其他的。我使用了点标签:{hideZeros:true}来隐藏零,其他一切都很好。谢谢。你能帮我整理一些传奇吗?图表上的图例显示在图表上,尽管我已经完成了放置:'outsideGrid'…是否也可以给图例表一个可滚动的?因此gui看起来不错。[接受链接和提示]。