gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 21:43:15 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com