javascript - 条形图上的 jqplot 工具提示

标签 javascript jquery graph charts jqplot

我正在使用 jquery 插件 jqplot 来绘制一些条形图。 悬停时,我想在工具提示上显示栏的刻度及其值。我已经尝试过

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
            }

但它不起作用。条形图在视觉上变得更亮,顶部有一个小点(理想情况下它会消失——可能来自折线图渲染器的东西),但任何地方都没有工具提示。有人知道我该怎么做吗?我会有很多条形图,因此如果我只将它们显示在那里,x 轴就会变得困惑并且有点困惑。

最佳答案

我浏览 jqplot.highlighter.js 并找到一个未记录的属性:tooltipContentEditor。 我用它来自定义工具提示以显示 x 轴标签。

使用这样的东西:

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

关于javascript - 条形图上的 jqplot 工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4889464/

相关文章:

algorithm - 有向图 : Euler Path

algorithm - 模糊图自同构群成员测试

jquery - 有没有像这样的 jquery 菜单插件?

java - LinkedList Array 中每个索引的 LinkedList

javascript - 使用Reduce Javascript更新对象属性并将它们添加到新的Arr中

javascript - Jquery 单击仅在切换时工作一次

javascript - 使用函数的字符串名称应用 JavaScript 函数

javascript - 如何在react-native或reactjs中维护react usestate中的先前数据和当前数据?

jquery - 水平菜单与 css 或 jquery 对齐

javascript - 如何在 D3 Sankey 图中突出显示整个路径?