jqplot在条形图的工具提示 [英] jqplot tooltip on bar chart

查看:221
本文介绍了jqplot在条形图的工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jquery插件jqplot绘制一些条形图。
on hover,我想在工具提示上显示条形的标记及其值。我尝试过

I'm using the jquery plugin jqplot for plotting some bar charts. on hover, I'd like to display the tick for the bar and its value on a tooltip. I've tried

highlighter: { show: true, 
            showTooltip: true,      // show a tooltip with data point values.
            tooltipLocation: 'nw',  // location of tooltip: n, ne, e, se, s, sw, w, nw.
            tooltipAxes: 'both',    // which axis values to display in the tooltip, x, y or both.
            lineWidthAdjust: 2.5   // pixels to add to the size line stroking the data point marker
            }

但它不工作。该条视觉上变得更轻,并且在顶部有一个小点(这将理想地消失 - 可能从线图表渲染器的东西),但没有工具提示任何地方。任何人知道我怎么能这样做?

but it doesn't work. the bar visually gets lighter, and there's a small dot on the top (which would ideally go away--probably from line chart renderer stuff), but there is no tooltip anywhere. Anyone know how I can do this? I'll have lots of bars so the x-axis will be cluttered and kind of a mess if I show them down there only.

推荐答案

这是一个很好的解决方案,

我通过jqplot.highlighter.js并找到一个未公开的属性: tooltipContentEditor
我使用它来自定义工具提示以显示x轴标签。

I go through jqplot.highlighter.js and find an undocumented property: tooltipContentEditor. I use it to customize the tooltip to display x-axis label.

使用这样的东西:

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];
}

这篇关于jqplot在条形图的工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆