如何在jqplot图表的区域上显示值,而不是百分比
How to show the values on the regions of the jqplot chart instead of percentage
我有如下javascript代码:
var plot1 = jQuery.jqplot ('chartdiv', [data],
{
seriesDefaults: {
// Make this a pie chart.
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
showDataLabels: true,
dataLabels: 'value'
}
},
legend: { show:true, location:'e'}
});
var handler = function(ev, gridpos, datapos, neighbor, plot) {
if (neighbor) {
alert('x:' + neighbor.data[0] + ' y:' + neighbor.data[1]);
}
};
$.jqplot.eventListenerHooks.push(['jqplotClick', handler]);
现在,通过使用dataLabels:'value',我可以显示值,但显示的值是51,而不是50.667。值是四舍五入的。但我需要显示出确切的价值。怎么做到的??
我的第二个问题是,当我把鼠标指针放在图表的任何区域时,我都想显示一些东西。这会使用jqplotDataMouseOver完成吗?但是如何使用它?
您的第一个问题可以用dataLabelFormatString
属性解决:
seriesDefaults: {
// Make this a pie chart.
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
showDataLabels: true,
dataLabels: 'value',
dataLabelFormatString:'%.4f'
}
},
'%.4f'
将显示小数点后4位。
你的第二个问题比较难。显然,条形图上的事件并没有用jqplot完全解决。但该链接中的最后一个建议对我有效:
$('#chartdiv').bind('jqplotDataMouseOver', function (ev, seriesIndex, pointIndex, data) { alert('series: '+seriesIndex+', point: '+pointIndex+', data: '+data)});
这里有一个jsfiddle,记住要缓存JS文件,因为jqplot不允许热链接。
相关文章:
- 当我使用高度百分比时,谷歌地图javascript api不会显示
- 在Javascript中计算并显示具有2个税收百分比的现有总值
- 显示php中的加载百分比文本
- 如何删除谷歌图表中的日期空间并更正百分比显示
- 如何在可动手表格中显示百分比而不是比率
- 循环进度条在滚动时显示 - 百分比文本问题
- 显示使用 AJAX 获取数据时的加载百分比
- 谷歌图表显示的是金钱而不是百分比
- 使 NVD3 饼图显示带小数的百分比
- 如何显示正确的百分比
- 如何在酒窝 js 的饼图中显示百分比
- Google可视化-尝试格式化每个工具提示,以便按格式化程序或查询显示百分比
- 如何在NVD3饼图上显示百分比%
- CSS圆圈动画显示百分比
- 在jqplot piechart工具提示中显示百分比
- 使用php和mysql显示百分比的可能性
- 如何改变z数据悬停显示百分比以及百分比的颜色
- 如何在 jqgrid 中显示百分比
- 在dc.js行图中显示百分比
- 谷歌饼图显示百分比和值