jqPlot 显示带有光标的自定义工具提示

3
我正在使用Cursor插件在jqplot图表上显示一条垂直线。Cursor插件的工具提示显示X和Y值。
我想要向绘图点添加元数据。
[x,y,1337]其中1337是元数据。
我想要修改Cursor插件的工具提示,以显示这个元数据以及它已经显示的数据。
用例:我有多个系列已被缩放到0-100跨越所有系列的趋势。我需要显示未缩放的值。
更新:
我通过修改jqplot.cursor.js使其正常工作,是否有更好的方法?
Line 468: function updateToolTip(gridpos, datapos, plot){
              // ...
              s += $.jqplot.sprintf(c.tooltipFormatString, label, sx, sy, data[2]);
1个回答

2

这是我如何覆盖 tooltipContentEditor jqplot 函数的方法,它非常有效。

highlighter: {
                    show: true,
                    showMarker:true,
                    showTooltip:true,
                    sizeAdjust: 10,
                    tooltipLocation: 'se',
                    tooltipAxes: 'xy',
                    yvalues: 1,
                    formatString:'<table class="jqplot-highlighter"><tr><td>date:</td><td>%s</td></tr><tr><td>PiecesPerHour:</td><td align="right">%s</td></tr></table>',
                    useAxesFormatters: true,
                    tooltipContentEditor: function(str, seriesIndex, pointIndex, plot){
                        var data = plot.series[seriesIndex].data[pointIndex];
                        var label = plot.legend.labels[seriesIndex].indexOf('Target')
                        var format = [];
                        //A little formatting to the data before I join it to the Html string
                        if (that.model.get('groupBy')==='month')
                            format[0] = new Date(data[0] + 1000*60*60*24).format('mmmm yyyy');
                        else
                            format[0] = new Date(data[0] ).format('mmmm dd, yyyy');
                        format[1] = new Number(data[1]).toFixed(1)

                        //join the data to the Html string:
                        str = $.jqplot.sprintf.apply($.jqplot.sprintf, [str].concat(format));
                        return str;
                    }
               }

基本上,您获取系列和点数据,并使用sprintf将其连接到Html字符串中,然后返回该字符串。

1
我并没有使用荧光笔,而是使用光标。 - Chris G.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接