javascript – jqplot工具提示内容编辑器
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – jqplot工具提示内容编辑器,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1943字,纯文字阅读大概需要3分钟。
内容图文
![javascript – jqplot工具提示内容编辑器](/upload/InfoBanner/zyjiaocheng/744/4f2b00e5abad4309bcb7717528112a0a.jpg)
我在显示jq绘图条形图的工具提示时面临问题
我的jqPlot代码是
<script class="code" type="text/javascript">
$(document).ready(function(){
var s1 = [0,10,20,30,40,50,60,70,80,90,100];
var s2 = [-100,-90,-80,-70,-60,-50,-40,-30,-20,-10,-0];
var ticks = ['01-jun','02-jun','03s-jun','04-jun','05-jun','06-jun','07-jun','08-jun','09-jun','10-jun'];
var plot1 = $.jqplot('chart1', [s1, s2], {
animate: !$.jqplot.use_excanvas,
stackSeries: true,
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {fillToZero: true, barPadding: 10,barMargin: 15},
pointLabels: { show: true }
},
series: [
{ color: '#68BA38',label:'Uptime' },
{ color: 'red',label:'Downtime' },
{ label:'abcd' }
],
legend: {
show: true,
placement: 'outsideGrid'
},
axes: {
// Use a category axis on the x axis and use our custom ticks.
xaxis: {
pad: 1,
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
},
// 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: {
pad: 1,
min:-100,
max: 100,
}
},
highlighter:{
show:true,
tooltipContentEditor:tooltipContentEditor
},
});
});
function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
// display series_label, x-axis_tick, y-axis value
return plot.series[seriesIndex]["label"] + ", " + plot.data[seriesIndex][pointIndex];
}
</script>
它的显示工具提示如下:正常运行时间,20或停机时间,-20
我想显示工具提示包含我的刻度值,如:01-jun
解决方法:
我自己就是这个问题,所以我使用Firefox的Web Developer工具检查tooltipContentEditor函数中的绘图对象,以找到x轴标签的位置.它位于plot.options.axes.xaxis.ticks中.因此,您希望获取数据点的x轴标签的代码是:
plot.options.axes.xaxis.ticks[pointIndex]
这是所讨论的点索引的x轴标签.
我现在使用的回调函数的完整代码是:
function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
return plot.series[seriesIndex]["label"] + ": " + plot.options.axes.xaxis.ticks[pointIndex] + ", " + plot.data[seriesIndex][pointIndex];
}
这显示了系列标签,x轴刻度标签,然后是数据点值.
内容总结
以上是互联网集市为您收集整理的javascript – jqplot工具提示内容编辑器全部内容,希望文章能够帮你解决javascript – jqplot工具提示内容编辑器所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。